Error : llvm/include/llvm/Pass.h:188: error: incomplete type 'llvm::DominatorTree' used in nested name specifier

I am creating a new pass (function pass) called Dfl from the Hello
example and notes on "Writing an LLVM Pass". When I compile the
program I get inncomplete type error (llvm/include/llvm/Pass.h:188:
error: incomplete type 'llvm::DominatorTree' used in nested name
specifier). The code is given below.


struct Dfl : public FunctionPass {
    raw_ostream *Out;
    static char ID;
    Dfl() : FunctionPass(&ID) { }
    virtual bool runOnFunction(Function &F) {
      // //BlocksCounter++; EdgesCounter++; InstCounter++;
      bool modified=false;
      errs() << "In Dfl for Function : " << F.getName();
      if (F.empty()) errs() << " is empty." << "\n";
      else errs() << "\n";
      // DT = &getAnalysis<DominatorTree>();
      modified = printDfl(Out, &F); // , &DT);
      return modified;
    // pass interface to other passes
    virtual void getAnalysisUsage(AnalysisUsage &AU) const {
      AU.addRequired<DominatorTree>(); /// ***error
line ***********

}; // end struc Dfl

Hi Surinder,

Did you remember to #include “llvm/Analysis/Dominators.h”?



Thank you, that has fixed the compilation error.