diff options
| author | Chris Wailes <chris.wailes@gmail.com> | 2013-10-31 15:38:12 +0000 |
|---|---|---|
| committer | Chris Wailes <chris.wailes@gmail.com> | 2013-10-31 15:38:12 +0000 |
| commit | 93edffa8fe3d1e042dcceecda6d62dc090fee346 (patch) | |
| tree | aed47683751b6cffabc7c70545b6b9b52065aa28 /clang/lib/Analysis | |
| parent | aca9739a1affb675a1fab6a034b4e95e156318a5 (diff) | |
| download | bcm5719-llvm-93edffa8fe3d1e042dcceecda6d62dc090fee346.tar.gz bcm5719-llvm-93edffa8fe3d1e042dcceecda6d62dc090fee346.zip | |
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.
llvm-svn: 193751
Diffstat (limited to 'clang/lib/Analysis')
| -rw-r--r-- | clang/lib/Analysis/Consumed.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/Analysis/Consumed.cpp b/clang/lib/Analysis/Consumed.cpp index 35267c1cf06..13306f92a5c 100644 --- a/clang/lib/Analysis/Consumed.cpp +++ b/clang/lib/Analysis/Consumed.cpp @@ -142,10 +142,13 @@ static bool isCallableInState(const CallableWhenAttr *CWAttr, } 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 State) { 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::VisitParmVarDecl(const ParmVarDecl *Param) { 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) && |

