[clang] [clang] Fix assertion failure when printing atomic apvalues (PR #85259)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 14 09:01:04 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
When printing an `_Atomic(some struct type)`, we would later run into an assertion because we do a `Ty->castAs<RecordType>()`, which doesn't work with an `AtomicType`.
Not sure how to best write a test for, this, but OTOH, `printPretty` is currently only used for debugging as far as I know(?).
---
Full diff: https://github.com/llvm/llvm-project/pull/85259.diff
1 Files Affected:
- (modified) clang/lib/AST/APValue.cpp (+3)
``````````diff
diff --git a/clang/lib/AST/APValue.cpp b/clang/lib/AST/APValue.cpp
index 4eae308ef5b34c..d8042321319a67 100644
--- a/clang/lib/AST/APValue.cpp
+++ b/clang/lib/AST/APValue.cpp
@@ -704,6 +704,9 @@ void APValue::printPretty(raw_ostream &Out, const PrintingPolicy &Policy,
return;
}
+ if (const auto *AT = Ty->getAs<AtomicType>())
+ Ty = AT->getValueType();
+
switch (getKind()) {
case APValue::None:
Out << "<out of lifetime>";
``````````
</details>
https://github.com/llvm/llvm-project/pull/85259
More information about the cfe-commits
mailing list