zequanwu updated this revision to Diff 290846.
zequanwu added a comment.
Remove unused field.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87425/new/
https://reviews.llvm.org/D87425
Files:
clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
clang/include/clang/AST/EvaluatedExprVisitor.h
clang/include/clang/AST/ExprCXX.h
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprCXX.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/Analysis/ExprMutationAnalyzer.cpp
clang/lib/CodeGen/CGExprCXX.cpp
clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
clang/test/SemaCXX/constant-expression-cxx2a.cpp
Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===================================================================
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -309,7 +309,7 @@
static_assert(&B2().ti2 == &typeid(B2));
extern B2 extern_b2;
// expected-note@+1 {{typeid applied to object 'extern_b2' whose dynamic type is not constant}}
- static_assert(&typeid(extern_b2) == &typeid(B2)); // expected-error {{constant expression}}
+ static_assert(&typeid(*&extern_b2) == &typeid(B2)); // expected-error {{constant expression}}
constexpr B2 b2;
constexpr const B &b1 = b2;
Index: clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
===================================================================
--- clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-typeid.cpp
@@ -46,9 +46,11 @@
const std::type_info* test5_typeid() { return &typeid(v); }
// CHECK: define dso_local %struct.type_info* @"?test5_typeid@@YAPBUtype_info@@XZ"()
-// CHECK: [[RT:%.*]] = call i8* @__RTtypeid(i8* bitcast (%struct.V* @"?v@@3UV@@A" to i8*))
-// CHECK-NEXT: [[RET:%.*]] = bitcast i8* [[RT]] to %struct.type_info*
-// CHECK-NEXT: ret %struct.type_info* [[RET]]
+// CHECK: ret %struct.type_info* bitcast (%rtti.TypeDescriptor7* @"??_R0?AUV@@@8" to %struct.type_info*)
+
+const std::type_info *test6_typeid() { return &typeid((V &)v); }
+// CHECK: define dso_local %struct.type_info* @"?test6_typeid@@YAPBUtype_info@@XZ"()
+// CHECK: ret %struct.type_info* bitcast (%rtti.TypeDescriptor7* @"??_R0?AUV@@@8" to %struct.type_info*)
namespace PR26329 {
struct Polymorphic {
Index: clang/lib/CodeGen/CGExprCXX.cpp
===================================================================
--- clang/lib/CodeGen/CGExprCXX.cpp
+++ clang/lib/CodeGen/CGExprCXX.cpp
@@ -2199,7 +2199,7 @@
// polymorphic class type, the result refers to a std::type_info object
// representing the type of the most derived object (that is, the dynamic
// type) to which the glvalue refers.
- if (E->isPotentiallyEvaluated())
+ if (E->isPotentiallyEvaluated(getContext()))
return EmitTypeidFromVTable(*this, E->getExprOperand(),
StdTypeInfoPtrTy);
Index: clang/lib/Analysis/ExprMutationAnalyzer.cpp
===================================================================
--- clang/lib/Analysis/ExprMutationAnalyzer.cpp
+++ clang/lib/Analysis/ExprMutationAnalyzer.cpp
@@ -40,7 +40,7 @@
cxxTypeidExpr;
AST_MATCHER(CXXTypeidExpr, isPotentiallyEvaluated) {
- return Node.isPotentiallyEvaluated();
+ return Node.isPotentiallyEvaluated(Finder->getASTContext());
}
const ast_matchers::internal::VariadicDynCastAllOfMatcher<Stmt,
Index: clang/lib/AST/ExprConstant.cpp
===================================================================
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -7969,7 +7969,7 @@
bool LValueExprEvaluator::VisitCXXTypeidExpr(const CXXTypeidExpr *E) {
TypeInfoLValue TypeInfo;
- if (!E->isPotentiallyEvaluated()) {
+ if (!E->isPotentiallyEvaluated(Info.Ctx)) {
if (E->isTypeOperand())
TypeInfo = TypeInfoLValue(E->getTypeOperand(Info.Ctx).getTypePtr());
else
Index: clang/lib/AST/ExprCXX.cpp
===================================================================
--- clang/lib/AST/ExprCXX.cpp
+++ clang/lib/AST/ExprCXX.cpp
@@ -131,14 +131,20 @@
return Result;
}
-bool CXXTypeidExpr::isPotentiallyEvaluated() const {
+bool CXXTypeidExpr::isPotentiallyEvaluated(const ASTContext &Context) const {
if (isTypeOperand())
return false;
+ Expr *E = getExprOperand()->IgnoreParenNoopCasts(Context);
+ if (auto *DRE = dyn_cast<DeclRefExpr>(E)) {
+ QualType Ty = DRE->getDecl()->getType();
+ if (!Ty->isPointerType() && !Ty->isReferenceType())
+ return false;
+ }
+
// C++11 [expr.typeid]p3:
// When typeid is applied to an expression other than a glvalue of
// polymorphic class type, [...] the expression is an unevaluated operand.
- const Expr *E = getExprOperand();
if (const CXXRecordDecl *RD = E->getType()->getAsCXXRecordDecl())
if (RD->isPolymorphic() && E->isGLValue())
return true;
Index: clang/lib/AST/Expr.cpp
===================================================================
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -3477,7 +3477,7 @@
case CXXTypeidExprClass:
// typeid might throw if its subexpression is potentially-evaluated, so has
// side-effects in that case whether or not its subexpression does.
- return cast<CXXTypeidExpr>(this)->isPotentiallyEvaluated();
+ return cast<CXXTypeidExpr>(this)->isPotentiallyEvaluated(Ctx);
case CXXConstructExprClass:
case CXXTemporaryObjectExprClass: {
Index: clang/include/clang/AST/ExprCXX.h
===================================================================
--- clang/include/clang/AST/ExprCXX.h
+++ clang/include/clang/AST/ExprCXX.h
@@ -838,7 +838,7 @@
/// Determine whether this typeid has a type operand which is potentially
/// evaluated, per C++11 [expr.typeid]p3.
- bool isPotentiallyEvaluated() const;
+ bool isPotentiallyEvaluated(const ASTContext &Context) const;
bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); }
Index: clang/include/clang/AST/EvaluatedExprVisitor.h
===================================================================
--- clang/include/clang/AST/EvaluatedExprVisitor.h
+++ clang/include/clang/AST/EvaluatedExprVisitor.h
@@ -77,7 +77,7 @@
}
void VisitCXXTypeidExpr(PTR(CXXTypeidExpr) E) {
- if (E->isPotentiallyEvaluated())
+ if (E->isPotentiallyEvaluated(Context))
return this->Visit(E->getExprOperand());
}
Index: clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
@@ -40,7 +40,7 @@
}
}
if (const auto *TypeIDExpr = dyn_cast<CXXTypeidExpr>(&Node))
- return !TypeIDExpr->isPotentiallyEvaluated();
+ return !TypeIDExpr->isPotentiallyEvaluated(Finder->getASTContext());
return false;
}
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits