]> granicus.if.org Git - clang/commitdiff
Fixed FieldDecl source range.
authorAbramo Bagnara <abramo.bagnara@gmail.com>
Fri, 5 Aug 2011 08:02:55 +0000 (08:02 +0000)
committerAbramo Bagnara <abramo.bagnara@gmail.com>
Fri, 5 Aug 2011 08:02:55 +0000 (08:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136963 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Decl.cpp
test/Index/in-class-init.cpp [new file with mode: 0644]

index 32b9a624e0e0899d385b74f361856f917242fdf5..6c7deca5fd6184fe2e99248448293526a0f4dc03 100644 (file)
@@ -2197,8 +2197,8 @@ unsigned FieldDecl::getFieldIndex() const {
 }
 
 SourceRange FieldDecl::getSourceRange() const {
-  if (isBitField())
-    return SourceRange(getInnerLocStart(), getBitWidth()->getLocEnd());
+  if (const Expr *E = InitializerOrBitWidth.getPointer())
+    return SourceRange(getInnerLocStart(), E->getLocEnd());
   return DeclaratorDecl::getSourceRange();
 }
 
diff --git a/test/Index/in-class-init.cpp b/test/Index/in-class-init.cpp
new file mode 100644 (file)
index 0000000..9469434
--- /dev/null
@@ -0,0 +1,6 @@
+struct S {
+  int field = 2;
+};
+
+// RUN: c-index-test -test-load-source all -std=c++0x %s | FileCheck %s
+// CHECK: 2:7: FieldDecl=field:2:7 (Definition) Extent=[2:3 - 2:16]