return X.first->getName().compare(Y.first->getName());
}
+static bool shouldIgnoreMacro(MacroDirective *MD, bool IsModule,
+ const Preprocessor &PP) {
+ if (MD->getInfo()->isBuiltinMacro())
+ return true;
+
+ if (IsModule) {
+ SourceLocation Loc = MD->getLocation();
+ if (Loc.isInvalid())
+ return true;
+ if (PP.getSourceManager().getFileID(Loc) == PP.getPredefinesFileID())
+ return true;
+ }
+
+ return false;
+}
+
/// \brief Writes the block containing the serialized form of the
/// preprocessor.
///
for (MacroDirective *MD = MacrosToEmit[I].second; MD;
MD = MD->getPrevious()) {
+ if (shouldIgnoreMacro(MD, IsModule, PP))
+ continue;
+
MacroID ID = getMacroRef(MD);
if (!ID)
continue;
return false;
if (Macro || (Macro = PP.getMacroDirectiveHistory(II)))
- return !Macro->getInfo()->isBuiltinMacro() &&
+ return !shouldIgnoreMacro(Macro, IsModule, PP) &&
(!IsModule || Macro->isPublic());
return false;
DataLen += 2; // 2 bytes for flags
if (hadMacroDefinition(II, Macro)) {
for (MacroDirective *M = Macro; M; M = M->getPrevious()) {
+ if (shouldIgnoreMacro(M, IsModule, PP))
+ continue;
if (Writer.getMacroRef(M) != 0)
DataLen += 4;
}
if (HadMacroDefinition) {
// Write all of the macro IDs associated with this identifier.
for (MacroDirective *M = Macro; M; M = M->getPrevious()) {
+ if (shouldIgnoreMacro(M, IsModule, PP))
+ continue;
if (MacroID ID = Writer.getMacroRef(M))
clang::io::Emit32(Out, ID);
}