[cfe-commits] [PATCH] Fix for VarDecl::getSourceRange() when static array has initializer.

Will Wilson will at indefiant.com
Wed Jan 9 08:36:48 PST 2013


Hi All,

Here's a simple patch that fixes a bug in VarDecl::getSourceRange() which
occurs when a static member array has an element type with an implicit
initializer expression.

Basically, this detect the edge case where the initializer has no size and
falls back on the usual DeclaratorDecl::getSourceRange() allowing any
postfix tokens to be included in the range calculation.

All tests passed locally, but I'm afraid I didn't have a chance to
construct a suitable test-case. However the following snippet reproduces
the issue if needed. Either way I hope this should be safe to commit.

----

struct ElemType { char padding[16]; };

class TemplatedClass
{
public:
static ElemType Arr[4];
};

ElemType TemplatedClass::Arr[4];  // Issue: '[4]' missing from
VarDecl::getSourceRange()

static TemplatedClass Instance;

----

Cheers,
Will.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130109/668a201f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: static-member-array-source-range-fix.patch
Type: application/octet-stream
Size: 513 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130109/668a201f/attachment.obj>


More information about the cfe-commits mailing list