[PATCH] D62399: [clang] Add storage for APValue in ConstantExpr

Tyker via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 24 08:55:39 PDT 2019


Tyker created this revision.
Tyker added a reviewer: rsmith.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith, hiraditya.
Herald added a reviewer: martong.
Herald added a reviewer: shafik.
Herald added projects: clang, LLVM.

When using ConstantExpr we often need the result of the expression to be kept in the AST. Currently this is done on a by the node that needs the result and has been done multiple times for enumerator, for constexpr variables... . This patch adds to ConstantExpr the ability to store the result of evaluating the expression. no functional changes expected.

Changes:

- Add trailling object to ConstantExpr that can hold an APValue or an APSInt. the APSInt is here because most ConstantExpr yield integral values so they will only take enough memory to store an integral values in this case.
- Add basic* serialization support for the trailing result.
- Move conversion functions from an enum to a fltSemantics from clang::FloatingLiteral to llvm::APFloatBase. this change is to make it usable for serializing APValues.
- Add basic* Import support for the trailing result.
- ConstantExpr created in CheckConvertedConstantExpression now stores the result in the ConstantExpr Node.
- Adapt AST dump to print the result when present.

basic* : Uninitialized, Int, Float, FixedPoint, ComplexInt, ComplexFloat,
the result is not yet used anywhere but for -ast-dump.


Repository:
  rC Clang

https://reviews.llvm.org/D62399

Files:
  clang/include/clang/AST/APValue.h
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/AST/TextNodeDumper.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/AST/APValue.cpp
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/AST/ast-dump-color.cpp
  llvm/include/llvm/ADT/APFloat.h
  llvm/lib/Support/APFloat.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62399.201262.patch
Type: text/x-patch
Size: 31647 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190524/e1f8c4fd/attachment.bin>


More information about the llvm-commits mailing list