[llvm-branch-commits] [cfe-branch] r122488 - in /cfe/branches/Apple/whitney: include/clang/AST/Decl.h lib/AST/Decl.cpp test/Index/annotate-tokens.m

Daniel Dunbar daniel at zuster.org
Wed Dec 22 21:40:51 PST 2010


Author: ddunbar
Date: Wed Dec 22 23:40:51 2010
New Revision: 122488

URL: http://llvm.org/viewvc/llvm-project?rev=122488&view=rev
Log:
Merge r122338:
--
Author: Douglas Gregor <dgregor at apple.com>
Date:   Tue Dec 21 16:27:07 2010 +0000

    Implement BlockDecl::getSourceRange(). The bogus source-range
    information caused token-annotation to fail in funny ways. Fixes
    <rdar://problem/8595386>.

Modified:
    cfe/branches/Apple/whitney/include/clang/AST/Decl.h
    cfe/branches/Apple/whitney/lib/AST/Decl.cpp
    cfe/branches/Apple/whitney/test/Index/annotate-tokens.m

Modified: cfe/branches/Apple/whitney/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/include/clang/AST/Decl.h?rev=122488&r1=122487&r2=122488&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/include/clang/AST/Decl.h (original)
+++ cfe/branches/Apple/whitney/include/clang/AST/Decl.h Wed Dec 22 23:40:51 2010
@@ -2491,6 +2491,8 @@
   }
   void setParams(ParmVarDecl **NewParamInfo, unsigned NumParams);
 
+  virtual SourceRange getSourceRange() const;
+  
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classof(const BlockDecl *D) { return true; }

Modified: cfe/branches/Apple/whitney/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/AST/Decl.cpp?rev=122488&r1=122487&r2=122488&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/AST/Decl.cpp (original)
+++ cfe/branches/Apple/whitney/lib/AST/Decl.cpp Wed Dec 22 23:40:51 2010
@@ -1985,6 +1985,9 @@
   return NumParams;
 }
 
+SourceRange BlockDecl::getSourceRange() const {
+  return SourceRange(getLocation(), Body? Body->getLocEnd() : getLocation());
+}
 
 //===----------------------------------------------------------------------===//
 // Other Decl Allocation/Deallocation Method Implementations

Modified: cfe/branches/Apple/whitney/test/Index/annotate-tokens.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/Index/annotate-tokens.m?rev=122488&r1=122487&r2=122488&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/test/Index/annotate-tokens.m (original)
+++ cfe/branches/Apple/whitney/test/Index/annotate-tokens.m Wed Dec 22 23:40:51 2010
@@ -116,6 +116,21 @@
 @dynamic foo2;
 @end
 
+// <rdar://problem/8778404> Blocks don't get colored if annotation starts within the block itself
+ at interface Rdar8778404
+ at end
+
+ at implementation Rdar8778404
+- (int)blah:(int)arg, ... { return arg; }
+- (int)blarg:(int)x {
+  (void)^ {
+    int result = [self blah:5, x];
+    Rdar8778404 *a = self;
+    return 0;
+  };
+}
+ at end
+
 // RUN: c-index-test -test-annotate-tokens=%s:1:1:118:1 %s -DIBOutlet='__attribute__((iboutlet))' -DIBAction='void)__attribute__((ibaction)' | FileCheck %s
 // CHECK: Punctuation: "@" [1:1 - 1:2] ObjCInterfaceDecl=Foo:1:12
 // CHECK: Keyword: "interface" [1:2 - 1:11] ObjCInterfaceDecl=Foo:1:12
@@ -485,3 +500,22 @@
 // CHECK: Punctuation: "=" [115:17 - 115:18] UnexposedDecl=foo:110:33 (Definition)
 // CHECK: Identifier: "_foo" [115:19 - 115:23] MemberRef=_foo:107:8
 // CHECK: Punctuation: ";" [115:23 - 115:24] ObjCImplementationDecl=Rdar8595386:114:1 (Definition)
+
+// RUN: c-index-test -test-annotate-tokens=%s:127:1:130:1 %s -DIBOutlet='__attribute__((iboutlet))' -DIBAction='void)__attribute__((ibaction)' | FileCheck -check-prefix=CHECK-INSIDE_BLOCK %s
+// CHECK-INSIDE_BLOCK: Keyword: "int" [127:5 - 127:8] VarDecl=result:127:9 (Definition)
+// CHECK-INSIDE_BLOCK: Identifier: "result" [127:9 - 127:15] VarDecl=result:127:9 (Definition)
+// CHECK-INSIDE_BLOCK: Punctuation: "=" [127:16 - 127:17] VarDecl=result:127:9 (Definition)
+// CHECK-INSIDE_BLOCK: Punctuation: "[" [127:18 - 127:19] ObjCMessageExpr=blah::124:1
+// CHECK-INSIDE_BLOCK: Identifier: "self" [127:19 - 127:23] DeclRefExpr=self:0:0
+// CHECK-INSIDE_BLOCK: Identifier: "blah" [127:24 - 127:28] ObjCMessageExpr=blah::124:1
+// CHECK-INSIDE_BLOCK: Punctuation: ":" [127:28 - 127:29] ObjCMessageExpr=blah::124:1
+// CHECK-INSIDE_BLOCK: Literal: "5" [127:29 - 127:30] UnexposedExpr=
+// CHECK-INSIDE_BLOCK: Punctuation: "," [127:30 - 127:31] ObjCMessageExpr=blah::124:1
+// CHECK-INSIDE_BLOCK: Identifier: "x" [127:32 - 127:33] DeclRefExpr=x:125:19
+// CHECK-INSIDE_BLOCK: Punctuation: "]" [127:33 - 127:34] ObjCMessageExpr=blah::124:1
+// CHECK-INSIDE_BLOCK: Punctuation: ";" [127:34 - 127:35] UnexposedStmt=
+// CHECK-INSIDE_BLOCK: Identifier: "Rdar8778404" [128:5 - 128:16] ObjCClassRef=Rdar8778404:120:12
+// CHECK-INSIDE_BLOCK: Punctuation: "*" [128:17 - 128:18] VarDecl=a:128:18 (Definition)
+// CHECK-INSIDE_BLOCK: Identifier: "a" [128:18 - 128:19] VarDecl=a:128:18 (Definition)
+// CHECK-INSIDE_BLOCK: Punctuation: "=" [128:20 - 128:21] VarDecl=a:128:18 (Definition)
+// CHECK-INSIDE_BLOCK: Identifier: "self" [128:22 - 128:26] DeclRefExpr=self:0:0





More information about the llvm-branch-commits mailing list