Consumed analysis: add 'consumable' class attribute.
Patch by chris.wailes@gmail.com
Adds the 'consumable' attribute that can be attached to classes. This replaces
the previous method of scanning a class's methods to see if any of them have
consumed analysis attributes attached to them. If consumed analysis attributes
are attached to methods of a class that isn't marked 'consumable' a warning
is generated.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189702 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/warn-consumed-parsing.cpp b/test/SemaCXX/warn-consumed-parsing.cpp
index 23df1d1..ae71e29 100644
--- a/test/SemaCXX/warn-consumed-parsing.cpp
+++ b/test/SemaCXX/warn-consumed-parsing.cpp
@@ -1,29 +1,35 @@
// RUN: %clang_cc1 -fsyntax-only -verify -Wconsumed -std=c++11 %s
+#define CONSUMABLE __attribute__ ((consumable))
#define CONSUMES __attribute__ ((consumes))
#define TESTS_UNCONSUMED __attribute__ ((tests_unconsumed))
#define CALLABLE_WHEN_UNCONSUMED __attribute__ ((callable_when_unconsumed))
class AttrTester0 {
- void Consumes(void) __attribute__ ((consumes(42))); // expected-error {{attribute takes no arguments}}
- bool TestsUnconsumed(void) __attribute__ ((tests_unconsumed(42))); // expected-error {{attribute takes no arguments}}
- void CallableWhenUnconsumed(void)
+ void Consumes() __attribute__ ((consumes(42))); // expected-error {{attribute takes no arguments}}
+ bool TestsUnconsumed() __attribute__ ((tests_unconsumed(42))); // expected-error {{attribute takes no arguments}}
+ void CallableWhenUnconsumed()
__attribute__ ((callable_when_unconsumed(42))); // expected-error {{attribute takes no arguments}}
};
int var0 CONSUMES; // expected-warning {{'consumes' attribute only applies to methods}}
int var1 TESTS_UNCONSUMED; // expected-warning {{'tests_unconsumed' attribute only applies to methods}}
int var2 CALLABLE_WHEN_UNCONSUMED; // expected-warning {{'callable_when_unconsumed' attribute only applies to methods}}
+int var3 CONSUMABLE; // expected-warning {{'consumable' attribute only applies to classes}}
-void function0(void) CONSUMES; // expected-warning {{'consumes' attribute only applies to methods}}
-void function1(void) TESTS_UNCONSUMED; // expected-warning {{'tests_unconsumed' attribute only applies to methods}}
-void function2(void) CALLABLE_WHEN_UNCONSUMED; // expected-warning {{'callable_when_unconsumed' attribute only applies to methods}}
+void function0() CONSUMES; // expected-warning {{'consumes' attribute only applies to methods}}
+void function1() TESTS_UNCONSUMED; // expected-warning {{'tests_unconsumed' attribute only applies to methods}}
+void function2() CALLABLE_WHEN_UNCONSUMED; // expected-warning {{'callable_when_unconsumed' attribute only applies to methods}}
+void function3() CONSUMABLE; // expected-warning {{'consumable' attribute only applies to classes}}
-class AttrTester1 {
- void consumes(void) CONSUMES;
- bool testsUnconsumed(void) TESTS_UNCONSUMED;
+class CONSUMABLE AttrTester1 {
+ void callableWhenUnconsumed() CALLABLE_WHEN_UNCONSUMED;
+ void consumes() CONSUMES;
+ bool testsUnconsumed() TESTS_UNCONSUMED;
};
class AttrTester2 {
- void callableWhenUnconsumed(void) CALLABLE_WHEN_UNCONSUMED;
+ void callableWhenUnconsumed() CALLABLE_WHEN_UNCONSUMED; // expected-warning {{consumed analysis attribute is attached to class 'AttrTester2' which isn't marked as consumable}}
+ void consumes() CONSUMES; // expected-warning {{consumed analysis attribute is attached to class 'AttrTester2' which isn't marked as consumable}}
+ bool testsUnconsumed() TESTS_UNCONSUMED; // expected-warning {{consumed analysis attribute is attached to class 'AttrTester2' which isn't marked as consumable}}
};