diff options
author | Nico Weber <nicolasweber@gmx.de> | 2013-01-22 17:00:09 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2013-01-22 17:00:09 +0000 |
commit | 3a344f9fc7a62ad0a8d26b2a1ccf5e4989720d0c (patch) | |
tree | 66d83b42a902594ec046ffa5c4996624533c91d5 /lib/AST/Decl.cpp | |
parent | f5ecfa5b4fb01dee3f357efc815fbc715706aba5 (diff) |
Fix a bug in VarDecl::getSourceRange() for static member arrays with an element
type with an implicit initializer expression.
Patch from Will Wilson <will@indefiant.com>!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173170 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r-- | lib/AST/Decl.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index c053b6d17e..7a51814325 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -1206,7 +1206,9 @@ void VarDecl::setStorageClass(StorageClass SC) { SourceRange VarDecl::getSourceRange() const { if (const Expr *Init = getInit()) { SourceLocation InitEnd = Init->getLocEnd(); - if (InitEnd.isValid()) + // If Init is implicit, ignore its source range and fallback on + // DeclaratorDecl::getSourceRange() to handle postfix elements. + if (InitEnd.isValid() && InitEnd != getLocation()) return SourceRange(getOuterLocStart(), InitEnd); } return DeclaratorDecl::getSourceRange(); |