clang API Documentation

Enumerations | Functions
PPMacroExpansion.cpp File Reference
#include "clang/Lex/Preprocessor.h"
#include "clang/Basic/Attributes.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Lex/CodeCompletionHandler.h"
#include "clang/Lex/ExternalPreprocessorSource.h"
#include "clang/Lex/LexDiagnostic.h"
#include "clang/Lex/MacroArgs.h"
#include "clang/Lex/MacroInfo.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
#include <cstdio>
#include <ctime>
Include dependency graph for PPMacroExpansion.cpp:

Go to the source code of this file.

Enumerations

enum  Bracket { Brace, Paren }

Functions

static IdentifierInfoRegisterBuiltinMacro (Preprocessor &PP, const char *Name)
static bool isTrivialSingleTokenExpansion (const MacroInfo *MI, const IdentifierInfo *MacroIdent, Preprocessor &PP)
static bool CheckMatchedBrackets (const SmallVectorImpl< Token > &Tokens)
static bool GenerateNewArgTokens (Preprocessor &PP, SmallVectorImpl< Token > &OldTokens, SmallVectorImpl< Token > &NewTokens, unsigned &NumArgs, SmallVectorImpl< SourceRange > &ParenHints, SmallVectorImpl< SourceRange > &InitLists)
static void ComputeDATE_TIME (SourceLocation &DATELoc, SourceLocation &TIMELoc, Preprocessor &PP)
static bool HasFeature (const Preprocessor &PP, const IdentifierInfo *II)
static bool HasExtension (const Preprocessor &PP, const IdentifierInfo *II)
static bool EvaluateHasIncludeCommon (Token &Tok, IdentifierInfo *II, Preprocessor &PP, const DirectoryLookup *LookupFrom, const FileEntry *LookupFromFile)
static bool EvaluateHasInclude (Token &Tok, IdentifierInfo *II, Preprocessor &PP)
static bool EvaluateHasIncludeNext (Token &Tok, IdentifierInfo *II, Preprocessor &PP)
static bool EvaluateBuildingModule (Token &Tok, IdentifierInfo *II, Preprocessor &PP)
 Process __building_module(identifier) expression.

Enumeration Type Documentation

enum Bracket
Enumerator:
Brace 
Paren 

Definition at line 384 of file PPMacroExpansion.cpp.


Function Documentation

static bool CheckMatchedBrackets ( const SmallVectorImpl< Token > &  Tokens) [static]

CheckMatchedBrackets - Returns true if the braces and parentheses in the token vector are properly nested.

Definition at line 391 of file PPMacroExpansion.cpp.

References Brace, and Paren.

Referenced by GenerateNewArgTokens().

static void ComputeDATE_TIME ( SourceLocation DATELoc,
SourceLocation TIMELoc,
Preprocessor PP 
) [static]

ComputeDATE_TIME - Compute the current time, enter it into the specified scratch buffer, then return DATELoc/TIMELoc locations with the position of the identifier tokens inserted.

Definition at line 822 of file PPMacroExpansion.cpp.

References clang::Preprocessor::CreateString(), clang::Token::getLocation(), and clang::Token::startToken().

static bool EvaluateBuildingModule ( Token Tok,
IdentifierInfo II,
Preprocessor PP 
) [static]

Process __building_module(identifier) expression.

Returns:
true if we are building the named module, false otherwise.

Definition at line 1202 of file PPMacroExpansion.cpp.

References clang::LangOptions::CurrentModule, clang::Preprocessor::Diag(), clang::Token::getIdentifierInfo(), clang::Preprocessor::getLangOpts(), clang::Token::getLocation(), clang::IdentifierInfo::getName(), clang::Token::isNot(), and clang::Preprocessor::LexNonComment().

static bool EvaluateHasInclude ( Token Tok,
IdentifierInfo II,
Preprocessor PP 
) [static]

EvaluateHasInclude - Process a '__has_include("path")' expression. Returns true if successful.

Definition at line 1165 of file PPMacroExpansion.cpp.

References EvaluateHasIncludeCommon().

static bool EvaluateHasIncludeCommon ( Token Tok,
IdentifierInfo II,
Preprocessor PP,
const DirectoryLookup LookupFrom,
const FileEntry LookupFromFile 
) [static]
static bool EvaluateHasIncludeNext ( Token Tok,
IdentifierInfo II,
Preprocessor PP 
) [static]
static bool GenerateNewArgTokens ( Preprocessor PP,
SmallVectorImpl< Token > &  OldTokens,
SmallVectorImpl< Token > &  NewTokens,
unsigned NumArgs,
SmallVectorImpl< SourceRange > &  ParenHints,
SmallVectorImpl< SourceRange > &  InitLists 
) [static]

GenerateNewArgTokens - Returns true if OldTokens can be converted to a new vector of tokens in NewTokens. The new number of arguments will be placed in NumArgs and the ranges which need to surrounded in parentheses will be in ParenHints. Returns false if the token stream cannot be changed. If this is because of an initializer list starting a macro argument, the range of those initializer lists will be place in InitLists.

Definition at line 422 of file PPMacroExpansion.cpp.

References CheckMatchedBrackets(), clang::comments::tok::eof, clang::Preprocessor::getLocForEndOfToken(), clang::Token::setKind(), clang::Token::setLength(), clang::Token::setLocation(), and clang::Token::startToken().

static bool HasExtension ( const Preprocessor PP,
const IdentifierInfo II 
) [static]

HasExtension - Return true if we recognize and implement the feature specified by the identifier, either as an extension or a standard language feature.

Definition at line 1010 of file PPMacroExpansion.cpp.

References clang::diag::Error, clang::Preprocessor::getDiagnostics(), clang::DiagnosticsEngine::getExtensionHandlingBehavior(), clang::Preprocessor::getLangOpts(), clang::IdentifierInfo::getName(), clang::Preprocessor::getTargetInfo(), HasFeature(), and clang::TargetInfo::isTLSSupported().

static bool HasFeature ( const Preprocessor PP,
const IdentifierInfo II 
) [static]
static bool isTrivialSingleTokenExpansion ( const MacroInfo MI,
const IdentifierInfo MacroIdent,
Preprocessor PP 
) [static]
static IdentifierInfo* RegisterBuiltinMacro ( Preprocessor PP,
const char *  Name 
) [static]

RegisterBuiltinMacro - Register the specified identifier in the identifier table and mark it as a builtin macro to be expanded.

Definition at line 77 of file PPMacroExpansion.cpp.

References clang::Preprocessor::AllocateMacroInfo(), clang::Preprocessor::appendDefMacroDirective(), clang::Preprocessor::getIdentifierInfo(), and clang::MacroInfo::setIsBuiltinMacro().