[cfe-commits] r149929 - in /cfe/trunk: lib/CodeGen/CGDebugInfo.cpp test/CodeGenObjC/debug-info-property4.m

Devang Patel dpatel at apple.com
Mon Feb 6 15:24:13 PST 2012


Author: dpatel
Date: Mon Feb  6 17:24:13 2012
New Revision: 149929

URL: http://llvm.org/viewvc/llvm-project?rev=149929&view=rev
Log:
Relax valid location check. This fixes a clang crash while emitting debug info for properties that are synthesized by the compiler by default.

Added:
    cfe/trunk/test/CodeGenObjC/debug-info-property4.m
Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=149929&r1=149928&r2=149929&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Feb  6 17:24:13 2012
@@ -233,7 +233,8 @@
 /// getLineNumber - Get line number for the location. If location is invalid
 /// then use current location.
 unsigned CGDebugInfo::getLineNumber(SourceLocation Loc) {
-  assert((Loc.isValid() || CurLoc.isValid()) && "Invalid current location!");
+  if (Loc.isInvalid() && CurLoc.isInvalid())
+    return 0;
   SourceManager &SM = CGM.getContext().getSourceManager();
   PresumedLoc PLoc = SM.getPresumedLoc(Loc.isValid() ? Loc : CurLoc);
   return PLoc.isValid()? PLoc.getLine() : 0;
@@ -242,7 +243,8 @@
 /// getColumnNumber - Get column number for the location. If location is 
 /// invalid then use current location.
 unsigned CGDebugInfo::getColumnNumber(SourceLocation Loc) {
-  assert((Loc.isValid() || CurLoc.isValid()) && "Invalid current location!");
+  if (Loc.isInvalid() && CurLoc.isInvalid())
+    return 0;
   SourceManager &SM = CGM.getContext().getSourceManager();
   PresumedLoc PLoc = SM.getPresumedLoc(Loc.isValid() ? Loc : CurLoc);
   return PLoc.isValid()? PLoc.getColumn() : 0;

Added: cfe/trunk/test/CodeGenObjC/debug-info-property4.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/debug-info-property4.m?rev=149929&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/debug-info-property4.m (added)
+++ cfe/trunk/test/CodeGenObjC/debug-info-property4.m Mon Feb  6 17:24:13 2012
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fobjc-default-synthesize-properties -masm-verbose -S -g %s -o - | FileCheck %s
+
+// CHECK: AT_APPLE_property_name
+// CHECK: AT_APPLE_property_getter
+// CHECK: AT_APPLE_property_setter
+// CHECK: AT_APPLE_property_attribute
+// CHECK: AT_APPLE_property
+
+
+ at interface I1
+ at property int p1;
+ at end
+
+ at implementation I1
+ at end
+
+void foo(I1 *ptr) {}





More information about the cfe-commits mailing list