/// MacroUndefined - This hook is called whenever a macro #undef is seen.
/// MI is released immediately following this callback.
- virtual void MacroUndefined(const IdentifierInfo *II, const MacroInfo *MI) {
+ virtual void MacroUndefined(SourceLocation Loc, const IdentifierInfo *II,
+ const MacroInfo *MI) {
}
};
Second->MacroDefined(II, MI);
}
- virtual void MacroUndefined(const IdentifierInfo *II, const MacroInfo *MI) {
- First->MacroUndefined(II, MI);
- Second->MacroUndefined(II, MI);
+ virtual void MacroUndefined(SourceLocation Loc, const IdentifierInfo *II,
+ const MacroInfo *MI) {
+ First->MacroUndefined(Loc, II, MI);
+ Second->MacroUndefined(Loc, II, MI);
}
};
virtual void MacroExpands(const Token &Id, const MacroInfo* MI);
virtual void MacroDefined(const IdentifierInfo *II, const MacroInfo *MI);
- virtual void MacroUndefined(const IdentifierInfo *II, const MacroInfo *MI);
+ virtual void MacroUndefined(SourceLocation Loc, const IdentifierInfo *II,
+ const MacroInfo *MI);
};
} // end namespace clang
/// MacroDefined - This hook is called whenever a macro definition is seen.
void MacroDefined(const IdentifierInfo *II, const MacroInfo *MI);
+ /// MacroUndefined - This hook is called whenever a macro #undef is seen.
+ void MacroUndefined(SourceLocation Loc, const IdentifierInfo *II,
+ const MacroInfo *MI);
};
} // end anonymous namespace
EmittedMacroOnThisLine = true;
}
+void PrintPPOutputPPCallbacks::MacroUndefined(SourceLocation Loc,
+ const IdentifierInfo *II,
+ const MacroInfo *MI) {
+ // Only print out macro definitions in -dD mode.
+ if (!DumpDefines) return;
+
+ MoveToLine(Loc);
+ OS << "#undef " << II->getName();
+ EmittedMacroOnThisLine = true;
+}
void PrintPPOutputPPCallbacks::PragmaComment(SourceLocation Loc,
const IdentifierInfo *Kind,
// If the callbacks want to know, tell them about the macro #undef.
if (Callbacks)
- Callbacks->MacroUndefined(MacroNameTok.getIdentifierInfo(), MI);
+ Callbacks->MacroUndefined(MacroNameTok.getLocation(),
+ MacroNameTok.getIdentifierInfo(), MI);
// Free macro definition.
ReleaseMacroInfo(MI);
PreprocessedEntities.push_back(Def);
}
-void PreprocessingRecord::MacroUndefined(const IdentifierInfo *II,
+void PreprocessingRecord::MacroUndefined(SourceLocation Loc,
+ const IdentifierInfo *II,
const MacroInfo *MI) {
llvm::DenseMap<const MacroInfo *, MacroDefinition *>::iterator Pos
= MacroDefinitions.find(MI);
--- /dev/null
+// RUN: %clang_cc1 -E -dD %s | FileCheck %s
+// PR7818
+
+// CHECK: # 1 "{{.+}}.c"
+#define X 3
+// CHECK: #define X 3
+#undef X
+// CHECK: #undef X