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