diff options
author | Richard Smith <richard@metafoo.co.uk> | 2020-09-02 14:42:37 -0700 |
---|---|---|
committer | Richard Smith <richard@metafoo.co.uk> | 2020-09-16 18:11:18 -0700 |
commit | 905b9ca26c94fa86339451a528cedde5004fc1bb (patch) | |
tree | 38cf5aa37cc4e11d9dc86643137768c0609acbb8 /clang/lib/AST/ExprConstant.cpp | |
parent | 344a3d0bc0fb0868b519c3342b4982d6121eece3 (diff) | |
download | llvm-905b9ca26c94fa86339451a528cedde5004fc1bb.zip llvm-905b9ca26c94fa86339451a528cedde5004fc1bb.tar.gz llvm-905b9ca26c94fa86339451a528cedde5004fc1bb.tar.bz2 |
Canonicalize declaration pointers when forming APValues.
References to different declarations of the same entity aren't different
values, so shouldn't have different representations.
Recommit of e6393ee813178e9d3306b8e3c6949a4f32f8a2cb with fixed
handling for weak declarations. We now look for attributes on the most
recent declaration when determining whether a declaration is weak.
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index e8f132d..8e43b62 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -1978,18 +1978,11 @@ static bool HasSameBase(const LValue &A, const LValue &B) { return false; if (A.getLValueBase().getOpaqueValue() != - B.getLValueBase().getOpaqueValue()) { - const Decl *ADecl = GetLValueBaseDecl(A); - if (!ADecl) - return false; - const Decl *BDecl = GetLValueBaseDecl(B); - if (!BDecl || ADecl->getCanonicalDecl() != BDecl->getCanonicalDecl()) - return false; - } + B.getLValueBase().getOpaqueValue()) + return false; - return IsGlobalLValue(A.getLValueBase()) || - (A.getLValueCallIndex() == B.getLValueCallIndex() && - A.getLValueVersion() == B.getLValueVersion()); + return A.getLValueCallIndex() == B.getLValueCallIndex() && + A.getLValueVersion() == B.getLValueVersion(); } static void NoteLValueLocation(EvalInfo &Info, APValue::LValueBase Base) { @@ -3108,7 +3101,8 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E, // If we're currently evaluating the initializer of this declaration, use that // in-flight value. - if (Info.EvaluatingDecl.dyn_cast<const ValueDecl*>() == VD) { + if (declaresSameEntity(Info.EvaluatingDecl.dyn_cast<const ValueDecl *>(), + VD)) { Result = Info.EvaluatingDeclValue; return true; } |