llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> We can save some small preparations this way, e.g. calling `getRootVarDecl()`. --- Full diff: https://github.com/llvm/llvm-project/pull/224906.diff 1 Files Affected: - (modified) clang/lib/AST/ByteCode/Interp.cpp (+11-6) ``````````diff diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp index 49ebcc789b7dd..7afed0e05c886 100644 --- a/clang/lib/AST/ByteCode/Interp.cpp +++ b/clang/lib/AST/ByteCode/Interp.cpp @@ -129,9 +129,8 @@ static void diagnoseNonConstVariable(InterpState &S, CodePtr OpPC, static bool diagnoseUnknownDecl(InterpState &S, CodePtr OpPC, const ValueDecl *D, AccessKinds AK = AK_Read) { // This function tries pretty hard to produce a good diagnostic. Just skip - // that if nobody will see it anyway. - if (!S.diagnosing()) - return false; + // that if nobody will see it anyway. This should be handled in the caller. + assert(S.diagnosing()); if (isa<ParmVarDecl>(D)) { if (D->getType()->isReferenceType()) { @@ -1346,6 +1345,9 @@ bool CheckDeleteSource(InterpState &S, CodePtr OpPC, const Expr *Source, /// We aleady know the given DeclRefExpr is invalid for some reason, /// now figure out why and print appropriate diagnostics. bool CheckDeclRef(InterpState &S, CodePtr OpPC, const DeclRefExpr *DR) { + if (!S.diagnosing()) + return false; + const ValueDecl *D = DR->getDecl(); return diagnoseUnknownDecl(S, OpPC, D); } @@ -1370,12 +1372,15 @@ bool CheckDummy(InterpState &S, CodePtr OpPC, const Pointer &Ptr, if (!Ptr.isDummy()) return true; - const VarDecl *D = Ptr.getRootVarDecl(); - if (!D) + if (!S.diagnosing()) return false; - if (AK == AK_Read || AK == AK_Increment || AK == AK_Decrement) + if (AK == AK_Read || AK == AK_Increment || AK == AK_Decrement) { + const VarDecl *D = Ptr.getRootVarDecl(); + if (!D) + return false; return diagnoseUnknownDecl(S, OpPC, D, AK); + } if (AK == AK_Destroy || S.getLangOpts().CPlusPlus14) S.FFDiag(S.Current->getSource(OpPC), diag::note_constexpr_modify_global); `````````` </details> https://github.com/llvm/llvm-project/pull/224906 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
