forked from OSchip/llvm-project
parent
693ba203a1
commit
5f089128e9
|
@ -15,12 +15,12 @@
|
|||
#define LLVM_CLANG_AST_ATTR_H
|
||||
|
||||
#include "llvm/Support/Casting.h"
|
||||
using llvm::dyn_cast;
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
using llvm::dyn_cast;
|
||||
|
||||
namespace clang {
|
||||
class ASTContext;
|
||||
|
@ -217,7 +217,7 @@ public:
|
|||
class AnnotateAttr : public Attr {
|
||||
std::string Annotation;
|
||||
public:
|
||||
AnnotateAttr(const std::string &ann) : Attr(Annotate), Annotation(ann) {}
|
||||
AnnotateAttr(llvm::StringRef ann) : Attr(Annotate), Annotation(ann) {}
|
||||
|
||||
const std::string& getAnnotation() const { return Annotation; }
|
||||
|
||||
|
@ -233,7 +233,7 @@ public:
|
|||
class AsmLabelAttr : public Attr {
|
||||
std::string Label;
|
||||
public:
|
||||
AsmLabelAttr(const std::string &L) : Attr(AsmLabel), Label(L) {}
|
||||
AsmLabelAttr(llvm::StringRef L) : Attr(AsmLabel), Label(L) {}
|
||||
|
||||
const std::string& getLabel() const { return Label; }
|
||||
|
||||
|
@ -251,7 +251,7 @@ DEF_SIMPLE_ATTR(AlwaysInline);
|
|||
class AliasAttr : public Attr {
|
||||
std::string Aliasee;
|
||||
public:
|
||||
AliasAttr(const std::string &aliasee) : Attr(Alias), Aliasee(aliasee) {}
|
||||
AliasAttr(llvm::StringRef aliasee) : Attr(Alias), Aliasee(aliasee) {}
|
||||
|
||||
const std::string& getAliasee() const { return Aliasee; }
|
||||
|
||||
|
@ -325,7 +325,7 @@ DEF_SIMPLE_ATTR(Final);
|
|||
class SectionAttr : public Attr {
|
||||
std::string Name;
|
||||
public:
|
||||
SectionAttr(const std::string &N) : Attr(Section), Name(N) {}
|
||||
SectionAttr(llvm::StringRef N) : Attr(Section), Name(N) {}
|
||||
|
||||
const std::string& getName() const { return Name; }
|
||||
|
||||
|
@ -384,11 +384,11 @@ class FormatAttr : public Attr {
|
|||
std::string Type;
|
||||
int formatIdx, firstArg;
|
||||
public:
|
||||
FormatAttr(const std::string &type, int idx, int first) : Attr(Format),
|
||||
FormatAttr(llvm::StringRef type, int idx, int first) : Attr(Format),
|
||||
Type(type), formatIdx(idx), firstArg(first) {}
|
||||
|
||||
const std::string& getType() const { return Type; }
|
||||
void setType(const std::string &type) { Type = type; }
|
||||
void setType(llvm::StringRef type) { Type = type; }
|
||||
int getFormatIdx() const { return formatIdx; }
|
||||
int getFirstArg() const { return firstArg; }
|
||||
|
||||
|
|
|
@ -2407,8 +2407,7 @@ Sema::ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC,
|
|||
if (Expr *E = (Expr*) D.getAsmLabel()) {
|
||||
// The parser guarantees this is a string.
|
||||
StringLiteral *SE = cast<StringLiteral>(E);
|
||||
NewVD->addAttr(::new (Context) AsmLabelAttr(std::string(SE->getStrData(),
|
||||
SE->getByteLength())));
|
||||
NewVD->addAttr(::new (Context) AsmLabelAttr(SE->getString()));
|
||||
}
|
||||
|
||||
// Don't consider existing declarations that are in a different
|
||||
|
@ -2924,8 +2923,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
|
|||
if (Expr *E = (Expr*) D.getAsmLabel()) {
|
||||
// The parser guarantees this is a string.
|
||||
StringLiteral *SE = cast<StringLiteral>(E);
|
||||
NewFD->addAttr(::new (Context) AsmLabelAttr(std::string(SE->getStrData(),
|
||||
SE->getByteLength())));
|
||||
NewFD->addAttr(::new (Context) AsmLabelAttr(SE->getString()));
|
||||
}
|
||||
|
||||
// Copy the parameter declarations from the declarator D to the function
|
||||
|
|
|
@ -411,12 +411,9 @@ static void HandleAliasAttr(Decl *d, const AttributeList &Attr, Sema &S) {
|
|||
return;
|
||||
}
|
||||
|
||||
const char *Alias = Str->getStrData();
|
||||
unsigned AliasLen = Str->getByteLength();
|
||||
|
||||
// FIXME: check if target symbol exists in current file
|
||||
|
||||
d->addAttr(::new (S.Context) AliasAttr(std::string(Alias, AliasLen)));
|
||||
d->addAttr(::new (S.Context) AliasAttr(Str->getString()));
|
||||
}
|
||||
|
||||
static void HandleAlwaysInlineAttr(Decl *d, const AttributeList &Attr,
|
||||
|
@ -1006,12 +1003,10 @@ static void HandleSectionAttr(Decl *D, const AttributeList &Attr, Sema &S) {
|
|||
return;
|
||||
}
|
||||
|
||||
std::string SectionStr(SE->getStrData(), SE->getByteLength());
|
||||
|
||||
// If the target wants to validate the section specifier, make it happen.
|
||||
std::string Error = S.Context.Target.isValidSectionSpecifier(SectionStr);
|
||||
std::string Error = S.Context.Target.isValidSectionSpecifier(SE->getString());
|
||||
if (Error.empty()) {
|
||||
D->addAttr(::new (S.Context) SectionAttr(SectionStr));
|
||||
D->addAttr(::new (S.Context) SectionAttr(SE->getString()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1518,8 +1513,7 @@ static void HandleAnnotateAttr(Decl *d, const AttributeList &Attr, Sema &S) {
|
|||
S.Diag(ArgExpr->getLocStart(), diag::err_attribute_not_string) <<"annotate";
|
||||
return;
|
||||
}
|
||||
d->addAttr(::new (S.Context) AnnotateAttr(std::string(SE->getStrData(),
|
||||
SE->getByteLength())));
|
||||
d->addAttr(::new (S.Context) AnnotateAttr(SE->getString()));
|
||||
}
|
||||
|
||||
static void HandleAlignedAttr(Decl *d, const AttributeList &Attr, Sema &S) {
|
||||
|
|
Loading…
Reference in New Issue