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 | 3093b20d824a953d8bc7a786dd952414898f8d6d (patch) | |
tree | 03754db02ab0c0c437ca9d6e04e1f3de656a16b5 /lib/Lex/PPDirectives.cpp | |
parent | 6e629882ea67dbcd4dd2b0ccf636d2f758b86284 (diff) |
Lexer::ReadToEndOfLine: Only build the string if it's actually used and do so in a less malloc-intensive way.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157064 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PPDirectives.cpp')
-rw-r--r-- | lib/Lex/PPDirectives.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index 625a204af9..c629017089 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/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 |