diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-04-23 23:29:05 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-04-23 23:29:05 +0000 |
commit | 50474bf5d2356feab24d985cac3ea91f856df59b (patch) | |
tree | 0936843b327d846c0a5f6775361e71e7bb5768ba /clang/lib/Serialization | |
parent | 43fb8a157b270e70d553231c8561a2efd012c774 (diff) | |
download | bcm5719-llvm-50474bf5d2356feab24d985cac3ea91f856df59b.tar.gz bcm5719-llvm-50474bf5d2356feab24d985cac3ea91f856df59b.zip |
[modules] Refactor creation of ModuleMacros and create them when importing from local submodules.
llvm-svn: 235669
Diffstat (limited to 'clang/lib/Serialization')
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 847f1ff8817..39aac12328f 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -1735,9 +1735,7 @@ struct ASTReader::ModuleMacroInfo { } MacroDirective *import(Preprocessor &PP, SourceLocation ImportLoc) const { - if (auto *MI = MM->getMacroInfo()) - return PP.AllocateDefMacroDirective(MI, ImportLoc, MM); - return PP.AllocateUndefMacroDirective(ImportLoc, MM); + return PP.AllocateImportedMacroDirective(MM, ImportLoc); } }; @@ -1843,16 +1841,17 @@ void ASTReader::resolvePendingMacro(IdentifierInfo *II, ModuleMacro *MM = nullptr; if (SubmoduleID ImportedFrom = getGlobalSubmoduleID(M, Record[Idx++])) MM = PP.getModuleMacro(getSubmodule(ImportedFrom), II); - DefMacroDirective *DefMD = PP.AllocateDefMacroDirective(MI, Loc, MM); - DefMD->setAmbiguous(IsAmbiguous); - MD = DefMD; + MD = MM ? PP.AllocateImportedMacroDirective(MM, Loc) + : PP.AllocateDefMacroDirective(MI, Loc); + cast<DefMacroDirective>(MD)->setAmbiguous(IsAmbiguous); break; } case MacroDirective::MD_Undefine: { ModuleMacro *MM = nullptr; if (SubmoduleID ImportedFrom = getGlobalSubmoduleID(M, Record[Idx++])) MM = PP.getModuleMacro(getSubmodule(ImportedFrom), II); - MD = PP.AllocateUndefMacroDirective(Loc, MM); + MD = MM ? PP.AllocateImportedMacroDirective(MM, Loc) + : PP.AllocateUndefMacroDirective(Loc); break; } case MacroDirective::MD_Visibility: |