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 | e8219a655128b98d0573658a139de5d848451fda (patch) | |
tree | fbf31a548eb9eb74a27ff378c4d7eb101c3685c8 /lib/Serialization/ASTReader.cpp | |
parent | 42adacbb9bc7b6172bd36f9baa297180c77ab6d7 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165746 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTReader.cpp')
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 5657ee23bc..8f18eb8465 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/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. |