diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-03-22 21:12:57 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-03-22 21:12:57 +0000 |
commit | 9317ab94bb68122ba6fc728eb73c1308fb913cd1 (patch) | |
tree | f25f1f99dedccdd0963443fbaf6397a8414ee924 /lib/Lex/PPDirectives.cpp | |
parent | baa74bd3968028d8e5b10ee9b50d0dceb41e85a9 (diff) |
[PCH/Modules] De/Serialize MacroInfos separately than MacroDirectives.
-Serialize the macro directives history into its own section
-Get rid of the macro updates section
-When de/serializing an identifier from a module, associate only one macro per
submodule that defined+exported it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177761 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PPDirectives.cpp')
-rw-r--r-- | lib/Lex/PPDirectives.cpp | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index 163dbf413e..7020da3940 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/lib/Lex/PPDirectives.cpp @@ -1119,23 +1119,26 @@ void Preprocessor::HandleMacroPublicDirective(Token &Tok) { // Check to see if this is the last token on the #__public_macro line. CheckEndOfDirective("__public_macro"); + IdentifierInfo *II = MacroNameTok.getIdentifierInfo(); // Okay, we finally have a valid identifier to undef. - MacroDirective *MD = getMacroDirective(MacroNameTok.getIdentifierInfo()); + MacroDirective *MD = getMacroDirective(II); // If the macro is not defined, this is an error. if (MD == 0) { - Diag(MacroNameTok, diag::err_pp_visibility_non_macro) - << MacroNameTok.getIdentifierInfo(); + Diag(MacroNameTok, diag::err_pp_visibility_non_macro) << II; return; } // Note that this macro has now been exported. MD->setVisibility(/*IsPublic=*/true, MacroNameTok.getLocation()); - // If this macro definition came from a PCH file, mark it - // as having changed since serialization. - if (MD->isImported()) + // If this macro directive came from a PCH file, mark it as having changed + // since serialization. + if (MD->isFromPCH()) { MD->setChangedAfterLoad(); + assert(II->isFromAST()); + II->setChangedSinceDeserialization(); + } } /// \brief Handle a #private directive. @@ -1150,23 +1153,26 @@ void Preprocessor::HandleMacroPrivateDirective(Token &Tok) { // Check to see if this is the last token on the #__private_macro line. CheckEndOfDirective("__private_macro"); + IdentifierInfo *II = MacroNameTok.getIdentifierInfo(); // Okay, we finally have a valid identifier to undef. - MacroDirective *MD = getMacroDirective(MacroNameTok.getIdentifierInfo()); + MacroDirective *MD = getMacroDirective(II); // If the macro is not defined, this is an error. if (MD == 0) { - Diag(MacroNameTok, diag::err_pp_visibility_non_macro) - << MacroNameTok.getIdentifierInfo(); + Diag(MacroNameTok, diag::err_pp_visibility_non_macro) << II; return; } // Note that this macro has now been marked private. MD->setVisibility(/*IsPublic=*/false, MacroNameTok.getLocation()); - // If this macro definition came from a PCH file, mark it - // as having changed since serialization. - if (MD->isImported()) + // If this macro directive came from a PCH file, mark it as having changed + // since serialization. + if (MD->isFromPCH()) { MD->setChangedAfterLoad(); + assert(II->isFromAST()); + II->setChangedSinceDeserialization(); + } } //===----------------------------------------------------------------------===// @@ -2011,7 +2017,7 @@ void Preprocessor::HandleUndefDirective(Token &UndefTok) { void Preprocessor::UndefineMacro(IdentifierInfo *II, MacroDirective *MD, SourceLocation UndefLoc) { MD->setUndefLoc(UndefLoc); - if (MD->isImported()) { + if (MD->isFromPCH()) { MD->setChangedAfterLoad(); if (Listener) Listener->UndefinedMacro(MD); |