Add missing "classof" methods to NonNullAttr, fixing a heisencrash.

llvm-svn: 54373
This commit is contained in:
Ted Kremenek 2008-08-05 21:29:52 +00:00
parent ee12a7aeff
commit 182ab758a3
1 changed files with 6 additions and 5 deletions

View File

@ -231,17 +231,15 @@ class NonNullAttr : public Attr {
unsigned* ArgNums; unsigned* ArgNums;
unsigned Size; unsigned Size;
public: public:
NonNullAttr(unsigned* arg_nums = 0, unsigned size = 0) : Attr(NonNull) { NonNullAttr(unsigned* arg_nums = 0, unsigned size = 0) : Attr(NonNull),
ArgNums(0), Size(0) {
if (size) { if (size) {
assert (arg_nums); assert (arg_nums);
ArgNums = new unsigned[size]; ArgNums = new unsigned[size];
Size = size; Size = size;
memcpy(ArgNums, arg_nums, sizeof(*ArgNums)*size); memcpy(ArgNums, arg_nums, sizeof(*ArgNums)*size);
} }
else {
ArgNums = 0;
Size = 0;
}
} }
virtual ~NonNullAttr() { virtual ~NonNullAttr() {
@ -251,6 +249,9 @@ public:
bool isNonNull(unsigned arg) const { bool isNonNull(unsigned arg) const {
return ArgNums ? std::binary_search(ArgNums, ArgNums+Size, arg) : true; return ArgNums ? std::binary_search(ArgNums, ArgNums+Size, arg) : true;
} }
static bool classof(const Attr *A) { return A->getKind() == NonNull; }
static bool classof(const NonNullAttr *A) { return true; }
}; };
class FormatAttr : public Attr { class FormatAttr : public Attr {