aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Frontend/CommandLineSourceLoc.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-09-20 00:39:15 +0000
committerChris Lattner <sabre@nondot.org>2009-09-20 00:39:15 +0000
commit59b2172751e78ef7c0895d9a5d1359b61ab63a33 (patch)
tree6fcd108ccbabbba23b7a56fadd251b72a23e048b /include/clang/Frontend/CommandLineSourceLoc.h
parent65f13c3381a31eae8a7219477c37c247ac9838fc (diff)
switch command line 'parse' methods to use StringRef for efficiency, which
is also required for an llvm-side change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82344 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Frontend/CommandLineSourceLoc.h')
-rw-r--r--include/clang/Frontend/CommandLineSourceLoc.h21
1 files changed, 10 insertions, 11 deletions
diff --git a/include/clang/Frontend/CommandLineSourceLoc.h b/include/clang/Frontend/CommandLineSourceLoc.h
index 4092724372..59f70ede91 100644
--- a/include/clang/Frontend/CommandLineSourceLoc.h
+++ b/include/clang/Frontend/CommandLineSourceLoc.h
@@ -37,39 +37,38 @@ namespace llvm {
class parser<clang::ParsedSourceLocation>
: public basic_parser<clang::ParsedSourceLocation> {
public:
- bool parse(Option &O, const char *ArgName,
- const std::string &ArgValue,
+ bool parse(Option &O, StringRef ArgName, StringRef ArgValue,
clang::ParsedSourceLocation &Val);
};
bool
parser<clang::ParsedSourceLocation>::
- parse(Option &O, const char *ArgName, const std::string &ArgValue,
+ parse(Option &O, StringRef ArgName, StringRef ArgValue,
clang::ParsedSourceLocation &Val) {
using namespace clang;
const char *ExpectedFormat
= "source location must be of the form filename:line:column";
- std::string::size_type SecondColon = ArgValue.rfind(':');
+ StringRef::size_type SecondColon = ArgValue.rfind(':');
if (SecondColon == std::string::npos) {
std::fprintf(stderr, "%s\n", ExpectedFormat);
return true;
}
- char *EndPtr;
- long Column
- = std::strtol(ArgValue.c_str() + SecondColon + 1, &EndPtr, 10);
- if (EndPtr != ArgValue.c_str() + ArgValue.size()) {
+
+ unsigned Column;
+ if (ArgValue.substr(SecondColon + 1).getAsInteger(10, Column)) {
std::fprintf(stderr, "%s\n", ExpectedFormat);
return true;
}
+ ArgValue = ArgValue.substr(0, SecondColon);
- std::string::size_type FirstColon = ArgValue.rfind(':', SecondColon-1);
+ StringRef::size_type FirstColon = ArgValue.rfind(':');
if (FirstColon == std::string::npos) {
std::fprintf(stderr, "%s\n", ExpectedFormat);
return true;
}
- long Line = std::strtol(ArgValue.c_str() + FirstColon + 1, &EndPtr, 10);
- if (EndPtr != ArgValue.c_str() + SecondColon) {
+ unsigned Line;
+ if (ArgValue.substr(FirstColon + 1).getAsInteger(10, Line)) {
std::fprintf(stderr, "%s\n", ExpectedFormat);
return true;
}