]> granicus.if.org Git - clang/commitdiff
Introduce Type::isStructureOrClassType(), which does the obvious
authorDouglas Gregor <dgregor@apple.com>
Mon, 26 Apr 2010 21:31:17 +0000 (21:31 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 26 Apr 2010 21:31:17 +0000 (21:31 +0000)
thing. Audit all uses of Type::isStructure(), changing those calls to
isStructureOrClassType() as needed (which is alsmost
everywhere). Fixes the remaining failure in Boost.Utility/Swap.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102386 91177308-0d34-0410-b5e6-96231b3b80d8

12 files changed:
include/clang/AST/CanonicalType.h
include/clang/AST/Type.h
lib/AST/ExprConstant.cpp
lib/AST/Type.cpp
lib/Checker/BasicStore.cpp
lib/Checker/CallAndMessageChecker.cpp
lib/Checker/CastToStructChecker.cpp
lib/Checker/GRExprEngine.cpp
lib/Checker/RegionStore.cpp
lib/Frontend/RewriteObjC.cpp
lib/Sema/SemaInit.cpp
test/SemaCXX/aggregate-initialization.cpp

index b2a87f617063c0ae3f536cd327fc51e0db327c44..93dcad7512214c28eeaea0183822330a22d8cb47 100644 (file)
@@ -263,6 +263,7 @@ public:
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isMemberFunctionPointerType)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isClassType)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isStructureType)
+  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isStructureOrClassType)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isUnionType)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isComplexIntegerType)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isNullPtrType)
index 72793651c4be9fd1c6c773b7fbbfe95cb1d86bb0..f42d799325ff890156feefa29fc7965ed45d9e93 100644 (file)
@@ -871,6 +871,7 @@ public:
   bool isRecordType() const;
   bool isClassType() const;
   bool isStructureType() const;
+  bool isStructureOrClassType() const;
   bool isUnionType() const;
   bool isComplexIntegerType() const;            // GCC _Complex integer type.
   bool isVectorType() const;                    // GCC vector type.
index a80d50a5070bbcff87f3491a27a26e811eaf39c9..a52cf6fe4c8154fd6a7675ff031b902339eb0395 100644 (file)
@@ -968,7 +968,7 @@ static int EvaluateBuiltinClassifyType(const CallExpr *E) {
     return complex_type_class;
   else if (ArgTy->isFunctionType())
     return function_type_class;
-  else if (ArgTy->isStructureType())
+  else if (ArgTy->isStructureOrClassType())
     return record_type_class;
   else if (ArgTy->isUnionType())
     return union_type_class;
index 27a277ddbcb00fc0d1a6228e783027ca7a2f92d7..d21890daf754ede01b965b68ee2a5b7b357cb9dc 100644 (file)
@@ -225,6 +225,11 @@ bool Type::isStructureType() const {
     return RT->getDecl()->isStruct();
   return false;
 }
+bool Type::isStructureOrClassType() const {
+  if (const RecordType *RT = getAs<RecordType>())
+    return RT->getDecl()->isStruct() || RT->getDecl()->isClass();
+  return false;
+}
 bool Type::isVoidPointerType() const {
   if (const PointerType *PT = getAs<PointerType>())
     return PT->getPointeeType()->isVoidType();
index 7c5399113df73d6f55a96c786b7cc799a67d15b5..34470af29f4a0a56e630f5d34627d2d343424ccf 100644 (file)
@@ -401,7 +401,7 @@ Store BasicStoreManager::BindDeclInternal(Store store, const VarRegion* VR,
   const VarDecl *VD = VR->getDecl();
 
   // BasicStore does not model arrays and structs.
-  if (VD->getType()->isArrayType() || VD->getType()->isStructureType())
+  if (VD->getType()->isArrayType() || VD->getType()->isStructureOrClassType())
     return store;
 
   if (VD->hasGlobalStorage()) {
index 9d0dc3339527f0e111117dffe532f6f5c0bdab56..c619d75479ed721e3ed49361188d1b578eedcffd 100644 (file)
@@ -290,7 +290,7 @@ void CallAndMessageChecker::HandleNilReceiver(CheckerContext &C,
   ASTContext &Ctx = C.getASTContext();
   CanQualType CanRetTy = Ctx.getCanonicalType(RetTy);
 
-  if (CanRetTy->isStructureType()) {
+  if (CanRetTy->isStructureOrClassType()) {
     // FIXME: At some point we shouldn't rely on isConsumedExpr(), but instead
     // have the "use of undefined value" be smarter about where the
     // undefined value came from.
index 2c16f89058119849235d47922d0bf988806c0bd7..eeaed970b53380648a8c43c0d232a8497b4008b7 100644 (file)
@@ -51,7 +51,7 @@ void CastToStructChecker::PreVisitCastExpr(CheckerContext &C,
   QualType OrigPointeeTy = OrigPTy->getPointeeType();
   QualType ToPointeeTy = ToPTy->getPointeeType();
 
-  if (!ToPointeeTy->isStructureType())
+  if (!ToPointeeTy->isStructureOrClassType())
     return;
 
   // We allow cast from void*.
index 376f9fcd87c62091fc82df27cc15406c5ac75af7..c11a16ff7b4c1fb3cd50839f973c771725a8bc3c 100644 (file)
@@ -2504,9 +2504,7 @@ void GRExprEngine::VisitInitListExpr(InitListExpr* E, ExplodedNode* Pred,
   QualType T = getContext().getCanonicalType(E->getType());
   unsigned NumInitElements = E->getNumInits();
 
-  if (T->isArrayType() || T->isStructureType() ||
-      T->isUnionType() || T->isVectorType()) {
-
+  if (T->isArrayType() || T->isRecordType() || T->isVectorType()) {
     llvm::ImmutableList<SVal> StartVals = getBasicVals().getEmptySValList();
 
     // Handle base case where the initializer has no elements.
index 73158f295502a8930f93859ff8547cd50dc1219e..1e15d43a5ac2286f16d65eeb6970ef2081b6e9c3 100644 (file)
@@ -1037,7 +1037,7 @@ SVal RegionStoreManager::Retrieve(Store store, Loc L, QualType T) {
   }
 #endif
 
-  if (RTy->isStructureType() || RTy->isClassType())
+  if (RTy->isStructureOrClassType())
     return RetrieveStruct(store, R);
 
   // FIXME: Handle unions.
@@ -1345,7 +1345,7 @@ SVal RegionStoreManager::RetrieveLazySymbol(const TypedRegion *R) {
 
 SVal RegionStoreManager::RetrieveStruct(Store store, const TypedRegion* R) {
   QualType T = R->getValueType(getContext());
-  assert(T->isStructureType() || T->isClassType());
+  assert(T->isStructureOrClassType());
   return ValMgr.makeLazyCompoundVal(store, R);
 }
 
@@ -1375,7 +1375,7 @@ Store RegionStoreManager::Bind(Store store, Loc L, SVal V) {
 
   // Check if the region is a struct region.
   if (const TypedRegion* TR = dyn_cast<TypedRegion>(R))
-    if (TR->getValueType(getContext())->isStructureType())
+    if (TR->getValueType(getContext())->isStructureOrClassType())
       return BindStruct(store, TR, V);
 
   // Special case: the current region represents a cast and it and the super
@@ -1429,7 +1429,7 @@ Store RegionStoreManager::BindDecl(Store store, const VarRegion *VR,
 
   if (T->isArrayType())
     return BindArray(store, VR, InitVal);
-  if (T->isStructureType())
+  if (T->isStructureOrClassType())
     return BindStruct(store, VR, InitVal);
 
   return Bind(store, ValMgr.makeLoc(VR), InitVal);
@@ -1454,7 +1454,7 @@ Store RegionStoreManager::setImplicitDefaultValue(Store store,
     V = ValMgr.makeNull();
   else if (T->isIntegerType())
     V = ValMgr.makeZeroVal(T);
-  else if (T->isStructureType() || T->isArrayType()) {
+  else if (T->isStructureOrClassType() || T->isArrayType()) {
     // Set the default value to a zero constant when it is a structure
     // or array.  The type doesn't really matter.
     V = ValMgr.makeZeroVal(ValMgr.getContext().IntTy);
@@ -1530,7 +1530,7 @@ Store RegionStoreManager::BindArray(Store store, const TypedRegion* R,
     SVal Idx = ValMgr.makeArrayIndex(i);
     const ElementRegion *ER = MRMgr.getElementRegion(ElementTy, Idx, R, getContext());
 
-    if (ElementTy->isStructureType())
+    if (ElementTy->isStructureOrClassType())
       store = BindStruct(store, ER, *VI);
     else
       store = Bind(store, ValMgr.makeLoc(ER), *VI);
@@ -1551,7 +1551,7 @@ Store RegionStoreManager::BindStruct(Store store, const TypedRegion* R,
     return store;
 
   QualType T = R->getValueType(getContext());
-  assert(T->isStructureType());
+  assert(T->isStructureOrClassType());
 
   const RecordType* RT = T->getAs<RecordType>();
   RecordDecl* RD = RT->getDecl();
@@ -1583,7 +1583,7 @@ Store RegionStoreManager::BindStruct(Store store, const TypedRegion* R,
 
     if (FTy->isArrayType())
       store = BindArray(store, FR, *VI);
-    else if (FTy->isStructureType())
+    else if (FTy->isStructureOrClassType())
       store = BindStruct(store, FR, *VI);
     else
       store = Bind(store, ValMgr.makeLoc(FR), *VI);
index a1cbb324c497b153eeffb3cf732b7ffa3c174b37..11698325e9b11f2769e7fc28e2105da9d68df4a0 100644 (file)
@@ -2708,7 +2708,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
   FunctionDecl *MsgSendStretFlavor = 0;
   if (ObjCMethodDecl *mDecl = Exp->getMethodDecl()) {
     QualType resultType = mDecl->getResultType();
-    if (resultType->isStructureType() || resultType->isUnionType())
+    if (resultType->isRecordType())
       MsgSendStretFlavor = MsgSendStretFunctionDecl;
     else if (resultType->isRealFloatingType())
       MsgSendFlavor = MsgSendFpretFunctionDecl;
index ccd6d5f28400a8e6aa44aa42ad47c5902212a4bc..1caa94bf81c64a97f3b18e765b52774753ae0d93 100644 (file)
@@ -458,7 +458,7 @@ void InitListChecker::CheckImplicitInitList(const InitializedEntity &Entity,
 
   if (T->isArrayType())
     maxElements = numArrayElements(T);
-  else if (T->isStructureType() || T->isUnionType())
+  else if (T->isRecordType())
     maxElements = numStructUnionElements(T);
   else if (T->isVectorType())
     maxElements = T->getAs<VectorType>()->getNumElements();
index 81a0e6f74401f5b6f539c926ced21327c0608b05..4c34447940ff346b0d5944f348eee747ba3ed53e 100644 (file)
@@ -67,3 +67,16 @@ void f() {
   
   C c1 = { 1 };
 }
+
+class Agg {
+public:
+  int i, j;
+};
+
+class AggAgg {
+public:
+  Agg agg1;
+  Agg agg2;
+};
+
+AggAgg aggagg = { 1, 2, 3, 4 };