diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 14 |
2 files changed, 6 insertions, 14 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 6121719abb6..220ceddbf65 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -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 diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index f40f125683b..b2124fe0145 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -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) { |