mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-19 19:45:40 -04:00

The new '#pragma clang attribute' directive can be used to apply attributes to multiple declarations. An attribute must satisfy the following conditions to be supported by the pragma: - It must have a subject list that's defined in the TableGen file. - It must be documented. - It must not be late parsed. - It must have a GNU/C++11 spelling. Differential Revision: https://reviews.llvm.org/D30009 llvm-svn: 300539
29 lines
1.0 KiB
C++
29 lines
1.0 KiB
C++
#include "clang/Basic/Attributes.h"
|
|
#include "clang/Basic/AttrSubjectMatchRules.h"
|
|
#include "clang/Basic/IdentifierTable.h"
|
|
#include "llvm/ADT/StringSwitch.h"
|
|
using namespace clang;
|
|
|
|
int clang::hasAttribute(AttrSyntax Syntax, const IdentifierInfo *Scope,
|
|
const IdentifierInfo *Attr, const TargetInfo &Target,
|
|
const LangOptions &LangOpts) {
|
|
StringRef Name = Attr->getName();
|
|
// Normalize the attribute name, __foo__ becomes foo.
|
|
if (Name.size() >= 4 && Name.startswith("__") && Name.endswith("__"))
|
|
Name = Name.substr(2, Name.size() - 4);
|
|
|
|
#include "clang/Basic/AttrHasAttributeImpl.inc"
|
|
|
|
return 0;
|
|
}
|
|
|
|
const char *attr::getSubjectMatchRuleSpelling(attr::SubjectMatchRule Rule) {
|
|
switch (Rule) {
|
|
#define ATTR_MATCH_RULE(NAME, SPELLING, IsAbstract) \
|
|
case attr::NAME: \
|
|
return SPELLING;
|
|
#include "clang/Basic/AttrSubMatchRulesList.inc"
|
|
}
|
|
llvm_unreachable("Invalid subject match rule");
|
|
}
|