summaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Core/CallEvent.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2013-05-22 18:09:44 +0000
committerJordan Rose <jordan_rose@apple.com>2013-05-22 18:09:44 +0000
commiteb41640fb417e25eb3218c2662a0dd512cdab04a (patch)
tree11ec4fa8c6df2179f39bd55284d9fc6743dd4ef6 /lib/StaticAnalyzer/Core/CallEvent.cpp
parentf0219cdcc6af557676f23c2c8d1f922caaf6f49a (diff)
downloadclang-eb41640fb417e25eb3218c2662a0dd512cdab04a.tar.gz
clang-eb41640fb417e25eb3218c2662a0dd512cdab04a.tar.bz2
clang-eb41640fb417e25eb3218c2662a0dd512cdab04a.tar.xz
[analyzer] Don't crash if a block doesn't have a type signature.
Currently, blocks instantiated in templates lose their "signature as written"; it's not clear if this is intentional. Change the analyzer's use of BlockDecl::getSignatureAsWritten to check whether or not the signature is actually there. <rdar://problem/13954714> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182497 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/CallEvent.cpp')
-rw-r--r--lib/StaticAnalyzer/Core/CallEvent.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/StaticAnalyzer/Core/CallEvent.cpp b/lib/StaticAnalyzer/Core/CallEvent.cpp
index dfd20b8b33..8ac09ebb2d 100644
--- a/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ b/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -245,10 +245,13 @@ 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.
- QualType Ty = BD->getSignatureAsWritten()->getType();
- if (const FunctionType *FT = Ty->getAs<FunctionType>())
+ // FIXME: All blocks should have signatures-as-written, even if the return
+ // type is inferred. (That's signified is 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();
+ }
return QualType();
}