1 //===--- ModelConsumer.cpp - ASTConsumer for consuming model files --------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// This file implements an ASTConsumer for consuming model files.
13 /// This ASTConsumer handles the AST of a parsed model file. All top level
14 /// function definitions will be collected from that model file for later
15 /// retrieval during the static analysis. The body of these functions will not
16 /// be injected into the ASTUnit of the analyzed translation unit. It will be
17 /// available through the BodyFarm which is utilized by the AnalysisDeclContext
20 //===----------------------------------------------------------------------===//
22 #include "clang/StaticAnalyzer/Frontend/ModelConsumer.h"
23 #include "clang/AST/Decl.h"
24 #include "clang/AST/DeclGroup.h"
26 using namespace clang;
29 ModelConsumer::ModelConsumer(llvm::StringMap<Stmt *> &Bodies)
32 bool ModelConsumer::HandleTopLevelDecl(DeclGroupRef D) {
33 for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I) {
35 // Only interested in definitions.
36 const FunctionDecl *func = llvm::dyn_cast<FunctionDecl>(*I);
37 if (func && func->hasBody()) {
38 Bodies.insert(std::make_pair(func->getName(), func->getBody()));