diff options
Diffstat (limited to 'lib/Lex')
-rw-r--r-- | lib/Lex/HeaderSearch.cpp | 4 | ||||
-rw-r--r-- | lib/Lex/Pragma.cpp | 20 | ||||
-rw-r--r-- | lib/Lex/Preprocessor.cpp | 2 | ||||
-rw-r--r-- | lib/Lex/TokenConcatenation.cpp | 8 |
4 files changed, 24 insertions, 10 deletions
diff --git a/lib/Lex/HeaderSearch.cpp b/lib/Lex/HeaderSearch.cpp index 129fa1ae35fa..9023b11022b1 100644 --- a/lib/Lex/HeaderSearch.cpp +++ b/lib/Lex/HeaderSearch.cpp @@ -215,9 +215,7 @@ const FileEntry *HeaderSearch::LookupFile(const char *FilenameStart, const DirectoryLookup *&CurDir, const FileEntry *CurFileEnt) { // If 'Filename' is absolute, check to see if it exists and no searching. - // FIXME: Portability. This should be a sys::Path interface, this doesn't - // handle things like C:\foo.txt right, nor win32 \\network\device\blah. - if (FilenameStart[0] == '/') { + if (llvm::sys::Path::isAbsolute(FilenameStart, FilenameEnd-FilenameStart)) { CurDir = 0; // If this was an #include_next "/absolute/file", fail. diff --git a/lib/Lex/Pragma.cpp b/lib/Lex/Pragma.cpp index ce5934134f42..3227d1cf09c5 100644 --- a/lib/Lex/Pragma.cpp +++ b/lib/Lex/Pragma.cpp @@ -93,7 +93,7 @@ void Preprocessor::HandlePragmaDirective() { PragmaHandlers->HandlePragma(*this, Tok); // If the pragma handler didn't read the rest of the line, consume it now. - if (CurPPLexer->ParsingPreprocessorDirective) + if (CurPPLexer && CurPPLexer->ParsingPreprocessorDirective) DiscardUntilEndOfDirective(); } @@ -195,8 +195,10 @@ void Preprocessor::HandlePragmaOnce(Token &OnceTok) { void Preprocessor::HandlePragmaMark() { assert(CurPPLexer && "No current lexer?"); - if (CurLexer) CurLexer->ReadToEndOfLine(); - else CurPTHLexer->DiscardToEndOfLine(); + if (CurLexer) + CurLexer->ReadToEndOfLine(); + else + CurPTHLexer->DiscardToEndOfLine(); } @@ -254,6 +256,18 @@ void Preprocessor::HandlePragmaSystemHeader(Token &SysHeaderTok) { // Mark the file as a system header. HeaderInfo.MarkFileSystemHeader(TheLexer->getFileEntry()); + + PresumedLoc PLoc = SourceMgr.getPresumedLoc(SysHeaderTok.getLocation()); + unsigned FilenameLen = strlen(PLoc.getFilename()); + unsigned FilenameID = SourceMgr.getLineTableFilenameID(PLoc.getFilename(), + FilenameLen); + + // Emit a line marker. This will change any source locations from this point + // forward to realize they are in a system header. + // Create a line note with this information. + SourceMgr.AddLineNote(SysHeaderTok.getLocation(), PLoc.getLine(), FilenameID, + false, false, true, false); + // Notify the client, if desired, that we are in a new source file. if (Callbacks) Callbacks->FileChanged(SysHeaderTok.getLocation(), diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index 0a7d92eb83cf..24ee5d8a8f92 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -51,7 +51,7 @@ Preprocessor::Preprocessor(Diagnostic &diags, const LangOptions &opts, IdentifierInfoLookup* IILookup) : Diags(&diags), Features(opts), Target(target),FileMgr(Headers.getFileMgr()), SourceMgr(SM), HeaderInfo(Headers), Identifiers(opts, IILookup), - CurPPLexer(0), CurDirLookup(0), Callbacks(0) { + BuiltinInfo(Target), CurPPLexer(0), CurDirLookup(0), Callbacks(0) { ScratchBuf = new ScratchBuffer(SourceMgr); CounterValue = 0; // __COUNTER__ starts at 0. diff --git a/lib/Lex/TokenConcatenation.cpp b/lib/Lex/TokenConcatenation.cpp index ab989cafc156..be13b274574a 100644 --- a/lib/Lex/TokenConcatenation.cpp +++ b/lib/Lex/TokenConcatenation.cpp @@ -192,7 +192,8 @@ bool TokenConcatenation::AvoidConcat(const Token &PrevTok, return isalnum(FirstChar) || Tok.is(tok::numeric_constant) || FirstChar == '+' || FirstChar == '-' || FirstChar == '.'; case tok::period: // ..., .*, .1234 - return FirstChar == '.' || isdigit(FirstChar) || FirstChar == '*'; + return FirstChar == '.' || isdigit(FirstChar) || + (PP.getLangOptions().CPlusPlus && FirstChar == '*'); case tok::amp: // && return FirstChar == '&'; case tok::plus: // ++ @@ -210,10 +211,11 @@ bool TokenConcatenation::AvoidConcat(const Token &PrevTok, case tok::percent: // %>, %: return FirstChar == '>' || FirstChar == ':'; case tok::colon: // ::, :> - return FirstChar == ':' ||FirstChar == '>'; + return FirstChar == '>' || + (PP.getLangOptions().CPlusPlus && FirstChar == ':'); case tok::hash: // ##, #@, %:%: return FirstChar == '#' || FirstChar == '@' || FirstChar == '%'; case tok::arrow: // ->* - return FirstChar == '*'; + return PP.getLangOptions().CPlusPlus && FirstChar == '*'; } } |