Fixed FieldDecl source range.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136963 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 32b9a62..6c7deca 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -2197,8 +2197,8 @@
 }
 
 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
index 0000000..9469434
--- /dev/null
+++ b/test/Index/in-class-init.cpp
@@ -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]