clang API Documentation

Defines | Functions
InitPreprocessor.cpp File Reference
#include "clang/Frontend/Utils.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/MacroBuilder.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/Version.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/Frontend/FrontendOptions.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Serialization/ASTReader.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
Include dependency graph for InitPreprocessor.cpp:

Go to the source code of this file.

Defines

#define TOSTR2(X)   #X
#define TOSTR(X)   TOSTR2(X)
#define DEFINE_LOCK_FREE_MACRO(TYPE, Type)

Functions

static bool MacroBodyEndsInBackslash (StringRef MacroBody)
static void DefineBuiltinMacro (MacroBuilder &Builder, StringRef Macro, DiagnosticsEngine &Diags)
static void AddImplicitInclude (MacroBuilder &Builder, StringRef File)
static void AddImplicitIncludeMacros (MacroBuilder &Builder, StringRef File)
static void AddImplicitIncludePTH (MacroBuilder &Builder, Preprocessor &PP, StringRef ImplicitIncludePTH)
static void AddImplicitIncludePCH (MacroBuilder &Builder, Preprocessor &PP, StringRef ImplicitIncludePCH)
 Add an implicit #include using the original file used to generate a PCH file.
template<typename T >
static T PickFP (const llvm::fltSemantics *Sem, T IEEESingleVal, T IEEEDoubleVal, T X87DoubleExtendedVal, T PPCDoubleDoubleVal, T IEEEQuadVal)
static void DefineFloatMacros (MacroBuilder &Builder, StringRef Prefix, const llvm::fltSemantics *Sem, StringRef Ext)
static void DefineTypeSize (const Twine &MacroName, unsigned TypeWidth, StringRef ValSuffix, bool isSigned, MacroBuilder &Builder)
static void DefineTypeSize (const Twine &MacroName, TargetInfo::IntType Ty, const TargetInfo &TI, MacroBuilder &Builder)
static void DefineFmt (const Twine &Prefix, TargetInfo::IntType Ty, const TargetInfo &TI, MacroBuilder &Builder)
static void DefineType (const Twine &MacroName, TargetInfo::IntType Ty, MacroBuilder &Builder)
static void DefineTypeWidth (StringRef MacroName, TargetInfo::IntType Ty, const TargetInfo &TI, MacroBuilder &Builder)
static void DefineTypeSizeof (StringRef MacroName, unsigned BitWidth, const TargetInfo &TI, MacroBuilder &Builder)
static void DefineExactWidthIntType (TargetInfo::IntType Ty, const TargetInfo &TI, MacroBuilder &Builder)
static void DefineExactWidthIntTypeSize (TargetInfo::IntType Ty, const TargetInfo &TI, MacroBuilder &Builder)
static void DefineLeastWidthIntType (unsigned TypeWidth, bool IsSigned, const TargetInfo &TI, MacroBuilder &Builder)
static void DefineFastIntType (unsigned TypeWidth, bool IsSigned, const TargetInfo &TI, MacroBuilder &Builder)
static const char * getLockFreeValue (unsigned TypeWidth, unsigned TypeAlign, unsigned InlineWidth)
static void AddObjCXXARCLibstdcxxDefines (const LangOptions &LangOpts, MacroBuilder &Builder)
 Add definitions required for a smooth interaction between Objective-C++ automated reference counting and libstdc++ (4.2).
static void InitializeStandardPredefinedMacros (const TargetInfo &TI, const LangOptions &LangOpts, const FrontendOptions &FEOpts, MacroBuilder &Builder)
static void InitializeCPlusPlusFeatureTestMacros (const LangOptions &LangOpts, MacroBuilder &Builder)
static void InitializePredefinedMacros (const TargetInfo &TI, const LangOptions &LangOpts, const FrontendOptions &FEOpts, MacroBuilder &Builder)

Define Documentation

#define DEFINE_LOCK_FREE_MACRO (   TYPE,
  Type 
)
Value:
Builder.defineMacro("__GCC_ATOMIC_" #TYPE "_LOCK_FREE", \
                        getLockFreeValue(TI.get##Type##Width(), \
                                         TI.get##Type##Align(), \
                                         InlineWidthBits));

Referenced by InitializePredefinedMacros().

#define TOSTR (   X)    TOSTR2(X)
#define TOSTR2 (   X)    #X

Function Documentation

static void AddImplicitInclude ( MacroBuilder Builder,
StringRef  File 
) [static]

AddImplicitInclude - Add an implicit #include of the specified file to the predefines buffer. As these includes are generated by -include arguments the header search logic is going to search relatively to the current working directory.

Definition at line 70 of file InitPreprocessor.cpp.

References clang::MacroBuilder::append().

Referenced by AddImplicitIncludePCH(), AddImplicitIncludePTH(), and clang::InitializePreprocessor().

static void AddImplicitIncludeMacros ( MacroBuilder Builder,
StringRef  File 
) [static]

Definition at line 74 of file InitPreprocessor.cpp.

References clang::MacroBuilder::append().

Referenced by clang::InitializePreprocessor().

static void AddImplicitIncludePCH ( MacroBuilder Builder,
Preprocessor PP,
StringRef  ImplicitIncludePCH 
) [static]

Add an implicit #include using the original file used to generate a PCH file.

Definition at line 99 of file InitPreprocessor.cpp.

References AddImplicitInclude(), clang::Preprocessor::getDiagnostics(), clang::Preprocessor::getFileManager(), and clang::ASTReader::getOriginalSourceFile().

Referenced by clang::InitializePreprocessor().

static void AddImplicitIncludePTH ( MacroBuilder Builder,
Preprocessor PP,
StringRef  ImplicitIncludePTH 
) [static]

AddImplicitIncludePTH - Add an implicit #include using the original file used to generate a PTH cache.

Definition at line 82 of file InitPreprocessor.cpp.

References AddImplicitInclude(), clang::Preprocessor::getDiagnostics(), clang::PTHManager::getOriginalSourceFile(), clang::Preprocessor::getPTHManager(), P, and clang::DiagnosticsEngine::Report().

Referenced by clang::InitializePreprocessor().

static void AddObjCXXARCLibstdcxxDefines ( const LangOptions LangOpts,
MacroBuilder Builder 
) [static]

Add definitions required for a smooth interaction between Objective-C++ automated reference counting and libstdc++ (4.2).

Definition at line 302 of file InitPreprocessor.cpp.

References clang::MacroBuilder::append(), and clang::MacroBuilder::defineMacro().

Referenced by clang::InitializePreprocessor().

static void DefineBuiltinMacro ( MacroBuilder Builder,
StringRef  Macro,
DiagnosticsEngine Diags 
) [static]
static void DefineExactWidthIntType ( TargetInfo::IntType  Ty,
const TargetInfo TI,
MacroBuilder Builder 
) [static]
static void DefineExactWidthIntTypeSize ( TargetInfo::IntType  Ty,
const TargetInfo TI,
MacroBuilder Builder 
) [static]
static void DefineFastIntType ( unsigned  TypeWidth,
bool  IsSigned,
const TargetInfo TI,
MacroBuilder Builder 
) [static]
static void DefineFloatMacros ( MacroBuilder Builder,
StringRef  Prefix,
const llvm::fltSemantics *  Sem,
StringRef  Ext 
) [static]

Definition at line 128 of file InitPreprocessor.cpp.

References clang::MacroBuilder::defineMacro(), and PickFP().

Referenced by InitializePredefinedMacros().

static void DefineFmt ( const Twine &  Prefix,
TargetInfo::IntType  Ty,
const TargetInfo TI,
MacroBuilder Builder 
) [static]
static void DefineLeastWidthIntType ( unsigned  TypeWidth,
bool  IsSigned,
const TargetInfo TI,
MacroBuilder Builder 
) [static]
static void DefineType ( const Twine &  MacroName,
TargetInfo::IntType  Ty,
MacroBuilder Builder 
) [static]
static void DefineTypeSize ( const Twine &  MacroName,
unsigned  TypeWidth,
StringRef  ValSuffix,
bool  isSigned,
MacroBuilder Builder 
) [static]

DefineTypeSize - Emit a macro to the predefines buffer that declares a macro named MacroName with the max value for a type with width 'TypeWidth' a signedness of 'isSigned' and with a value suffix of 'ValSuffix' (e.g. LL).

Definition at line 180 of file InitPreprocessor.cpp.

References clang::MacroBuilder::defineMacro().

Referenced by DefineExactWidthIntTypeSize(), DefineFastIntType(), DefineLeastWidthIntType(), DefineTypeSize(), and InitializePredefinedMacros().

static void DefineTypeSize ( const Twine &  MacroName,
TargetInfo::IntType  Ty,
const TargetInfo TI,
MacroBuilder Builder 
) [static]

DefineTypeSize - An overloaded helper that uses TargetInfo to determine the width, suffix, and signedness of the given type

Definition at line 190 of file InitPreprocessor.cpp.

References Builder, DefineTypeSize(), clang::TargetInfo::getTypeConstantSuffix(), clang::TargetInfo::getTypeWidth(), and clang::TargetInfo::isTypeSigned().

static void DefineTypeSizeof ( StringRef  MacroName,
unsigned  BitWidth,
const TargetInfo TI,
MacroBuilder Builder 
) [static]
static void DefineTypeWidth ( StringRef  MacroName,
TargetInfo::IntType  Ty,
const TargetInfo TI,
MacroBuilder Builder 
) [static]
static const char* getLockFreeValue ( unsigned  TypeWidth,
unsigned  TypeAlign,
unsigned  InlineWidth 
) [static]

Get the value the ATOMIC_*_LOCK_FREE macro should have for a type with the specified properties.

Definition at line 288 of file InitPreprocessor.cpp.

Referenced by InitializePredefinedMacros().

static void InitializeCPlusPlusFeatureTestMacros ( const LangOptions LangOpts,
MacroBuilder Builder 
) [static]

Initialize the predefined C++ language feature test macros defined in ISO/IEC JTC1/SC22/WG21 (C++) SD-6: "SG10 Feature Test Recommendations".

Definition at line 410 of file InitPreprocessor.cpp.

References clang::MacroBuilder::defineMacro().

Referenced by InitializePredefinedMacros().

static void InitializePredefinedMacros ( const TargetInfo TI,
const LangOptions LangOpts,
const FrontendOptions FEOpts,
MacroBuilder Builder 
) [static]

Definition at line 456 of file InitPreprocessor.cpp.

References Builder, CLANG_VERSION_STRING, DEFINE_LOCK_FREE_MACRO, DefineExactWidthIntType(), DefineExactWidthIntTypeSize(), DefineFastIntType(), DefineFloatMacros(), DefineFmt(), DefineLeastWidthIntType(), clang::MacroBuilder::defineMacro(), DefineType(), DefineTypeSize(), DefineTypeSizeof(), DefineTypeWidth(), clang::TargetInfo::getChar16Type(), clang::TargetInfo::getChar32Type(), clang::TargetInfo::getCharWidth(), clang::getClangFullCPPVersion(), clang::getClangFullRepositoryVersion(), clang::TargetInfo::getDoubleFormat(), clang::TargetInfo::getDoubleWidth(), clang::TargetInfo::getFloatEvalMethod(), clang::TargetInfo::getFloatFormat(), clang::TargetInfo::getFloatWidth(), clang::TargetInfo::getIntMaxType(), clang::TargetInfo::getIntPtrType(), clang::TargetInfo::getIntWidth(), clang::ObjCRuntime::getKind(), getLockFreeValue(), clang::TargetInfo::getLongDoubleFormat(), clang::TargetInfo::getLongDoubleWidth(), clang::TargetInfo::getLongLongWidth(), clang::TargetInfo::getLongWidth(), clang::VersionTuple::getMajor(), clang::TargetInfo::getMaxAtomicInlineWidth(), clang::VersionTuple::getMinor(), clang::TargetInfo::getPointerAlign(), clang::TargetInfo::getPointerWidth(), clang::TargetInfo::getPtrDiffType(), clang::TargetInfo::getShortWidth(), clang::TargetInfo::getSigAtomicType(), clang::TargetInfo::getSizeType(), clang::VersionTuple::getSubminor(), clang::TargetInfo::getTargetDefines(), clang::TargetInfo::getTypeConstantSuffix(), clang::TargetInfo::getTypeWidth(), clang::TargetInfo::getUIntMaxType(), clang::TargetInfo::getUIntPtrType(), clang::TargetInfo::getUserLabelPrefix(), clang::ObjCRuntime::getVersion(), clang::TargetInfo::getWCharType(), clang::TargetInfo::getWIntType(), clang::TargetInfo::hasInt128Type(), InitializeCPlusPlusFeatureTestMacros(), clang::TargetInfo::isBigEndian(), clang::ObjCRuntime::isNeXTFamily(), clang::ObjCRuntime::isNonFragile(), clang::TargetInfo::isTypeSigned(), clang::LangOptions::NonGC, clang::LangOptions::ObjCRuntime, clang::ObjCRuntime::ObjFW, PickFP(), clang::FrontendOptions::ProgramAction, clang::frontend::RewriteObjC, clang::frontend::RunAnalysis, clang::TargetInfo::SignedChar, clang::TargetInfo::SignedInt, clang::TargetInfo::SignedLong, clang::TargetInfo::SignedLongLong, clang::TargetInfo::SignedShort, clang::LangOptions::SSPOn, clang::LangOptions::SSPReq, clang::LangOptions::SSPStrong, TOSTR, clang::TargetInfo::UnsignedChar, clang::TargetInfo::UnsignedInt, clang::TargetInfo::UnsignedLong, clang::TargetInfo::UnsignedLongLong, and clang::TargetInfo::UnsignedShort.

Referenced by clang::InitializePreprocessor().

static void InitializeStandardPredefinedMacros ( const TargetInfo TI,
const LangOptions LangOpts,
const FrontendOptions FEOpts,
MacroBuilder Builder 
) [static]

Definition at line 353 of file InitPreprocessor.cpp.

References clang::MacroBuilder::defineMacro().

Referenced by clang::InitializePreprocessor().

static bool MacroBodyEndsInBackslash ( StringRef  MacroBody) [static]

Definition at line 32 of file InitPreprocessor.cpp.

References clang::isWhitespace().

Referenced by DefineBuiltinMacro().

template<typename T >
static T PickFP ( const llvm::fltSemantics *  Sem,
IEEESingleVal,
IEEEDoubleVal,
X87DoubleExtendedVal,
PPCDoubleDoubleVal,
IEEEQuadVal 
) [static]

PickFP - This is used to pick a value based on the FP semantics of the specified FP model.

Definition at line 113 of file InitPreprocessor.cpp.

Referenced by DefineFloatMacros(), and InitializePredefinedMacros().