llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> 1) When creating the global variables for them, always use the first decl 2) When converting null pointers to `APValue`, don't cast the nullptr base to `Expr` or `ValueDecl`. Use `LValueBase()` instead, so the internal `PointerUnion` has an all-zeros value as `getOpaqueValue()`. If we don't do this, we run into problems with merging of `TemplateParamObjectDecls` because they don't compare equal via `::Profile()`. --- Full diff: https://github.com/llvm/llvm-project/pull/208734.diff 3 Files Affected: - (modified) clang/lib/AST/ByteCode/Compiler.cpp (+5-2) - (modified) clang/lib/AST/ByteCode/Pointer.cpp (+1-1) - (modified) clang/test/PCH/cxx20-template-args.cpp (+1) ``````````diff diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 46762ed8291f9..c581e9e4a188f 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -8064,11 +8064,14 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) { return F && this->emitGetFnPtr(F, E); } if (const auto *TPOD = dyn_cast<TemplateParamObjectDecl>(D)) { + TPOD = TPOD->getFirstDecl(); if (DiscardResult) return true; + if (UnsignedOrNone GlobalIndex = P.getGlobal(TPOD)) + return this->emitGetPtrGlobal(*GlobalIndex, E); - if (UnsignedOrNone Index = P.getOrCreateGlobal(D)) { - if (OptPrimType T = classify(D->getType())) { + if (UnsignedOrNone Index = P.getOrCreateGlobal(TPOD)) { + if (OptPrimType T = classify(TPOD->getType())) { if (!this->visitAPValue(TPOD->getValue(), *T, E)) return false; return this->emitInitGlobal(*T, *Index, E); diff --git a/clang/lib/AST/ByteCode/Pointer.cpp b/clang/lib/AST/ByteCode/Pointer.cpp index 6d19379d6ecd7..43af58d7bcb83 100644 --- a/clang/lib/AST/ByteCode/Pointer.cpp +++ b/clang/lib/AST/ByteCode/Pointer.cpp @@ -174,7 +174,7 @@ APValue Pointer::toAPValue(const ASTContext &ASTCtx) const { llvm::SmallVector<APValue::LValuePathEntry, 5> Path; if (isZero()) - return APValue(static_cast<const Expr *>(nullptr), CharUnits::Zero(), Path, + return APValue(APValue::LValueBase(), CharUnits::Zero(), Path, /*IsOnePastEnd=*/false, /*IsNullPtr=*/true); if (isIntegralPointer()) return APValue(static_cast<const Expr *>(nullptr), diff --git a/clang/test/PCH/cxx20-template-args.cpp b/clang/test/PCH/cxx20-template-args.cpp index f9ac35ba53a45..5bb816fcbaf09 100644 --- a/clang/test/PCH/cxx20-template-args.cpp +++ b/clang/test/PCH/cxx20-template-args.cpp @@ -2,6 +2,7 @@ // RUN: %clang_cc1 -std=c++20 -emit-pch %s -o %t // RUN: %clang_cc1 -std=c++20 -include-pch %t -verify %s +// RUN: %clang_cc1 -std=c++20 -include-pch %t -verify %s -fexperimental-new-constant-interpreter // expected-no-diagnostics `````````` </details> https://github.com/llvm/llvm-project/pull/208734 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
