mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-11 17:08:42 +00:00
[clang][AST] fix lack comparison of declRefExpr in ASTStructuralEquivalence (#66041)
Fixed #66047 Before fix,the following testcase expected true. ```cpp TEST_F(StructuralEquivalenceStmtTest, DeclRefENoEq) { std::string Prefix = "enum Test { AAA, BBB };"; auto t = makeStmts( Prefix + "void foo(int i) {if (i > 0) {i = AAA;} else {i = BBB;}}", Prefix + "void foo(int i) {if (i > 0) {i = BBB;} else {i = AAA;}}", Lang_CXX03, ifStmt()); EXPECT_FALSE(testStructuralMatch(t)); // EXPECT_TRUE } ```
This commit is contained in:
parent
dc925be68b
commit
3542168be0
@ -244,6 +244,8 @@ Bug Fixes in This Version
|
|||||||
(`#65156 <https://github.com/llvm/llvm-project/issues/65156>`_)
|
(`#65156 <https://github.com/llvm/llvm-project/issues/65156>`_)
|
||||||
- Clang no longer considers the loss of ``__unaligned`` qualifier from objects as
|
- Clang no longer considers the loss of ``__unaligned`` qualifier from objects as
|
||||||
an invalid conversion during method function overload resolution.
|
an invalid conversion during method function overload resolution.
|
||||||
|
- Fix lack of comparison of declRefExpr in ASTStructuralEquivalence
|
||||||
|
(`#66047 <https://github.com/llvm/llvm-project/issues/66047>`_)
|
||||||
- Fix parser crash when dealing with ill-formed objective C++ header code. Fixes
|
- Fix parser crash when dealing with ill-formed objective C++ header code. Fixes
|
||||||
(`#64836 <https://github.com/llvm/llvm-project/issues/64836>`_)
|
(`#64836 <https://github.com/llvm/llvm-project/issues/64836>`_)
|
||||||
- Clang now allows an ``_Atomic`` qualified integer in a switch statement. Fixes
|
- Clang now allows an ``_Atomic`` qualified integer in a switch statement. Fixes
|
||||||
|
@ -214,6 +214,15 @@ class StmtComparer {
|
|||||||
return E1->size() == E2->size();
|
return E1->size() == E2->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsStmtEquivalent(const DeclRefExpr *DRE1, const DeclRefExpr *DRE2) {
|
||||||
|
const ValueDecl *Decl1 = DRE1->getDecl();
|
||||||
|
const ValueDecl *Decl2 = DRE2->getDecl();
|
||||||
|
if (!Decl1 || !Decl2)
|
||||||
|
return false;
|
||||||
|
return IsStructurallyEquivalent(Context, const_cast<ValueDecl *>(Decl1),
|
||||||
|
const_cast<ValueDecl *>(Decl2));
|
||||||
|
}
|
||||||
|
|
||||||
bool IsStmtEquivalent(const DependentScopeDeclRefExpr *DE1,
|
bool IsStmtEquivalent(const DependentScopeDeclRefExpr *DE1,
|
||||||
const DependentScopeDeclRefExpr *DE2) {
|
const DependentScopeDeclRefExpr *DE2) {
|
||||||
if (!IsStructurallyEquivalent(Context, DE1->getDeclName(),
|
if (!IsStructurallyEquivalent(Context, DE1->getDeclName(),
|
||||||
|
@ -2393,5 +2393,14 @@ TEST_F(StructuralEquivalenceCacheTest, GotoStmtNoEq) {
|
|||||||
EXPECT_FALSE(testStructuralMatch(S));
|
EXPECT_FALSE(testStructuralMatch(S));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(StructuralEquivalenceStmtTest, DeclRefExpr) {
|
||||||
|
std::string Prefix = "enum Test { AAA, BBB };";
|
||||||
|
auto t = makeStmts(
|
||||||
|
Prefix + "void foo(int i) {if (i > 0) {i = AAA;} else {i = BBB;}}",
|
||||||
|
Prefix + "void foo(int i) {if (i > 0) {i = BBB;} else {i = AAA;}}",
|
||||||
|
Lang_CXX03, ifStmt());
|
||||||
|
EXPECT_FALSE(testStructuralMatch(t));
|
||||||
|
}
|
||||||
|
|
||||||
} // end namespace ast_matchers
|
} // end namespace ast_matchers
|
||||||
} // end namespace clang
|
} // end namespace clang
|
||||||
|
Loading…
Reference in New Issue
Block a user