forked from OSchip/llvm-project
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:
parent
658ba85820
commit
f89771cb87
|
@ -51,12 +51,15 @@ class Context {
|
||||||
unsigned NumTSRecords;
|
unsigned NumTSRecords;
|
||||||
public:
|
public:
|
||||||
Context() : TSRecords(0), NumTSRecords(0) {}
|
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
|
/// InitializeBuiltins - Mark the identifiers for all the builtins with their
|
||||||
/// appropriate builtin ID # and mark any non-portable builtin identifiers as
|
/// appropriate builtin ID # and mark any non-portable builtin identifiers as
|
||||||
/// such.
|
/// such.
|
||||||
void InitializeBuiltins(IdentifierTable &Table, const TargetInfo &Target,
|
void InitializeBuiltins(IdentifierTable &Table, bool NoBuiltins = false);
|
||||||
bool NoBuiltins = false);
|
|
||||||
|
|
||||||
/// Builtin::GetName - Return the identifier name for the specified builtin,
|
/// Builtin::GetName - Return the identifier name for the specified builtin,
|
||||||
/// e.g. "__builtin_abs".
|
/// e.g. "__builtin_abs".
|
||||||
|
|
|
@ -41,7 +41,8 @@ ASTContext::ASTContext(const LangOptions& LOpts, SourceManager &SM,
|
||||||
ExternalSource(0) {
|
ExternalSource(0) {
|
||||||
if (size_reserve > 0) Types.reserve(size_reserve);
|
if (size_reserve > 0) Types.reserve(size_reserve);
|
||||||
InitBuiltinTypes();
|
InitBuiltinTypes();
|
||||||
BuiltinInfo.InitializeBuiltins(idents, Target, LangOpts.NoBuiltin);
|
BuiltinInfo.InitializeTargetBuiltins(Target);
|
||||||
|
BuiltinInfo.InitializeBuiltins(idents, LangOpts.NoBuiltin);
|
||||||
TUDecl = TranslationUnitDecl::Create(*this);
|
TUDecl = TranslationUnitDecl::Create(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,12 +32,16 @@ const Builtin::Info &Builtin::Context::GetRecord(unsigned ID) const {
|
||||||
return TSRecords[ID - Builtin::FirstTSBuiltin];
|
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
|
/// InitializeBuiltins - Mark the identifiers for all the builtins with their
|
||||||
/// appropriate builtin ID # and mark any non-portable builtin identifiers as
|
/// appropriate builtin ID # and mark any non-portable builtin identifiers as
|
||||||
/// such.
|
/// such.
|
||||||
void Builtin::Context::InitializeBuiltins(IdentifierTable &Table,
|
void Builtin::Context::InitializeBuiltins(IdentifierTable &Table,
|
||||||
const TargetInfo &Target,
|
|
||||||
bool NoBuiltins) {
|
bool NoBuiltins) {
|
||||||
// Step #1: mark all target-independent builtins with their ID's.
|
// Step #1: mark all target-independent builtins with their ID's.
|
||||||
for (unsigned i = Builtin::NotBuiltin+1; i != Builtin::FirstTSBuiltin; ++i)
|
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')))
|
(!NoBuiltins || !strchr(BuiltinInfo[i].Attributes, 'f')))
|
||||||
Table.get(BuiltinInfo[i].Name).setBuiltinID(i);
|
Table.get(BuiltinInfo[i].Name).setBuiltinID(i);
|
||||||
|
|
||||||
// Step #2: Get target builtins.
|
// Step #2: Register target-specific builtins.
|
||||||
Target.getTargetBuiltins(TSRecords, NumTSRecords);
|
|
||||||
|
|
||||||
// Step #3: Register target-specific builtins.
|
|
||||||
for (unsigned i = 0, e = NumTSRecords; i != e; ++i)
|
for (unsigned i = 0, e = NumTSRecords; i != e; ++i)
|
||||||
if (!TSRecords[i].Suppressed &&
|
if (!TSRecords[i].Suppressed &&
|
||||||
(!NoBuiltins ||
|
(!NoBuiltins ||
|
||||||
|
|
|
@ -1762,6 +1762,9 @@ PCHReader::PCHReadResult PCHReader::ReadPCH(const std::string &FileName) {
|
||||||
if (Pos == IdTable->end())
|
if (Pos == IdTable->end())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
fprintf(stderr, "Looked up pre-allocated IdentifierInfo \"%s\"\n",
|
||||||
|
II->getName());
|
||||||
|
|
||||||
// Dereferencing the iterator has the effect of populating the
|
// Dereferencing the iterator has the effect of populating the
|
||||||
// IdentifierInfo node with the various declarations it needs.
|
// IdentifierInfo node with the various declarations it needs.
|
||||||
(void)*Pos;
|
(void)*Pos;
|
||||||
|
|
Loading…
Reference in New Issue