[all-commits] [llvm/llvm-project] 08c8d5: Properly track whether a variable is constant-init...
Richard Smith via All-commits
all-commits at lists.llvm.org
Mon Oct 19 23:59:49 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 08c8d5bc51c512e605840b8003fcf38c86d0fc96
https://github.com/llvm/llvm-project/commit/08c8d5bc51c512e605840b8003fcf38c86d0fc96
Author: Richard Smith <richard at metafoo.co.uk>
Date: 2020-10-19 (Mon, 19 Oct 2020)
Changed paths:
M clang/include/clang/AST/Decl.h
M clang/include/clang/AST/Expr.h
M clang/lib/AST/Decl.cpp
M clang/lib/AST/ExprConstant.cpp
M clang/lib/CodeGen/CGExprConstant.cpp
M clang/test/CodeGenCXX/builtin-is-constant-evaluated.cpp
A clang/test/PCH/builtin-is-constant-evaluated.cpp
M clang/test/SemaCXX/attr-require-constant-initialization.cpp
M clang/test/SemaCXX/builtin-is-constant-evaluated.cpp
Log Message:
-----------
Properly track whether a variable is constant-initialized.
This fixes miscomputation of __builtin_constant_evaluated in the
initializer of a variable that's not usable in constant expressions, but
is readable when constant-folding.
If evaluation of a constant initializer fails, we throw away the
evaluated result instead of keeping it as a non-constant-initializer
value for the variable, because it might not be a correct value.
To avoid regressions for initializers that are foldable but not formally
constant initializers, we now try constant-evaluating some globals in
C++ twice: once to check for a constant initializer (in an mode where
is_constannt_evaluated returns true) and again to determine the runtime
value if the initializer is not a constant initializer.
More information about the All-commits
mailing list