make -dM emit macros in a deterministic (sorted) order instead of
random hash table order, I don't like non-determinstic output. llvm-svn: 64248
This commit is contained in:
parent
99c7275118
commit
1ec246d233
|
@ -583,7 +583,6 @@ static void PrintMacroDefinition(IdentifierInfo &II, const MacroInfo &MI,
|
||||||
OS << ' ';
|
OS << ' ';
|
||||||
|
|
||||||
llvm::SmallVector<char, 128> SpellingBuffer;
|
llvm::SmallVector<char, 128> SpellingBuffer;
|
||||||
|
|
||||||
for (MacroInfo::tokens_iterator I = MI.tokens_begin(), E = MI.tokens_end();
|
for (MacroInfo::tokens_iterator I = MI.tokens_begin(), E = MI.tokens_end();
|
||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
if (I->hasLeadingSpace())
|
if (I->hasLeadingSpace())
|
||||||
|
@ -599,6 +598,14 @@ static void PrintMacroDefinition(IdentifierInfo &II, const MacroInfo &MI,
|
||||||
OS << "\n";
|
OS << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
struct SortMacrosByID {
|
||||||
|
typedef std::pair<IdentifierInfo*, MacroInfo*> id_macro_pair;
|
||||||
|
bool operator()(const id_macro_pair &LHS, const id_macro_pair &RHS) const {
|
||||||
|
return strcmp(LHS.first->getName(), RHS.first->getName()) < 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// DoPrintPreprocessedInput - This implements -E mode.
|
/// DoPrintPreprocessedInput - This implements -E mode.
|
||||||
///
|
///
|
||||||
|
@ -629,9 +636,14 @@ void clang::DoPrintPreprocessedInput(Preprocessor &PP,
|
||||||
do PP.Lex(Tok);
|
do PP.Lex(Tok);
|
||||||
while (Tok.isNot(tok::eof));
|
while (Tok.isNot(tok::eof));
|
||||||
|
|
||||||
|
std::vector<std::pair<IdentifierInfo*, MacroInfo*> > MacrosByID;
|
||||||
for (Preprocessor::macro_iterator I = PP.macro_begin(), E = PP.macro_end();
|
for (Preprocessor::macro_iterator I = PP.macro_begin(), E = PP.macro_end();
|
||||||
I != E; ++I)
|
I != E; ++I)
|
||||||
PrintMacroDefinition(*I->first, *I->second, PP, OS);
|
MacrosByID.push_back(*I);
|
||||||
|
std::sort(MacrosByID.begin(), MacrosByID.end(), SortMacrosByID());
|
||||||
|
|
||||||
|
for (unsigned i = 0, e = MacrosByID.size(); i != e; ++i)
|
||||||
|
PrintMacroDefinition(*MacrosByID[i].first, *MacrosByID[i].second, PP, OS);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
PrintPPOutputPPCallbacks *Callbacks;
|
PrintPPOutputPPCallbacks *Callbacks;
|
||||||
|
|
Loading…
Reference in New Issue