[cfe-commits] r102386 - in /cfe/trunk: 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
Douglas Gregor
dgregor at apple.com
Mon Apr 26 14:31:17 PDT 2010
Author: dgregor
Date: Mon Apr 26 16:31:17 2010
New Revision: 102386
URL: http://llvm.org/viewvc/llvm-project?rev=102386&view=rev
Log:
Introduce Type::isStructureOrClassType(), which does the obvious
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.
Modified:
cfe/trunk/include/clang/AST/CanonicalType.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/Checker/BasicStore.cpp
cfe/trunk/lib/Checker/CallAndMessageChecker.cpp
cfe/trunk/lib/Checker/CastToStructChecker.cpp
cfe/trunk/lib/Checker/GRExprEngine.cpp
cfe/trunk/lib/Checker/RegionStore.cpp
cfe/trunk/lib/Frontend/RewriteObjC.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/SemaCXX/aggregate-initialization.cpp
Modified: cfe/trunk/include/clang/AST/CanonicalType.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CanonicalType.h?rev=102386&r1=102385&r2=102386&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/CanonicalType.h (original)
+++ cfe/trunk/include/clang/AST/CanonicalType.h Mon Apr 26 16:31:17 2010
@@ -263,6 +263,7 @@
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)
Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=102386&r1=102385&r2=102386&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Mon Apr 26 16:31:17 2010
@@ -871,6 +871,7 @@
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.
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=102386&r1=102385&r2=102386&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Apr 26 16:31:17 2010
@@ -968,7 +968,7 @@
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;
Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=102386&r1=102385&r2=102386&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Mon Apr 26 16:31:17 2010
@@ -225,6 +225,11 @@
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();
Modified: cfe/trunk/lib/Checker/BasicStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/BasicStore.cpp?rev=102386&r1=102385&r2=102386&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/BasicStore.cpp (original)
+++ cfe/trunk/lib/Checker/BasicStore.cpp Mon Apr 26 16:31:17 2010
@@ -401,7 +401,7 @@
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()) {
Modified: cfe/trunk/lib/Checker/CallAndMessageChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/CallAndMessageChecker.cpp?rev=102386&r1=102385&r2=102386&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/CallAndMessageChecker.cpp (original)
+++ cfe/trunk/lib/Checker/CallAndMessageChecker.cpp Mon Apr 26 16:31:17 2010
@@ -290,7 +290,7 @@
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.
Modified: cfe/trunk/lib/Checker/CastToStructChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/CastToStructChecker.cpp?rev=102386&r1=102385&r2=102386&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/CastToStructChecker.cpp (original)
+++ cfe/trunk/lib/Checker/CastToStructChecker.cpp Mon Apr 26 16:31:17 2010
@@ -51,7 +51,7 @@
QualType OrigPointeeTy = OrigPTy->getPointeeType();
QualType ToPointeeTy = ToPTy->getPointeeType();
- if (!ToPointeeTy->isStructureType())
+ if (!ToPointeeTy->isStructureOrClassType())
return;
// We allow cast from void*.
Modified: cfe/trunk/lib/Checker/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRExprEngine.cpp?rev=102386&r1=102385&r2=102386&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Checker/GRExprEngine.cpp Mon Apr 26 16:31:17 2010
@@ -2504,9 +2504,7 @@
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.
Modified: cfe/trunk/lib/Checker/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/RegionStore.cpp?rev=102386&r1=102385&r2=102386&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/RegionStore.cpp (original)
+++ cfe/trunk/lib/Checker/RegionStore.cpp Mon Apr 26 16:31:17 2010
@@ -1037,7 +1037,7 @@
}
#endif
- if (RTy->isStructureType() || RTy->isClassType())
+ if (RTy->isStructureOrClassType())
return RetrieveStruct(store, R);
// FIXME: Handle unions.
@@ -1345,7 +1345,7 @@
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 @@
// 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 @@
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 @@
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 @@
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 @@
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 @@
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);
Modified: cfe/trunk/lib/Frontend/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/RewriteObjC.cpp?rev=102386&r1=102385&r2=102386&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/RewriteObjC.cpp (original)
+++ cfe/trunk/lib/Frontend/RewriteObjC.cpp Mon Apr 26 16:31:17 2010
@@ -2708,7 +2708,7 @@
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;
Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=102386&r1=102385&r2=102386&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Mon Apr 26 16:31:17 2010
@@ -458,7 +458,7 @@
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();
Modified: cfe/trunk/test/SemaCXX/aggregate-initialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/aggregate-initialization.cpp?rev=102386&r1=102385&r2=102386&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/aggregate-initialization.cpp (original)
+++ cfe/trunk/test/SemaCXX/aggregate-initialization.cpp Mon Apr 26 16:31:17 2010
@@ -67,3 +67,16 @@
C c1 = { 1 };
}
+
+class Agg {
+public:
+ int i, j;
+};
+
+class AggAgg {
+public:
+ Agg agg1;
+ Agg agg2;
+};
+
+AggAgg aggagg = { 1, 2, 3, 4 };
More information about the cfe-commits
mailing list