#include "TestingSupport.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/AST/Stmt.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/ASTMatchers/ASTMatchers.h" #include "clang/Analysis/FlowSensitive/NoopAnalysis.h" #include "clang/Basic/LLVM.h" #include "clang/Basic/LangOptions.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/TokenKinds.h" #include "clang/Lex/Lexer.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSet.h" #include "llvm/Support/Error.h" #include "llvm/Testing/Annotations/Annotations.h" #include "gtest/gtest.h" #include <cassert> #include <functional> #include <string> #include <system_error> #include <utility> #include <vector> usingnamespaceclang; usingnamespacedataflow; usingnamespaceast_matchers; static bool isAnnotationDirectlyAfterStatement(const Stmt *Stmt, unsigned AnnotationBegin, const SourceManager &SourceManager, const LangOptions &LangOptions) { … } llvm::DenseMap<unsigned, std::string> test::buildLineToAnnotationMapping( const SourceManager &SM, const LangOptions &LangOpts, SourceRange BoundingRange, llvm::Annotations AnnotatedCode) { … } llvm::Expected<llvm::DenseMap<const Stmt *, std::string>> test::buildStatementToAnnotationMapping(const FunctionDecl *Func, llvm::Annotations AnnotatedCode) { … } llvm::Error test::checkDataflowWithNoopAnalysis( llvm::StringRef Code, std::function< void(const llvm::StringMap<DataflowAnalysisState<NoopLattice>> &, ASTContext &)> VerifyResults, DataflowAnalysisOptions Options, LangStandard::Kind Std, llvm::StringRef TargetFun) { … } llvm::Error test::checkDataflowWithNoopAnalysis( llvm::StringRef Code, ast_matchers::internal::Matcher<FunctionDecl> TargetFuncMatcher, std::function< void(const llvm::StringMap<DataflowAnalysisState<NoopLattice>> &, ASTContext &)> VerifyResults, DataflowAnalysisOptions Options, LangStandard::Kind Std, std::function<llvm::StringMap<QualType>(QualType)> SyntheticFieldCallback) { … } const ValueDecl *test::findValueDecl(ASTContext &ASTCtx, llvm::StringRef Name) { … } const IndirectFieldDecl *test::findIndirectFieldDecl(ASTContext &ASTCtx, llvm::StringRef Name) { … } std::vector<const Formula *> test::parseFormulas(Arena &A, StringRef Lines) { … }