[cfe-commits] r122338 - in /cfe/trunk: include/clang/AST/Decl.h lib/AST/Decl.cpp test/Index/annotate-tokens.m

Douglas Gregor dgregor at apple.com
Tue Dec 21 08:36:03 PST 2010


On Dec 21, 2010, at 8:27 AM, Douglas Gregor wrote:

> Author: dgregor
> Date: Tue Dec 21 10:27:07 2010
> New Revision: 122338
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=122338&view=rev
> Log:
> Implement BlockDecl::getSourceRange(). The bogus source-range
> information caused token-annotation to fail in funny ways. Fixes
> <rdar://problem/8595386>.

This was <rdar://problem/8778404>, for those following along at home. 

	- Doug

> Modified:
>    cfe/trunk/include/clang/AST/Decl.h
>    cfe/trunk/lib/AST/Decl.cpp
>    cfe/trunk/test/Index/annotate-tokens.m
> 
> Modified: cfe/trunk/include/clang/AST/Decl.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=122338&r1=122337&r2=122338&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/AST/Decl.h (original)
> +++ cfe/trunk/include/clang/AST/Decl.h Tue Dec 21 10:27:07 2010
> @@ -2548,6 +2548,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/trunk/lib/AST/Decl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=122338&r1=122337&r2=122338&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/Decl.cpp (original)
> +++ cfe/trunk/lib/AST/Decl.cpp Tue Dec 21 10:27:07 2010
> @@ -2062,6 +2062,9 @@
>   return NumParams;
> }
> 
> +SourceRange BlockDecl::getSourceRange() const {
> +  return SourceRange(getLocation(), Body? Body->getLocEnd() : getLocation());
> +}
> 
> //===----------------------------------------------------------------------===//
> // Other Decl Allocation/Deallocation Method Implementations
> 
> Modified: cfe/trunk/test/Index/annotate-tokens.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-tokens.m?rev=122338&r1=122337&r2=122338&view=diff
> ==============================================================================
> --- cfe/trunk/test/Index/annotate-tokens.m (original)
> +++ cfe/trunk/test/Index/annotate-tokens.m Tue Dec 21 10:27:07 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
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits





More information about the cfe-commits mailing list