#ifndef LLVM_CLANG_AST_ASTCONTEXT_H
#define LLVM_CLANG_AST_ASTCONTEXT_H
-#include "clang/Basic/Builtins.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/LangOptions.h"
#include "clang/AST/Attr.h"
class ObjCIvarRefExpr;
class ObjCIvarDecl;
+ namespace Builtin { class Context; }
+
/// ASTContext - This class holds long-lived AST nodes (such as types and
/// decls) that can be referred to throughout the semantic analysis of a file.
class ASTContext {
TargetInfo &Target;
IdentifierTable &Idents;
SelectorTable &Selectors;
+ Builtin::Context &BuiltinInfo;
DeclarationNameTable DeclarationNames;
llvm::OwningPtr<ExternalASTSource> ExternalSource;
clang::PrintingPolicy PrintingPolicy;
TranslationUnitDecl *getTranslationUnitDecl() const { return TUDecl; }
- Builtin::Context BuiltinInfo;
// Builtin Types.
QualType VoidTy;
QualType DependentTy;
ASTContext(const LangOptions& LOpts, SourceManager &SM, TargetInfo &t,
- IdentifierTable &idents, SelectorTable &sels,
- bool FreeMemory = true, unsigned size_reserve=0,
- bool InitializeBuiltins = true);
+ IdentifierTable &idents, SelectorTable &sels,
+ Builtin::Context &builtins,
+ bool FreeMemory = true, unsigned size_reserve=0);
~ASTContext();
- /// \brief Initialize builtins.
- ///
- /// Typically, this routine will be called automatically by the
- /// constructor. However, in certain cases (e.g., when there is a
- /// PCH file to be loaded), the constructor does not perform
- /// initialization for builtins. This routine can be called to
- /// perform the initialization.
- void InitializeBuiltins(IdentifierTable &idents);
-
/// \brief Attach an external AST source to the AST context.
///
/// The external AST source provides the ability to load parts of
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, bool NoBuiltins = false);
+ void InitializeBuiltins(IdentifierTable &Table, const TargetInfo &Target,
+ bool NoBuiltins = false);
/// \brief Popular the vector with the names of all of the builtins.
void GetBuiltinNames(llvm::SmallVectorImpl<const char *> &Names,
#include "clang/Lex/PPCallbacks.h"
#include "clang/Lex/TokenLexer.h"
#include "clang/Lex/PTHManager.h"
+#include "clang/Basic/Builtins.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/SourceLocation.h"
/// the lifetime fo the preprocessor.
SelectorTable Selectors;
+ /// BuiltinInfo - Information about builtins.
+ Builtin::Context BuiltinInfo;
+
/// PragmaHandlers - This tracks all of the pragmas that the client registered
/// with this preprocessor.
PragmaNamespace *PragmaHandlers;
IdentifierTable &getIdentifierTable() { return Identifiers; }
SelectorTable &getSelectorTable() { return Selectors; }
+ Builtin::Context &getBuiltinInfo() { return BuiltinInfo; }
llvm::BumpPtrAllocator &getPreprocessorAllocator() { return BP; }
void setPTHManager(PTHManager* pm);
#include "clang/AST/Expr.h"
#include "clang/AST/ExternalASTSource.h"
#include "clang/AST/RecordLayout.h"
+#include "clang/Basic/Builtins.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/StringExtras.h"
ASTContext::ASTContext(const LangOptions& LOpts, SourceManager &SM,
TargetInfo &t,
IdentifierTable &idents, SelectorTable &sels,
- bool FreeMem, unsigned size_reserve,
- bool InitializeBuiltins) :
+ Builtin::Context &builtins,
+ bool FreeMem, unsigned size_reserve) :
GlobalNestedNameSpecifier(0), CFConstantStringTypeDecl(0),
ObjCFastEnumerationStateTypeDecl(0), SourceMgr(SM), LangOpts(LOpts),
FreeMemory(FreeMem), Target(t), Idents(idents), Selectors(sels),
- ExternalSource(0) {
+ BuiltinInfo(builtins), ExternalSource(0) {
if (size_reserve > 0) Types.reserve(size_reserve);
InitBuiltinTypes();
TUDecl = TranslationUnitDecl::Create(*this);
- BuiltinInfo.InitializeTargetBuiltins(Target);
- if (InitializeBuiltins)
- this->InitializeBuiltins(idents);
PrintingPolicy.CPlusPlus = LangOpts.CPlusPlus;
}
TUDecl->Destroy(*this);
}
-void ASTContext::InitializeBuiltins(IdentifierTable &idents) {
- BuiltinInfo.InitializeBuiltins(idents, LangOpts.NoBuiltin);
-}
-
void
ASTContext::setExternalSource(llvm::OwningPtr<ExternalASTSource> &Source) {
ExternalSource.reset(Source.take());
// There are two things which impact the integer rank: the width, and
// the ordering of builtins. The builtin ordering is encoded in the
// bottom three bits; the width is encoded in the bits above that.
- if (FixedWidthIntType* FWIT = dyn_cast<FixedWidthIntType>(T)) {
+ if (FixedWidthIntType* FWIT = dyn_cast<FixedWidthIntType>(T))
return FWIT->getWidth() << 3;
- }
switch (cast<BuiltinType>(T)->getKind()) {
default: assert(0 && "getIntegerRank(): not a built-in integer");
#include "clang/AST/Stmt.h"
#include "clang/AST/Expr.h"
#include "clang/AST/PrettyPrinter.h"
+#include "clang/Basic/Builtins.h"
#include "clang/Basic/IdentifierTable.h"
#include <vector>
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/RecordLayout.h"
#include "clang/AST/StmtVisitor.h"
+#include "clang/Basic/Builtins.h"
#include "clang/Basic/TargetInfo.h"
#include <algorithm>
using namespace clang;
#include "clang/AST/RecordLayout.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/AST/ASTDiagnostic.h"
+#include "clang/Basic/Builtins.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/Compiler.h"
#include "clang/Analysis/PathSensitive/BugReporter.h"
#include "clang/AST/ParentMap.h"
#include "clang/AST/StmtObjC.h"
+#include "clang/Basic/Builtins.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/PrettyStackTrace.h"
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)
if (!BuiltinInfo[i].Suppressed &&
(!NoBuiltins || !strchr(BuiltinInfo[i].Attributes, 'f')))
Table.get(BuiltinInfo[i].Name).setBuiltinID(i);
+
+ // Get the target specific builtins from the target.
+ Target.getTargetBuiltins(TSRecords, NumTSRecords);
// Step #2: Register target-specific builtins.
for (unsigned i = 0, e = NumTSRecords; i != e; ++i)
#include "clang/AST/APValue.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/StmtVisitor.h"
+#include "clang/Basic/Builtins.h"
#include "llvm/Constants.h"
#include "llvm/Function.h"
#include "llvm/GlobalVariable.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclCXX.h"
+#include "clang/Basic/Builtins.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/Expr.h"
#include "clang/Parse/DeclSpec.h"
+#include "clang/Basic/Builtins.h"
#include "clang/Basic/LangOptions.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
-// RUN: clang-cc %s --triple=i686-apple-darwin9
+// RUN: clang-cc %s --triple=i686-apple-darwin9 &&
+// RUN: clang-cc %s -E --triple=i686-apple-darwin9
#ifndef __has_feature
#error Should have __has_feature
#endif
PP.getTargetInfo(),
PP.getIdentifierTable(),
PP.getSelectorTable(),
+ PP.getBuiltinInfo(),
/* FreeMemory = */ !DisableFree,
- /* size_reserve = */0,
- /* InitializeBuiltins = */ImplicitIncludePCH.empty()));
+ /* size_reserve = */0));
+
llvm::OwningPtr<PCHReader> Reader;
llvm::OwningPtr<ExternalASTSource> Source;
PhonyDependencyTarget);
}
- if (ImplicitIncludePCH.empty() &&
- InitializeSourceManager(*PP.get(), InFile))
- continue;
+ if (ImplicitIncludePCH.empty()) {
+ if (InitializeSourceManager(*PP.get(), InFile))
+ continue;
+
+ // Initialize builtin info.
+ PP->getBuiltinInfo().InitializeBuiltins(PP->getIdentifierTable(),
+ PP->getTargetInfo(),
+ PP->getLangOptions().NoBuiltin);
+ }
if (!HTMLDiag.empty())
((PathDiagnosticClient*)DiagClient.get())->SetPreprocessor(PP.get());