diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-05-18 19:32:16 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-05-18 19:32:16 +0000 |
commit | e5fbc6c85d98f91357f6f8bfd19c67e96c4f143f (patch) | |
tree | d11597f25c1e236cfa2738ed3b8e2c2ce06a6d91 /clang/lib/Lex/PPDirectives.cpp | |
parent | 4b63d2ae1dd1cedbb0b2a61fa0da9559043dfabb (diff) | |
download | bcm5719-llvm-e5fbc6c85d98f91357f6f8bfd19c67e96c4f143f.tar.gz bcm5719-llvm-e5fbc6c85d98f91357f6f8bfd19c67e96c4f143f.zip |
Lexer::ReadToEndOfLine: Only build the string if it's actually used and do so in a less malloc-intensive way.
llvm-svn: 157064
Diffstat (limited to 'clang/lib/Lex/PPDirectives.cpp')
-rw-r--r-- | clang/lib/Lex/PPDirectives.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index 625a204af99..c6290170892 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -1018,15 +1018,13 @@ void Preprocessor::HandleUserDiagnosticDirective(Token &Tok, // tokens. For example, this is allowed: "#warning ` 'foo". GCC does // collapse multiple consequtive white space between tokens, but this isn't // specified by the standard. - std::string Message = CurLexer->ReadToEndOfLine(); + SmallString<128> Message; + CurLexer->ReadToEndOfLine(&Message); // Find the first non-whitespace character, so that we can make the // diagnostic more succinct. - StringRef Msg(Message); - size_t i = Msg.find_first_not_of(' '); - if (i < Msg.size()) - Msg = Msg.substr(i); - + StringRef Msg = Message.str().ltrim(" "); + if (isWarning) Diag(Tok, diag::pp_hash_warning) << Msg; else |