Skip to content

PR for llvm/llvm-project#60781 #360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -593,9 +593,6 @@ Improvements to Clang's diagnostics
language version and specifies in which version it will be a keyword. This
supports both C and C++.

- When diagnosing multi-level pack expansions of mismatched lengths, Clang will
now, in most cases, be able to point to the relevant outer parameter.

- ``no_sanitize("...")`` on a global variable for known but not relevant
sanitizers is now just a warning. It now says that this will be ignored
instead of incorrectly saying no_sanitize only applies to functions and
Expand Down Expand Up @@ -781,9 +778,6 @@ Bug Fixes to Attribute Support

Bug Fixes to C++ Support
^^^^^^^^^^^^^^^^^^^^^^^^
- Fix multi-level pack expansion of undeclared function parameters.
(`#56094 <https://github.com/llvm/llvm-project/issues/56094>`_)

- Address the thread identification problems in coroutines.
(`#47177 <https://github.com/llvm/llvm-project/issues/47177>`_,
`#47179 <https://github.com/llvm/llvm-project/issues/47179>`_)
Expand Down
13 changes: 0 additions & 13 deletions clang/include/clang/Lex/Preprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,6 @@ class Preprocessor {
LangOptions::FPEvalMethodKind CurrentFPEvalMethod =
LangOptions::FPEvalMethodKind::FEM_UnsetOnCommandLine;

// Keeps the value of the last evaluation method before a
// `pragma float_control (precise,off) is applied.
LangOptions::FPEvalMethodKind LastFPEvalMethod =
LangOptions::FPEvalMethodKind::FEM_UnsetOnCommandLine;

// The most recent pragma location where the floating point evaluation
// method was modified. This is used to determine whether the
// 'pragma clang fp eval_method' was used whithin the current scope.
Expand Down Expand Up @@ -2335,14 +2330,6 @@ class Preprocessor {
return LastFPEvalPragmaLocation;
}

LangOptions::FPEvalMethodKind getLastFPEvalMethod() const {
return LastFPEvalMethod;
}

void setLastFPEvalMethod(LangOptions::FPEvalMethodKind Val) {
LastFPEvalMethod = Val;
}

void setCurrentFPEvalMethod(SourceLocation PragmaLoc,
LangOptions::FPEvalMethodKind Val) {
assert(Val != LangOptions::FEM_UnsetOnCommandLine &&
Expand Down
37 changes: 8 additions & 29 deletions clang/lib/Lex/PPMacroExpansion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1637,35 +1637,14 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
Tok.setKind(tok::string_literal);
} else if (II == Ident__FLT_EVAL_METHOD__) {
// __FLT_EVAL_METHOD__ is set to the default value.
if (getTUFPEvalMethod() ==
LangOptions::FPEvalMethodKind::FEM_Indeterminable) {
// This is possible if `AllowFPReassoc` or `AllowReciprocal` is enabled.
// These modes can be triggered via the command line option `-ffast-math`
// or via a `pragam float_control`.
// __FLT_EVAL_METHOD__ expands to -1.
// The `minus` operator is the next token we read from the stream.
auto Toks = std::make_unique<Token[]>(1);
OS << "-";
Tok.setKind(tok::minus);
// Push the token `1` to the stream.
Token NumberToken;
NumberToken.startToken();
NumberToken.setKind(tok::numeric_constant);
NumberToken.setLiteralData("1");
NumberToken.setLength(1);
Toks[0] = NumberToken;
EnterTokenStream(std::move(Toks), 1, /*DisableMacroExpansion*/ false,
/*IsReinject*/ false);
} else {
OS << getTUFPEvalMethod();
// __FLT_EVAL_METHOD__ expands to a simple numeric value.
Tok.setKind(tok::numeric_constant);
if (getLastFPEvalPragmaLocation().isValid()) {
// The program is ill-formed. The value of __FLT_EVAL_METHOD__ is
// altered by the pragma.
Diag(Tok, diag::err_illegal_use_of_flt_eval_macro);
Diag(getLastFPEvalPragmaLocation(), diag::note_pragma_entered_here);
}
OS << getTUFPEvalMethod();
// __FLT_EVAL_METHOD__ expands to a simple numeric value.
Tok.setKind(tok::numeric_constant);
if (getLastFPEvalPragmaLocation().isValid()) {
// The program is ill-formed. The value of __FLT_EVAL_METHOD__ is altered
// by the pragma.
Diag(Tok, diag::err_illegal_use_of_flt_eval_macro);
Diag(getLastFPEvalPragmaLocation(), diag::note_pragma_entered_here);
}
} else if (II == Ident__COUNTER__) {
// __COUNTER__ expands to a simple numeric value.
Expand Down
5 changes: 0 additions & 5 deletions clang/lib/Lex/Preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,6 @@ void Preprocessor::Initialize(const TargetInfo &Target,
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() {
Expand Down
17 changes: 0 additions & 17 deletions clang/lib/Sema/SemaAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,13 +565,6 @@ void Sema::ActOnPragmaFloatControl(SourceLocation Loc,
case PFC_Precise:
NewFPFeatures.setFPPreciseEnabled(true);
FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
if (PP.getCurrentFPEvalMethod() ==
LangOptions::FPEvalMethodKind::FEM_Indeterminable &&
PP.getLastFPEvalPragmaLocation().isValid())
// A preceding `pragma float_control(precise,off)` has changed
// the value of the evaluation method.
// Set it back to its old value.
PP.setCurrentFPEvalMethod(SourceLocation(), PP.getLastFPEvalMethod());
break;
case PFC_NoPrecise:
if (CurFPFeatures.getExceptionMode() == LangOptions::FPE_Strict)
Expand All @@ -581,10 +574,6 @@ void Sema::ActOnPragmaFloatControl(SourceLocation Loc,
else
NewFPFeatures.setFPPreciseEnabled(false);
FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
PP.setLastFPEvalMethod(PP.getCurrentFPEvalMethod());
// `AllowFPReassoc` or `AllowReciprocal` option is enabled.
PP.setCurrentFPEvalMethod(
Loc, LangOptions::FPEvalMethodKind::FEM_Indeterminable);
break;
case PFC_Except:
if (!isPreciseFPEnabled())
Expand All @@ -608,12 +597,6 @@ void Sema::ActOnPragmaFloatControl(SourceLocation Loc,
}
FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
NewFPFeatures = FpPragmaStack.CurrentValue;
if (CurFPFeatures.getAllowFPReassociate() ||
CurFPFeatures.getAllowReciprocal())
// Since we are popping the pragma, we don't want to be passing
// a location here.
PP.setCurrentFPEvalMethod(SourceLocation(),
CurFPFeatures.getFPEvalMethod());
break;
}
CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGen/X86/fexcess-precision.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ _Float16 f(_Float16 a, _Float16 b, _Float16 c, _Float16 d) {
//
// CHECK-UNSAFE-LABEL: @getFEM(
// CHECK-UNSAFE-NEXT: entry:
// CHECK-UNSAFE-NEXT: ret i32 -1
// CHECK-UNSAFE-NEXT: ret i32 0
//
int getFEM() {
return __FLT_EVAL_METHOD__;
Expand Down
117 changes: 0 additions & 117 deletions clang/test/CodeGen/eval-method-fast-math.cpp

This file was deleted.

3 changes: 1 addition & 2 deletions clang/test/Preprocessor/flt_eval_macro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// RUN: %s -o - | FileCheck %s -strict-whitespace

// RUN: %clang_cc1 -E -dM -triple=x86_64-apple-macos13.0 -ffast-math \
// RUN: %s -o - | FileCheck %s -check-prefix=CHECK-MINUS-ONE -strict-whitespace
// RUN: %s -o - | FileCheck %s -check-prefix=CHECK -strict-whitespace

// RUN: %clang_cc1 -E -dM -triple i386-pc-windows -target-cpu pentium4 %s -o - \
// RUN: | FileCheck %s -strict-whitespace
Expand Down Expand Up @@ -64,7 +64,6 @@

int foo() {
// CHECK: #define Name "One"
// CHECK-MINUS-ONE: #define Name "MinusOne"
// EXT: #define Name "Three"
return Name;
}
Expand Down