mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1185188 - Support multiple clang-plugin annotations; r=ehsan
This commit is contained in:
parent
818972d2a3
commit
b2987686b9
@ -232,12 +232,17 @@ public:
|
||||
TraverseDecl(ctx.getTranslationUnitDecl());
|
||||
}
|
||||
|
||||
static bool hasCustomAnnotation(const Decl *d, const char *spelling) {
|
||||
AnnotateAttr *attr = d->getAttr<AnnotateAttr>();
|
||||
if (!attr)
|
||||
return false;
|
||||
static bool hasCustomAnnotation(const Decl *D, const char *Spelling) {
|
||||
iterator_range<specific_attr_iterator<AnnotateAttr> > Attrs =
|
||||
D->specific_attrs<AnnotateAttr>();
|
||||
|
||||
return attr->getAnnotation() == spelling;
|
||||
for (AnnotateAttr *Attr : Attrs) {
|
||||
if (Attr->getAnnotation() == Spelling) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void HandleUnusedExprResult(const Stmt *stmt) {
|
||||
|
17
build/clang-plugin/tests/TestMultipleAnnotations.cpp
Normal file
17
build/clang-plugin/tests/TestMultipleAnnotations.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#define MOZ_MUST_USE __attribute__((annotate("moz_must_use")))
|
||||
#define MOZ_STACK_CLASS __attribute__((annotate("moz_stack_class")))
|
||||
|
||||
class MOZ_MUST_USE MOZ_STACK_CLASS TestClass {};
|
||||
|
||||
TestClass foo; // expected-error {{variable of type 'TestClass' only valid on the stack}}
|
||||
|
||||
TestClass f()
|
||||
{
|
||||
TestClass bar;
|
||||
return bar;
|
||||
}
|
||||
|
||||
void g()
|
||||
{
|
||||
f(); // expected-error {{Unused MOZ_MUST_USE value of type 'TestClass'}}
|
||||
}
|
@ -9,6 +9,7 @@ SOURCES += [
|
||||
'TestCustomHeap.cpp',
|
||||
'TestExplicitOperatorBool.cpp',
|
||||
'TestGlobalClass.cpp',
|
||||
'TestMultipleAnnotations.cpp',
|
||||
'TestMustOverride.cpp',
|
||||
'TestMustUse.cpp',
|
||||
'TestNANTestingExpr.cpp',
|
||||
|
Loading…
Reference in New Issue
Block a user