]> granicus.if.org Git - clang/commit
Use attribute argument information to determine when to parse attribute arguments...
authorDouglas Gregor <dgregor@apple.com>
Thu, 2 May 2013 23:08:12 +0000 (23:08 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 2 May 2013 23:08:12 +0000 (23:08 +0000)
commit3796d1539a39b999fd50bed7aea726ef6f845e17
tree4aa5a6709bfbb3c14b11596e77336fc0875e680a
parent1880039e2b9faece69d64bab8b57dbeaf09cf643
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
include/clang/Basic/Attr.td
include/clang/Parse/CMakeLists.txt
include/clang/Parse/Makefile
lib/Parse/CMakeLists.txt
lib/Parse/ParseDecl.cpp
lib/Sema/SemaDecl.cpp
test/SemaObjC/format-arg-attribute.m
test/SemaTemplate/attributes.cpp
utils/TableGen/ClangAttrEmitter.cpp
utils/TableGen/TableGen.cpp
utils/TableGen/TableGenBackends.h