[PATCH] D112159: Relax assert in ExprConstant to a return None.
Jon Chesterfield via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 20 11:20:31 PDT 2021
JonChesterfield updated this revision to Diff 381037.
JonChesterfield added a comment.
- fix up call sites
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112159/new/
https://reviews.llvm.org/D112159
Files:
clang/lib/AST/ExprConstant.cpp
clang/test/SemaTemplate/atomics.cpp
Index: clang/test/SemaTemplate/atomics.cpp
===================================================================
--- clang/test/SemaTemplate/atomics.cpp
+++ clang/test/SemaTemplate/atomics.cpp
@@ -15,3 +15,13 @@
}
void h() { g<int>(0); }
}
+
+// Can pass value dependent integer to atomic builtin
+template <int Order>
+void fetchAdd(int *A, int V) {
+ __atomic_fetch_add(A, V, Order);
+}
+
+void fetchAddUse(int *A, int V) {
+ fetchAdd<__ATOMIC_ACQ_REL>(A, V);
+}
Index: clang/lib/AST/ExprConstant.cpp
===================================================================
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -15501,8 +15501,10 @@
Optional<llvm::APSInt> Expr::getIntegerConstantExpr(const ASTContext &Ctx,
SourceLocation *Loc,
bool isEvaluated) const {
- assert(!isValueDependent() &&
- "Expression evaluator can't be called on a dependent expression.");
+ if (isValueDependent()) {
+ // Expression evaluator can't succeed on a dependent expression.
+ return None;
+ }
APSInt Value;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112159.381037.patch
Type: text/x-patch
Size: 1156 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211020/7b1b15fa/attachment.bin>
More information about the cfe-commits
mailing list