Blocks,
Const,
Pure,
- Cleanup
+ Cleanup,
+ Nodebug
};
private:
static bool classof(const CleanupAttr *A) { return true; }
};
+class NodebugAttr : public Attr {
+public:
+ NodebugAttr() : Attr(Nodebug) {}
+
+ // Implement isa/cast/dyncast/etc.
+
+ static bool classof(const Attr *A) { return A->getKind() == Nodebug; }
+ static bool classof(const DeprecatedAttr *A) { return true; }
+};
+
} // end namespace clang
#endif
case 7:
if (!memcmp(Str, "aligned", 7)) return AT_aligned;
if (!memcmp(Str, "cleanup", 7)) return AT_cleanup;
+ if (!memcmp(Str, "nodebug", 7)) return AT_nodebug;
if (!memcmp(Str, "nonnull", 7)) return AT_nonnull;
if (!memcmp(Str, "nothrow", 7)) return AT_nothrow;
if (!memcmp(Str, "objc_gc", 7)) return AT_objc_gc;
cast<ValueDecl>(D)->setType(NewTy);
}
+static void HandleNodebugAttr(Decl *d, const AttributeList &Attr, Sema &S) {
+ // check the attribute arguments.
+ if (Attr.getNumArgs() > 0) {
+ S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
+ return;
+ }
+ FunctionDecl *Fn = dyn_cast<FunctionDecl>(d);
+ if (!Fn) {
+ S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
+ << "nodebug" << "function";
+ return;
+ }
+
+ d->addAttr(new NodebugAttr());
+}
+
//===----------------------------------------------------------------------===//
// Top Level Sema Entry Points
//===----------------------------------------------------------------------===//
case AttributeList::AT_const: HandleConstAttr (D, Attr, S); break;
case AttributeList::AT_pure: HandlePureAttr (D, Attr, S); break;
case AttributeList::AT_cleanup: HandleCleanupAttr (D, Attr, S); break;
+ case AttributeList::AT_nodebug: HandleNodebugAttr (D, Attr, S); break;
default:
#if 0
// TODO: when we have the full set of attributes, warn about unknown ones.
- S.Diag(Attr->getLoc(), diag::warn_attribute_ignored) << Attr->getName();
+ S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
#endif
break;
}
--- /dev/null
+// RUN: clang %s -verify -fsyntax-only
+
+int a __attribute__((nodebug)); // expected-warning {{'nodebug' attribute only applies to function types}}
+
+void t1() __attribute__((nodebug));
+
+void t2() __attribute__((nodebug(2))); // expected-error {{attribute requires 0 argument(s)}}
+