diff --git a/utils/TableGen/ClangASTNodesEmitter.cpp b/utils/TableGen/ClangASTNodesEmitter.cpp index 187ab467999..d9d5a3ccd90 100644 --- a/utils/TableGen/ClangASTNodesEmitter.cpp +++ b/utils/TableGen/ClangASTNodesEmitter.cpp @@ -155,10 +155,13 @@ void ClangDeclContextEmitter::run(raw_ostream &OS) { } } - for (RecordSet::iterator i = DeclContexts.begin(), e = DeclContexts.end(); - i != e; ++i) { - OS << "DECL_CONTEXT(" << (*i)->getName() << ")\n"; - } + // To keep identical order, RecordVector may be used + // instead of RecordSet. + for (RecordVector::iterator + i = DeclContextsVector.begin(), e = DeclContextsVector.end(); + i != e; ++i) + if (DeclContexts.find(*i) != DeclContexts.end()) + OS << "DECL_CONTEXT(" << (*i)->getName() << ")\n"; OS << "#undef DECL_CONTEXT\n"; OS << "#undef DECL_CONTEXT_BASE\n";