summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-04-13 08:18:42 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-04-13 08:18:42 +0000
commit0a7aa3b60b234d272bb7f7d468aca54e93b8c626 (patch)
tree5d83c99d8fde4a040c603ae43ccb746e7b46c25a /clang/lib/Analysis
parent71c58f3d59a4eaa90f5ab43fbc964122258e0379 (diff)
downloadbcm5719-llvm-0a7aa3b60b234d272bb7f7d468aca54e93b8c626.tar.gz
bcm5719-llvm-0a7aa3b60b234d272bb7f7d468aca54e93b8c626.zip
Teach -Wuninitialized about C++'s typeid expression, including both the
evaluated and unevaluated contexts. Add some testing of sizeof and typeid. Both of the typeid tests added here were triggering warnings previously. Now the one false positive is suppressed without suppressing the warning on actually buggy code. llvm-svn: 129431
Diffstat (limited to 'clang/lib/Analysis')
-rw-r--r--clang/lib/Analysis/UninitializedValues.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Analysis/UninitializedValues.cpp b/clang/lib/Analysis/UninitializedValues.cpp
index d2eaff29ac7..59a42813fc5 100644
--- a/clang/lib/Analysis/UninitializedValues.cpp
+++ b/clang/lib/Analysis/UninitializedValues.cpp
@@ -390,6 +390,7 @@ public:
void VisitBinaryOperator(BinaryOperator *bo);
void VisitCastExpr(CastExpr *ce);
void VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *se);
+ void VisitCXXTypeidExpr(CXXTypeidExpr *E);
void BlockStmt_VisitObjCForCollectionStmt(ObjCForCollectionStmt *fs);
bool isTrackedVar(const VarDecl *vd) {
@@ -618,6 +619,17 @@ void TransferFunctions::VisitUnaryExprOrTypeTraitExpr(
}
}
+void TransferFunctions::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
+ // typeid(expression) is potentially evaluated when the argument is
+ // a glvalue of polymorphic type. (C++ 5.2.8p2-3)
+ if (!E->isTypeOperand() && E->Classify(ac.getASTContext()).isGLValue()) {
+ QualType SubExprTy = E->getExprOperand()->getType();
+ if (const RecordType *Record = SubExprTy->getAs<RecordType>())
+ if (cast<CXXRecordDecl>(Record->getDecl())->isPolymorphic())
+ Visit(E->getExprOperand());
+ }
+}
+
//------------------------------------------------------------------------====//
// High-level "driver" logic for uninitialized values analysis.
//====------------------------------------------------------------------------//
OpenPOWER on IntegriCloud