[libcxx-commits] [PATCH] D155064: [clang][SemaCXX] Diagnose tautological uses of consteval if and is_constant_evaluated
Takuya Shimizu via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jul 12 03:21:04 PDT 2023
hazohelet created this revision.
hazohelet added reviewers: aaron.ballman, rsmith, cor3ntin, erichkeane, tbaeder.
Herald added a project: All.
hazohelet requested review of this revision.
Herald added projects: clang, libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
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 `Sema::ExpressionEvaluationContext` kind 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 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`.
Fixes https://github.com/llvm/llvm-project/issues/43760
Fixes https://github.com/llvm/llvm-project/issues/51567
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D155064
Files:
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticASTKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/ExprConstant.cpp
clang/lib/Parse/ParseCXXInlineMethods.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Parse/ParseExpr.cpp
clang/lib/Parse/ParseStmt.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprMember.cpp
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/SemaStmt.cpp
clang/test/AST/Interp/builtins.cpp
clang/test/AST/Interp/if.cpp
clang/test/AST/Interp/literals.cpp
clang/test/CXX/expr/expr.const/p2-0x.cpp
clang/test/CXX/expr/expr.const/p6-2a.cpp
clang/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp
clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p4.cpp
clang/test/Parser/pragma-fenv_access.c
clang/test/SemaCXX/constant-expression-cxx11.cpp
clang/test/SemaCXX/cxx2a-consteval.cpp
clang/test/SemaCXX/cxx2b-consteval-if.cpp
clang/test/SemaCXX/ext-int.cpp
clang/test/SemaCXX/warn-constant-evaluated-constexpr.cpp
clang/test/SemaCXX/warn-tautological-meta-constant.cpp
clang/test/SemaTemplate/concepts.cpp
clang/unittests/Support/TimeProfilerTest.cpp
libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy.segmented.pass.cpp
libcxx/test/std/utilities/meta/meta.const.eval/is_constant_evaluated.verify.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155064.539461.patch
Type: text/x-patch
Size: 53386 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230712/c3fe2b7e/attachment-0001.bin>
More information about the libcxx-commits
mailing list