Test?
On Thu, Oct 31, 2013 at 11:38 AM, Chris Wailes <[email protected]>wrote: > Author: chris.wailes > Date: Thu Oct 31 10:38:12 2013 > New Revision: 193751 > > URL: http://llvm.org/viewvc/llvm-project?rev=193751&view=rev > Log: > Fixed bug with checking the kind of types. > > The isLValueReferenceType function checks to see if the QualType's > canonical type is an LValue reference, and not if the QualType > itself is an LValue reference. This caused a segfault when trying > to cast the QualType's Type to a LValueReference. This is now > fixed by casting the result of getCanonicalType(). > > In addition, a test was added to isConsumableType to prevent > segfaults when a type being tested by the analysis is a reference > to a pointer or a pointer to a reference. > > Modified: > cfe/trunk/lib/Analysis/Consumed.cpp > > Modified: cfe/trunk/lib/Analysis/Consumed.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/Consumed.cpp?rev=193751&r1=193750&r2=193751&view=diff > > ============================================================================== > --- cfe/trunk/lib/Analysis/Consumed.cpp (original) > +++ cfe/trunk/lib/Analysis/Consumed.cpp Thu Oct 31 10:38:12 2013 > @@ -142,10 +142,13 @@ static bool isCallableInState(const Call > } > > static bool isConsumableType(const QualType &QT) { > + if (QT->isPointerType() || QT->isReferenceType()) > + return false; > + > if (const CXXRecordDecl *RD = QT->getAsCXXRecordDecl()) > return RD->hasAttr<ConsumableAttr>(); > - else > - return false; > + > + return false; > } > > static bool isKnownState(ConsumedState State) { > @@ -163,7 +166,8 @@ static bool isKnownState(ConsumedState S > static bool isRValueRefish(QualType ParamType) { > return ParamType->isRValueReferenceType() || > (ParamType->isLValueReferenceType() && > - !cast<LValueReferenceType>(*ParamType).isSpelledAsLValue()); > + !cast<LValueReferenceType>( > + ParamType.getCanonicalType())->isSpelledAsLValue()); > } > > static bool isTestingFunction(const FunctionDecl *FunDecl) { > @@ -864,7 +868,7 @@ void ConsumedStmtVisitor::VisitParmVarDe > const ParamTypestateAttr *PTAttr = > Param->getAttr<ParamTypestateAttr>(); > ParamState = mapParamTypestateAttrState(PTAttr); > > - } else if (isValueType(ParamType) && isConsumableType(ParamType)) { > + } else if (isConsumableType(ParamType)) { > ParamState = mapConsumableAttrState(ParamType); > > } else if (isRValueRefish(ParamType) && > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
