<div dir="ltr">LGTM.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Oct 30, 2013 at 11:00 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">Hi dblaikie, delesley, aaron.ballman,<br>
<br>
Fix for bugs 17632 and 17724.<br>
<br>
The isLValueReferenceType function checks to see if the QualType's canonical type is an LValueReferenceType, and not if the QualType itself is an LValueReferenceType. This caused a segfault when trying to cast the QualType's Type to a LValueReferenceType. This is now fixed by casting the result of getCanonicalType().<br>
<br>
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.<br>
<br>
Link to bugs:<br>
<a href="http://llvm.org/bugs/show_bug.cgi?id=17632" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=17632</a><br>
<a href="http://llvm.org/bugs/show_bug.cgi?id=17724" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=17724</a><br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D2065" target="_blank">http://llvm-reviews.chandlerc.com/D2065</a><br>
<br>
Files:<br>
lib/Analysis/Consumed.cpp<br>
<br>
Index: lib/Analysis/Consumed.cpp<br>
===================================================================<br>
--- lib/Analysis/Consumed.cpp<br>
+++ lib/Analysis/Consumed.cpp<br>
@@ -142,10 +142,13 @@<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 @@<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 @@<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>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>DeLesley Hutchins | Software Engineer | <a href="mailto:delesley@google.com" target="_blank">delesley@google.com</a> | 505-206-0315<br>
</div>