diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2016-12-20 08:28:19 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2016-12-20 08:28:19 +0000 |
commit | 4e57f52faea670d545cbe937f52e6e9cf5d19b0b (patch) | |
tree | 0e1a34ef183e1a86041560a01939b35c280421a0 /include | |
parent | 4e23c3c7878efe0251fcf3af27231635a438359e (diff) |
Revert r290149: Add the alloc_size attribute to clang.
This commit fails MSan when running test/CodeGen/object-size.c in
a confusing way. After some discussion with George, it isn't really
clear what is going on here. We can make the MSan failure go away by
testing for the invalid bit, but *why* things are invalid isn't clear.
And yet, other code in the surrounding area is doing precisely this and
testing for invalid.
George is going to take a closer look at this to better understand the
nature of the failure and recommit it, for now backing it out to clean
up MSan builds.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290169 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/Basic/Attr.td | 9 | ||||
-rw-r--r-- | include/clang/Basic/AttrDocs.td | 38 | ||||
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 3 |
3 files changed, 0 insertions, 50 deletions
diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td index f6a5e54b2b..4c8276a553 100644 --- a/include/clang/Basic/Attr.td +++ b/include/clang/Basic/Attr.td @@ -780,15 +780,6 @@ def EmptyBases : InheritableAttr, TargetSpecificAttr<TargetMicrosoftCXXABI> { let Documentation = [EmptyBasesDocs]; } -def AllocSize : InheritableAttr { - let Spellings = [GCC<"alloc_size">]; - let Subjects = SubjectList<[HasFunctionProto], WarnDiag, - "ExpectedFunctionWithProtoType">; - let Args = [IntArgument<"ElemSizeParam">, IntArgument<"NumElemsParam", 1>]; - let TemplateDependent = 1; - let Documentation = [AllocSizeDocs]; -} - def EnableIf : InheritableAttr { let Spellings = [GNU<"enable_if">]; let Subjects = SubjectList<[Function]>; diff --git a/include/clang/Basic/AttrDocs.td b/include/clang/Basic/AttrDocs.td index b57833a15f..5502af2a58 100644 --- a/include/clang/Basic/AttrDocs.td +++ b/include/clang/Basic/AttrDocs.td @@ -206,44 +206,6 @@ to enforce the provided alignment assumption. }]; } -def AllocSizeDocs : Documentation { - let Category = DocCatFunction; - let Content = [{ -The ``alloc_size`` attribute can be placed on functions that return pointers in -order to hint to the compiler how many bytes of memory will be available at the -returned poiner. ``alloc_size`` takes one or two arguments. - -- ``alloc_size(N)`` implies that argument number N equals the number of - available bytes at the returned pointer. -- ``alloc_size(N, M)`` implies that the product of argument number N and - argument number M equals the number of available bytes at the returned - pointer. - -Argument numbers are 1-based. - -An example of how to use ``alloc_size`` - -.. code-block:: c - - void *my_malloc(int a) __attribute__((alloc_size(1))); - void *my_calloc(int a, int b) __attribute__((alloc_size(1, 2))); - - int main() { - void *const p = my_malloc(100); - assert(__builtin_object_size(p, 0) == 100); - void *const a = my_calloc(20, 5); - assert(__builtin_object_size(a, 0) == 100); - } - -.. Note:: This attribute works differently in clang than it does in GCC. - Specifically, clang will only trace ``const`` pointers (as above); we give up - on pointers that are not marked as ``const``. In the vast majority of cases, - this is unimportant, because LLVM has support for the ``alloc_size`` - attribute. However, this may cause mildly unintuitive behavior when used with - other attributes, such as ``enable_if``. - }]; -} - def EnableIfDocs : Documentation { let Category = DocCatFunction; let Content = [{ diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 068f9de673..69322f0f75 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -2297,9 +2297,6 @@ def warn_attribute_pointers_only : Warning< "%0 attribute only applies to%select{| constant}1 pointer arguments">, InGroup<IgnoredAttributes>; def err_attribute_pointers_only : Error<warn_attribute_pointers_only.Text>; -def err_attribute_integers_only : Error< - "%0 attribute argument may only refer to a function parameter of integer " - "type">; def warn_attribute_return_pointers_only : Warning< "%0 attribute only applies to return values that are pointers">, InGroup<IgnoredAttributes>; |