aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/clang/lib/Lex/Preprocessor.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2022-07-04 19:20:19 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-02-08 19:02:26 +0000
commit81ad626541db97eb356e2c1d4a20eb2a26a766ab (patch)
tree311b6a8987c32b1e1dcbab65c54cfac3fdb56175 /contrib/llvm-project/clang/lib/Lex/Preprocessor.cpp
parent5fff09660e06a66bed6482da9c70df328e16bbb6 (diff)
parent145449b1e420787bb99721a429341fa6be3adfb6 (diff)
Diffstat (limited to 'contrib/llvm-project/clang/lib/Lex/Preprocessor.cpp')
-rw-r--r--contrib/llvm-project/clang/lib/Lex/Preprocessor.cpp38
1 files changed, 29 insertions, 9 deletions
diff --git a/contrib/llvm-project/clang/lib/Lex/Preprocessor.cpp b/contrib/llvm-project/clang/lib/Lex/Preprocessor.cpp
index 3c338a2b8123..281f01fb28a4 100644
--- a/contrib/llvm-project/clang/lib/Lex/Preprocessor.cpp
+++ b/contrib/llvm-project/clang/lib/Lex/Preprocessor.cpp
@@ -158,11 +158,6 @@ Preprocessor::Preprocessor(std::shared_ptr<PreprocessorOptions> PPOpts,
if (this->PPOpts->GeneratePreamble)
PreambleConditionalStack.startRecording();
- ExcludedConditionalDirectiveSkipMappings =
- this->PPOpts->ExcludedConditionalDirectiveSkipMappings;
- if (ExcludedConditionalDirectiveSkipMappings)
- ExcludedConditionalDirectiveSkipMappings->clear();
-
MaxTokens = LangOpts.MaxTokens;
}
@@ -208,6 +203,21 @@ void Preprocessor::Initialize(const TargetInfo &Target,
// Populate the identifier table with info about keywords for the current language.
Identifiers.AddKeywords(LangOpts);
+
+ // Initialize the __FTL_EVAL_METHOD__ macro to the TargetInfo.
+ setTUFPEvalMethod(getTargetInfo().getFPEvalMethod());
+
+ if (getLangOpts().getFPEvalMethod() == LangOptions::FEM_UnsetOnCommandLine)
+ // Use setting from TargetInfo.
+ setCurrentFPEvalMethod(SourceLocation(), Target.getFPEvalMethod());
+ else
+ // Set initial value of __FLT_EVAL_METHOD__ from the command line.
+ setCurrentFPEvalMethod(SourceLocation(), getLangOpts().getFPEvalMethod());
+ // When `-ffast-math` option is enabled, it triggers several driver math
+ // options to be enabled. Among those, only one the following two modes
+ // affect the eval-method: reciprocal or reassociate.
+ if (getLangOpts().AllowFPReassoc || getLangOpts().AllowRecip)
+ setCurrentFPEvalMethod(SourceLocation(), LangOptions::FEM_Indeterminable);
}
void Preprocessor::InitializeForModelFile() {
@@ -229,8 +239,10 @@ void Preprocessor::FinalizeForModelFile() {
}
void Preprocessor::DumpToken(const Token &Tok, bool DumpFlags) const {
- llvm::errs() << tok::getTokenName(Tok.getKind()) << " '"
- << getSpelling(Tok) << "'";
+ llvm::errs() << tok::getTokenName(Tok.getKind());
+
+ if (!Tok.isAnnotation())
+ llvm::errs() << " '" << getSpelling(Tok) << "'";
if (!DumpFlags) return;
@@ -377,7 +389,9 @@ StringRef Preprocessor::getLastMacroWithSpelling(
void Preprocessor::recomputeCurLexerKind() {
if (CurLexer)
- CurLexerKind = CLK_Lexer;
+ CurLexerKind = CurLexer->isDependencyDirectivesLexer()
+ ? CLK_DependencyDirectivesLexer
+ : CLK_Lexer;
else if (CurTokenLexer)
CurLexerKind = CLK_TokenLexer;
else
@@ -640,6 +654,9 @@ void Preprocessor::SkipTokensWhileUsingPCH() {
case CLK_CachingLexer:
CachingLex(Tok);
break;
+ case CLK_DependencyDirectivesLexer:
+ CurLexer->LexDependencyDirectiveToken(Tok);
+ break;
case CLK_LexAfterModuleImport:
LexAfterModuleImport(Tok);
break;
@@ -901,6 +918,9 @@ void Preprocessor::Lex(Token &Result) {
CachingLex(Result);
ReturnedToken = true;
break;
+ case CLK_DependencyDirectivesLexer:
+ ReturnedToken = CurLexer->LexDependencyDirectiveToken(Result);
+ break;
case CLK_LexAfterModuleImport:
ReturnedToken = LexAfterModuleImport(Result);
break;
@@ -1345,7 +1365,7 @@ bool Preprocessor::FinishLexStringLiteral(Token &Result, std::string &String,
// Concatenate and parse the strings.
StringLiteralParser Literal(StrToks, *this);
- assert(Literal.isAscii() && "Didn't allow wide strings in");
+ assert(Literal.isOrdinary() && "Didn't allow wide strings in");
if (Literal.hadError)
return false;