r235648 - [modules] Remove the now-redundant import of all pending macros at the end of building a module.
Richard Smith
richard-llvm at metafoo.co.uk
Thu Apr 23 14:20:19 PDT 2015
Author: rsmith
Date: Thu Apr 23 16:20:19 2015
New Revision: 235648
URL: http://llvm.org/viewvc/llvm-project?rev=235648&view=rev
Log:
[modules] Remove the now-redundant import of all pending macros at the end of building a module.
Since we now track module macros separately from their visibility state, this
is no longer necessary.
Modified:
cfe/trunk/include/clang/Lex/MacroInfo.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReader.cpp
Modified: cfe/trunk/include/clang/Lex/MacroInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/MacroInfo.h?rev=235648&r1=235647&r2=235648&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/MacroInfo.h (original)
+++ cfe/trunk/include/clang/Lex/MacroInfo.h Thu Apr 23 16:20:19 2015
@@ -507,8 +507,7 @@ public:
class UndefMacroDirective : public MacroDirective {
UndefMacroDirective(SourceLocation UndefLoc, ModuleMacro *ImportedFrom)
: MacroDirective(MD_Undefine, UndefLoc, ImportedFrom) {
- // FIXME: We should have a valid UndefLoc even for an imported macro.
- assert((UndefLoc.isValid() || ImportedFrom) && "Invalid UndefLoc!");
+ assert(UndefLoc.isValid() && "Invalid UndefLoc!");
}
public:
Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=235648&r1=235647&r2=235648&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Apr 23 16:20:19 2015
@@ -1366,8 +1366,7 @@ public:
bool Complain);
/// \brief Make the names within this set of hidden names visible.
- void makeNamesVisible(const HiddenNames &Names, Module *Owner,
- bool FromFinalization);
+ void makeNamesVisible(const HiddenNames &Names, Module *Owner);
/// \brief Take the AST callbacks listener.
std::unique_ptr<ASTReaderListener> takeListener() {
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=235648&r1=235647&r2=235648&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Apr 23 16:20:19 2015
@@ -1965,14 +1965,6 @@ void ASTReader::installImportedMacro(Ide
assert(II && Owner);
SourceLocation ImportLoc = Owner->MacroVisibilityLoc;
- if (ImportLoc.isInvalid()) {
- // FIXME: If we made macros from this module visible but didn't provide a
- // source location for the import, we don't have a location for the macro.
- // Use the location at which the containing module file was first imported
- // for now.
- ImportLoc = MMI.F->DirectImportLoc;
- assert(ImportLoc.isValid() && "no import location for a visible macro?");
- }
AmbiguousMacros *Prev =
removeOverriddenMacros(II, ImportLoc, MMI.getOverriddenMacros());
@@ -3426,8 +3418,10 @@ static void moveMethodToBackOfGlobalList
}
}
-void ASTReader::makeNamesVisible(const HiddenNames &Names, Module *Owner,
- bool FromFinalization) {
+void ASTReader::makeNamesVisible(const HiddenNames &Names, Module *Owner) {
+ assert(Owner->NameVisibility >= Module::MacrosVisible &&
+ "nothing to make visible?");
+
// FIXME: Only do this if Owner->NameVisibility == AllVisible.
for (Decl *D : Names.HiddenDecls) {
bool wasHidden = D->Hidden;
@@ -3440,15 +3434,8 @@ void ASTReader::makeNamesVisible(const H
}
}
- assert((FromFinalization || Owner->NameVisibility >= Module::MacrosVisible) &&
- "nothing to make visible?");
- for (const auto &Macro : Names.HiddenMacros) {
- if (FromFinalization)
- PP.appendMacroDirective(Macro.first,
- Macro.second->import(PP, SourceLocation()));
- else
- installImportedMacro(Macro.first, *Macro.second, Owner);
- }
+ for (const auto &Macro : Names.HiddenMacros)
+ installImportedMacro(Macro.first, *Macro.second, Owner);
}
void ASTReader::makeModuleVisible(Module *Mod,
@@ -3484,8 +3471,7 @@ void ASTReader::makeModuleVisible(Module
if (Hidden != HiddenNamesMap.end()) {
auto HiddenNames = std::move(*Hidden);
HiddenNamesMap.erase(Hidden);
- makeNamesVisible(HiddenNames.second, HiddenNames.first,
- /*FromFinalization*/false);
+ makeNamesVisible(HiddenNames.second, HiddenNames.first);
assert(HiddenNamesMap.find(Mod) == HiddenNamesMap.end() &&
"making names visible added hidden names");
}
@@ -4018,12 +4004,7 @@ void ASTReader::InitializeContext() {
}
void ASTReader::finalizeForWriting() {
- while (!HiddenNamesMap.empty()) {
- auto HiddenNames = std::move(*HiddenNamesMap.begin());
- HiddenNamesMap.erase(HiddenNamesMap.begin());
- makeNamesVisible(HiddenNames.second, HiddenNames.first,
- /*FromFinalization*/true);
- }
+ // Nothing to do for now.
}
/// \brief Given a cursor at the start of an AST file, scan ahead and drop the
More information about the cfe-commits
mailing list