Richard Smith | 534986f | 2012-04-14 00:33:13 +0000 | [diff] [blame^] | 1 | //===--- SemaStmtAttr.cpp - Statement Attribute Handling ------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements stmt-related attribute processing. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "clang/Sema/SemaInternal.h" |
| 15 | #include "TargetAttributesSema.h" |
| 16 | #include "clang/AST/ASTContext.h" |
| 17 | #include "clang/Basic/SourceManager.h" |
| 18 | #include "clang/Sema/DelayedDiagnostic.h" |
| 19 | #include "clang/Sema/Lookup.h" |
| 20 | #include "llvm/ADT/StringExtras.h" |
| 21 | using namespace clang; |
| 22 | using namespace sema; |
| 23 | |
| 24 | |
| 25 | static Attr *ProcessStmtAttribute(Sema &S, Stmt *St, const AttributeList &A) { |
| 26 | switch (A.getKind()) { |
| 27 | default: |
| 28 | // if we're here, then we parsed an attribute, but didn't recognize it as a |
| 29 | // statement attribute => it is declaration attribute |
| 30 | S.Diag(A.getRange().getBegin(), diag::warn_attribute_invalid_on_stmt) << |
| 31 | A.getName()->getName(); |
| 32 | return 0; |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | StmtResult Sema::ProcessStmtAttributes(Stmt *S, AttributeList *AttrList, |
| 37 | SourceRange Range) { |
| 38 | AttrVec Attrs; |
| 39 | for (const AttributeList* l = AttrList; l; l = l->getNext()) { |
| 40 | if (Attr *a = ProcessStmtAttribute(*this, S, *l)) |
| 41 | Attrs.push_back(a); |
| 42 | } |
| 43 | |
| 44 | if (Attrs.empty()) |
| 45 | return S; |
| 46 | |
| 47 | return ActOnAttributedStmt(Range.getBegin(), Attrs, S); |
| 48 | } |