Files
clang-p2996/clang/test/Analysis/casts.m
John McCall fe96e0b6be Change the AST representation of operations on Objective-C
property references to use a new PseudoObjectExpr
expression which pairs a syntactic form of the expression
with a set of semantic expressions implementing it.
This should significantly reduce the complexity required
elsewhere in the compiler to deal with these kinds of
expressions (e.g. IR generation's special l-value kind,
the static analyzer's Message abstraction), at the lower
cost of specifically dealing with the odd AST structure
of these expressions.  It should also greatly simplify
efforts to implement similar language features in the
future, most notably Managed C++'s properties and indexed
properties.

Most of the effort here is in dealing with the various
clients of the AST.  I've gone ahead and simplified the
ObjC rewriter's use of properties;  other clients, like
IR-gen and the static analyzer, have all the old
complexity *and* all the new complexity, at least
temporarily.  Many thanks to Ted for writing and advising
on the necessary changes to the static analyzer.

I've xfailed a small diagnostics regression in the static
analyzer at Ted's request.

llvm-svn: 143867
2011-11-06 09:01:30 +00:00

43 lines
1.1 KiB
Objective-C

// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify %s
// Test function pointer casts. Currently we track function addresses using
// loc::FunctionVal. Because casts can be arbitrary, do we need to model
// functions with regions?
typedef void* (*MyFuncTest1)(void);
MyFuncTest1 test1_aux(void);
void test1(void) {
void *x;
void* (*p)(void);
p = ((void*) test1_aux());
if (p != ((void*) 0)) x = (*p)();
}
// Test casts from void* to function pointers. Same issue as above:
// should we eventually model function pointers using regions?
void* test2(void *p) {
MyFuncTest1 fp = (MyFuncTest1) p;
return (*fp)();
}
// <radar://10087620>
// A cast from int onjective C property reference to int.
typedef signed char BOOL;
@protocol NSObject - (BOOL)isEqual:(id)object; @end
@interface NSObject <NSObject> {} - (id)init; @end
typedef enum {
EEOne,
EETwo
} RDR10087620Enum;
@interface RDR10087620 : NSObject {
RDR10087620Enum elem;
}
@property (readwrite, nonatomic) RDR10087620Enum elem;
@end
static void
adium_media_ready_cb(RDR10087620 *InObj)
{
InObj.elem |= EEOne;
}