clang: lib/Lex/PPDirectives.cpp File Reference (original) (raw)
Implements # directive processing for the Preprocessor. More...
#include "[clang/Basic/CharInfo.h](CharInfo%5F8h%5Fsource.html)"
#include "[clang/Basic/DirectoryEntry.h](DirectoryEntry%5F8h%5Fsource.html)"
#include "[clang/Basic/FileManager.h](FileManager%5F8h%5Fsource.html)"
#include "[clang/Basic/IdentifierTable.h](IdentifierTable%5F8h%5Fsource.html)"
#include "[clang/Basic/LangOptions.h](LangOptions%5F8h%5Fsource.html)"
#include "[clang/Basic/Module.h](Module%5F8h%5Fsource.html)"
#include "[clang/Basic/SourceLocation.h](SourceLocation%5F8h%5Fsource.html)"
#include "[clang/Basic/SourceManager.h](SourceManager%5F8h%5Fsource.html)"
#include "[clang/Basic/TargetInfo.h](include%5F2clang%5F2Basic%5F2TargetInfo%5F8h%5Fsource.html)"
#include "[clang/Basic/TokenKinds.h](TokenKinds%5F8h%5Fsource.html)"
#include "[clang/Lex/CodeCompletionHandler.h](CodeCompletionHandler%5F8h%5Fsource.html)"
#include "[clang/Lex/HeaderSearch.h](HeaderSearch%5F8h%5Fsource.html)"
#include "[clang/Lex/LexDiagnostic.h](LexDiagnostic%5F8h%5Fsource.html)"
#include "[clang/Lex/LiteralSupport.h](LiteralSupport%5F8h%5Fsource.html)"
#include "[clang/Lex/MacroInfo.h](MacroInfo%5F8h%5Fsource.html)"
#include "[clang/Lex/ModuleLoader.h](ModuleLoader%5F8h%5Fsource.html)"
#include "[clang/Lex/ModuleMap.h](ModuleMap%5F8h%5Fsource.html)"
#include "[clang/Lex/PPCallbacks.h](PPCallbacks%5F8h%5Fsource.html)"
#include "[clang/Lex/Pragma.h](Pragma%5F8h%5Fsource.html)"
#include "[clang/Lex/Preprocessor.h](Preprocessor%5F8h%5Fsource.html)"
#include "[clang/Lex/PreprocessorOptions.h](PreprocessorOptions%5F8h%5Fsource.html)"
#include "[clang/Lex/Token.h](Token%5F8h%5Fsource.html)"
#include "[clang/Lex/VariadicMacroSupport.h](VariadicMacroSupport%5F8h%5Fsource.html)"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/SaveAndRestore.h"
#include <algorithm>
#include <cassert>
#include <cstring>
#include <optional>
#include <string>
#include <utility>
Go to the source code of this file.
Enumerations | |
---|---|
enum | MacroDiag { MD_NoWarn, MD_KeywordDef, MD_ReservedMacro } |
Enumerates possible cases of #define/#undef a reserved identifier. More... | |
enum | PPElifDiag { PED_Elif, PED_Elifdef, PED_Elifndef } |
Enumerates possible select values for the pp_err_elif_after_else and pp_err_elif_without_if diagnostics. More... | |
Functions | |
---|---|
static bool | isFeatureTestMacro (StringRef MacroName) |
static bool | isLanguageDefinedBuiltin (const SourceManager &SourceMgr, const MacroInfo *MI, const StringRef MacroName) |
static MacroDiag | shouldWarnOnMacroDef (Preprocessor &PP, IdentifierInfo *II) |
static MacroDiag | shouldWarnOnMacroUndef (Preprocessor &PP, IdentifierInfo *II) |
static bool | warnByDefaultOnWrongCase (StringRef Include) |
static std::optional< StringRef > | findSimilarStr (StringRef LHS, const std::vector< StringRef > &Candidates) |
Find a similar string in Candidates. | |
static bool | GetLineValue (Token &DigitTok, unsigned &Val, unsigned DiagID, Preprocessor &PP, bool IsGNULineDirective=false) |
GetLineValue - Convert a numeric token into an unsigned value, emitting Diagnostic DiagID if it is invalid, and returning the value in Val. | |
static bool | ReadLineMarkerFlags (bool &IsFileEntry, bool &IsFileExit, SrcMgr::CharacteristicKind &FileKind, Preprocessor &PP) |
ReadLineMarkerFlags - Parse and validate any flags at the end of a GNU line marker directive. | |
static void | diagnoseAutoModuleImport (Preprocessor &PP, SourceLocation HashLoc, Token &IncludeTok, ArrayRef< std::pair< IdentifierInfo *, SourceLocation > > Path, SourceLocation PathEnd) |
Produce a diagnostic informing the user that a #include or similar was implicitly treated as a module import. | |
static bool | trySimplifyPath (SmallVectorImpl< StringRef > &Components, StringRef RealPathName, llvm::sys::path::Style Separator) |
static bool | isConfigurationPattern (Token &MacroName, MacroInfo *MI, const LangOptions &LOptions) |
static bool | isObjCProtectedMacro (const IdentifierInfo *II) |
Implements # directive processing for the Preprocessor.
Definition in file PPDirectives.cpp.
◆ MacroDiag
Enumerates possible cases of #define/#undef a reserved identifier.
Enumerator |
---|
MD_NoWarn |
MD_KeywordDef |
MD_ReservedMacro |
Definition at line 97 of file PPDirectives.cpp.
◆ PPElifDiag
Enumerates possible select values for the pp_err_elif_after_else and pp_err_elif_without_if diagnostics.
Enumerator |
---|
PED_Elif |
PED_Elifdef |
PED_Elifndef |
Definition at line 105 of file PPDirectives.cpp.
◆ diagnoseAutoModuleImport()
◆ findSimilarStr()
static std::optional< StringRef > findSimilarStr ( StringRef LHS, const std::vector< StringRef > & Candidates ) | static |
---|
Find a similar string in Candidates
.
Parameters
LHS | a string for a similar string in Candidates |
---|---|
Candidates | the candidates to find a similar string. |
Returns
a similar string if exists. If no similar string exists, returns std::nullopt.
Definition at line 284 of file PPDirectives.cpp.
References clang::C.
◆ GetLineValue()
GetLineValue - Convert a numeric token into an unsigned value, emitting Diagnostic DiagID if it is invalid, and returning the value in Val.
Definition at line 1412 of file PPDirectives.cpp.
References clang::Preprocessor::AdvanceToTokenCharacter(), clang::Preprocessor::Diag(), clang::Preprocessor::DiscardUntilEndOfDirective(), clang::Token::getLength(), clang::Token::getLocation(), clang::Preprocessor::getSpelling(), clang::Invalid, clang::isDigit(), and clang::Token::isNot().
Referenced by ReadLineMarkerFlags().
◆ isConfigurationPattern()
◆ isFeatureTestMacro()
static bool isFeatureTestMacro ( StringRef MacroName) | static |
---|
◆ isLanguageDefinedBuiltin()
◆ isObjCProtectedMacro()
◆ ReadLineMarkerFlags()
ReadLineMarkerFlags - Parse and validate any flags at the end of a GNU line marker directive.
Definition at line 1549 of file PPDirectives.cpp.
References clang::SrcMgr::C_ExternCSystem, clang::SrcMgr::C_System, clang::Preprocessor::Diag(), clang::Preprocessor::DiscardUntilEndOfDirective(), clang::PresumedLoc::getIncludeLoc(), GetLineValue(), clang::Token::getLocation(), clang::Preprocessor::getSourceManager(), clang::Token::is(), clang::SourceLocation::isInvalid(), clang::PresumedLoc::isInvalid(), clang::Preprocessor::Lex(), and SM.
◆ shouldWarnOnMacroDef()
◆ shouldWarnOnMacroUndef()
◆ trySimplifyPath()
static bool trySimplifyPath ( SmallVectorImpl< StringRef > & Components, StringRef RealPathName, llvm::sys::path::Style Separator ) | static |
---|
◆ warnByDefaultOnWrongCase()
static bool warnByDefaultOnWrongCase ( StringRef Include) | static |
---|