diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-08-31 18:19:18 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-08-31 18:19:18 +0000 |
commit | d65f1c8d6ebdd070db205f958d647d88b93fcf5b (patch) | |
tree | db951f63ac27dd5201555dd56816856ae326d852 /clang/test/Analysis/retain-release.mm | |
parent | facebca6ba52a8c186d39ed76f5acf00f0876573 (diff) | |
download | bcm5719-llvm-d65f1c8d6ebdd070db205f958d647d88b93fcf5b.tar.gz bcm5719-llvm-d65f1c8d6ebdd070db205f958d647d88b93fcf5b.zip |
[analyzer] RetainCountChecker: don't assume all functions have names.
Fixes a hard-to-reach crash when calling a non-member overloaded operator
with arguments that may be callbacks.
Future-proofing: don't make the same assumption in MallocSizeofChecker.
Aside from possibly respecting attributes in the future, it might be
possible to call 'malloc' through a function pointer.
I audited all other uses of FunctionDecl::getIdentifier() in the analyzer;
they all now correctly test to see if the identifier is present before
using it.
llvm-svn: 163012
Diffstat (limited to 'clang/test/Analysis/retain-release.mm')
-rw-r--r-- | clang/test/Analysis/retain-release.mm | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/test/Analysis/retain-release.mm b/clang/test/Analysis/retain-release.mm index 01727ea6443..d92237b185a 100644 --- a/clang/test/Analysis/retain-release.mm +++ b/clang/test/Analysis/retain-release.mm @@ -366,3 +366,22 @@ NSString * radar11152419(NSString *string1, NSString *key1, NSMapTable *map) { return string; } +//===----------------------------------------------------------------------===// +// Don't crash on non-member functions with "callbacks" but without names. +//===----------------------------------------------------------------------===// + +struct IntWrapper { + int arg; +}; + +int operator>> (const IntWrapper &W, int (*f)(int)) { + return f(W.arg); +} + +void testCallback() { + IntWrapper val = { 42 }; + + extern int process(int); + val >> process; +} + |