[PATCH] D117931: [Clang] Support `address_space` attribute in `#pragma clang attribute

Egor Zhdan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 21 15:14:15 PST 2022


egorzhdan created this revision.
Herald added a reviewer: aaron.ballman.
Herald added a subscriber: jdoerfert.
egorzhdan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This change adds support for type attributes (for example, `address_space`) in pragmas, so that the following code now compiles correctly:

  #pragma clang attribute push (__attribute__ ((address_space(1))), apply_to=variable(is_global))
  
  int var;
  
  #pragma clang attribute pop

Since the attribute matching logic (`attr::SubjectMatchRule`) applies to an already constructed `Decl`, we first determine the declaration's type ignoring pragma attributes, then construct the `Decl`, and then recalculate its type if any type attribute was applied.

rdar://78269223


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117931

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/AST/address_space_attribute.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Parser/pragma-attribute.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117931.402117.patch
Type: text/x-patch
Size: 7854 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220121/9056bfb8/attachment.bin>


More information about the cfe-commits mailing list