#ifndef LLVM_CLANG_SEMA_ANALYSIS_WARNINGS_H
#define LLVM_CLANG_SEMA_ANALYSIS_WARNINGS_H
-#include "clang/AST/Type.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/DenseMap.h"
namespace clang {
+class BlockExpr;
+class Decl;
class FunctionDecl;
+class ObjCMethodDecl;
+class QualType;
class Sema;
namespace sema {
enum VisitFlag { NotVisited = 0, Visited = 1, Pending = 2 };
llvm::DenseMap<const FunctionDecl*, VisitFlag> VisitedFD;
+ void IssueWarnings(Policy P, const Decl *D, QualType BlockTy);
+
public:
AnalysisBasedWarnings(Sema &s);
Policy getDefaultPolicy() { return DefaultPolicy; }
- void IssueWarnings(Policy P, const Decl *D, QualType BlockTy = QualType());
+ void IssueWarnings(Policy P, const BlockExpr *E);
+ void IssueWarnings(Policy P, const FunctionDecl *D);
+ void IssueWarnings(Policy P, const ObjCMethodDecl *D);
};
}} // end namespace clang::sema
S.SourceMgr.isInSystemHeader(D->getLocation()))
return;
- if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
- // For function templates, class templates and member function templates
- // we'll do the analysis at instantiation time.
- if (FD->isDependentContext())
- return;
- }
+ // For code in dependent contexts, we'll do this at instantiation time.
+ if (cast<DeclContext>(D)->isDependentContext())
+ return;
const Stmt *Body = D->getBody();
assert(Body);
if (P.enableCheckUnreachable)
CheckUnreachable(S, AC);
}
+
+void clang::sema::
+AnalysisBasedWarnings::IssueWarnings(sema::AnalysisBasedWarnings::Policy P,
+ const BlockExpr *E) {
+ return IssueWarnings(P, E->getBlockDecl(), E->getType());
+}
+
+void clang::sema::
+AnalysisBasedWarnings::IssueWarnings(sema::AnalysisBasedWarnings::Policy P,
+ const ObjCMethodDecl *D) {
+ return IssueWarnings(P, D, QualType());
+}
+
+void clang::sema::
+AnalysisBasedWarnings::IssueWarnings(sema::AnalysisBasedWarnings::Policy P,
+ const FunctionDecl *D) {
+ return IssueWarnings(P, D, QualType());
+}
// enabled.
QualType ResultType;
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(dcl)) {
- ResultType = FD->getResultType();
- }
- else {
+ AnalysisWarnings.IssueWarnings(WP, FD);
+ } else {
ObjCMethodDecl *MD = cast<ObjCMethodDecl>(dcl);
- ResultType = MD->getResultType();
+ AnalysisWarnings.IssueWarnings(WP, MD);
}
- AnalysisWarnings.IssueWarnings(WP, dcl);
}
assert(ExprTemporaries.empty() && "Leftover temporaries in function");
return ExprError();
}
+ BlockExpr *Result = new (Context) BlockExpr(BSI->TheDecl, BlockTy,
+ BSI->hasBlockDeclRefExprs);
+
// Issue any analysis-based warnings.
const sema::AnalysisBasedWarnings::Policy &WP =
AnalysisWarnings.getDefaultPolicy();
- AnalysisWarnings.IssueWarnings(WP, BSI->TheDecl, BlockTy);
+ AnalysisWarnings.IssueWarnings(WP, Result);
- Expr *Result = new (Context) BlockExpr(BSI->TheDecl, BlockTy,
- BSI->hasBlockDeclRefExprs);
PopFunctionOrBlockScope();
return Owned(Result);
}