summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2013-05-30 18:14:27 +0000
committerJordan Rose <jordan_rose@apple.com>2013-05-30 18:14:27 +0000
commit278d9de314b713933a37de186804593e2bf5becf (patch)
treef3dc700ed92dec7918f4847797505155dd450f1c /clang/lib/StaticAnalyzer/Core/CallEvent.cpp
parent4c9a38a47ad73ef8a88f2ff577705100a9c61726 (diff)
downloadbcm5719-llvm-278d9de314b713933a37de186804593e2bf5becf.tar.gz
bcm5719-llvm-278d9de314b713933a37de186804593e2bf5becf.zip
[analyzer] Don't crash if a block's signature just has the return type.
It is okay to declare a block without an argument list: ^ {} or ^void {}. In these cases, the BlockDecl's signature-as-written will just contain the return type, rather than the entire function type. It is unclear if this is intentional, but the analyzer shouldn't crash because of it. <rdar://problem/14018351> llvm-svn: 182948
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/CallEvent.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/CallEvent.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
index 8ac09ebb2d1..dd33e014c30 100644
--- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -245,12 +245,17 @@ QualType CallEvent::getDeclaredResultType(const Decl *D) {
// Blocks are difficult because the return type may not be stored in the
// BlockDecl itself. The AST should probably be enhanced, but for now we
// just do what we can.
+ // If the block is declared without an explicit argument list, the
+ // signature-as-written just includes the return type, not the entire
+ // function type.
// FIXME: All blocks should have signatures-as-written, even if the return
- // type is inferred. (That's signified is with a dependent result type.)
+ // type is inferred. (That's signified with a dependent result type.)
if (const TypeSourceInfo *TSI = BD->getSignatureAsWritten()) {
- const FunctionType *FT = TSI->getType()->castAs<FunctionType>();
- if (!FT->getResultType()->isDependentType())
- return FT->getResultType();
+ QualType Ty = TSI->getType();
+ if (const FunctionType *FT = Ty->getAs<FunctionType>())
+ Ty = FT->getResultType();
+ if (!Ty->isDependentType())
+ return Ty;
}
return QualType();
OpenPOWER on IntegriCloud