diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-10-11 21:07:39 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-10-11 21:07:39 +0000 |
commit | 5968b1b71f880582dd9cc57e8f3669ba100ee9f9 (patch) | |
tree | 442be3212befcc1c9b2698a4ab424dff6566bce0 /clang/lib/Serialization | |
parent | c9822ebc97035714de8eb3076625e5eab7dd01a6 (diff) | |
download | bcm5719-llvm-5968b1b71f880582dd9cc57e8f3669ba100ee9f9.tar.gz bcm5719-llvm-5968b1b71f880582dd9cc57e8f3669ba100ee9f9.zip |
Diagnose the expansion of ambiguous macro definitions. This can happen
only with modules, when two disjoint modules #define the same
identifier to different token sequences.
llvm-svn: 165746
Diffstat (limited to 'clang/lib/Serialization')
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 5657ee23bc1..8f18eb8465b 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -1254,6 +1254,24 @@ void ASTReader::ReadMacroRecord(ModuleFile &F, uint64_t Offset, SmallVector<IdentifierInfo*, 16> MacroArgs; MacroInfo *Macro = 0; + // RAII object to add the loaded macro information once we're done + // adding tokens. + struct AddLoadedMacroInfoRAII { + Preprocessor &PP; + MacroInfo *Hint; + MacroInfo *MI; + IdentifierInfo *II; + + AddLoadedMacroInfoRAII(Preprocessor &PP, MacroInfo *Hint) + : PP(PP), Hint(Hint), MI(), II() { } + ~AddLoadedMacroInfoRAII( ) { + if (MI) { + // Finally, install the macro. + PP.addLoadedMacroInfo(II, MI, Hint); + } + } + } AddLoadedMacroInfo(PP, Hint); + while (true) { unsigned Code = Stream.ReadCode(); switch (Code) { @@ -1370,8 +1388,9 @@ void ASTReader::ReadMacroRecord(ModuleFile &F, uint64_t Offset, } MI->setHidden(Hidden); - // Finally, install the macro. - PP.addLoadedMacroInfo(II, MI, Hint); + // Make sure we install the macro once we're done. + AddLoadedMacroInfo.MI = MI; + AddLoadedMacroInfo.II = II; // Remember that we saw this macro last so that we add the tokens that // form its body to it. |