Index: include/clang/Basic/Diagnostic.h =================================================================== --- include/clang/Basic/Diagnostic.h +++ include/clang/Basic/Diagnostic.h @@ -165,6 +165,9 @@ /// const char * ak_c_string, + // ak_std_string, printed with quotes. + ak_quoted_std_string, + /// int ak_sint, @@ -1152,6 +1155,15 @@ DiagObj->DiagArgumentsStr[NumArgs++] = S; } + void AddQuotedString(StringRef S) const { + assert(isActive() && "Clients must not add to cleared diagnostic!"); + assert(NumArgs < DiagnosticsEngine::MaxArguments && + "Too many arguments to diagnostic!"); + DiagObj->DiagArgumentsKind[NumArgs] = + DiagnosticsEngine::ak_quoted_std_string; + DiagObj->DiagArgumentsStr[NumArgs++] = S; + } + void AddTaggedVal(intptr_t V, DiagnosticsEngine::ArgumentKind Kind) const { assert(isActive() && "Clients must not add to cleared diagnostic!"); assert(NumArgs < DiagnosticsEngine::MaxArguments && @@ -1343,7 +1355,8 @@ /// Return the provided argument string specified by \p Idx. /// \pre getArgKind(Idx) == DiagnosticsEngine::ak_std_string const std::string &getArgStdStr(unsigned Idx) const { - assert(getArgKind(Idx) == DiagnosticsEngine::ak_std_string && + assert((getArgKind(Idx) == DiagnosticsEngine::ak_std_string || + getArgKind(Idx) == DiagnosticsEngine::ak_quoted_std_string) && "invalid argument accessor!"); return DiagObj->DiagArgumentsStr[Idx]; } Index: include/clang/Basic/PartialDiagnostic.h =================================================================== --- include/clang/Basic/PartialDiagnostic.h +++ include/clang/Basic/PartialDiagnostic.h @@ -289,6 +289,17 @@ DiagStorage->DiagArgumentsStr[DiagStorage->NumDiagArgs++] = V; } + void AddQuotedString(StringRef V) const { + if (!DiagStorage) + DiagStorage = getStorage(); + + assert(DiagStorage->NumDiagArgs < Storage::MaxArguments && + "Too many arguments to diagnostic!"); + DiagStorage->DiagArgumentsKind[DiagStorage->NumDiagArgs] = + DiagnosticsEngine::ak_quoted_std_string; + DiagStorage->DiagArgumentsStr[DiagStorage->NumDiagArgs++] = V; + } + void Emit(const DiagnosticBuilder &DB) const { if (!DiagStorage) return; Index: include/clang/Sema/ParsedAttr.h =================================================================== --- include/clang/Sema/ParsedAttr.h +++ include/clang/Sema/ParsedAttr.h @@ -16,6 +16,7 @@ #define LLVM_CLANG_SEMA_ATTRIBUTELIST_H #include "clang/Basic/AttrSubjectMatchRules.h" +#include "clang/Basic/Diagnostic.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/TargetInfo.h" #include "clang/Sema/Ownership.h" @@ -361,6 +362,7 @@ }; IdentifierInfo *getName() const { return AttrName; } + StringRef getNormalizedName() const; SourceLocation getLoc() const { return AttrRange.getBegin(); } SourceRange getRange() const { return AttrRange; } @@ -939,6 +941,30 @@ ExpectedFunctionWithProtoType, }; +inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, + const ParsedAttr &At) { + DB.AddQuotedString(At.getNormalizedName()); + return DB; +} + +inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD, + const ParsedAttr &At) { + PD.AddQuotedString(At.getNormalizedName()); + return PD; +} + +inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, + const ParsedAttr *At) { + DB.AddQuotedString(At->getNormalizedName()); + return DB; +} + +inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD, + const ParsedAttr *At) { + PD.AddQuotedString(At->getNormalizedName()); + return PD; +} + } // namespace clang #endif // LLVM_CLANG_SEMA_ATTRIBUTELIST_H Index: include/clang/Sema/Sema.h =================================================================== --- include/clang/Sema/Sema.h +++ include/clang/Sema/Sema.h @@ -2456,11 +2456,11 @@ unsigned AttrSpellingListIndex); OptimizeNoneAttr *mergeOptimizeNoneAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex); - InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, SourceRange Range, - IdentifierInfo *Ident, - unsigned AttrSpellingListIndex); - CommonAttr *mergeCommonAttr(Decl *D, SourceRange Range, IdentifierInfo *Ident, - unsigned AttrSpellingListIndex); + InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL); + InternalLinkageAttr *mergeInternalLinkageAttr(Decl *D, + const InternalLinkageAttr &AL); + CommonAttr *mergeCommonAttr(Decl *D, const ParsedAttr &AL); + CommonAttr *mergeCommonAttr(Decl *D, const CommonAttr &AL); void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK = AMK_Redeclaration); Index: lib/Basic/Diagnostic.cpp =================================================================== --- lib/Basic/Diagnostic.cpp +++ lib/Basic/Diagnostic.cpp @@ -889,6 +889,14 @@ OutStr.append(S.begin(), S.end()); break; } + case DiagnosticsEngine::ak_quoted_std_string: { + const std::string &S = getArgStdStr(ArgNo); + assert(ModifierLen == 0 && "No modifiers for strings yet"); + OutStr.push_back('\''); + OutStr.append(S.begin(), S.end()); + OutStr.push_back('\''); + break; + } case DiagnosticsEngine::ak_c_string: { const char *S = getArgCStr(ArgNo); assert(ModifierLen == 0 && "No modifiers for strings yet"); Index: lib/Sema/ParsedAttr.cpp =================================================================== --- lib/Sema/ParsedAttr.cpp +++ lib/Sema/ParsedAttr.cpp @@ -114,6 +114,14 @@ return AttrName; } +StringRef ParsedAttr::getNormalizedName() const { + // Normalize the attribute name, __foo__ becomes foo. This is only allowable + // for GNU attributes. + return normalizeAttrName(AttrName->getName(), + ScopeName ? ScopeName->getName() : "", + static_cast(SyntaxUsed)); +} + ParsedAttr::Kind ParsedAttr::getKind(const IdentifierInfo *Name, const IdentifierInfo *ScopeName, Syntax SyntaxUsed) { @@ -138,8 +146,7 @@ // Both variables will be used in tablegen generated // attribute spell list index matching code. StringRef Scope = ScopeName ? ScopeName->getName() : ""; - StringRef Name = normalizeAttrName(AttrName->getName(), Scope, - (ParsedAttr::Syntax)SyntaxUsed); + StringRef Name = getNormalizedName(); #include "clang/Sema/AttrSpellingListIndex.inc" Index: lib/Sema/SemaDecl.cpp =================================================================== --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -2474,14 +2474,9 @@ else if (const auto *OA = dyn_cast(Attr)) NewAttr = S.mergeOptimizeNoneAttr(D, OA->getRange(), AttrSpellingListIndex); else if (const auto *InternalLinkageA = dyn_cast(Attr)) - NewAttr = S.mergeInternalLinkageAttr( - D, InternalLinkageA->getRange(), - &S.Context.Idents.get(InternalLinkageA->getSpelling()), - AttrSpellingListIndex); + NewAttr = S.mergeInternalLinkageAttr(D, *InternalLinkageA); else if (const auto *CommonA = dyn_cast(Attr)) - NewAttr = S.mergeCommonAttr(D, CommonA->getRange(), - &S.Context.Idents.get(CommonA->getSpelling()), - AttrSpellingListIndex); + NewAttr = S.mergeCommonAttr(D, *CommonA); else if (isa(Attr)) // AlignedAttrs are handled separately, because we need to handle all // such attributes on a declaration at the same time. Index: lib/Sema/SemaDeclAttr.cpp =================================================================== --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -182,7 +182,7 @@ unsigned Num, unsigned Diag, Compare Comp) { if (Comp(getNumAttributeArgs(AL), Num)) { - S.Diag(AL.getLoc(), Diag) << AL.getName() << Num; + S.Diag(AL.getLoc(), Diag) << AL << Num; return false; } @@ -225,18 +225,6 @@ } static SourceLocation getAttrLoc(const ParsedAttr &AL) { return AL.getLoc(); } -/// A helper function to provide Attribute Name for the Attr types -/// AND the ParsedAttr. -template -static typename std::enable_if::value, - const AttrInfo *>::type -getAttrName(const AttrInfo &AL) { - return &AL; -} -static const IdentifierInfo *getAttrName(const ParsedAttr &AL) { - return AL.getName(); -} - /// If Expr is a valid integer constant, get the value of the integer /// expression and return success or failure. May output an error. template @@ -247,12 +235,11 @@ !Expr->isIntegerConstantExpr(I, S.Context)) { if (Idx != UINT_MAX) S.Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type) - << getAttrName(AI) << Idx << AANT_ArgumentIntegerConstant - << Expr->getSourceRange(); + << AI << Idx << AANT_ArgumentIntegerConstant + << Expr->getSourceRange(); else S.Diag(getAttrLoc(AI), diag::err_attribute_argument_type) - << getAttrName(AI) << AANT_ArgumentIntegerConstant - << Expr->getSourceRange(); + << AI << AANT_ArgumentIntegerConstant << Expr->getSourceRange(); return false; } @@ -291,10 +278,19 @@ /// Diagnose mutually exclusive attributes when present on a given /// declaration. Returns true if diagnosed. template -static bool checkAttrMutualExclusion(Sema &S, Decl *D, SourceRange Range, - IdentifierInfo *Ident) { +static bool checkAttrMutualExclusion(Sema &S, Decl *D, const ParsedAttr &AL) { + if (const auto *A = D->getAttr()) { + S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; + S.Diag(A->getLocation(), diag::note_conflicting_attribute); + return true; + } + return false; +} + +template +static bool checkAttrMutualExclusion(Sema &S, Decl *D, const Attr &AL) { if (const auto *A = D->getAttr()) { - S.Diag(Range.getBegin(), diag::err_attributes_are_not_compatible) << Ident + S.Diag(AL.getLocation(), diag::err_attributes_are_not_compatible) << &AL << A; S.Diag(A->getLocation(), diag::note_conflicting_attribute); return true; @@ -324,22 +320,21 @@ if (IdxExpr->isTypeDependent() || IdxExpr->isValueDependent() || !IdxExpr->isIntegerConstantExpr(IdxInt, S.Context)) { S.Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type) - << getAttrName(AI) << AttrArgNum << AANT_ArgumentIntegerConstant - << IdxExpr->getSourceRange(); + << &AI << AttrArgNum << AANT_ArgumentIntegerConstant + << IdxExpr->getSourceRange(); return false; } unsigned IdxSource = IdxInt.getLimitedValue(UINT_MAX); if (IdxSource < 1 || (!IV && IdxSource > NumParams)) { S.Diag(getAttrLoc(AI), diag::err_attribute_argument_out_of_bounds) - << getAttrName(AI) << AttrArgNum << IdxExpr->getSourceRange(); + << &AI << AttrArgNum << IdxExpr->getSourceRange(); return false; } if (HasImplicitThisParam && !CanIndexImplicitThis) { if (IdxSource == 1) { - S.Diag(getAttrLoc(AI), - diag::err_attribute_invalid_implicit_this_argument) - << getAttrName(AI) << IdxExpr->getSourceRange(); + S.Diag(getAttrLoc(AI), diag::err_attribute_invalid_implicit_this_argument) + << &AI << IdxExpr->getSourceRange(); return false; } } @@ -359,7 +354,7 @@ if (AL.isArgIdent(ArgNum)) { IdentifierLoc *Loc = AL.getArgAsIdent(ArgNum); Diag(Loc->Loc, diag::err_attribute_argument_type) - << AL.getName() << AANT_ArgumentString + << AL << AANT_ArgumentString << FixItHint::CreateInsertion(Loc->Loc, "\"") << FixItHint::CreateInsertion(getLocForEndOfToken(Loc->Loc), "\""); Str = Loc->Ident->getName(); @@ -376,7 +371,7 @@ if (!Literal || !Literal->isAscii()) { Diag(ArgExpr->getLocStart(), diag::err_attribute_argument_type) - << AL.getName() << AANT_ArgumentString; + << AL << AANT_ArgumentString; return false; } @@ -404,8 +399,7 @@ typename... IncompatibleAttrTypes> static void handleSimpleAttributeWithExclusions(Sema &S, Decl *D, const ParsedAttr &AL) { - if (checkAttrMutualExclusion(S, D, AL.getRange(), - AL.getName())) + if (checkAttrMutualExclusion(S, D, AL)) return; handleSimpleAttributeWithExclusions(S, D, AL); @@ -455,8 +449,7 @@ return true; } - S.Diag(AL.getLoc(), diag::warn_thread_attribute_decl_not_pointer) - << AL.getName() << QT; + S.Diag(AL.getLoc(), diag::warn_thread_attribute_decl_not_pointer) << AL << QT; return false; } @@ -582,7 +575,7 @@ // We allow constant strings to be used as a placeholder for expressions // that are not valid C++ syntax, but warn that they are ignored. - S.Diag(AL.getLoc(), diag::warn_thread_attribute_ignored) << AL.getName(); + S.Diag(AL.getLoc(), diag::warn_thread_attribute_ignored) << AL; Args.push_back(ArgExp); continue; } @@ -611,7 +604,7 @@ uint64_t ParamIdxFromZero = ParamIdxFromOne - 1; if (!ArgValue.isStrictlyPositive() || ParamIdxFromOne > NumParams) { S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_range) - << AL.getName() << Idx + 1 << NumParams; + << AL << Idx + 1 << NumParams; continue; } ArgTy = FD->getParamDecl(ParamIdxFromZero)->getType(); @@ -624,7 +617,7 @@ // boolean logic expression. Eg) requires_capability(A || B && !C) if (!typeHasCapability(S, ArgTy) && !isCapabilityExpr(S, ArgExp)) S.Diag(AL.getLoc(), diag::warn_thread_attribute_argument_not_lockable) - << AL.getName() << ArgTy; + << AL << ArgTy; Args.push_back(ArgExp); } @@ -686,8 +679,7 @@ // Check that this attribute only applies to lockable types. QualType QT = cast(D)->getType(); if (!QT->isDependentType() && !typeHasCapability(S, QT)) { - S.Diag(AL.getLoc(), diag::warn_thread_attribute_decl_not_lockable) - << AL.getName(); + S.Diag(AL.getLoc(), diag::warn_thread_attribute_decl_not_lockable) << AL; return false; } @@ -774,7 +766,7 @@ if (!Param->getType()->isIntegerType() && !Param->getType()->isCharType()) { SourceLocation SrcLoc = AttrArg->getLocStart(); S.Diag(SrcLoc, diag::err_attribute_integers_only) - << getAttrName(AI) << Param->getSourceRange(); + << AI << Param->getSourceRange(); return false; } return true; @@ -787,8 +779,7 @@ const auto *FD = cast(D); if (!FD->getReturnType()->isPointerType()) { - S.Diag(AL.getLoc(), diag::warn_attribute_return_pointers_only) - << AL.getName(); + S.Diag(AL.getLoc(), diag::warn_attribute_return_pointers_only) << AL; return; } @@ -825,7 +816,7 @@ if (!isIntOrBool(AL.getArgAsExpr(0))) { S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) - << AL.getName() << 1 << AANT_ArgumentIntOrBool; + << AL << 1 << AANT_ArgumentIntOrBool; return false; } @@ -907,8 +898,7 @@ if (isa(D) && !Cond->isValueDependent() && !Expr::isPotentialConstantExprUnevaluated(Cond, cast(D), Diags)) { - S.Diag(AL.getLoc(), diag::err_attr_cond_never_constant_expr) - << AL.getName(); + S.Diag(AL.getLoc(), diag::err_attr_cond_never_constant_expr) << AL; for (const PartialDiagnosticAt &PDiag : Diags) S.Diag(PDiag.first, PDiag.second); return false; @@ -1002,8 +992,7 @@ static void handlePassObjectSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (D->hasAttr()) { - S.Diag(D->getLocStart(), diag::err_attribute_only_once_per_parameter) - << AL.getName(); + S.Diag(D->getLocStart(), diag::err_attribute_only_once_per_parameter) << AL; return; } @@ -1017,7 +1006,7 @@ // argument; namely, it must be in the range [0, 3]. if (Type > 3) { S.Diag(E->getLocStart(), diag::err_attribute_argument_outof_range) - << AL.getName() << 0 << 3 << E->getSourceRange(); + << AL << 0 << 3 << E->getSourceRange(); return; } @@ -1026,8 +1015,7 @@ // At this point, we have no clue if `D` belongs to a function declaration or // definition, so we defer the constness check until later. if (!cast(D)->getType()->isPointerType()) { - S.Diag(D->getLocStart(), diag::err_attribute_pointers_only) - << AL.getName() << 1; + S.Diag(D->getLocStart(), diag::err_attribute_pointers_only) << AL << 1; return; } @@ -1042,13 +1030,13 @@ IdentifierLoc *IL = AL.getArgAsIdent(0); if (!ConsumableAttr::ConvertStrToConsumedState(IL->Ident->getName(), DefaultState)) { - S.Diag(IL->Loc, diag::warn_attribute_type_not_supported) - << AL.getName() << IL->Ident; + S.Diag(IL->Loc, diag::warn_attribute_type_not_supported) << AL + << IL->Ident; return; } } else { S.Diag(AL.getLoc(), diag::err_attribute_argument_type) - << AL.getName() << AANT_ArgumentIdentifier; + << AL << AANT_ArgumentIdentifier; return; } @@ -1098,8 +1086,7 @@ if (!CallableWhenAttr::ConvertStrToConsumedState(StateString, CallableState)) { - S.Diag(Loc, diag::warn_attribute_type_not_supported) - << AL.getName() << StateString; + S.Diag(Loc, diag::warn_attribute_type_not_supported) << AL << StateString; return; } @@ -1121,12 +1108,12 @@ if (!ParamTypestateAttr::ConvertStrToConsumedState(StateString, ParamState)) { S.Diag(Ident->Loc, diag::warn_attribute_type_not_supported) - << AL.getName() << StateString; + << AL << StateString; return; } } else { - S.Diag(AL.getLoc(), diag::err_attribute_argument_type) << - AL.getName() << AANT_ArgumentIdentifier; + S.Diag(AL.getLoc(), diag::err_attribute_argument_type) + << AL << AANT_ArgumentIdentifier; return; } @@ -1154,13 +1141,13 @@ IdentifierLoc *IL = AL.getArgAsIdent(0); if (!ReturnTypestateAttr::ConvertStrToConsumedState(IL->Ident->getName(), ReturnState)) { - S.Diag(IL->Loc, diag::warn_attribute_type_not_supported) - << AL.getName() << IL->Ident; + S.Diag(IL->Loc, diag::warn_attribute_type_not_supported) << AL + << IL->Ident; return; } } else { - S.Diag(AL.getLoc(), diag::err_attribute_argument_type) << - AL.getName() << AANT_ArgumentIdentifier; + S.Diag(AL.getLoc(), diag::err_attribute_argument_type) + << AL << AANT_ArgumentIdentifier; return; } @@ -1203,13 +1190,13 @@ IdentifierLoc *Ident = AL.getArgAsIdent(0); StringRef Param = Ident->Ident->getName(); if (!SetTypestateAttr::ConvertStrToConsumedState(Param, NewState)) { - S.Diag(Ident->Loc, diag::warn_attribute_type_not_supported) - << AL.getName() << Param; + S.Diag(Ident->Loc, diag::warn_attribute_type_not_supported) << AL + << Param; return; } } else { - S.Diag(AL.getLoc(), diag::err_attribute_argument_type) << - AL.getName() << AANT_ArgumentIdentifier; + S.Diag(AL.getLoc(), diag::err_attribute_argument_type) + << AL << AANT_ArgumentIdentifier; return; } @@ -1227,13 +1214,13 @@ IdentifierLoc *Ident = AL.getArgAsIdent(0); StringRef Param = Ident->Ident->getName(); if (!TestTypestateAttr::ConvertStrToConsumedState(Param, TestState)) { - S.Diag(Ident->Loc, diag::warn_attribute_type_not_supported) - << AL.getName() << Param; + S.Diag(Ident->Loc, diag::warn_attribute_type_not_supported) << AL + << Param; return; } } else { - S.Diag(AL.getLoc(), diag::err_attribute_argument_type) << - AL.getName() << AANT_ArgumentIdentifier; + S.Diag(AL.getLoc(), diag::err_attribute_argument_type) + << AL << AANT_ArgumentIdentifier; return; } @@ -1261,7 +1248,7 @@ if (BitfieldByteAligned) // The PS4 target needs to maintain ABI backwards compatibility. S.Diag(AL.getLoc(), diag::warn_attribute_ignored_for_field_of_type) - << AL.getName() << FD->getType(); + << AL << FD->getType(); else FD->addAttr(::new (S.Context) PackedAttr( AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); @@ -1275,7 +1262,7 @@ } } else - S.Diag(AL.getLoc(), diag::warn_attribute_ignored) << AL.getName(); + S.Diag(AL.getLoc(), diag::warn_attribute_ignored) << AL; } static bool checkIBOutletCommon(Sema &S, Decl *D, const ParsedAttr &AL) { @@ -1285,19 +1272,19 @@ if (const auto *VD = dyn_cast(D)) { if (!VD->getType()->getAs()) { S.Diag(AL.getLoc(), diag::warn_iboutlet_object_type) - << AL.getName() << VD->getType() << 0; + << AL << VD->getType() << 0; return false; } } else if (const auto *PD = dyn_cast(D)) { if (!PD->getType()->getAs()) { S.Diag(AL.getLoc(), diag::warn_iboutlet_object_type) - << AL.getName() << PD->getType() << 1; + << AL << PD->getType() << 1; return false; } } else { - S.Diag(AL.getLoc(), diag::warn_attribute_iboutlet) << AL.getName(); + S.Diag(AL.getLoc(), diag::warn_attribute_iboutlet) << AL; return false; } @@ -1317,8 +1304,7 @@ // The iboutletcollection attribute can have zero or one arguments. if (AL.getNumArgs() > 1) { - S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) - << AL.getName() << 1; + S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1; return; } @@ -1390,10 +1376,10 @@ if (!S.isValidPointerAttrType(T)) { if (isReturnValue) S.Diag(AL.getLoc(), diag::warn_attribute_return_pointers_only) - << AL.getName() << AttrParmRange << TypeRange; + << AL << AttrParmRange << TypeRange; else S.Diag(AL.getLoc(), diag::warn_attribute_pointers_only) - << AL.getName() << AttrParmRange << TypeRange << 0; + << AL << AttrParmRange << TypeRange << 0; return false; } return true; @@ -1486,7 +1472,7 @@ QualType T = cast(D)->getType(); if (!S.isValidPointerAttrType(T, /* RefOkay */ true)) { S.Diag(AL.getLoc(), diag::warn_attribute_pointers_only) - << AL.getName() << AL.getRange() << 0; + << AL << AL.getRange() << 0; return; } @@ -1611,7 +1597,7 @@ if (!AL.isArgIdent(0)) { S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) - << AL.getName() << 1 << AANT_ArgumentIdentifier; + << AL << 1 << AANT_ArgumentIdentifier; return; } @@ -1625,15 +1611,13 @@ case OwnershipAttr::Takes: case OwnershipAttr::Holds: if (AL.getNumArgs() < 2) { - S.Diag(AL.getLoc(), diag::err_attribute_too_few_arguments) - << AL.getName() << 2; + S.Diag(AL.getLoc(), diag::err_attribute_too_few_arguments) << AL << 2; return; } break; case OwnershipAttr::Returns: if (AL.getNumArgs() > 2) { - S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments) - << AL.getName() << 1; + S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments) << AL << 1; return; } break; @@ -1668,8 +1652,8 @@ break; } if (-1 != Err) { - S.Diag(AL.getLoc(), diag::err_ownership_type) << AL.getName() << Err - << Ex->getSourceRange(); + S.Diag(AL.getLoc(), diag::err_ownership_type) << AL << Err + << Ex->getSourceRange(); return; } @@ -1679,8 +1663,7 @@ // index. if (I->getOwnKind() != K && I->args_end() != std::find(I->args_begin(), I->args_end(), Idx)) { - S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) - << AL.getName() << I; + S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << I; return; } else if (K == OwnershipAttr::Returns && I->getOwnKind() == OwnershipAttr::Returns) { @@ -1710,8 +1693,7 @@ static void handleWeakRefAttr(Sema &S, Decl *D, const ParsedAttr &AL) { // Check the attribute arguments. if (AL.getNumArgs() > 1) { - S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) - << AL.getName() << 1; + S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1; return; } @@ -1846,7 +1828,7 @@ } S.Diag(AL.getLoc(), diag::warn_attribute_return_pointers_only) - << AL.getName() << getFunctionOrMethodResultSourceRange(D); + << AL << getFunctionOrMethodResultSourceRange(D); } static void handleCPUSpecificAttr(Sema &S, Decl *D, const ParsedAttr &AL) { @@ -1858,7 +1840,7 @@ for (unsigned ArgNo = 0; ArgNo < getNumAttributeArgs(AL); ++ArgNo) { if (!AL.isArgIdent(ArgNo)) { S.Diag(AL.getLoc(), diag::err_attribute_argument_type) - << AL.getName() << AANT_ArgumentIdentifier; + << AL << AANT_ArgumentIdentifier; return; } @@ -1896,18 +1878,16 @@ static void handleCommonAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (S.LangOpts.CPlusPlus) { S.Diag(AL.getLoc(), diag::err_attribute_not_supported_in_lang) - << AL.getName() << AttributeLangSupport::Cpp; + << AL << AttributeLangSupport::Cpp; return; } - if (CommonAttr *CA = S.mergeCommonAttr(D, AL.getRange(), AL.getName(), - AL.getAttributeSpellingListIndex())) + if (CommonAttr *CA = S.mergeCommonAttr(D, AL)) D->addAttr(CA); } static void handleNakedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { - if (checkAttrMutualExclusion(S, D, AL.getRange(), - AL.getName())) + if (checkAttrMutualExclusion(S, D, AL)) return; if (AL.isDeclspecAttribute()) { @@ -1916,7 +1896,7 @@ if (Arch != llvm::Triple::x86 && (Arch != llvm::Triple::arm && Arch != llvm::Triple::thumb)) { S.Diag(AL.getLoc(), diag::err_attribute_not_supported_on_arch) - << AL.getName() << Triple.getArchName(); + << AL << Triple.getArchName(); return; } } @@ -1930,7 +1910,7 @@ if (!isa(D)) { S.Diag(Attrs.getLoc(), diag::warn_attribute_wrong_decl_type) - << Attrs.getName() << ExpectedFunctionOrMethod; + << Attrs << ExpectedFunctionOrMethod; return; } @@ -1957,7 +1937,7 @@ bool Sema::CheckAttrTarget(const ParsedAttr &AL) { // Check whether the attribute is valid on the current target. if (!AL.existsInTarget(Context.getTargetInfo())) { - Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored) << AL.getName(); + Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored) << AL; AL.setInvalid(); return true; } @@ -1973,10 +1953,10 @@ ValueDecl *VD = dyn_cast(D); if (!VD || (!VD->getType()->isBlockPointerType() && !VD->getType()->isFunctionPointerType())) { - S.Diag(AL.getLoc(), - AL.isCXX11Attribute() ? diag::err_attribute_wrong_decl_type - : diag::warn_attribute_wrong_decl_type) - << AL.getName() << ExpectedFunctionMethodOrBlock; + S.Diag(AL.getLoc(), AL.isCXX11Attribute() + ? diag::err_attribute_wrong_decl_type + : diag::warn_attribute_wrong_decl_type) + << AL << ExpectedFunctionMethodOrBlock; return; } } @@ -2065,7 +2045,7 @@ // If this is spelled as the standard C++17 attribute, but not in C++17, warn // about using it as an extension. if (!S.getLangOpts().CPlusPlus17 && IsCXX17Attr) - S.Diag(AL.getLoc(), diag::ext_cxx17_attr) << AL.getName(); + S.Diag(AL.getLoc(), diag::ext_cxx17_attr) << AL; D->addAttr(::new (S.Context) UnusedAttr( AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); @@ -2108,7 +2088,7 @@ const ParsedAttr &AL) { if (!cast(D)->isThisDeclarationADefinition()) { S.Diag(AL.getLoc(), diag::err_objc_attr_protocol_requires_definition) - << AL.getName() << AL.getRange(); + << AL << AL.getRange(); return; } @@ -2506,8 +2486,7 @@ bool isTypeVisibility) { // Visibility attributes don't mean anything on a typedef. if (isa(D)) { - S.Diag(AL.getRange().getBegin(), diag::warn_attribute_ignored) - << AL.getName(); + S.Diag(AL.getRange().getBegin(), diag::warn_attribute_ignored) << AL; return; } @@ -2517,7 +2496,7 @@ isa(D) || isa(D))) { S.Diag(AL.getRange().getBegin(), diag::err_attribute_wrong_decl_type) - << AL.getName() << ExpectedTypeOrNamespace; + << AL << ExpectedTypeOrNamespace; return; } @@ -2529,8 +2508,8 @@ VisibilityAttr::VisibilityType type; if (!VisibilityAttr::ConvertStrToVisibilityType(TypeStr, type)) { - S.Diag(LiteralLoc, diag::warn_attribute_type_not_supported) - << AL.getName() << TypeStr; + S.Diag(LiteralLoc, diag::warn_attribute_type_not_supported) << AL + << TypeStr; return; } @@ -2559,15 +2538,14 @@ const auto *M = cast(D); if (!AL.isArgIdent(0)) { S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) - << AL.getName() << 1 << AANT_ArgumentIdentifier; + << AL << 1 << AANT_ArgumentIdentifier; return; } IdentifierLoc *IL = AL.getArgAsIdent(0); ObjCMethodFamilyAttr::FamilyKind F; if (!ObjCMethodFamilyAttr::ConvertStrToFamilyKind(IL->Ident->getName(), F)) { - S.Diag(IL->Loc, diag::warn_attribute_type_not_supported) - << AL.getName() << IL->Ident; + S.Diag(IL->Loc, diag::warn_attribute_type_not_supported) << AL << IL->Ident; return; } @@ -2631,15 +2609,14 @@ static void handleBlocksAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!AL.isArgIdent(0)) { S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) - << AL.getName() << 1 << AANT_ArgumentIdentifier; + << AL << 1 << AANT_ArgumentIdentifier; return; } IdentifierInfo *II = AL.getArgAsIdent(0)->Ident; BlocksAttr::BlockType type; if (!BlocksAttr::ConvertStrToBlockType(II->getName(), type)) { - S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) - << AL.getName() << II; + S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) << AL << II; return; } @@ -2656,8 +2633,7 @@ if (E->isTypeDependent() || E->isValueDependent() || !E->isIntegerConstantExpr(Idx, S.Context)) { S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) - << AL.getName() << 1 << AANT_ArgumentIntegerConstant - << E->getSourceRange(); + << AL << 1 << AANT_ArgumentIntegerConstant << E->getSourceRange(); return; } @@ -2677,8 +2653,7 @@ if (E->isTypeDependent() || E->isValueDependent() || !E->isIntegerConstantExpr(Idx, S.Context)) { S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) - << AL.getName() << 2 << AANT_ArgumentIntegerConstant - << E->getSourceRange(); + << AL << 2 << AANT_ArgumentIntegerConstant << E->getSourceRange(); return; } nullPos = Idx.getZExtValue(); @@ -2726,12 +2701,12 @@ } } else { S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type) - << AL.getName() << ExpectedFunctionMethodOrBlock; + << AL << ExpectedFunctionMethodOrBlock; return; } } else { S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type) - << AL.getName() << ExpectedFunctionMethodOrBlock; + << AL << ExpectedFunctionMethodOrBlock; return; } D->addAttr(::new (S.Context) @@ -2742,14 +2717,12 @@ static void handleWarnUnusedResult(Sema &S, Decl *D, const ParsedAttr &AL) { if (D->getFunctionType() && D->getFunctionType()->getReturnType()->isVoidType()) { - S.Diag(AL.getLoc(), diag::warn_attribute_void_function_method) - << AL.getName() << 0; + S.Diag(AL.getLoc(), diag::warn_attribute_void_function_method) << AL << 0; return; } if (const auto *MD = dyn_cast(D)) if (MD->getReturnType()->isVoidType()) { - S.Diag(AL.getLoc(), diag::warn_attribute_void_function_method) - << AL.getName() << 1; + S.Diag(AL.getLoc(), diag::warn_attribute_void_function_method) << AL << 1; return; } @@ -2757,7 +2730,7 @@ // about using it as an extension. if (!S.getLangOpts().CPlusPlus17 && AL.isCXX11Attribute() && !AL.getScopeName()) - S.Diag(AL.getLoc(), diag::ext_cxx17_attr) << AL.getName(); + S.Diag(AL.getLoc(), diag::ext_cxx17_attr) << AL; D->addAttr(::new (S.Context) WarnUnusedResultAttr(AL.getRange(), S.Context, @@ -2777,7 +2750,7 @@ // Nothing to warn about here. } else S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type) - << AL.getName() << ExpectedVariableOrFunction; + << AL << ExpectedVariableOrFunction; return; } @@ -2797,7 +2770,7 @@ return; if (WGSize[i] == 0) { S.Diag(AL.getLoc(), diag::err_attribute_argument_is_zero) - << AL.getName() << E->getSourceRange(); + << AL << E->getSourceRange(); return; } } @@ -2806,7 +2779,7 @@ if (Existing && !(Existing->getXDim() == WGSize[0] && Existing->getYDim() == WGSize[1] && Existing->getZDim() == WGSize[2])) - S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL.getName(); + S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; D->addAttr(::new (S.Context) WorkGroupAttr(AL.getRange(), S.Context, WGSize[0], WGSize[1], WGSize[2], @@ -2821,14 +2794,14 @@ return; if (SGSize == 0) { S.Diag(AL.getLoc(), diag::err_attribute_argument_is_zero) - << AL.getName() << E->getSourceRange(); + << AL << E->getSourceRange(); return; } OpenCLIntelReqdSubGroupSizeAttr *Existing = D->getAttr(); if (Existing && Existing->getSubGroupSize() != SGSize) - S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL.getName(); + S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; D->addAttr(::new (S.Context) OpenCLIntelReqdSubGroupSizeAttr( AL.getRange(), S.Context, SGSize, @@ -2837,8 +2810,7 @@ static void handleVecTypeHint(Sema &S, Decl *D, const ParsedAttr &AL) { if (!AL.hasParsedType()) { - S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) - << AL.getName() << 1; + S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1; return; } @@ -2856,7 +2828,7 @@ if (VecTypeHintAttr *A = D->getAttr()) { if (!S.Context.hasSameType(A->getTypeHint(), ParmType)) { - S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL.getName(); + S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; return; } } @@ -3030,7 +3002,7 @@ MinVectorWidthAttr *Existing = D->getAttr(); if (Existing && Existing->getVectorWidth() != VecWidth) { - S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL.getName(); + S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; return; } @@ -3100,7 +3072,7 @@ const ParsedAttr &AL) { if (!AL.isArgIdent(0)) { S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) - << AL.getName() << 0 << AANT_ArgumentIdentifier; + << AL << 0 << AANT_ArgumentIdentifier; return; } @@ -3108,8 +3080,7 @@ IdentifierInfo *II = AL.getArgAsIdent(0)->Ident; if (!EnumExtensibilityAttr::ConvertStrToKind(II->getName(), ExtensibilityKind)) { - S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) - << AL.getName() << II; + S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) << AL << II; return; } @@ -3188,7 +3159,7 @@ /// http://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Attributes.html static void handleInitPriorityAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!S.getLangOpts().CPlusPlus) { - S.Diag(AL.getLoc(), diag::warn_attribute_ignored) << AL.getName(); + S.Diag(AL.getLoc(), diag::warn_attribute_ignored) << AL; return; } @@ -3215,7 +3186,7 @@ if (prioritynum < 101 || prioritynum > 65535) { S.Diag(AL.getLoc(), diag::err_attribute_argument_outof_range) - << E->getSourceRange() << AL.getName() << 101 << 65535; + << E->getSourceRange() << AL << 101 << 65535; AL.setInvalid(); return; } @@ -3250,7 +3221,7 @@ static void handleFormatAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!AL.isArgIdent(0)) { S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) - << AL.getName() << 1 << AANT_ArgumentIdentifier; + << AL << 1 << AANT_ArgumentIdentifier; return; } @@ -3275,7 +3246,7 @@ if (Kind == InvalidFormat) { S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) - << AL.getName() << II->getName(); + << AL << II->getName(); return; } @@ -3287,7 +3258,7 @@ if (Idx < 1 || Idx > NumArgs) { S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds) - << AL.getName() << 2 << IdxExpr->getSourceRange(); + << AL << 2 << IdxExpr->getSourceRange(); return; } @@ -3358,7 +3329,7 @@ // if 0 it disables parameter checking (to use with e.g. va_list) } else if (FirstArg != 0 && FirstArg != NumArgs) { S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds) - << AL.getName() << 3 << FirstArgExpr->getSourceRange(); + << AL << 3 << FirstArgExpr->getSourceRange(); return; } @@ -3379,8 +3350,8 @@ RD = dyn_cast(D); if (!RD || !RD->isUnion()) { - S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type) - << AL.getName() << ExpectedUnion; + S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type) << AL + << ExpectedUnion; return; } @@ -3513,8 +3484,7 @@ static void handleAlignedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { // check the attribute arguments. if (AL.getNumArgs() > 1) { - S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) - << AL.getName() << 1; + S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1; return; } @@ -3794,8 +3764,8 @@ // This attribute isn't documented, but glibc uses it. It changes // the width of an int or unsigned int to the specified size. if (!AL.isArgIdent(0)) { - S.Diag(AL.getLoc(), diag::err_attribute_argument_type) << AL.getName() - << AANT_ArgumentIdentifier; + S.Diag(AL.getLoc(), diag::err_attribute_argument_type) + << AL << AANT_ArgumentIdentifier; return; } @@ -3968,26 +3938,55 @@ AttrSpellingListIndex); } -CommonAttr *Sema::mergeCommonAttr(Decl *D, SourceRange Range, - IdentifierInfo *Ident, - unsigned AttrSpellingListIndex) { - if (checkAttrMutualExclusion(*this, D, Range, Ident)) +CommonAttr *Sema::mergeCommonAttr(Decl *D, const ParsedAttr &AL) { + if (checkAttrMutualExclusion(*this, D, AL)) return nullptr; - return ::new (Context) CommonAttr(Range, Context, AttrSpellingListIndex); + return ::new (Context) + CommonAttr(AL.getRange(), Context, AL.getAttributeSpellingListIndex()); +} + +CommonAttr *Sema::mergeCommonAttr(Decl *D, const CommonAttr &AL) { + if (checkAttrMutualExclusion(*this, D, AL)) + return nullptr; + + return ::new (Context) + CommonAttr(AL.getRange(), Context, AL.getSpellingListIndex()); } +InternalLinkageAttr *Sema::mergeInternalLinkageAttr(Decl *D, + const ParsedAttr &AL) { + if (const auto *VD = dyn_cast(D)) { + // Attribute applies to Var but not any subclass of it (like ParmVar, + // ImplicitParm or VarTemplateSpecialization). + if (VD->getKind() != Decl::Var) { + Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type) + << AL << (getLangOpts().CPlusPlus ? ExpectedFunctionVariableOrClass + : ExpectedVariableOrFunction); + return nullptr; + } + // Attribute does not apply to non-static local variables. + if (VD->hasLocalStorage()) { + Diag(VD->getLocation(), diag::warn_internal_linkage_local_storage); + return nullptr; + } + } + + if (checkAttrMutualExclusion(*this, D, AL)) + return nullptr; + + return ::new (Context) InternalLinkageAttr( + AL.getRange(), Context, AL.getAttributeSpellingListIndex()); +} InternalLinkageAttr * -Sema::mergeInternalLinkageAttr(Decl *D, SourceRange Range, - IdentifierInfo *Ident, - unsigned AttrSpellingListIndex) { +Sema::mergeInternalLinkageAttr(Decl *D, const InternalLinkageAttr &AL) { if (const auto *VD = dyn_cast(D)) { // Attribute applies to Var but not any subclass of it (like ParmVar, // ImplicitParm or VarTemplateSpecialization). if (VD->getKind() != Decl::Var) { - Diag(Range.getBegin(), diag::warn_attribute_wrong_decl_type) - << Ident << (getLangOpts().CPlusPlus ? ExpectedFunctionVariableOrClass - : ExpectedVariableOrFunction); + Diag(AL.getLocation(), diag::warn_attribute_wrong_decl_type) + << &AL << (getLangOpts().CPlusPlus ? ExpectedFunctionVariableOrClass + : ExpectedVariableOrFunction); return nullptr; } // Attribute does not apply to non-static local variables. @@ -3997,11 +3996,11 @@ } } - if (checkAttrMutualExclusion(*this, D, Range, Ident)) + if (checkAttrMutualExclusion(*this, D, AL)) return nullptr; return ::new (Context) - InternalLinkageAttr(Range, Context, AttrSpellingListIndex); + InternalLinkageAttr(AL.getRange(), Context, AL.getSpellingListIndex()); } MinSizeAttr *Sema::mergeMinSizeAttr(Decl *D, SourceRange Range, @@ -4039,8 +4038,7 @@ } static void handleAlwaysInlineAttr(Sema &S, Decl *D, const ParsedAttr &AL) { - if (checkAttrMutualExclusion(S, D, AL.getRange(), - AL.getName())) + if (checkAttrMutualExclusion(S, D, AL)) return; if (AlwaysInlineAttr *Inline = S.mergeAlwaysInlineAttr( @@ -4062,8 +4060,7 @@ } static void handleConstantAttr(Sema &S, Decl *D, const ParsedAttr &AL) { - if (checkAttrMutualExclusion(S, D, AL.getRange(), - AL.getName())) + if (checkAttrMutualExclusion(S, D, AL)) return; const auto *VD = cast(D); if (!VD->hasGlobalStorage()) { @@ -4075,8 +4072,7 @@ } static void handleSharedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { - if (checkAttrMutualExclusion(S, D, AL.getRange(), - AL.getName())) + if (checkAttrMutualExclusion(S, D, AL)) return; const auto *VD = cast(D); // extern __shared__ is only allowed on arrays with no length (e.g. @@ -4095,10 +4091,8 @@ } static void handleGlobalAttr(Sema &S, Decl *D, const ParsedAttr &AL) { - if (checkAttrMutualExclusion(S, D, AL.getRange(), - AL.getName()) || - checkAttrMutualExclusion(S, D, AL.getRange(), - AL.getName())) { + if (checkAttrMutualExclusion(S, D, AL) || + checkAttrMutualExclusion(S, D, AL)) { return; } const auto *FD = cast(D); @@ -4150,7 +4144,7 @@ if (!isa(D)) { S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type) - << AL.getName() << ExpectedFunctionOrMethod; + << AL << ExpectedFunctionOrMethod; return; } @@ -4344,7 +4338,7 @@ TargetInfo::CallingConvCheckResult A = TI.checkCallingConvention(CC); if (A != TargetInfo::CCCR_OK) { if (A == TargetInfo::CCCR_Warning) - Diag(Attrs.getLoc(), diag::warn_cconv_ignored) << Attrs.getName(); + Diag(Attrs.getLoc(), diag::warn_cconv_ignored) << Attrs; // This convention is not valid for the target. Use the default function or // method calling convention. @@ -4559,7 +4553,7 @@ const ParsedAttr &AL) { if (!AL.isArgIdent(0)) { S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) - << AL.getName() << /* arg num = */ 1 << AANT_ArgumentIdentifier; + << AL << /* arg num = */ 1 << AANT_ArgumentIdentifier; return; } @@ -4579,8 +4573,7 @@ unsigned ArgumentIdxAST = ArgumentIdx.getASTIndex(); if (ArgumentIdxAST >= getFunctionOrMethodNumParams(D) || !getFunctionOrMethodParamType(D, ArgumentIdxAST)->isPointerType()) - S.Diag(AL.getLoc(), diag::err_attribute_pointers_only) - << AL.getName() << 0; + S.Diag(AL.getLoc(), diag::err_attribute_pointers_only) << AL << 0; } D->addAttr(::new (S.Context) ArgumentWithTypeTagAttr( @@ -4592,7 +4585,7 @@ const ParsedAttr &AL) { if (!AL.isArgIdent(0)) { S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) - << AL.getName() << 1 << AANT_ArgumentIdentifier; + << AL << 1 << AANT_ArgumentIdentifier; return; } @@ -4601,7 +4594,7 @@ if (!isa(D)) { S.Diag(AL.getLoc(), diag::err_attribute_wrong_decl_type) - << AL.getName() << ExpectedVariable; + << AL << ExpectedVariable; return; } @@ -4715,8 +4708,7 @@ ReturnType = Param->getType()->getPointeeType(); if (ReturnType.isNull()) { S.Diag(D->getLocStart(), diag::warn_ns_attribute_wrong_parameter_type) - << AL.getName() << /*pointer-to-CF*/2 - << AL.getRange(); + << AL << /*pointer-to-CF*/ 2 << AL.getRange(); return; } } else if (AL.isUsedAsTypeAttr()) { @@ -4737,7 +4729,7 @@ break; } S.Diag(D->getLocStart(), diag::warn_attribute_wrong_decl_type) - << AL.getRange() << AL.getName() << ExpectedDeclKind; + << AL.getRange() << AL << ExpectedDeclKind; return; } @@ -4769,8 +4761,7 @@ if (isa(D)) { S.Diag(D->getLocStart(), diag::warn_ns_attribute_wrong_parameter_type) - << AL.getName() << /*pointer-to-CF*/2 - << AL.getRange(); + << AL << /*pointer-to-CF*/ 2 << AL.getRange(); } else { // Needs to be kept in sync with warn_ns_attribute_wrong_return_type. enum : unsigned { @@ -4783,8 +4774,7 @@ else if (isa(D)) SubjectKind = Property; S.Diag(D->getLocStart(), diag::warn_ns_attribute_wrong_return_type) - << AL.getName() << SubjectKind << Cf - << AL.getRange(); + << AL << SubjectKind << Cf << AL.getRange(); } return; } @@ -4830,10 +4820,9 @@ if (!resultType->isReferenceType() && (!resultType->isPointerType() || resultType->isObjCRetainableType())) { S.Diag(D->getLocStart(), diag::warn_ns_attribute_wrong_return_type) - << SourceRange(loc) - << Attrs.getName() - << (isa(D) ? EP_ObjCMethod : EP_ObjCProperty) - << /*non-retainable pointer*/ 2; + << SourceRange(loc) << Attrs + << (isa(D) ? EP_ObjCMethod : EP_ObjCProperty) + << /*non-retainable pointer*/ 2; // Drop the attribute. return; @@ -4849,14 +4838,14 @@ const DeclContext *DC = Method->getDeclContext(); if (const auto *PDecl = dyn_cast_or_null(DC)) { - S.Diag(D->getLocStart(), diag::warn_objc_requires_super_protocol) - << Attrs.getName() << 0; + S.Diag(D->getLocStart(), diag::warn_objc_requires_super_protocol) << Attrs + << 0; S.Diag(PDecl->getLocation(), diag::note_protocol_decl); return; } if (Method->getMethodFamily() == OMF_dealloc) { - S.Diag(D->getLocStart(), diag::warn_objc_requires_super_protocol) - << Attrs.getName() << 1; + S.Diag(D->getLocStart(), diag::warn_objc_requires_super_protocol) << Attrs + << 1; return; } @@ -4868,15 +4857,14 @@ IdentifierLoc *Parm = AL.isArgIdent(0) ? AL.getArgAsIdent(0) : nullptr; if (!Parm) { - S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << AL.getName() << 0; + S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << AL << 0; return; } // Typedefs only allow objc_bridge(id) and have some additional checking. if (const auto *TD = dyn_cast(D)) { if (!Parm->Ident->isStr("id")) { - S.Diag(AL.getLoc(), diag::err_objc_attr_typedef_not_id) - << AL.getName(); + S.Diag(AL.getLoc(), diag::err_objc_attr_typedef_not_id) << AL; return; } @@ -4898,7 +4886,7 @@ IdentifierLoc *Parm = AL.isArgIdent(0) ? AL.getArgAsIdent(0) : nullptr; if (!Parm) { - S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << AL.getName() << 0; + S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << AL << 0; return; } @@ -4912,7 +4900,7 @@ IdentifierInfo *RelatedClass = AL.isArgIdent(0) ? AL.getArgAsIdent(0)->Ident : nullptr; if (!RelatedClass) { - S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << AL.getName() << 0; + S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << AL << 0; return; } IdentifierInfo *ClassMethod = @@ -4983,7 +4971,7 @@ if (hasDeclarator(D)) return; S.Diag(D->getLocStart(), diag::err_attribute_wrong_decl_type) - << AL.getRange() << AL.getName() << ExpectedVariable; + << AL.getRange() << AL << ExpectedVariable; } static void handleObjCPreciseLifetimeAttr(Sema &S, Decl *D, @@ -5047,7 +5035,7 @@ static void handleUuidAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!S.LangOpts.CPlusPlus) { S.Diag(AL.getLoc(), diag::err_attribute_not_supported_in_lang) - << AL.getName() << AttributeLangSupport::C; + << AL << AttributeLangSupport::C; return; } @@ -5097,7 +5085,7 @@ static void handleMSInheritanceAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!S.LangOpts.CPlusPlus) { S.Diag(AL.getLoc(), diag::err_attribute_not_supported_in_lang) - << AL.getName() << AttributeLangSupport::C; + << AL << AttributeLangSupport::C; return; } MSInheritanceAttr *IA = S.mergeMSInheritanceAttr( @@ -5163,8 +5151,7 @@ static void handleARMInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { // Check the attribute arguments. if (AL.getNumArgs() > 1) { - S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments) - << AL.getName() << 1; + S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments) << AL << 1; return; } @@ -5178,8 +5165,8 @@ ARMInterruptAttr::InterruptType Kind; if (!ARMInterruptAttr::ConvertStrToInterruptType(Str, Kind)) { - S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) - << AL.getName() << Str << ArgLoc; + S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) << AL << Str + << ArgLoc; return; } @@ -5193,8 +5180,8 @@ return; if (!AL.isArgExpr(0)) { - S.Diag(AL.getLoc(), diag::err_attribute_argument_type) << AL.getName() - << AANT_ArgumentIntegerConstant; + S.Diag(AL.getLoc(), diag::err_attribute_argument_type) + << AL << AANT_ArgumentIntegerConstant; return; } @@ -5204,16 +5191,16 @@ llvm::APSInt NumParams(32); if (!NumParamsExpr->isIntegerConstantExpr(NumParams, S.Context)) { S.Diag(AL.getLoc(), diag::err_attribute_argument_type) - << AL.getName() << AANT_ArgumentIntegerConstant - << NumParamsExpr->getSourceRange(); + << AL << AANT_ArgumentIntegerConstant + << NumParamsExpr->getSourceRange(); return; } unsigned Num = NumParams.getLimitedValue(255); if ((Num & 1) || Num > 30) { S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds) - << AL.getName() << (int)NumParams.getSExtValue() - << NumParamsExpr->getSourceRange(); + << AL << (int)NumParams.getSExtValue() + << NumParamsExpr->getSourceRange(); return; } @@ -5226,8 +5213,7 @@ static void handleMipsInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { // Only one optional argument permitted. if (AL.getNumArgs() > 1) { - S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments) - << AL.getName() << 1; + S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments) << AL << 1; return; } @@ -5266,14 +5252,13 @@ return; } - if (checkAttrMutualExclusion(S, D, AL.getRange(), - AL.getName())) + if (checkAttrMutualExclusion(S, D, AL)) return; MipsInterruptAttr::InterruptType Kind; if (!MipsInterruptAttr::ConvertStrToInterruptType(Str, Kind)) { S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) - << AL.getName() << "'" + std::string(Str) + "'"; + << AL << "'" + std::string(Str) + "'"; return; } @@ -5292,7 +5277,7 @@ CXXMethodDecl::isStaticOverloadedOperator( cast(D)->getDeclName().getCXXOverloadedOperator())) { S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type) - << AL.getName() << ExpectedFunctionWithProtoType; + << AL << ExpectedFunctionWithProtoType; return; } // Interrupt handler must have void return type. @@ -5421,8 +5406,8 @@ RISCVInterruptAttr::InterruptType Kind; if (!RISCVInterruptAttr::ConvertStrToInterruptType(Str, Kind)) { - S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) - << AL.getName() << Str << ArgLoc; + S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) << AL << Str + << ArgLoc; return; } @@ -5470,13 +5455,11 @@ return; if (Min == 0 && Max != 0) { - S.Diag(AL.getLoc(), diag::err_attribute_argument_invalid) - << AL.getName() << 0; + S.Diag(AL.getLoc(), diag::err_attribute_argument_invalid) << AL << 0; return; } if (Min > Max) { - S.Diag(AL.getLoc(), diag::err_attribute_argument_invalid) - << AL.getName() << 1; + S.Diag(AL.getLoc(), diag::err_attribute_argument_invalid) << AL << 1; return; } @@ -5499,13 +5482,11 @@ } if (Min == 0 && Max != 0) { - S.Diag(AL.getLoc(), diag::err_attribute_argument_invalid) - << AL.getName() << 0; + S.Diag(AL.getLoc(), diag::err_attribute_argument_invalid) << AL << 0; return; } if (Max != 0 && Min > Max) { - S.Diag(AL.getLoc(), diag::err_attribute_argument_invalid) - << AL.getName() << 1; + S.Diag(AL.getLoc(), diag::err_attribute_argument_invalid) << AL << 1; return; } @@ -5552,7 +5533,7 @@ // Attribute can only be applied to function types. if (!isa(D)) { S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type) - << AL.getName() << ExpectedFunction; + << AL << ExpectedFunction; return; } @@ -5570,7 +5551,7 @@ // TODO: Investigate what happens with the next major version of MSVC. if (Version != LangOptions::MSVC2015) { S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds) - << AL.getName() << Version << VersionExpr->getSourceRange(); + << AL << Version << VersionExpr->getSourceRange(); return; } @@ -5608,8 +5589,7 @@ static void handleDLLAttr(Sema &S, Decl *D, const ParsedAttr &A) { if (isa(D) && S.Context.getTargetInfo().getCXXABI().isMicrosoft()) { - S.Diag(A.getRange().getBegin(), diag::warn_attribute_ignored) - << A.getName(); + S.Diag(A.getRange().getBegin(), diag::warn_attribute_ignored) << A; return; } @@ -5618,7 +5598,7 @@ !S.Context.getTargetInfo().getCXXABI().isMicrosoft()) { // MinGW doesn't allow dllimport on inline functions. S.Diag(A.getRange().getBegin(), diag::warn_attribute_ignored_on_inline) - << A.getName(); + << A; return; } } @@ -5626,7 +5606,7 @@ if (const auto *MD = dyn_cast(D)) { if (S.Context.getTargetInfo().getCXXABI().isMicrosoft() && MD->getParent()->isLambda()) { - S.Diag(A.getRange().getBegin(), diag::err_attribute_dll_lambda) << A.getName(); + S.Diag(A.getRange().getBegin(), diag::err_attribute_dll_lambda) << A; return; } } @@ -5791,7 +5771,7 @@ if (!S.getLangOpts().CPlusPlus14) if (AL.isCXX11Attribute() && !(AL.hasScope() && AL.getScopeName()->isStr("gnu"))) - S.Diag(AL.getLoc(), diag::ext_cxx14_attr) << AL.getName(); + S.Diag(AL.getLoc(), diag::ext_cxx14_attr) << AL; D->addAttr(::new (S.Context) DeprecatedAttr(AL.getRange(), S.Context, Str, Replacement, @@ -5821,7 +5801,7 @@ S.Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << SanitizerName; else if (isGlobalVar(D) && SanitizerName != "address") S.Diag(D->getLocation(), diag::err_attribute_wrong_decl_type) - << AL.getName() << ExpectedFunctionOrMethod; + << AL << ExpectedFunctionOrMethod; Sanitizers.push_back(SanitizerName); } @@ -5841,26 +5821,24 @@ .Case("no_sanitize_memory", "memory"); if (isGlobalVar(D) && SanitizerName != "address") S.Diag(D->getLocation(), diag::err_attribute_wrong_decl_type) - << AL.getName() << ExpectedFunction; + << AL << ExpectedFunction; D->addAttr(::new (S.Context) NoSanitizeAttr(AL.getRange(), S.Context, &SanitizerName, 1, AL.getAttributeSpellingListIndex())); } static void handleInternalLinkageAttr(Sema &S, Decl *D, const ParsedAttr &AL) { - if (InternalLinkageAttr *Internal = - S.mergeInternalLinkageAttr(D, AL.getRange(), AL.getName(), - AL.getAttributeSpellingListIndex())) + if (InternalLinkageAttr *Internal = S.mergeInternalLinkageAttr(D, AL)) D->addAttr(Internal); } static void handleOpenCLNoSVMAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (S.LangOpts.OpenCLVersion != 200) S.Diag(AL.getLoc(), diag::err_attribute_requires_opencl_version) - << AL.getName() << "2.0" << 0; + << AL << "2.0" << 0; else - S.Diag(AL.getLoc(), diag::warn_opencl_attr_deprecated_ignored) - << AL.getName() << "2.0"; + S.Diag(AL.getLoc(), diag::warn_opencl_attr_deprecated_ignored) << AL + << "2.0"; } /// Handles semantic checking for features that are common to all attributes, @@ -5928,7 +5906,7 @@ if (AL.getName()->getName().find("read_write") != StringRef::npos) { if (S.getLangOpts().OpenCLVersion < 200 || DeclTy->isPipeType()) { S.Diag(AL.getLoc(), diag::err_opencl_invalid_read_write) - << AL.getName() << PDecl->getType() << DeclTy->isImageType(); + << AL << PDecl->getType() << DeclTy->isImageType(); D->setInvalidDecl(true); return; } @@ -5965,7 +5943,7 @@ S.Diag(AL.getLoc(), AL.isDeclspecAttribute() ? diag::warn_unhandled_ms_attribute_ignored : diag::warn_unknown_attribute_ignored) - << AL.getName(); + << AL; return; } @@ -5980,7 +5958,7 @@ break; } S.Diag(AL.getLoc(), diag::err_stmt_attribute_invalid_on_decl) - << AL.getName() << D->getLocation(); + << AL << D->getLocation(); break; case ParsedAttr::AT_Interrupt: handleInterruptAttr(S, D, AL); @@ -6708,10 +6686,10 @@ if (AL.getKind() == ParsedAttr::UnknownAttribute) { S.Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored) - << AL.getName() << AL.getRange(); + << AL << AL.getRange(); } else { - S.Diag(AL.getLoc(), diag::warn_attribute_not_on_decl) - << AL.getName() << AL.getRange(); + S.Diag(AL.getLoc(), diag::warn_attribute_not_on_decl) << AL + << AL.getRange(); } } } Index: lib/Sema/SemaStmtAttr.cpp =================================================================== --- lib/Sema/SemaStmtAttr.cpp +++ lib/Sema/SemaStmtAttr.cpp @@ -56,8 +56,7 @@ static Attr *handleSuppressAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range) { if (A.getNumArgs() < 1) { - S.Diag(A.getLoc(), diag::err_attribute_too_few_arguments) - << A.getName() << 1; + S.Diag(A.getLoc(), diag::err_attribute_too_few_arguments) << A << 1; return nullptr; } @@ -284,8 +283,7 @@ unsigned NumArgs = A.getNumArgs(); if (NumArgs > 1) { - S.Diag(A.getLoc(), diag::err_attribute_too_many_arguments) << A.getName() - << 1; + S.Diag(A.getLoc(), diag::err_attribute_too_many_arguments) << A << 1; return nullptr; } @@ -297,7 +295,7 @@ if (!E->isIntegerConstantExpr(ArgVal, S.Context)) { S.Diag(A.getLoc(), diag::err_attribute_argument_type) - << A.getName() << AANT_ArgumentIntegerConstant << E->getSourceRange(); + << A << AANT_ArgumentIntegerConstant << E->getSourceRange(); return nullptr; } @@ -306,7 +304,7 @@ if (Val <= 0) { S.Diag(A.getRange().getBegin(), diag::err_attribute_requires_positive_integer) - << A.getName(); + << A; return nullptr; } UnrollFactor = Val; Index: lib/Sema/SemaType.cpp =================================================================== --- lib/Sema/SemaType.cpp +++ lib/Sema/SemaType.cpp @@ -5815,8 +5815,8 @@ // Check the attribute arguments. if (Attr.getNumArgs() != 1) { - S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) - << Attr.getName() << 1; + S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << Attr + << 1; Attr.setInvalid(); return; } @@ -5951,8 +5951,8 @@ S.getSourceManager().getImmediateExpansionRange(AttrLoc).getBegin(); if (!attr.isArgIdent(0)) { - S.Diag(AttrLoc, diag::err_attribute_argument_type) - << attr.getName() << AANT_ArgumentString; + S.Diag(AttrLoc, diag::err_attribute_argument_type) << attr + << AANT_ArgumentString; attr.setInvalid(); return true; } @@ -6122,14 +6122,14 @@ // Check the attribute arguments. if (!attr.isArgIdent(0)) { S.Diag(attr.getLoc(), diag::err_attribute_argument_type) - << attr.getName() << AANT_ArgumentString; + << attr << AANT_ArgumentString; attr.setInvalid(); return true; } Qualifiers::GC GCAttr; if (attr.getNumArgs() > 1) { - S.Diag(attr.getLoc(), diag::err_attribute_wrong_number_arguments) - << attr.getName() << 1; + S.Diag(attr.getLoc(), diag::err_attribute_wrong_number_arguments) << attr + << 1; attr.setInvalid(); return true; } @@ -6338,11 +6338,9 @@ // pointer-to-member types. if (!isa(Desugared)) { if (Type->isMemberPointerType()) - S.Diag(Attr.getLoc(), diag::err_attribute_no_member_pointers) - << Attr.getName(); + S.Diag(Attr.getLoc(), diag::err_attribute_no_member_pointers) << Attr; else - S.Diag(Attr.getLoc(), diag::err_attribute_pointers_only) - << Attr.getName() << 0; + S.Diag(Attr.getLoc(), diag::err_attribute_pointers_only) << Attr << 0; return true; } @@ -6906,8 +6904,8 @@ Sema &S) { // Check the attribute arguments. if (Attr.getNumArgs() != 1) { - S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) - << Attr.getName() << 1; + S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << Attr + << 1; Attr.setInvalid(); return; } @@ -6943,8 +6941,8 @@ Sema &S) { // check the attribute arguments. if (Attr.getNumArgs() != 1) { - S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) - << Attr.getName() << 1; + S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << Attr + << 1; return; } @@ -7032,14 +7030,14 @@ Sema &S, VectorType::VectorKind VecKind) { // Target must have NEON if (!S.Context.getTargetInfo().hasFeature("neon")) { - S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) << Attr.getName(); + S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) << Attr; Attr.setInvalid(); return; } // Check the attribute arguments. if (Attr.getNumArgs() != 1) { - S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) - << Attr.getName() << 1; + S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << Attr + << 1; Attr.setInvalid(); return; } @@ -7049,8 +7047,8 @@ if (numEltsExpr->isTypeDependent() || numEltsExpr->isValueDependent() || !numEltsExpr->isIntegerConstantExpr(numEltsInt, S.Context)) { S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) - << Attr.getName() << AANT_ArgumentIntegerConstant - << numEltsExpr->getSourceRange(); + << Attr << AANT_ArgumentIntegerConstant + << numEltsExpr->getSourceRange(); Attr.setInvalid(); return; } @@ -7256,7 +7254,7 @@ // A C++11 attribute on a declarator chunk must appertain to a type. if (attr.isCXX11Attribute() && TAL == TAL_DeclChunk) { state.getSema().Diag(attr.getLoc(), diag::err_attribute_not_type_attr) - << attr.getName(); + << attr; attr.setUsedAsTypeAttr(); } break; Index: test/Sema/attr-coldhot.c =================================================================== --- test/Sema/attr-coldhot.c +++ test/Sema/attr-coldhot.c @@ -3,10 +3,10 @@ int foo() __attribute__((__hot__)); int bar() __attribute__((__cold__)); -int var1 __attribute__((__cold__)); // expected-warning{{'__cold__' attribute only applies to functions}} -int var2 __attribute__((__hot__)); // expected-warning{{'__hot__' attribute only applies to functions}} +int var1 __attribute__((__cold__)); // expected-warning{{'cold' attribute only applies to functions}} +int var2 __attribute__((__hot__)); // expected-warning{{'hot' attribute only applies to functions}} -int qux() __attribute__((__hot__)) __attribute__((__cold__)); // expected-error{{'__cold__' and 'hot' attributes are not compatible}} \ +int qux() __attribute__((__hot__)) __attribute__((__cold__)); // expected-error{{'cold' and 'hot' attributes are not compatible}} \ // expected-note{{conflicting attribute is here}} -int baz() __attribute__((__cold__)) __attribute__((__hot__)); // expected-error{{'__hot__' and 'cold' attributes are not compatible}} \ +int baz() __attribute__((__cold__)) __attribute__((__hot__)); // expected-error{{'hot' and 'cold' attributes are not compatible}} \ // expected-note{{conflicting attribute is here}} Index: test/Sema/attr-min-vector-width.c =================================================================== --- test/Sema/attr-min-vector-width.c +++ test/Sema/attr-min-vector-width.c @@ -1,16 +1,16 @@ // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s int i; -void f(void) __attribute__((__min_vector_width__(i))); /* expected-error {{'__min_vector_width__' attribute requires an integer constant}} */ +void f(void) __attribute__((__min_vector_width__(i))); /* expected-error {{'min_vector_width' attribute requires an integer constant}} */ void f2(void) __attribute__((__min_vector_width__(128))); -void f3(void) __attribute__((__min_vector_width__(128), __min_vector_width__(256))); /* expected-warning {{attribute '__min_vector_width__' is already applied with different parameters}} */ +void f3(void) __attribute__((__min_vector_width__(128), __min_vector_width__(256))); /* expected-warning {{attribute 'min_vector_width' is already applied with different parameters}} */ -void f4(void) __attribute__((__min_vector_width__())); /* expected-error {{'__min_vector_width__' attribute takes one argument}} */ +void f4(void) __attribute__((__min_vector_width__())); /* expected-error {{'min_vector_width' attribute takes one argument}} */ -void f5(void) __attribute__((__min_vector_width__(128, 256))); /* expected-error {{'__min_vector_width__' attribute takes one argument}} */ +void f5(void) __attribute__((__min_vector_width__(128, 256))); /* expected-error {{'min_vector_width' attribute takes one argument}} */ void f6(void) { - int x __attribute__((__min_vector_width__(128))) = 0; /* expected-error {{'__min_vector_width__' attribute only applies to functions}} */ + int x __attribute__((__min_vector_width__(128))) = 0; /* expected-error {{'min_vector_width' attribute only applies to functions}} */ } Index: test/Sema/attr-minsize.c =================================================================== --- test/Sema/attr-minsize.c +++ test/Sema/attr-minsize.c @@ -2,4 +2,4 @@ int foo() __attribute__((__minsize__)); -int var1 __attribute__((__minsize__)); // expected-error{{'__minsize__' attribute only applies to functions and Objective-C methods}} +int var1 __attribute__((__minsize__)); // expected-error{{'minsize' attribute only applies to functions and Objective-C methods}} Index: test/Sema/attr-unavailable-message.c =================================================================== --- test/Sema/attr-unavailable-message.c +++ test/Sema/attr-unavailable-message.c @@ -8,7 +8,7 @@ void bar() __attribute__((__unavailable__)); // expected-note {{explicitly marked unavailable}} -int quux(void) __attribute__((__unavailable__(12))); // expected-error {{'__unavailable__' attribute requires a string}} +int quux(void) __attribute__((__unavailable__(12))); // expected-error {{'unavailable' attribute requires a string}} #define ACCEPTABLE "Use something else" int quux2(void) __attribute__((__unavailable__(ACCEPTABLE))); Index: test/SemaObjC/attr-objc-exception.m =================================================================== --- test/SemaObjC/attr-objc-exception.m +++ test/SemaObjC/attr-objc-exception.m @@ -7,10 +7,9 @@ @end + __attribute__((__objc_exception__)) // expected-error {{'objc_exception' attribute only applies to Objective-C interfaces}} + int X; -__attribute__((__objc_exception__)) // expected-error {{'__objc_exception__' attribute only applies to Objective-C interfaces}} -int X; - -__attribute__((__objc_exception__)) // expected-error {{'__objc_exception__' attribute only applies to Objective-C interfaces}} -void foo(); - +__attribute__((__objc_exception__)) // expected-error {{'objc_exception' attribute only applies to Objective-C interfaces}} +void +foo(); Index: test/SemaObjC/method-sentinel-attr.m =================================================================== --- test/SemaObjC/method-sentinel-attr.m +++ test/SemaObjC/method-sentinel-attr.m @@ -10,10 +10,10 @@ - (void) foo5 : (int)x, ... __attribute__ ((__sentinel__(1))); // expected-note {{method has been explicitly marked sentinel here}} - (void) foo6 : (int)x, ... __attribute__ ((__sentinel__(5))); // expected-note {{method has been explicitly marked sentinel here}} - (void) foo7 : (int)x, ... __attribute__ ((__sentinel__(0))); // expected-note {{method has been explicitly marked sentinel here}} -- (void) foo8 : (int)x, ... __attribute__ ((__sentinel__("a"))); // expected-error {{'__sentinel__' attribute requires parameter 1 to be an integer constant}} +- (void)foo8:(int)x, ... __attribute__((__sentinel__("a"))); // expected-error {{'sentinel' attribute requires parameter 1 to be an integer constant}} - (void) foo9 : (int)x, ... __attribute__ ((__sentinel__(-1))); // expected-error {{'sentinel' parameter 1 less than zero}} - (void) foo10 : (int)x, ... __attribute__ ((__sentinel__(1,1))); -- (void) foo11 : (int)x, ... __attribute__ ((__sentinel__(1,1,3))); // expected-error {{'__sentinel__' attribute takes no more than 2 arguments}} +- (void)foo11:(int)x, ... __attribute__((__sentinel__(1, 1, 3))); // expected-error {{'sentinel' attribute takes no more than 2 arguments}} - (void) foo12 : (int)x, ... ATTR; // expected-note {{method has been explicitly marked sentinel here}} // rdar://7975788 Index: utils/TableGen/ClangAttrEmitter.cpp =================================================================== --- utils/TableGen/ClangAttrEmitter.cpp +++ utils/TableGen/ClangAttrEmitter.cpp @@ -3335,7 +3335,7 @@ SS << (Warn ? "warn_attribute_wrong_decl_type_str" : "err_attribute_wrong_decl_type_str"); SS << ")\n"; - SS << " << Attr.getName() << "; + SS << " << Attr << "; SS << CalculateDiagnostic(*SubjectObj) << ";\n"; SS << " return false;\n"; SS << " }\n";