| //===--- SemaStmtAttr.cpp - Statement Attribute Handling ------------------===// |
| // |
| // The LLVM Compiler Infrastructure |
| // |
| // This file is distributed under the University of Illinois Open Source |
| // License. See LICENSE.TXT for details. |
| // |
| //===----------------------------------------------------------------------===// |
| // |
| // This file implements stmt-related attribute processing. |
| // |
| //===----------------------------------------------------------------------===// |
| |
| #include "clang/Sema/SemaInternal.h" |
| #include "TargetAttributesSema.h" |
| #include "clang/AST/ASTContext.h" |
| #include "clang/Basic/SourceManager.h" |
| #include "clang/Sema/DelayedDiagnostic.h" |
| #include "clang/Sema/Lookup.h" |
| #include "llvm/ADT/StringExtras.h" |
| using namespace clang; |
| using namespace sema; |
| |
| |
| static Attr *ProcessStmtAttribute(Sema &S, Stmt *St, const AttributeList &A) { |
| switch (A.getKind()) { |
| default: |
| // if we're here, then we parsed an attribute, but didn't recognize it as a |
| // statement attribute => it is declaration attribute |
| S.Diag(A.getRange().getBegin(), diag::warn_attribute_invalid_on_stmt) << |
| A.getName()->getName(); |
| return 0; |
| } |
| } |
| |
| StmtResult Sema::ProcessStmtAttributes(Stmt *S, AttributeList *AttrList, |
| SourceRange Range) { |
| AttrVec Attrs; |
| for (const AttributeList* l = AttrList; l; l = l->getNext()) { |
| if (Attr *a = ProcessStmtAttribute(*this, S, *l)) |
| Attrs.push_back(a); |
| } |
| |
| if (Attrs.empty()) |
| return S; |
| |
| return ActOnAttributedStmt(Range.getBegin(), Attrs, S); |
| } |