diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2009-10-14 18:03:49 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2009-10-14 18:03:49 +0000 |
commit | 9092c3e0fa01f3139b016d05d267a89e3b07747a (patch) | |
tree | 137ebebcae16fb0ce7ab4af456992bbd8d22fced /include/clang/Frontend/CommandLineSourceLoc.h | |
parent | 4981926bf654fe5a2c3893f24ca44106b217e71e (diff) | |
download | FreeBSD-src-9092c3e0fa01f3139b016d05d267a89e3b07747a.zip FreeBSD-src-9092c3e0fa01f3139b016d05d267a89e3b07747a.tar.gz |
Update clang to r84119.
Diffstat (limited to 'include/clang/Frontend/CommandLineSourceLoc.h')
-rw-r--r-- | include/clang/Frontend/CommandLineSourceLoc.h | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/include/clang/Frontend/CommandLineSourceLoc.h b/include/clang/Frontend/CommandLineSourceLoc.h index 1eaa958..59f70ed 100644 --- a/include/clang/Frontend/CommandLineSourceLoc.h +++ b/include/clang/Frontend/CommandLineSourceLoc.h @@ -34,46 +34,45 @@ namespace llvm { /// /// Source locations are of the form filename:line:column. template<> - class parser<clang::ParsedSourceLocation> + 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 + 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 + 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; } - + Val.FileName = ArgValue.substr(0, FirstColon); Val.Line = Line; Val.Column = Column; |