llvm-project/clang/lib/Analysis
Serge Pavlov f7819ce166 [FPEnv] Allow CompoundStmt to keep FP options
This is a recommit of b822efc740,
reverted in dc34d8df4c. The commit caused
fails because the test ast-print-fp-pragmas.c did not specify particular
target, and it failed on targets which do not support constrained
intrinsics. The original commit message is below.

AST does not have special nodes for pragmas. Instead a pragma modifies
some state variables of Sema, which in turn results in modified
attributes of AST nodes. This technique applies to floating point
operations as well. Every AST node that can depend on FP options keeps
current set of them.

This technique works well for options like exception behavior or fast
math options. They represent instructions to the compiler how to modify
code generation for the affected nodes. However treatment of FP control
modes has problems with this technique. Modifying FP control mode
(like rounding direction) usually requires operations on hardware, like
writing to control registers. It must be done prior to the first
operation that depends on the control mode. In particular, such
operations are required for implementation of `pragma STDC FENV_ROUND`,
compiler should set up necessary rounding direction at the beginning of
compound statement where the pragma occurs. As there is no representation
for pragmas in AST, the code generation becomes a complicated task in
this case.

To solve this issue FP options are kept inside CompoundStmt. Unlike to FP
options in expressions, these does not affect any operation on FP values,
but only inform the codegen about the FP options that act in the body of
the statement. As all pragmas that modify FP environment may occurs only
at the start of compound statement or at global level, such solution
works for all relevant pragmas. The options are kept as a difference
from the options in the enclosing compound statement or default options,
it helps codegen to set only changed control modes.

Differential Revision: https://reviews.llvm.org/D123952
2022-07-03 17:06:26 +07:00
..
FlowSensitive [clang][dataflow] Handle `for` statements without conditions 2022-06-30 07:00:35 +00:00
plugins clang-analyzer plugins require LLVM_ENABLE_PLUGINS also 2022-02-16 11:59:09 -05:00
AnalysisDeclContext.cpp [clang] Add a raw_ostream operator<< overload for QualType 2022-04-20 22:09:05 +01:00
BodyFarm.cpp [FPEnv] Allow CompoundStmt to keep FP options 2022-07-03 17:06:26 +07:00
CFG.cpp Correct -Winfinite-recursion warning on potentially-unevaluated operand 2022-06-30 09:09:28 -04:00
CFGReachabilityAnalysis.cpp
CFGStmtMap.cpp
CMakeLists.txt [clang][dataflow] Add base types for building dataflow analyses 2021-11-30 14:44:40 +00:00
CallGraph.cpp
CalledOnceCheck.cpp [clang] Don't use Optional::getValue (NFC) 2022-06-20 22:59:26 -07:00
CloneDetection.cpp [AST, Analysis] Use llvm::reverse (NFC) 2021-11-07 09:53:14 -08:00
CocoaConventions.cpp
CodeInjector.cpp
ConstructionContext.cpp
Consumed.cpp
Dominators.cpp
ExprMutationAnalyzer.cpp updated canResolveToExpr to accept both statements and expressions. Removed unnecessary code 2022-05-23 20:18:49 -07:00
IssueHash.cpp Revert "Revert "[analyzer] NFC: Move IssueHash to libAnalysis."" 2020-11-17 16:01:49 -08:00
LiveVariables.cpp [analyzer][Liveness][NFC] Remove an unneeded pass to collect variables that appear in an assignment 2021-02-12 16:19:20 +01:00
MacroExpansionContext.cpp PR51018: Remove explicit conversions from SmallString to StringRef to future-proof against C++23 2021-07-08 13:37:57 -07:00
ObjCNoReturn.cpp Use llvm::is_contained (NFC) 2021-10-24 09:32:57 -07:00
PathDiagnostic.cpp [clang] Don't use Optional::hasValue (NFC) 2022-06-25 22:26:24 -07:00
PostOrderCFGView.cpp AnalysisDeclContext::ManagedAnalyses: Use unique_ptr to simplify memory management 2020-04-28 22:31:16 -07:00
ProgramPoint.cpp [AST] Remove DeclCXX.h dep on ASTContext.h 2020-04-06 10:09:01 -07:00
ReachableCode.cpp [clang] Don't use Optional::getValue (NFC) 2022-06-20 22:59:26 -07:00
RetainSummaryManager.cpp [clang][NFC] Inclusive language: remove use of Whitelist in clang/lib/Analysis/ 2022-04-25 15:26:36 -05:00
ThreadSafety.cpp Thread safety analysis: Handle compound assignment and ->* overloads 2022-05-09 15:35:43 +02:00
ThreadSafetyCommon.cpp Thread safety analysis: Store capability kind in CapabilityExpr 2022-04-29 22:30:33 +02:00
ThreadSafetyLogical.cpp
ThreadSafetyTIL.cpp
UninitializedValues.cpp [clang] Don't use Optional::hasValue (NFC) 2022-06-25 22:26:24 -07:00