summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex
diff options
context:
space:
mode:
authorBen Langmuir <blangmuir@apple.com>2014-09-30 20:00:18 +0000
committerBen Langmuir <blangmuir@apple.com>2014-09-30 20:00:18 +0000
commitc28ce3aba646d0ea24ab584b9bac88e3a2a7374e (patch)
tree6905ba39906cfd0275cda91407d0e6f1a03211ff /clang/lib/Lex
parentc110c0b99a2b1ef9f5bbad280abc42664971dc80 (diff)
downloadbcm5719-llvm-c28ce3aba646d0ea24ab584b9bac88e3a2a7374e.tar.gz
bcm5719-llvm-c28ce3aba646d0ea24ab584b9bac88e3a2a7374e.zip
Avoid a crash after loading an #undef'd macro in code completion
In code-completion, don't assume there is a MacroInfo for everything, since we aren't serializing the def corresponding to a later #undef in the same module. Also setup the HadMacro bit correctly for undefs to avoid an assertion failure. rdar://18416901 llvm-svn: 218694
Diffstat (limited to 'clang/lib/Lex')
-rw-r--r--clang/lib/Lex/PPMacroExpansion.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp
index 62d2da56ba9..e875860f820 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -49,7 +49,10 @@ void Preprocessor::appendMacroDirective(IdentifierInfo *II, MacroDirective *MD){
MacroDirective *&StoredMD = Macros[II];
MD->setPrevious(StoredMD);
StoredMD = MD;
- II->setHasMacroDefinition(MD->isDefined());
+ // Setup the identifier as having associated macro history.
+ II->setHasMacroDefinition(true);
+ if (!MD->isDefined())
+ II->setHasMacroDefinition(false);
bool isImportedMacro = isa<DefMacroDirective>(MD) &&
cast<DefMacroDirective>(MD)->isImported();
if (II->isFromAST() && !isImportedMacro)
OpenPOWER on IntegriCloud