Skip to content

Commit 39b0be2

Browse files
martinboehmearsenm
authored andcommitted
Revert "[clang][dataflow] Teach AnalysisASTVisitor that typeid() can be evaluated." (#96766)
Reverts #96731 It causes CI failures.
1 parent 803aa88 commit 39b0be2

File tree

2 files changed

+1
-48
lines changed

2 files changed

+1
-48
lines changed

clang/include/clang/Analysis/FlowSensitive/ASTOps.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,7 @@ class AnalysisASTVisitor : public RecursiveASTVisitor<Derived> {
113113
// nevertheless it appears in the Clang CFG, so we don't exclude it here.
114114
bool TraverseDecltypeTypeLoc(DecltypeTypeLoc) { return true; }
115115
bool TraverseTypeOfExprTypeLoc(TypeOfExprTypeLoc) { return true; }
116-
bool TraverseCXXTypeidExpr(CXXTypeidExpr *TIE) {
117-
if (TIE->isPotentiallyEvaluated())
118-
return RecursiveASTVisitor<Derived>::TraverseCXXTypeidExpr(TIE);
119-
return true;
120-
}
116+
bool TraverseCXXTypeidExpr(CXXTypeidExpr *) { return true; }
121117
bool TraverseUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *) {
122118
return true;
123119
}

clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,49 +1637,6 @@ TEST(TransferTest, StructModeledFieldsWithAccessor) {
16371637
});
16381638
}
16391639

1640-
TEST(TransferTest, StructModeledFieldsInTypeid) {
1641-
// Test that we model fields mentioned inside a `typeid()` expression only if
1642-
// that expression is potentially evaluated -- i.e. if the expression inside
1643-
// `typeid()` is a glvalue of polymorphic type (see
1644-
// `CXXTypeidExpr::isPotentiallyEvaluated()` and [expr.typeid]p3).
1645-
std::string Code = R"(
1646-
// Definitions needed for `typeid`.
1647-
namespace std {
1648-
class type_info {};
1649-
class bad_typeid {};
1650-
} // namespace std
1651-
1652-
struct NonPolymorphic {};
1653-
1654-
struct Polymorphic {
1655-
virtual ~Polymorphic() = default;
1656-
};
1657-
1658-
struct S {
1659-
NonPolymorphic *NonPoly;
1660-
Polymorphic *Poly;
1661-
};
1662-
1663-
void target(S &s) {
1664-
typeid(*s.NonPoly);
1665-
typeid(*s.Poly);
1666-
// [[p]]
1667-
}
1668-
)";
1669-
runDataflow(
1670-
Code,
1671-
[](const llvm::StringMap<DataflowAnalysisState<NoopLattice>> &Results,
1672-
ASTContext &ASTCtx) {
1673-
const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
1674-
auto &SLoc = getLocForDecl<RecordStorageLocation>(ASTCtx, Env, "s");
1675-
std::vector<const ValueDecl *> Fields;
1676-
for (auto [Field, _] : SLoc.children())
1677-
Fields.push_back(Field);
1678-
EXPECT_THAT(Fields,
1679-
UnorderedElementsAre(findValueDecl(ASTCtx, "Poly")));
1680-
});
1681-
}
1682-
16831640
TEST(TransferTest, StructModeledFieldsWithComplicatedInheritance) {
16841641
std::string Code = R"(
16851642
struct Base1 {

0 commit comments

Comments
 (0)