[PATCH] D77545: Represent FP options in AST by special Expression node

Serge Pavlov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 6 06:27:42 PDT 2020


sepavloff created this revision.
sepavloff added reviewers: rsmith, rjmccall, andrew.w.kaylor, efriedma, mibintc, kpn, sammccall, hokein.
Herald added a subscriber: martong.
Herald added a project: clang.

The patch D76599 <https://reviews.llvm.org/D76599> proposed a new statement node to represent pragmas that
modifies floating point environment. These nodes are used to implement
FP environment tracking and control in a function. Such node modify FP
environment in enclosing compound statement thus organizing FP
environment in hierarchical manner.

That solution however cannot be applied to initializers of global
variables and some other objects. They represent expressions outside
function bodies and thus cannot be embedded into compound statements.

Expression node introduced here (FPEnvironmentExpr) is to represent
FP environment in such cases. It contains a field of type FPOptions,
which specifies FP environment in which subexpression of
FPEnvironmentExpr should be executed. The patch implements FP
environment in the following cases:

- Initializers of global variables, like:

  float v1 = 3,1415926535;

- Inline initializers of fields:

  struct C1 { float f1 = 1,4142135623; };

- Arguments of base constructors in constructors:

  struct C3 : public C2 { C3(double x, double y) : C2(x + y) {} };

- Default function arguments:

  void func_01(float x = 1.1);

In contrast to the solution for compound statements in D76599 <https://reviews.llvm.org/D76599>, this
solution does not keep reference to the source code construct that set
the FP environment, namely the file scope pragma. It may cause problems
for AST consumers like source analyzers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77545

Files:
  clang/include/clang/AST/EvaluatedExprVisitor.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/TextNodeDumper.h
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Basic/LangOptions.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGOpenCLRuntime.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/ConstantEmitter.h
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/AST/ast-dump-pragma.cpp
  clang/test/CodeGen/fp-contract-pragma.cpp
  clang/tools/libclang/CXCursor.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77545.255306.patch
Type: text/x-patch
Size: 27701 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200406/24ad51bb/attachment-0001.bin>


More information about the cfe-commits mailing list