From 32f5fe1467c4f6cb9c3efe174cb6c8a374e6e149 Mon Sep 17 00:00:00 2001 From: John McCall Date: Fri, 30 Sep 2011 05:12:12 +0000 Subject: Add explicit attributes to mark functions as having had their CoreFoundation object-transfer properties audited, and add a #pragma to cause them to be automatically applied to functions in a particular span of code. This has to be implemented largely in the preprocessor because of the requirement that the region be entirely contained in a single file; that's hard to impose from the parser without registering for a ton of callbacks. llvm-svn: 140846 --- clang/lib/Sema/SemaAttr.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'clang/lib/Sema/SemaAttr.cpp') diff --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp index cd03069ec85..77410db01f5 100644 --- a/clang/lib/Sema/SemaAttr.cpp +++ b/clang/lib/Sema/SemaAttr.cpp @@ -300,6 +300,18 @@ void Sema::ActOnPragmaUnused(const Token &IdTok, Scope *curScope, VD->addAttr(::new (Context) UnusedAttr(IdTok.getLocation(), Context)); } +void Sema::AddCFAuditedAttribute(Decl *D) { + SourceLocation Loc = PP.getPragmaARCCFCodeAuditedLoc(); + if (!Loc.isValid()) return; + + // Don't add a redundant or conflicting attribute. + if (D->hasAttr() || + D->hasAttr()) + return; + + D->addAttr(::new (Context) CFAuditedTransferAttr(Loc, Context)); +} + typedef std::vector > VisStack; enum { NoVisibility = (unsigned) -1 }; -- cgit v1.2.3