diff options
author | Abramo Bagnara <abramo.bagnara@gmail.com> | 2011-08-05 08:02:55 +0000 |
---|---|---|
committer | Abramo Bagnara <abramo.bagnara@gmail.com> | 2011-08-05 08:02:55 +0000 |
commit | d330e23f183cedb9e6c1cbb809407576f7bbab71 (patch) | |
tree | f64d45bc1b96b6123aba5864fe4077ca6feba49b | |
parent | 894e4d5d232a23668b3f585fdaa56858cfabf3d3 (diff) |
Fixed FieldDecl source range.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136963 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/Decl.cpp | 4 | ||||
-rw-r--r-- | test/Index/in-class-init.cpp | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 32b9a624e0..6c7deca5fd 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -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 index 0000000000..9469434024 --- /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] |