CheckerHelpers.h revision 280031
1//== CheckerHelpers.h - Helper functions for checkers ------------*- C++ -*--=// 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 defines CheckerVisitor. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CHECKERHELPERS_H 15#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CHECKERHELPERS_H 16 17#include "clang/AST/Stmt.h" 18 19namespace clang { 20 21namespace ento { 22 23bool containsMacro(const Stmt *S); 24bool containsEnum(const Stmt *S); 25bool containsStaticLocal(const Stmt *S); 26bool containsBuiltinOffsetOf(const Stmt *S); 27template <class T> bool containsStmt(const Stmt *S) { 28 if (isa<T>(S)) 29 return true; 30 31 for (Stmt::const_child_range I = S->children(); I; ++I) 32 if (const Stmt *child = *I) 33 if (containsStmt<T>(child)) 34 return true; 35 36 return false; 37} 38 39} // end GR namespace 40 41} // end clang namespace 42 43#endif 44