public:
MacroState() : MacroState(nullptr) {}
MacroState(MacroDirective *MD) : State(MD) {}
- void destroy() {
+ MacroState(MacroState &&O) LLVM_NOEXCEPT : State(O.State) {
+ O.State = (MacroDirective *)nullptr;
+ }
+ MacroState &operator=(MacroState &&O) LLVM_NOEXCEPT {
+ auto S = O.State;
+ O.State = (MacroDirective *)nullptr;
+ State = S;
+ return *this;
+ }
+ ~MacroState() {
if (auto *Info = State.dyn_cast<ModuleMacroInfo*>())
Info->~ModuleMacroInfo();
- State = (MacroDirective*)nullptr;
}
+
MacroDirective *getLatest() const {
if (auto *Info = State.dyn_cast<ModuleMacroInfo*>())
return Info->MD;
bool ExplicitlyPublic = false;
for (auto *MD = Macro.second.getLatest(); MD != SavedInfo.Latest;
MD = MD->getPrevious()) {
+ assert(MD && "broken macro directive chain");
+
// Skip macros defined in other submodules we #included along the way.
Module *Mod = getModuleContainingLocation(MD->getLocation());
if (Mod != Info.M)
Info.M->NameVisibility = Module::MacrosVisible;
Info.M->MacroVisibilityLoc = Info.ImportLoc;
++MacroVisibilityGeneration;
- // FIXME: Also mark any exported macros as visible, and check for conflicts.
+ // FIXME: Also mark any exported modules as visible, and check for
+ // conflicts.
}
BuildingSubmoduleStack.pop_back();
Preprocessor::~Preprocessor() {
assert(BacktrackPositions.empty() && "EnableBacktrack/Backtrack imbalance!");
- for (auto &Macro : Macros)
- Macro.second.destroy();
-
IncludeMacroStack.clear();
// Destroy any macro definitions.