Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
Removing the alloc_size attribute. The attribute was semantically han…
Browse files Browse the repository at this point in the history
…dled, but silently ignored. Most of this feature was already reverted in June 2012 (r159016), this just cleans up the pieces left over.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197866 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
AaronBallman committed Dec 21, 2013
1 parent c45cdf7 commit c047507
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 84 deletions.
5 changes: 0 additions & 5 deletions include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,6 @@ def AlignMac68k : InheritableAttr {
let SemaHandler = 0;
}

def AllocSize : InheritableAttr {
let Spellings = [GNU<"alloc_size">, CXX11<"gnu", "alloc_size">];
let Args = [VariadicUnsignedArgument<"Args">];
}

def AlwaysInline : InheritableAttr {
let Spellings = [GNU<"always_inline">, CXX11<"gnu", "always_inline">];
let Subjects = SubjectList<[Function]>;
Expand Down
42 changes: 0 additions & 42 deletions lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1177,47 +1177,6 @@ static void possibleTransparentUnionPointerType(QualType &T) {
}
}

static void handleAllocSizeAttr(Sema &S, Decl *D, const AttributeList &Attr) {
if (!isFunctionOrMethod(D)) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
<< Attr.getName() << ExpectedFunctionOrMethod;
return;
}

if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
return;

SmallVector<unsigned, 8> SizeArgs;
for (unsigned i = 0; i < Attr.getNumArgs(); ++i) {
Expr *Ex = Attr.getArgAsExpr(i);
uint64_t Idx;
if (!checkFunctionOrMethodArgumentIndex(S, D, Attr.getName()->getName(),
Attr.getLoc(), i + 1, Ex, Idx))
return;

// check if the function argument is of an integer type
QualType T = getFunctionOrMethodArgType(D, Idx).getNonReferenceType();
if (!T->isIntegerType()) {
S.Diag(Attr.getLoc(), diag::err_attribute_argument_type)
<< Attr.getName() << AANT_ArgumentIntegerConstant
<< Ex->getSourceRange();
return;
}
SizeArgs.push_back(Idx);
}

// check if the function returns a pointer
if (!getFunctionType(D)->getResultType()->isAnyPointerType()) {
S.Diag(Attr.getLoc(), diag::warn_ns_attribute_wrong_return_type)
<< Attr.getName() << 0 /*function*/<< 1 /*pointer*/ << D->getSourceRange();
}

D->addAttr(::new (S.Context)
AllocSizeAttr(Attr.getRange(), S.Context,
SizeArgs.data(), SizeArgs.size(),
Attr.getAttributeSpellingListIndex()));
}

static void handleNonNullAttr(Sema &S, Decl *D, const AttributeList &Attr) {
// GCC ignores the nonnull attribute on K&R style function prototypes, so we
// ignore it as well
Expand Down Expand Up @@ -3854,7 +3813,6 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
break;
case AttributeList::AT_Alias: handleAliasAttr (S, D, Attr); break;
case AttributeList::AT_Aligned: handleAlignedAttr (S, D, Attr); break;
case AttributeList::AT_AllocSize: handleAllocSizeAttr (S, D, Attr); break;
case AttributeList::AT_AlwaysInline:
handleSimpleAttribute<AlwaysInlineAttr>(S, D, Attr); break;
case AttributeList::AT_AnalyzerNoReturn:
Expand Down
8 changes: 0 additions & 8 deletions test/Misc/ast-dump-attr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,6 @@ __attribute__((type_tag_for_datatype(ident1,int)));
// CHECK: VarDecl{{.*}}TestType
// CHECK-NEXT: TypeTagForDatatypeAttr{{.*}} int

void *TestVariadicUnsigned1(int) __attribute__((alloc_size(1)));
// CHECK: FunctionDecl{{.*}}TestVariadicUnsigned1
// CHECK: AllocSizeAttr{{.*}} 0

void *TestVariadicUnsigned2(int, int) __attribute__((alloc_size(1,2)));
// CHECK: FunctionDecl{{.*}}TestVariadicUnsigned2
// CHECK: AllocSizeAttr{{.*}} 0 1

void TestLabel() {
L: __attribute__((unused)) int i;
// CHECK: LabelStmt{{.*}}'L'
Expand Down
27 changes: 0 additions & 27 deletions test/Sema/alloc_size.c

This file was deleted.

2 changes: 0 additions & 2 deletions test/SemaCXX/cxx11-gnu-attrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ void aliasa [[gnu::alias("_Z6alias1v")]] ();
void aligned_fn [[gnu::aligned(32)]] ();
struct [[gnu::aligned(8)]] aligned_struct {};

[[gnu::malloc, gnu::alloc_size(1,2)]] void *alloc_size(int a, int b);

void always_inline [[gnu::always_inline]] ();

__thread int tls_model [[gnu::tls_model("local-exec")]];
Expand Down

0 comments on commit c047507

Please sign in to comment.