summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-10-12 00:16:50 +0000
committerDouglas Gregor <dgregor@apple.com>2012-10-12 00:16:50 +0000
commitcfa46a82b8f74564522a493b9ae3e715d83d06a4 (patch)
tree4f183eb0f0cdf2e4cf0b9ee3a4cfe6791aeda8c7 /clang/lib/Lex
parent98b41645034f1373af6351d5d32f2fc3c43231ba (diff)
downloadbcm5719-llvm-cfa46a82b8f74564522a493b9ae3e715d83d06a4.tar.gz
bcm5719-llvm-cfa46a82b8f74564522a493b9ae3e715d83d06a4.zip
Track which particular submodule #undef's a macro, so that the actual
#undef only occurs if that submodule is imported. llvm-svn: 165773
Diffstat (limited to 'clang/lib/Lex')
-rw-r--r--clang/lib/Lex/PPMacroExpansion.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp
index dc3a45652ac..3959671fdaf 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -87,11 +87,13 @@ void Preprocessor::addLoadedMacroInfo(IdentifierInfo *II, MacroInfo *MI,
}
// Find the end of the definition chain.
- MacroInfo *Prev = StoredMI;
- MacroInfo *PrevPrev;
+ MacroInfo *Prev;
+ MacroInfo *PrevPrev = StoredMI;
bool Ambiguous = StoredMI->isAmbiguous();
bool MatchedOther = false;
do {
+ Prev = PrevPrev;
+
// If the macros are not identical, we have an ambiguity.
if (!Prev->isIdenticalTo(*MI, *this)) {
if (!Ambiguous) {
@@ -125,25 +127,29 @@ void Preprocessor::addLoadedMacroInfo(IdentifierInfo *II, MacroInfo *MI,
void Preprocessor::makeLoadedMacroInfoVisible(IdentifierInfo *II,
MacroInfo *MI) {
assert(MI->isFromAST() && "Macro must be from the AST");
- assert(MI->isDefined() && "Macro is not visible");
MacroInfo *&StoredMI = Macros[II];
if (StoredMI == MI) {
// Easy case: this is the first macro anyway.
- II->setHasMacroDefinition(true);
+ II->setHasMacroDefinition(MI->isDefined());
return;
}
// Go find the macro and pull it out of the list.
- // FIXME: Yes, this is O(N), and making a pile of macros visible would be
- // quadratic.
+ // FIXME: Yes, this is O(N), and making a pile of macros visible or hidden
+ // would be quadratic, but it's extremely rare.
MacroInfo *Prev = StoredMI;
while (Prev->getPreviousDefinition() != MI)
Prev = Prev->getPreviousDefinition();
Prev->setPreviousDefinition(MI->getPreviousDefinition());
+ MI->setPreviousDefinition(0);
// Add the macro back to the list.
addLoadedMacroInfo(II, MI);
+
+ II->setHasMacroDefinition(StoredMI->isDefined());
+ if (II->isFromAST())
+ II->setChangedSinceDeserialization();
}
/// \brief Undefine a macro for this identifier.
OpenPOWER on IntegriCloud