From e6fbdf538bc50122876639e08a1401e2bc9555ba Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 12 Mar 2009 22:15:08 +0000 Subject: [PATCH] Fix crash when using TypedViewRegions and ObjCQualifiedIdTypes (TypedViewRegion::getLValueType() was not implemented). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66830 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../clang/Analysis/PathSensitive/MemRegion.h | 5 +- test/Analysis/region-1.m | 90 +++++++++++++++++++ 2 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 test/Analysis/region-1.m diff --git a/include/clang/Analysis/PathSensitive/MemRegion.h b/include/clang/Analysis/PathSensitive/MemRegion.h index b6e4ccb274..8cf084ad57 100644 --- a/include/clang/Analysis/PathSensitive/MemRegion.h +++ b/include/clang/Analysis/PathSensitive/MemRegion.h @@ -238,7 +238,6 @@ public: class TypedViewRegion : public TypedRegion { friend class MemRegionManager; - QualType LValueType; TypedViewRegion(QualType lvalueType, const MemRegion* sreg) @@ -251,6 +250,10 @@ public: void print(llvm::raw_ostream& os) const; + QualType getLValueType(ASTContext&) const { + return LValueType; + } + QualType getRValueType(ASTContext&) const { const PointerType* PTy = LValueType->getAsPointerType(); assert(PTy); diff --git a/test/Analysis/region-1.m b/test/Analysis/region-1.m new file mode 100644 index 0000000000..2d44091a5f --- /dev/null +++ b/test/Analysis/region-1.m @@ -0,0 +1,90 @@ +// RUN: clang -analyze -checker-cfref -analyzer-store=basic -verify %s && +// RUN: clang -analyze -checker-cfref -analyzer-store=region -verify %s +// +// This test case simply should not crash. It evaluates the logic of not +// using MemRegion::getRValueType in incorrect places. + +typedef signed char BOOL; +typedef unsigned int NSUInteger; +@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; +@protocol NSObject - (BOOL)isEqual:(id)object; +- (Class)class; +- (BOOL)isLegOfClass:(Class)aClass; +@end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; +@end @interface NSObject { +} +@end @class NSArray; +@interface NSResponder : NSObject { +} +@end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView; +@class JabasectItem; +@protocol EcoClassifier; +@protocol EcoClassInterfaceCommons @end @protocol EcoImplementation; // expected-warning{{cannot find protocol}} +@protocol EcoBehavioredClassifier - (NSArray *) implementations; +@end enum { +CK_UNRESTRICTED= 0, CK_READ_ONLY, CK_ADD_ONLY, CK_REMOVE_ONLY }; +@protocol EcoClass - (NSArray *) ownedAttributes; +@end @protocol EcoNamespace; +@protocol EcoType; +@protocol EcoClassifier - (NSArray *) features; // expected-warning 2 {{cannot find protocol}} +@end @protocol EcoComment; +@protocol EcoElement - (NSArray *) ownedElements; +@end @protocol EcoDirectedRelationship; +@protocol EcoNamedElement - (NSString *) name; +@end extern NSString *const JabaPathSeparator; +@protocol EcoNamespace - (NSArray *) Legs; +@end enum { +PDK_IN=0, PDK_INOUT, PDK_OUT, PDK_RETURN }; +@interface EcoElementImp : NSObject { +} +@end @class EcoNamespace; +@interface EcoNamedElementImp : EcoElementImp { +} +@end @interface EcoNamespaceImp : EcoNamedElementImp { +} +@end @class JabaSCDocController, JabaSCDisplaySpecification; +@interface JabaSCSharedDiagramViewController : NSObject { +} +@end extern NSString *const JabaSCsectGraphicNamesectIdentifier; +@interface EcoClassifierImp : EcoNamespaceImp { +} +@end @class EcoOperationImp; +@interface EcoClassImp : EcoClassifierImp { +} +@end extern NSString *const JabaAddedUMLElements; +@class JabaSCClass, JabaSCInterface, JabaSCOperation; +@class DosLegVaseSymbol, DosProtocolSymbol, DosMethodSymbol, DosFileReference; +@interface HancodeFett : NSObject { +} ++ (DosLegVaseSymbol *) symbolFromClass: (JabaSCClass *) clz; +@end enum _JabaSourceLanguage { +JabaSourceUnknown=0, JabaSourcePrawn, JabaSourceC, JabaSourceCPP, JabaSourceObjectiveC }; +typedef NSUInteger JabaSourceLanguage; +@protocol JabaSCClassifier - (JabaSourceLanguage)language; +@end @interface JabaSCClass : EcoClassImp { +} +@end @class DosGlobalID, DosPQuLC, DosPQuUnLC; +@protocol XCProxyObjectProtocol - (id) representedObject; +@end typedef union _Dossymbollocation { +} + DosRecordArrPrl; +@interface DosIndexEntry : NSObject { +} +@end @class DosProjectIndex, DosTextPapyruswiggle, DosDocPapyruswiggle, DosLegVaseSymbol; +@interface DosSymbol : DosIndexEntry { +} +@end @interface DosLegVaseSymbol : DosSymbol { +} +@end typedef enum _DosTextRangeType { +Dos_CharacterRangeType = 0, Dos_LineRangeType = 1 } + DosTextRangeType; +@implementation JabaSCSharedDiagramViewController + (NSImage *)findImageNamed:(NSString *)name { +} +- (void)revealSourceInEditor:(JabasectItem *)sectItem duperGesture:(BOOL)duperGesture { + id selectedElement = [sectItem representedObject]; + id selectedClassifier = selectedElement; + DosSymbol *symbol=((void *)0); + if([selectedClassifier isLegOfClass:[JabaSCClass class]]) { + symbol = [HancodeFett symbolFromClass:(JabaSCClass *) selectedClassifier]; + } +} -- 2.40.0