[cfe-commits] r90140 - in /cfe/trunk: include/clang/AST/Attr.h lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclAttr.cpp
Benjamin Kramer
benny.kra at googlemail.com
Mon Nov 30 09:08:27 PST 2009
Author: d0k
Date: Mon Nov 30 11:08:26 2009
New Revision: 90140
URL: http://llvm.org/viewvc/llvm-project?rev=90140&view=rev
Log:
Use StringRef in Attr constructors.
Modified:
cfe/trunk/include/clang/AST/Attr.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
Modified: cfe/trunk/include/clang/AST/Attr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=90140&r1=90139&r2=90140&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Attr.h (original)
+++ cfe/trunk/include/clang/AST/Attr.h Mon Nov 30 11:08:26 2009
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
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; }
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=90140&r1=90139&r2=90140&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Nov 30 11:08:26 2009
@@ -2407,8 +2407,7 @@
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 @@
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
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=90140&r1=90139&r2=90140&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Nov 30 11:08:26 2009
@@ -411,12 +411,9 @@
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 @@
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 @@
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) {
More information about the cfe-commits
mailing list