diff options
Diffstat (limited to 'clang/lib/Sema/SemaDeclAttr.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 46 | 
1 files changed, 30 insertions, 16 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index f79523983ed8..838fd48357fb 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -2673,7 +2673,7 @@ static void handleAvailabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) {          if (IOSToWatchOSMapping) {            if (auto MappedVersion = IOSToWatchOSMapping->map(                    Version, MinimumWatchOSVersion, None)) { -            return MappedVersion.getValue(); +            return MappedVersion.value();            }          } @@ -2682,10 +2682,10 @@ static void handleAvailabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) {          if (NewMajor >= 2) {            if (Version.getMinor()) {              if (Version.getSubminor()) -              return VersionTuple(NewMajor, Version.getMinor().getValue(), -                                  Version.getSubminor().getValue()); +              return VersionTuple(NewMajor, Version.getMinor().value(), +                                  Version.getSubminor().value());              else -              return VersionTuple(NewMajor, Version.getMinor().getValue()); +              return VersionTuple(NewMajor, Version.getMinor().value());            }            return VersionTuple(NewMajor);          } @@ -3886,12 +3886,10 @@ static void handleFormatAttr(Sema &S, Decl *D, const ParsedAttr &AL) {    // check if the function is variadic if the 3rd argument non-zero    if (FirstArg != 0) { -    if (isFunctionOrMethodVariadic(D)) { +    if (isFunctionOrMethodVariadic(D))        ++NumArgs; // +1 for ... -    } else { -      S.Diag(D->getLocation(), diag::err_format_attribute_requires_variadic); -      return; -    } +    else +      S.Diag(D->getLocation(), diag::warn_gcc_requires_variadic_function) << AL;    }    // strftime requires FirstArg to be 0 because it doesn't read from any @@ -4314,13 +4312,6 @@ void Sema::AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,      return;    uint64_t AlignVal = Alignment.getZExtValue(); -  // 16 byte ByVal alignment not due to a vector member is not honoured by XL -  // on AIX. Emit a warning here that users are generating binary incompatible -  // code to be safe. -  if (AlignVal >= 16 && isa<FieldDecl>(D) && -      Context.getTargetInfo().getTriple().isOSAIX()) -    Diag(AttrLoc, diag::warn_not_xl_compatible) << E->getSourceRange(); -    // C++11 [dcl.align]p2:    //   -- if the constant expression evaluates to zero, the alignment    //      specifier shall have no effect @@ -8002,6 +7993,26 @@ static void handleZeroCallUsedRegsAttr(Sema &S, Decl *D, const ParsedAttr &AL) {    D->addAttr(ZeroCallUsedRegsAttr::Create(S.Context, Kind, AL));  } +static void handleFunctionReturnThunksAttr(Sema &S, Decl *D, +                                           const ParsedAttr &AL) { +  StringRef KindStr; +  SourceLocation LiteralLoc; +  if (!S.checkStringLiteralArgumentAttr(AL, 0, KindStr, &LiteralLoc)) +    return; + +  FunctionReturnThunksAttr::Kind Kind; +  if (!FunctionReturnThunksAttr::ConvertStrToKind(KindStr, Kind)) { +    S.Diag(LiteralLoc, diag::warn_attribute_type_not_supported) +        << AL << KindStr; +    return; +  } +  // FIXME: it would be good to better handle attribute merging rather than +  // silently replacing the existing attribute, so long as it does not break +  // the expected codegen tests. +  D->dropAttr<FunctionReturnThunksAttr>(); +  D->addAttr(FunctionReturnThunksAttr::Create(S.Context, Kind, AL)); +} +  static void handleSYCLKernelAttr(Sema &S, Decl *D, const ParsedAttr &AL) {    // The 'sycl_kernel' attribute applies only to function templates.    const auto *FD = cast<FunctionDecl>(D); @@ -8868,6 +8879,9 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL,    case ParsedAttr::AT_ZeroCallUsedRegs:      handleZeroCallUsedRegsAttr(S, D, AL);      break; +  case ParsedAttr::AT_FunctionReturnThunks: +    handleFunctionReturnThunksAttr(S, D, AL); +    break;    // Microsoft attributes:    case ParsedAttr::AT_LayoutVersion:  | 
