-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[clang][bytecode] Only print ptr/reference types via toAPValue() #137965
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Otherwise, convert them to an RValue to print them. This fixes the printing of e.g. complex values.
@llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) ChangesOtherwise, convert them to an RValue to print them. This fixes the printing of e.g. complex values. Full diff: https://github.com/llvm/llvm-project/pull/137965.diff 2 Files Affected:
diff --git a/clang/lib/AST/ByteCode/InterpFrame.cpp b/clang/lib/AST/ByteCode/InterpFrame.cpp
index 1a6e271c78d6f..e4bd4a6ba7656 100644
--- a/clang/lib/AST/ByteCode/InterpFrame.cpp
+++ b/clang/lib/AST/ByteCode/InterpFrame.cpp
@@ -107,7 +107,18 @@ void InterpFrame::destroy(unsigned Idx) {
template <typename T>
static void print(llvm::raw_ostream &OS, const T &V, ASTContext &ASTCtx,
QualType Ty) {
- V.toAPValue(ASTCtx).printPretty(OS, ASTCtx, Ty);
+ if constexpr (std::is_same_v<Pointer, T>) {
+ if (Ty->isPointerOrReferenceType())
+ V.toAPValue(ASTCtx).printPretty(OS, ASTCtx, Ty);
+ else {
+ if (std::optional<APValue> RValue = V.toRValue(ASTCtx, Ty))
+ RValue->printPretty(OS, ASTCtx, Ty);
+ else
+ OS << "...";
+ }
+ } else {
+ V.toAPValue(ASTCtx).printPretty(OS, ASTCtx, Ty);
+ }
}
static bool shouldSkipInBacktrace(const Function *F) {
diff --git a/clang/test/AST/ByteCode/constexpr-frame-describe.cpp b/clang/test/AST/ByteCode/constexpr-frame-describe.cpp
index d875d8730b7d6..1b19a7af0663b 100644
--- a/clang/test/AST/ByteCode/constexpr-frame-describe.cpp
+++ b/clang/test/AST/ByteCode/constexpr-frame-describe.cpp
@@ -79,8 +79,7 @@ static_assert(bar.fail1<int>()); // both-error {{constant expression}} \
static_assert(bar.fail2<int*, 42>()); // both-error {{constant expression}} \
// both-note {{in call to 'bar.fail2<int *, 42>()'}}
static_assert(bar.fail3(3, 4UL, bar, &bar)); // both-error {{constant expression}} \
- // expected-note {{in call to 'bar.fail3<int, unsigned long, Bar<int>, const Bar<int> *>(3, 4, &bar, &bar)'}} \
- // ref-note {{in call to 'bar.fail3<int, unsigned long, Bar<int>, const Bar<int> *>(3, 4, {}, &bar)'}}
+ // both-note {{in call to 'bar.fail3<int, unsigned long, Bar<int>, const Bar<int> *>(3, 4, {}, &bar)'}}
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/51/builds/15357 Here is the relevant piece of the build log for the reference
|
…m#137965) Otherwise, convert them to an RValue to print them. This fixes the printing of e.g. complex values.
…m#137965) Otherwise, convert them to an RValue to print them. This fixes the printing of e.g. complex values.
…m#137965) Otherwise, convert them to an RValue to print them. This fixes the printing of e.g. complex values.
…m#137965) Otherwise, convert them to an RValue to print them. This fixes the printing of e.g. complex values.
Otherwise, convert them to an RValue to print them. This fixes the printing of e.g. complex values.