[cfe-commits] r66830 - in /cfe/trunk: include/clang/Analysis/PathSensitive/MemRegion.h test/Analysis/region-1.m

Ted Kremenek kremenek at apple.com
Thu Mar 12 15:15:08 PDT 2009


Author: kremenek
Date: Thu Mar 12 17:15:08 2009
New Revision: 66830

URL: http://llvm.org/viewvc/llvm-project?rev=66830&view=rev
Log:
Fix crash when using TypedViewRegions and ObjCQualifiedIdTypes (TypedViewRegion::getLValueType() was not implemented).

Added:
    cfe/trunk/test/Analysis/region-1.m
Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h?rev=66830&r1=66829&r2=66830&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h Thu Mar 12 17:15:08 2009
@@ -238,7 +238,6 @@
 
 class TypedViewRegion : public TypedRegion {
   friend class MemRegionManager;
-
   QualType LValueType;
 
   TypedViewRegion(QualType lvalueType, const MemRegion* sreg)
@@ -251,6 +250,10 @@
 
   void print(llvm::raw_ostream& os) const;
   
+  QualType getLValueType(ASTContext&) const {
+    return LValueType;
+  }
+
   QualType getRValueType(ASTContext&) const {
     const PointerType* PTy = LValueType->getAsPointerType();
     assert(PTy);

Added: cfe/trunk/test/Analysis/region-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/region-1.m?rev=66830&view=auto

==============================================================================
--- cfe/trunk/test/Analysis/region-1.m (added)
+++ cfe/trunk/test/Analysis/region-1.m Thu Mar 12 17:15:08 2009
@@ -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;
+ at class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+ at protocol NSObject  - (BOOL)isEqual:(id)object;
+- (Class)class;
+- (BOOL)isLegOfClass:(Class)aClass;
+ at end  @protocol NSCoding  - (void)encodeWithCoder:(NSCoder *)aCoder;
+ at end    @interface NSObject <NSObject> {
+}
+ at end @class NSArray;
+ at interface NSResponder : NSObject <NSCoding> {
+}
+ at end  @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView;
+ at class JabasectItem;
+ at protocol EcoClassifier;
+ at protocol EcoClassInterfaceCommons <EcoClassifier>    @end  @protocol EcoImplementation;  // expected-warning{{cannot find protocol}}
+ at protocol EcoBehavioredClassifier <EcoClassInterfaceCommons>      - (NSArray *) implementations;
+ at end enum {
+CK_UNRESTRICTED= 0,     CK_READ_ONLY,     CK_ADD_ONLY,     CK_REMOVE_ONLY };
+ at protocol EcoClass <EcoBehavioredClassifier>      - (NSArray *) ownedAttributes;
+ at end @protocol EcoNamespace;
+ at protocol EcoType;
+ at protocol EcoClassifier <EcoNamespace,EcoType>    - (NSArray *) features; // expected-warning 2 {{cannot find protocol}}
+ at end @protocol EcoComment;
+ at protocol EcoElement <NSObject> - (NSArray *) ownedElements;
+ at end @protocol EcoDirectedRelationship;
+ at protocol EcoNamedElement <EcoElement>     - (NSString *) name;
+ at end  extern NSString *const JabaPathSeparator;
+ at protocol EcoNamespace <EcoNamedElement>       - (NSArray *) Legs;
+ at end enum {
+PDK_IN=0,     PDK_INOUT,     PDK_OUT,     PDK_RETURN };
+ at interface EcoElementImp : NSObject <EcoElement, NSCoding> {
+}
+ at end @class EcoNamespace;
+ at interface EcoNamedElementImp : EcoElementImp <EcoNamedElement>{
+}
+ at end   @interface EcoNamespaceImp : EcoNamedElementImp <EcoNamespace> {
+}
+ at end  @class JabaSCDocController, JabaSCDisplaySpecification;
+ at interface JabaSCSharedDiagramViewController : NSObject {
+}
+ at end  extern NSString *const JabaSCsectGraphicNamesectIdentifier;
+ at interface EcoClassifierImp : EcoNamespaceImp <EcoClassifier> {
+}
+ at end  @class EcoOperationImp;
+ at interface EcoClassImp : EcoClassifierImp <EcoClass> {
+}
+ at end  extern NSString *const JabaAddedUMLElements;
+ at class JabaSCClass, JabaSCInterface, JabaSCOperation;
+ at class DosLegVaseSymbol, DosProtocolSymbol, DosMethodSymbol, DosFileReference;
+ at interface HancodeFett : NSObject {
+}
++ (DosLegVaseSymbol *) symbolFromClass: (JabaSCClass *) clz;
+ at end enum _JabaSourceLanguage {
+JabaSourceUnknown=0,     JabaSourcePrawn,     JabaSourceC,     JabaSourceCPP,     JabaSourceObjectiveC };
+typedef NSUInteger JabaSourceLanguage;
+ at protocol JabaSCClassifier <EcoClassInterfaceCommons> - (JabaSourceLanguage)language;
+ at end  @interface JabaSCClass : EcoClassImp <JabaSCClassifier> {
+}
+ at end  @class DosGlobalID, DosPQuLC, DosPQuUnLC;
+ at protocol XCProxyObjectProtocol - (id) representedObject;
+ at end typedef union _Dossymbollocation {
+}
+  DosRecordArrPrl;
+ at interface DosIndexEntry : NSObject {
+}
+ at end    @class DosProjectIndex, DosTextPapyruswiggle, DosDocPapyruswiggle, DosLegVaseSymbol;
+ at interface DosSymbol : DosIndexEntry {
+}
+ at end  @interface DosLegVaseSymbol : DosSymbol {
+}
+ at end typedef enum _DosTextRangeType {
+Dos_CharacterRangeType = 0,     Dos_LineRangeType = 1 }
+  DosTextRangeType;
+ at implementation JabaSCSharedDiagramViewController  + (NSImage *)findImageNamed:(NSString *)name {
+}
+- (void)revealSourceInEditor:(JabasectItem *)sectItem duperGesture:(BOOL)duperGesture {
+  id <EcoNamedElement> selectedElement = [sectItem representedObject];
+  id <EcoNamedElement> selectedClassifier = selectedElement;
+  DosSymbol *symbol=((void *)0);
+  if([selectedClassifier isLegOfClass:[JabaSCClass class]]) {
+    symbol = [HancodeFett symbolFromClass:(JabaSCClass *) selectedClassifier];
+  }
+}





More information about the cfe-commits mailing list