diff options
| author | Chris Lattner <sabre@nondot.org> | 2006-10-30 05:58:32 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2006-10-30 05:58:32 +0000 |
| commit | c07ba1fe2f4ed331b73f7103ad685b502eefa9fc (patch) | |
| tree | 8d76f1a22d9d2bb891e947d664c344fee2dc05c4 /clang/Lex/Lexer.cpp | |
| parent | b8b94f1e9bf78a7cf9c50f054f37e6e25788ff89 (diff) | |
| download | bcm5719-llvm-c07ba1fe2f4ed331b73f7103ad685b502eefa9fc.tar.gz bcm5719-llvm-c07ba1fe2f4ed331b73f7103ad685b502eefa9fc.zip | |
Refactor the paths used for checking and getting the spelling of #include
filenames (and also '#pragma GCC dependency' of course). Now, assuming
no cleaning is needed, we can go all the way from lexing the filename to
doing filename lookups with no mallocs. This speeds up user PP time from
0.077 to 0.075s for Cocoa.h (2.6%).
llvm-svn: 39092
Diffstat (limited to 'clang/Lex/Lexer.cpp')
| -rw-r--r-- | clang/Lex/Lexer.cpp | 42 |
1 files changed, 4 insertions, 38 deletions
diff --git a/clang/Lex/Lexer.cpp b/clang/Lex/Lexer.cpp index 8b783d61c95..4892a21fe01 100644 --- a/clang/Lex/Lexer.cpp +++ b/clang/Lex/Lexer.cpp @@ -884,7 +884,7 @@ bool Lexer::SkipBlockComment(LexerToken &Result, const char *CurPtr) { /// LexIncludeFilename - After the preprocessor has parsed a #include, lex and /// (potentially) macro expand the filename. -std::string Lexer::LexIncludeFilename(LexerToken &FilenameTok) { +void Lexer::LexIncludeFilename(LexerToken &FilenameTok) { assert(ParsingPreprocessorDirective && ParsingFilename == false && "Must be in a preprocessing directive!"); @@ -895,46 +895,12 @@ std::string Lexer::LexIncludeFilename(LexerToken &FilenameTok) { // Lex the filename. Lex(FilenameTok); - // We should have gotten the filename now. + // We should have obtained the filename now. ParsingFilename = false; - - // No filename? - if (FilenameTok.getKind() == tok::eom) { - Diag(FilenameTok.getLocation(), diag::err_pp_expects_filename); - return ""; - } - // Get the text form of the filename. - std::string Filename = PP.getSpelling(FilenameTok); - assert(!Filename.empty() && "Can't have tokens with empty spellings!"); - - // Make sure the filename is <x> or "x". - if (Filename[0] == '<') { - if (Filename[Filename.size()-1] != '>') { - Diag(FilenameTok.getLocation(), diag::err_pp_expects_filename); - FilenameTok.setKind(tok::eom); - return ""; - } - } else if (Filename[0] == '"') { - if (Filename[Filename.size()-1] != '"') { - Diag(FilenameTok.getLocation(), diag::err_pp_expects_filename); - FilenameTok.setKind(tok::eom); - return ""; - } - } else { + // No filename? + if (FilenameTok.getKind() == tok::eom) Diag(FilenameTok.getLocation(), diag::err_pp_expects_filename); - FilenameTok.setKind(tok::eom); - return ""; - } - - // Diagnose #include "" as invalid. - if (Filename.size() == 2) { - Diag(FilenameTok.getLocation(), diag::err_pp_empty_filename); - FilenameTok.setKind(tok::eom); - return ""; - } - - return Filename; } /// ReadToEndOfLine - Read the rest of the current preprocessor line as an |

