aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-03-22 21:12:57 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-03-22 21:12:57 +0000
commit9317ab94bb68122ba6fc728eb73c1308fb913cd1 (patch)
treef25f1f99dedccdd0963443fbaf6397a8414ee924 /lib/Lex
parentbaa74bd3968028d8e5b10ee9b50d0dceb41e85a9 (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')
-rw-r--r--lib/Lex/PPDirectives.cpp32
-rw-r--r--lib/Lex/PPMacroExpansion.cpp20
2 files changed, 33 insertions, 19 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);
diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp
index 8e54f019ba..868820b400 100644
--- a/lib/Lex/PPMacroExpansion.cpp
+++ b/lib/Lex/PPMacroExpansion.cpp
@@ -42,20 +42,28 @@ Preprocessor::getMacroDirectiveHistory(const IdentifierInfo *II) const {
}
/// \brief Specify a macro for this identifier.
-MacroDirective *
-Preprocessor::setMacroDirective(IdentifierInfo *II, MacroInfo *MI,
- SourceLocation Loc, bool isImported) {
- assert(MI && "MacroInfo should be non-zero!");
+void Preprocessor::setMacroDirective(IdentifierInfo *II, MacroDirective *MD) {
+ assert(MD && "MacroDirective should be non-zero!");
- MacroDirective *MD = AllocateMacroDirective(MI, Loc, isImported);
MacroDirective *&StoredMD = Macros[II];
MD->setPrevious(StoredMD);
StoredMD = MD;
II->setHasMacroDefinition(true);
if (II->isFromAST())
II->setChangedSinceDeserialization();
+}
- return MD;
+void Preprocessor::setLoadedMacroDirective(IdentifierInfo *II,
+ MacroDirective *MD) {
+ assert(II && MD);
+ MacroDirective *&StoredMD = Macros[II];
+ assert(!StoredMD &&
+ "the macro history was modified before initializing it from a pch");
+ StoredMD = MD;
+ // Setup the identifier as having associated macro history.
+ II->setHasMacroDefinition(true);
+ if (!MD->isDefined())
+ II->setHasMacroDefinition(false);
}
void Preprocessor::addLoadedMacroInfo(IdentifierInfo *II, MacroDirective *MD,