diff options
author | John McCall <rjmccall@apple.com> | 2011-09-30 05:12:12 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-09-30 05:12:12 +0000 |
commit | 8dfac0baaf0f81d3945bcb306480e358ba8d1f08 (patch) | |
tree | 686c4b456894ceb992527fd530ed1c80776c0433 /lib/Sema/SemaAttr.cpp | |
parent | e4c6675cccbaac991843def43072687bca50d989 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140846 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaAttr.cpp')
-rw-r--r-- | lib/Sema/SemaAttr.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Sema/SemaAttr.cpp b/lib/Sema/SemaAttr.cpp index cd03069ec8..77410db01f 100644 --- a/lib/Sema/SemaAttr.cpp +++ b/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<CFAuditedTransferAttr>() || + D->hasAttr<CFUnknownTransferAttr>()) + return; + + D->addAttr(::new (Context) CFAuditedTransferAttr(Loc, Context)); +} + typedef std::vector<std::pair<unsigned, SourceLocation> > VisStack; enum { NoVisibility = (unsigned) -1 }; |