Reorganize built-in initialization to separate the creation of target builtins from marking IdentifierInfos as builtins. No functionality change

llvm-svn: 69774
This commit is contained in:
Douglas Gregor 2009-04-22 04:56:28 +00:00
parent 658ba85820
commit f89771cb87
4 changed files with 17 additions and 9 deletions

View File

@ -51,12 +51,15 @@ class Context {
unsigned NumTSRecords;
public:
Context() : TSRecords(0), NumTSRecords(0) {}
/// \brief Load all of the target builtins. This should be called
/// prior to initializing the builtin identifiers.
void InitializeTargetBuiltins(const TargetInfo &Target);
/// InitializeBuiltins - Mark the identifiers for all the builtins with their
/// appropriate builtin ID # and mark any non-portable builtin identifiers as
/// such.
void InitializeBuiltins(IdentifierTable &Table, const TargetInfo &Target,
bool NoBuiltins = false);
void InitializeBuiltins(IdentifierTable &Table, bool NoBuiltins = false);
/// Builtin::GetName - Return the identifier name for the specified builtin,
/// e.g. "__builtin_abs".

View File

@ -41,7 +41,8 @@ ASTContext::ASTContext(const LangOptions& LOpts, SourceManager &SM,
ExternalSource(0) {
if (size_reserve > 0) Types.reserve(size_reserve);
InitBuiltinTypes();
BuiltinInfo.InitializeBuiltins(idents, Target, LangOpts.NoBuiltin);
BuiltinInfo.InitializeTargetBuiltins(Target);
BuiltinInfo.InitializeBuiltins(idents, LangOpts.NoBuiltin);
TUDecl = TranslationUnitDecl::Create(*this);
}

View File

@ -32,12 +32,16 @@ const Builtin::Info &Builtin::Context::GetRecord(unsigned ID) const {
return TSRecords[ID - Builtin::FirstTSBuiltin];
}
/// \brief Load all of the target builtins. This must be called
/// prior to initializing the builtin identifiers.
void Builtin::Context::InitializeTargetBuiltins(const TargetInfo &Target) {
Target.getTargetBuiltins(TSRecords, NumTSRecords);
}
/// InitializeBuiltins - Mark the identifiers for all the builtins with their
/// appropriate builtin ID # and mark any non-portable builtin identifiers as
/// such.
void Builtin::Context::InitializeBuiltins(IdentifierTable &Table,
const TargetInfo &Target,
bool NoBuiltins) {
// Step #1: mark all target-independent builtins with their ID's.
for (unsigned i = Builtin::NotBuiltin+1; i != Builtin::FirstTSBuiltin; ++i)
@ -45,10 +49,7 @@ void Builtin::Context::InitializeBuiltins(IdentifierTable &Table,
(!NoBuiltins || !strchr(BuiltinInfo[i].Attributes, 'f')))
Table.get(BuiltinInfo[i].Name).setBuiltinID(i);
// Step #2: Get target builtins.
Target.getTargetBuiltins(TSRecords, NumTSRecords);
// Step #3: Register target-specific builtins.
// Step #2: Register target-specific builtins.
for (unsigned i = 0, e = NumTSRecords; i != e; ++i)
if (!TSRecords[i].Suppressed &&
(!NoBuiltins ||

View File

@ -1762,6 +1762,9 @@ PCHReader::PCHReadResult PCHReader::ReadPCH(const std::string &FileName) {
if (Pos == IdTable->end())
continue;
fprintf(stderr, "Looked up pre-allocated IdentifierInfo \"%s\"\n",
II->getName());
// Dereferencing the iterator has the effect of populating the
// IdentifierInfo node with the various declarations it needs.
(void)*Pos;