diff options
author | Douglas Gregor <dgregor@apple.com> | 2013-05-02 23:08:12 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2013-05-02 23:08:12 +0000 |
commit | 3796d1539a39b999fd50bed7aea726ef6f845e17 (patch) | |
tree | 4aa5a6709bfbb3c14b11596e77336fc0875e680a /include/clang/Basic | |
parent | 1880039e2b9faece69d64bab8b57dbeaf09cf643 (diff) |
Use attribute argument information to determine when to parse attribute arguments as expressions.
This change partly addresses a heinous problem we have with the
parsing of attribute arguments that are a lone identifier. Previously,
we would end up parsing the 'align' attribute of this as an expression
"(Align)":
template<unsigned Size, unsigned Align>
class my_aligned_storage
{
__attribute__((align((Align)))) char storage[Size];
};
while this would parse as a "parameter name" 'Align':
template<unsigned Size, unsigned Align>
class my_aligned_storage
{
__attribute__((align(Align))) char storage[Size];
};
The code that handles the alignment attribute would completely ignore
the parameter name, so the while the first of these would do what's
expected, the second would silently be equivalent to
template<unsigned Size, unsigned Align>
class my_aligned_storage
{
__attribute__((align)) char storage[Size];
};
i.e., use the maximal alignment rather than the specified alignment.
Address this by sniffing the "Args" provided in the TableGen
description of attributes. If the first argument is "obviously"
something that should be treated as an expression (rather than an
identifier to be matched later), parse it as an expression.
Fixes <rdar://problem/13700933>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180970 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic')
-rw-r--r-- | include/clang/Basic/Attr.td | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td index 441a79a23b..8d825ad8f2 100644 --- a/include/clang/Basic/Attr.td +++ b/include/clang/Basic/Attr.td @@ -152,7 +152,7 @@ def AddressSpace : Attr { def Alias : InheritableAttr { let Spellings = [GNU<"alias">, CXX11<"gnu", "alias">]; - let Args = [StringArgument<"Aliasee">]; + let Args = [IdentifierArgument<"Aliasee">]; } def Aligned : InheritableAttr { @@ -184,7 +184,7 @@ def AlwaysInline : InheritableAttr { def TLSModel : InheritableAttr { let Spellings = [GNU<"tls_model">, CXX11<"gnu", "tls_model">]; let Subjects = [Var]; - let Args = [StringArgument<"Model">]; + let Args = [IdentifierArgument<"Model">]; } def AnalyzerNoReturn : InheritableAttr { @@ -373,7 +373,7 @@ def MinSize : InheritableAttr { def Format : InheritableAttr { let Spellings = [GNU<"format">, CXX11<"gnu", "format">]; - let Args = [StringArgument<"Type">, IntArgument<"FormatIdx">, + let Args = [IdentifierArgument<"Type">, IntArgument<"FormatIdx">, IntArgument<"FirstArg">]; } |