[all-commits] [llvm/llvm-project] 491b28: [clang][SemaCXX] Diagnose tautological uses of con...
Takuya Shimizu via All-commits
all-commits at lists.llvm.org
Tue Sep 26 17:26:58 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 491b2810fb7fe5f080fa9c4f5945ed0a6909dc92
https://github.com/llvm/llvm-project/commit/491b2810fb7fe5f080fa9c4f5945ed0a6909dc92
Author: Takuya Shimizu <shimizu2486 at gmail.com>
Date: 2023-09-27 (Wed, 27 Sep 2023)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/include/clang/Basic/DiagnosticASTKinds.td
M clang/include/clang/Basic/DiagnosticSemaKinds.td
M clang/include/clang/Parse/Parser.h
M clang/include/clang/Sema/Sema.h
M clang/lib/AST/ExprConstant.cpp
M clang/lib/Parse/ParseDecl.cpp
M clang/lib/Parse/ParseDeclCXX.cpp
M clang/lib/Parse/ParseExpr.cpp
M clang/lib/Parse/ParseExprCXX.cpp
M clang/lib/Parse/ParseStmt.cpp
M clang/lib/Sema/SemaChecking.cpp
M clang/lib/Sema/SemaDecl.cpp
M clang/lib/Sema/SemaDeclCXX.cpp
M clang/lib/Sema/SemaExpr.cpp
M clang/lib/Sema/SemaLambda.cpp
M clang/lib/Sema/SemaStmt.cpp
M clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
M clang/test/AST/Interp/builtins.cpp
M clang/test/AST/Interp/if.cpp
M clang/test/AST/Interp/literals.cpp
M clang/test/CXX/expr/expr.const/p2-0x.cpp
M clang/test/CXX/expr/expr.const/p6-2a.cpp
M clang/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp
M clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p4.cpp
M clang/test/Parser/pragma-fenv_access.c
M clang/test/SemaCXX/constant-conversion.cpp
M clang/test/SemaCXX/constant-expression-cxx11.cpp
M clang/test/SemaCXX/cxx2a-consteval.cpp
M clang/test/SemaCXX/cxx2b-consteval-if.cpp
M clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
A clang/test/SemaCXX/fixit-tautological-meta-constant.cpp
M clang/test/SemaCXX/vartemplate-lambda.cpp
M clang/test/SemaCXX/warn-constant-evaluated-constexpr.cpp
A clang/test/SemaCXX/warn-tautological-meta-constant.cpp
M clang/test/SemaTemplate/concepts.cpp
M clang/unittests/Support/TimeProfilerTest.cpp
M libcxx/include/__type_traits/is_constant_evaluated.h
M libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy.segmented.pass.cpp
M libcxx/test/std/utilities/meta/meta.const.eval/is_constant_evaluated.verify.cpp
Log Message:
-----------
[clang][SemaCXX] Diagnose tautological uses of consteval if and is_constant_evaluated
This patch makes clang diagnose extensive cases of consteval if and is_constant_evaluated usage that are tautologically true or false.
This introduces a new IsRuntimeEvaluated boolean flag to Sema::ExpressionEvaluationContextRecord that means the immediate appearance of if consteval or is_constant_evaluated are tautologically false(e.g. inside if !consteval {} block or non-constexpr-qualified function definition body)
This patch also pushes new expression evaluation context when parsing the condition of if constexpr and initializer of constexpr variables so that Sema can be aware that the use of consteval if and is_consteval are tautologically true in if constexpr condition and constexpr variable initializers.
BEFORE this patch, the warning for is_constant_evaluated was emitted from constant evaluator. This patch moves the warning logic to Sema in order to diagnose tautological use of is_constant_evaluated in the same way as consteval if.
This patch separates initializer evaluation context from InitializerScopeRAII.
This fixes a bug that was happening when user takes address of function address in initializers of non-local variables.
Fixes https://github.com/llvm/llvm-project/issues/43760
Fixes https://github.com/llvm/llvm-project/issues/51567
Reviewed By: cor3ntin, ldionne
Differential Revision: https://reviews.llvm.org/D155064
More information about the All-commits
mailing list