clang  19.0.0git
Macros | Functions
InitPreprocessor.cpp File Reference
#include "clang/Basic/FileManager.h"
#include "clang/Basic/HLSLRuntime.h"
#include "clang/Basic/MacroBuilder.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/SyncScope.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/Version.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/Frontend/FrontendOptions.h"
#include "clang/Frontend/Utils.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/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "clang/Basic/OpenCLExtensions.def"
#include "clang/Basic/TargetOSMacros.def"

Go to the source code of this file.

Macros

#define OPENCL_GENERIC_EXTENSION(Ext, ...)    defineOpenCLExtMacro(#Ext, __VA_ARGS__);
 
#define TOSTR2(X)   #X
 
#define TOSTR(X)   TOSTR2(X)
 
#define DEFINE_LOCK_FREE_MACRO(TYPE, Type)
 
#define TARGET_OS(Name, Predicate)    Builder.defineMacro(#Name, (Predicate) ? "1" : "0");
 

Functions

static bool MacroBodyEndsInBackslash (StringRef MacroBody)
 
static void DefineBuiltinMacro (MacroBuilder &Builder, StringRef Macro, DiagnosticsEngine &Diags)
 
static void AddImplicitInclude (MacroBuilder &Builder, StringRef File)
 AddImplicitInclude - Add an implicit #include of the specified file to the predefines buffer. More...
 
static void AddImplicitIncludeMacros (MacroBuilder &Builder, StringRef File)
 
static void AddImplicitIncludePCH (MacroBuilder &Builder, Preprocessor &PP, const PCHContainerReader &PCHContainerRdr, StringRef ImplicitIncludePCH)
 Add an implicit #include using the original file used to generate a PCH file. More...
 
template<typename T >
static T PickFP (const llvm::fltSemantics *Sem, T IEEEHalfVal, T IEEESingleVal, T IEEEDoubleVal, T X87DoubleExtendedVal, T PPCDoubleDoubleVal, T IEEEQuadVal)
 PickFP - This is used to pick a value based on the FP semantics of the specified FP model. More...
 
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)
 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. More...
 
static void DefineTypeSize (const Twine &MacroName, TargetInfo::IntType Ty, const TargetInfo &TI, MacroBuilder &Builder)
 DefineTypeSize - An overloaded helper that uses TargetInfo to determine the width, suffix, and signedness of the given type. More...
 
static void DefineFmt (const LangOptions &LangOpts, 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 (const Twine &MacroName, TargetInfo::IntType Ty, const TargetInfo &TI, MacroBuilder &Builder)
 
static void DefineTypeSizeof (StringRef MacroName, unsigned BitWidth, const TargetInfo &TI, MacroBuilder &Builder)
 
static void DefineTypeSizeAndWidth (const Twine &Prefix, TargetInfo::IntType Ty, const TargetInfo &TI, MacroBuilder &Builder)
 
static void DefineExactWidthIntType (const LangOptions &LangOpts, TargetInfo::IntType Ty, const TargetInfo &TI, MacroBuilder &Builder)
 
static void DefineExactWidthIntTypeSize (TargetInfo::IntType Ty, const TargetInfo &TI, MacroBuilder &Builder)
 
static void DefineLeastWidthIntType (const LangOptions &LangOpts, unsigned TypeWidth, bool IsSigned, const TargetInfo &TI, MacroBuilder &Builder)
 
static void DefineFastIntType (const LangOptions &LangOpts, unsigned TypeWidth, bool IsSigned, const TargetInfo &TI, MacroBuilder &Builder)
 
static const char * getLockFreeValue (unsigned TypeWidth, const TargetInfo &TI)
 Get the value the ATOMIC_*_LOCK_FREE macro should have for a type with the specified properties. More...
 
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). More...
 
static void InitializeStandardPredefinedMacros (const TargetInfo &TI, const LangOptions &LangOpts, const FrontendOptions &FEOpts, MacroBuilder &Builder)
 
static void InitializeCPlusPlusFeatureTestMacros (const LangOptions &LangOpts, MacroBuilder &Builder)
 Initialize the predefined C++ language feature test macros defined in ISO/IEC JTC1/SC22/WG21 (C++) SD-6: "SG10 Feature Test Recommendations". More...
 
void InitializeOpenCLFeatureTestMacros (const TargetInfo &TI, const LangOptions &Opts, MacroBuilder &Builder)
 InitializeOpenCLFeatureTestMacros - Define OpenCL macros based on target settings and language version. More...
 
llvm::SmallString< 32 > ConstructFixedPointLiteral (llvm::APFixedPoint Val, llvm::StringRef Suffix)
 
void DefineFixedPointMacros (const TargetInfo &TI, MacroBuilder &Builder, llvm::StringRef TypeName, llvm::StringRef Suffix, unsigned Width, unsigned Scale, bool Signed)
 
static void InitializePredefinedMacros (const TargetInfo &TI, const LangOptions &LangOpts, const FrontendOptions &FEOpts, const PreprocessorOptions &PPOpts, MacroBuilder &Builder)
 
static void InitializePGOProfileMacros (const CodeGenOptions &CodeGenOpts, MacroBuilder &Builder)
 

Macro Definition Documentation

◆ DEFINE_LOCK_FREE_MACRO

#define DEFINE_LOCK_FREE_MACRO (   TYPE,
  Type 
)
Value:
Builder.defineMacro(Prefix + #TYPE "_LOCK_FREE", \
getLockFreeValue(TI.get##Type##Width(), TI));
#define TYPE(DERIVED, BASE)
Definition: ASTFwd.h:26
static const char * getLockFreeValue(unsigned TypeWidth, const TargetInfo &TI)
Get the value the ATOMIC_*_LOCK_FREE macro should have for a type with the specified properties.
The base class of the type hierarchy.
Definition: Type.h:1813

◆ OPENCL_GENERIC_EXTENSION

#define OPENCL_GENERIC_EXTENSION (   Ext,
  ... 
)     defineOpenCLExtMacro(#Ext, __VA_ARGS__);

◆ TARGET_OS

#define TARGET_OS (   Name,
  Predicate 
)     Builder.defineMacro(#Name, (Predicate) ? "1" : "0");

◆ TOSTR

#define TOSTR (   X)    TOSTR2(X)

◆ TOSTR2

#define TOSTR2 (   X)    #X

Function Documentation

◆ AddImplicitInclude()

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.

◆ AddImplicitIncludeMacros()

static void AddImplicitIncludeMacros ( MacroBuilder Builder,
StringRef  File 
)
static

Definition at line 74 of file InitPreprocessor.cpp.

◆ AddImplicitIncludePCH()

static void AddImplicitIncludePCH ( MacroBuilder Builder,
Preprocessor PP,
const PCHContainerReader PCHContainerRdr,
StringRef  ImplicitIncludePCH 
)
static

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

Definition at line 82 of file InitPreprocessor.cpp.

◆ AddObjCXXARCLibstdcxxDefines()

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 326 of file InitPreprocessor.cpp.

◆ ConstructFixedPointLiteral()

llvm::SmallString<32> ConstructFixedPointLiteral ( llvm::APFixedPoint  Val,
llvm::StringRef  Suffix 
)

Definition at line 809 of file InitPreprocessor.cpp.

◆ DefineBuiltinMacro()

static void DefineBuiltinMacro ( MacroBuilder Builder,
StringRef  Macro,
DiagnosticsEngine Diags 
)
static

Definition at line 41 of file InitPreprocessor.cpp.

◆ DefineExactWidthIntType()

static void DefineExactWidthIntType ( const LangOptions LangOpts,
TargetInfo::IntType  Ty,
const TargetInfo TI,
MacroBuilder Builder 
)
static

Definition at line 227 of file InitPreprocessor.cpp.

◆ DefineExactWidthIntTypeSize()

static void DefineExactWidthIntTypeSize ( TargetInfo::IntType  Ty,
const TargetInfo TI,
MacroBuilder Builder 
)
static

Definition at line 253 of file InitPreprocessor.cpp.

◆ DefineFastIntType()

static void DefineFastIntType ( const LangOptions LangOpts,
unsigned  TypeWidth,
bool  IsSigned,
const TargetInfo TI,
MacroBuilder Builder 
)
static

Definition at line 289 of file InitPreprocessor.cpp.

◆ DefineFixedPointMacros()

void DefineFixedPointMacros ( const TargetInfo TI,
MacroBuilder Builder,
llvm::StringRef  TypeName,
llvm::StringRef  Suffix,
unsigned  Width,
unsigned  Scale,
bool  Signed 
)

Definition at line 837 of file InitPreprocessor.cpp.

◆ DefineFloatMacros()

static void DefineFloatMacros ( MacroBuilder Builder,
StringRef  Prefix,
const llvm::fltSemantics *  Sem,
StringRef  Ext 
)
static

Definition at line 114 of file InitPreprocessor.cpp.

◆ DefineFmt()

static void DefineFmt ( const LangOptions LangOpts,
const Twine &  Prefix,
TargetInfo::IntType  Ty,
const TargetInfo TI,
MacroBuilder Builder 
)
static

Definition at line 184 of file InitPreprocessor.cpp.

◆ DefineLeastWidthIntType()

static void DefineLeastWidthIntType ( const LangOptions LangOpts,
unsigned  TypeWidth,
bool  IsSigned,
const TargetInfo TI,
MacroBuilder Builder 
)
static

Definition at line 270 of file InitPreprocessor.cpp.

◆ DefineType()

static void DefineType ( const Twine &  MacroName,
TargetInfo::IntType  Ty,
MacroBuilder Builder 
)
static

Definition at line 201 of file InitPreprocessor.cpp.

◆ DefineTypeSize() [1/2]

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 178 of file InitPreprocessor.cpp.

◆ DefineTypeSize() [2/2]

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 168 of file InitPreprocessor.cpp.

◆ DefineTypeSizeAndWidth()

static void DefineTypeSizeAndWidth ( const Twine &  Prefix,
TargetInfo::IntType  Ty,
const TargetInfo TI,
MacroBuilder Builder 
)
static

Definition at line 220 of file InitPreprocessor.cpp.

◆ DefineTypeSizeof()

static void DefineTypeSizeof ( StringRef  MacroName,
unsigned  BitWidth,
const TargetInfo TI,
MacroBuilder Builder 
)
static

Definition at line 211 of file InitPreprocessor.cpp.

◆ DefineTypeWidth()

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

Definition at line 206 of file InitPreprocessor.cpp.

◆ getLockFreeValue()

static const char* getLockFreeValue ( unsigned  TypeWidth,
const TargetInfo TI 
)
static

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

Definition at line 312 of file InitPreprocessor.cpp.

References clang::TargetInfo::hasBuiltinAtomic().

◆ InitializeCPlusPlusFeatureTestMacros()

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 661 of file InitPreprocessor.cpp.

◆ InitializeOpenCLFeatureTestMacros()

void InitializeOpenCLFeatureTestMacros ( const TargetInfo TI,
const LangOptions Opts,
MacroBuilder Builder 
)

InitializeOpenCLFeatureTestMacros - Define OpenCL macros based on target settings and language version.

Definition at line 788 of file InitPreprocessor.cpp.

◆ InitializePGOProfileMacros()

static void InitializePGOProfileMacros ( const CodeGenOptions CodeGenOpts,
MacroBuilder Builder 
)
static

Definition at line 1540 of file InitPreprocessor.cpp.

◆ InitializePredefinedMacros()

static void InitializePredefinedMacros ( const TargetInfo TI,
const LangOptions LangOpts,
const FrontendOptions FEOpts,
const PreprocessorOptions PPOpts,
MacroBuilder Builder 
)
static

Definition at line 863 of file InitPreprocessor.cpp.

◆ InitializeStandardPredefinedMacros()

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

Definition at line 381 of file InitPreprocessor.cpp.

◆ MacroBodyEndsInBackslash()

static bool MacroBodyEndsInBackslash ( StringRef  MacroBody)
static

Definition at line 32 of file InitPreprocessor.cpp.

References clang::isWhitespace().

◆ PickFP()

template<typename T >
static T PickFP ( const llvm::fltSemantics *  Sem,
IEEEHalfVal,
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 97 of file InitPreprocessor.cpp.