aboutsummaryrefslogtreecommitdiff
path: root/include/clang/AST/Attr.h
diff options
context:
space:
mode:
authorRoman Divacky <rdivacky@FreeBSD.org>2010-02-16 09:31:36 +0000
committerRoman Divacky <rdivacky@FreeBSD.org>2010-02-16 09:31:36 +0000
commitecb7e5c8afe929ee38155db94de6b084ec32a645 (patch)
tree53010172e19c77ea447bcd89e117cda052ab52e0 /include/clang/AST/Attr.h
parent5044f5c816adfd5cba17f1adee1a10127296d0bf (diff)
downloadsrc-ecb7e5c8afe929ee38155db94de6b084ec32a645.tar.gz
src-ecb7e5c8afe929ee38155db94de6b084ec32a645.zip
Update clang to r96341.
Notes
Notes: svn path=/vendor/clang/dist/; revision=203955
Diffstat (limited to 'include/clang/AST/Attr.h')
-rw-r--r--include/clang/AST/Attr.h78
1 files changed, 40 insertions, 38 deletions
diff --git a/include/clang/AST/Attr.h b/include/clang/AST/Attr.h
index 03ab0f07020b..37225907c6de 100644
--- a/include/clang/AST/Attr.h
+++ b/include/clang/AST/Attr.h
@@ -18,7 +18,6 @@
#include "llvm/ADT/StringRef.h"
#include <cassert>
#include <cstring>
-#include <string>
#include <algorithm>
using llvm::dyn_cast;
@@ -96,7 +95,8 @@ public:
FIRST_TARGET_ATTRIBUTE,
DLLExport,
DLLImport,
- MSP430Interrupt
+ MSP430Interrupt,
+ X86ForceAlignArgPointer
};
private:
@@ -119,8 +119,7 @@ protected:
assert(Next == 0 && "Destroy didn't work");
}
public:
-
- void Destroy(ASTContext &C);
+ virtual void Destroy(ASTContext &C);
/// \brief Whether this attribute should be merged to new
/// declarations.
@@ -156,6 +155,18 @@ public:
// Implement isa/cast/dyncast/etc.
static bool classof(const Attr *) { return true; }
};
+
+class AttrWithString : public Attr {
+private:
+ const char *Str;
+ unsigned StrLen;
+protected:
+ AttrWithString(Attr::Kind AK, ASTContext &C, llvm::StringRef s);
+ llvm::StringRef getString() const { return llvm::StringRef(Str, StrLen); }
+ void ReplaceString(ASTContext &C, llvm::StringRef newS);
+public:
+ virtual void Destroy(ASTContext &C);
+};
#define DEF_SIMPLE_ATTR(ATTR) \
class ATTR##Attr : public Attr { \
@@ -213,12 +224,12 @@ public:
static bool classof(const AlignedAttr *A) { return true; }
};
-class AnnotateAttr : public Attr {
- std::string Annotation;
+class AnnotateAttr : public AttrWithString {
public:
- AnnotateAttr(llvm::StringRef ann) : Attr(Annotate), Annotation(ann) {}
+ AnnotateAttr(ASTContext &C, llvm::StringRef ann)
+ : AttrWithString(Annotate, C, ann) {}
- const std::string& getAnnotation() const { return Annotation; }
+ llvm::StringRef getAnnotation() const { return getString(); }
virtual Attr* clone(ASTContext &C) const;
@@ -229,12 +240,12 @@ public:
static bool classof(const AnnotateAttr *A) { return true; }
};
-class AsmLabelAttr : public Attr {
- std::string Label;
+class AsmLabelAttr : public AttrWithString {
public:
- AsmLabelAttr(llvm::StringRef L) : Attr(AsmLabel), Label(L) {}
+ AsmLabelAttr(ASTContext &C, llvm::StringRef L)
+ : AttrWithString(AsmLabel, C, L) {}
- const std::string& getLabel() const { return Label; }
+ llvm::StringRef getLabel() const { return getString(); }
virtual Attr* clone(ASTContext &C) const;
@@ -247,12 +258,12 @@ public:
DEF_SIMPLE_ATTR(AlwaysInline);
-class AliasAttr : public Attr {
- std::string Aliasee;
+class AliasAttr : public AttrWithString {
public:
- AliasAttr(llvm::StringRef aliasee) : Attr(Alias), Aliasee(aliasee) {}
+ AliasAttr(ASTContext &C, llvm::StringRef aliasee)
+ : AttrWithString(Alias, C, aliasee) {}
- const std::string& getAliasee() const { return Aliasee; }
+ llvm::StringRef getAliasee() const { return getString(); }
virtual Attr *clone(ASTContext &C) const;
@@ -321,12 +332,12 @@ DEF_SIMPLE_ATTR(AnalyzerNoReturn);
DEF_SIMPLE_ATTR(Deprecated);
DEF_SIMPLE_ATTR(Final);
-class SectionAttr : public Attr {
- std::string Name;
+class SectionAttr : public AttrWithString {
public:
- SectionAttr(llvm::StringRef N) : Attr(Section), Name(N) {}
+ SectionAttr(ASTContext &C, llvm::StringRef N)
+ : AttrWithString(Section, C, N) {}
- const std::string& getName() const { return Name; }
+ llvm::StringRef getName() const { return getString(); }
virtual Attr *clone(ASTContext &C) const;
@@ -350,19 +361,9 @@ class NonNullAttr : public Attr {
unsigned* ArgNums;
unsigned Size;
public:
- NonNullAttr(unsigned* arg_nums = 0, unsigned size = 0) : Attr(NonNull),
- ArgNums(0), Size(0) {
-
- if (size == 0) return;
- assert(arg_nums);
- ArgNums = new unsigned[size];
- Size = size;
- memcpy(ArgNums, arg_nums, sizeof(*ArgNums)*size);
- }
+ NonNullAttr(ASTContext &C, unsigned* arg_nums = 0, unsigned size = 0);
- virtual ~NonNullAttr() {
- delete [] ArgNums;
- }
+ virtual void Destroy(ASTContext &C);
typedef const unsigned *iterator;
iterator begin() const { return ArgNums; }
@@ -379,15 +380,14 @@ public:
static bool classof(const NonNullAttr *A) { return true; }
};
-class FormatAttr : public Attr {
- std::string Type;
+class FormatAttr : public AttrWithString {
int formatIdx, firstArg;
public:
- FormatAttr(llvm::StringRef type, int idx, int first) : Attr(Format),
- Type(type), formatIdx(idx), firstArg(first) {}
+ FormatAttr(ASTContext &C, llvm::StringRef type, int idx, int first)
+ : AttrWithString(Format, C, type), formatIdx(idx), firstArg(first) {}
- const std::string& getType() const { return Type; }
- void setType(llvm::StringRef type) { Type = type; }
+ llvm::StringRef getType() const { return getString(); }
+ void setType(ASTContext &C, llvm::StringRef type);
int getFormatIdx() const { return formatIdx; }
int getFirstArg() const { return firstArg; }
@@ -570,6 +570,8 @@ public:
static bool classof(const MSP430InterruptAttr *A) { return true; }
};
+DEF_SIMPLE_ATTR(X86ForceAlignArgPointer);
+
#undef DEF_SIMPLE_ATTR
} // end namespace clang