diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Frontend/PrintPreprocessedOutput.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Lex/TokenConcatenation.cpp | 12 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 38 |
3 files changed, 33 insertions, 20 deletions
diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp index 17d7279e3ff..7c1d9a56883 100644 --- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp @@ -332,7 +332,10 @@ void PrintPPOutputPPCallbacks::InclusionDirective(SourceLocation HashLoc, MoveToLine(HashLoc); OS << "@import " << Imported->getFullModuleName() << ";" << " /* clang -E: implicit import for \"" << File->getName() << "\" */"; + // Since we want a newline after the @import, but not a #<line>, start a new + // line immediately. EmittedTokensOnThisLine = true; + startNewLineIfNeeded(); } } diff --git a/clang/lib/Lex/TokenConcatenation.cpp b/clang/lib/Lex/TokenConcatenation.cpp index 0a66bba91fc..866cbb142c8 100644 --- a/clang/lib/Lex/TokenConcatenation.cpp +++ b/clang/lib/Lex/TokenConcatenation.cpp @@ -163,8 +163,8 @@ bool TokenConcatenation::AvoidConcat(const Token &PrevPrevTok, return false; tok::TokenKind PrevKind = PrevTok.getKind(); - if (PrevTok.getIdentifierInfo()) // Language keyword or named operator. - PrevKind = tok::identifier; + if (!PrevTok.isAnnotation() && PrevTok.getIdentifierInfo()) + PrevKind = tok::identifier; // Language keyword or named operator. // Look up information on when we should avoid concatenation with prevtok. unsigned ConcatInfo = TokenInfo[PrevKind]; @@ -178,6 +178,14 @@ bool TokenConcatenation::AvoidConcat(const Token &PrevPrevTok, return true; ConcatInfo &= ~aci_avoid_equal; } + if (Tok.isAnnotation()) { + // Modules annotation can show up when generated automatically for includes. + assert((Tok.is(tok::annot_module_include) || + Tok.is(tok::annot_module_begin) || + Tok.is(tok::annot_module_end)) && + "unexpected annotation in AvoidConcat"); + ConcatInfo = 0; + } if (ConcatInfo == 0) return false; diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 8f1d88c6d58..93c01cb1e12 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -6893,11 +6893,11 @@ void ASTReader::InitializeSema(Sema &S) { // Makes sure any declarations that were deserialized "too early" // still get added to the identifier's declaration chains. - for (unsigned I = 0, N = PreloadedDecls.size(); I != N; ++I) { - pushExternalDeclIntoScope(PreloadedDecls[I], - PreloadedDecls[I]->getDeclName()); + for (uint64_t ID : PreloadedDeclIDs) { + NamedDecl *D = cast<NamedDecl>(GetDecl(ID)); + pushExternalDeclIntoScope(D, D->getDeclName()); } - PreloadedDecls.clear(); + PreloadedDeclIDs.clear(); // FIXME: What happens if these are changed by a module import? if (!FPPragmaOptions.empty()) { @@ -7349,24 +7349,26 @@ ASTReader::SetGloballyVisibleDecls(IdentifierInfo *II, } for (unsigned I = 0, N = DeclIDs.size(); I != N; ++I) { - NamedDecl *D = cast<NamedDecl>(GetDecl(DeclIDs[I])); - if (SemaObj) { - // If we're simply supposed to record the declarations, do so now. - if (Decls) { - Decls->push_back(D); - continue; - } - - // Introduce this declaration into the translation-unit scope - // and add it to the declaration chain for this identifier, so - // that (unqualified) name lookup will find it. - pushExternalDeclIntoScope(D, II); - } else { + if (!SemaObj) { // Queue this declaration so that it will be added to the // translation unit scope and identifier's declaration chain // once a Sema object is known. - PreloadedDecls.push_back(D); + PreloadedDeclIDs.push_back(DeclIDs[I]); + continue; } + + NamedDecl *D = cast<NamedDecl>(GetDecl(DeclIDs[I])); + + // If we're simply supposed to record the declarations, do so now. + if (Decls) { + Decls->push_back(D); + continue; + } + + // Introduce this declaration into the translation-unit scope + // and add it to the declaration chain for this identifier, so + // that (unqualified) name lookup will find it. + pushExternalDeclIntoScope(D, II); } } |