示例#1
0
  void ClangInternalState::compare(const std::string& name) {
    assert(name == m_Name && "Different names!?");
    m_DiffPair.reset(new ClangInternalState(m_ASTContext, m_Preprocessor,
                                            m_Module, m_CodeGen, name));
    std::string differences = "";
    // Ignore the builtins
    typedef llvm::SmallVector<const char*, 1024> Builtins;
    Builtins builtinNames;
    m_ASTContext.BuiltinInfo.GetBuiltinNames(builtinNames);
    for (Builtins::iterator I = builtinNames.begin();
         I != builtinNames.end();) {
      if (llvm::StringRef(*I).startswith("__builtin"))
        I = builtinNames.erase(I);
      else
        ++I;
    }

    builtinNames.push_back(".*__builtin.*");

    if (differentContent(m_LookupTablesFile, m_DiffPair->m_LookupTablesFile,
                         differences, &builtinNames)) {
      llvm::errs() << "Differences in the lookup tables\n";
      llvm::errs() << differences << "\n";
      differences = "";
    }
    if (differentContent(m_IncludedFilesFile, m_DiffPair->m_IncludedFilesFile,
                         differences)) {
      llvm::errs() << "Differences in the included files\n";
      llvm::errs() << differences << "\n";
      differences = "";
    }
    if (differentContent(m_ASTFile, m_DiffPair->m_ASTFile, differences)) {
      llvm::errs() << "Differences in the AST \n";
      llvm::errs() << differences << "\n";
      differences = "";
    }
    if (m_Module) {
      assert(m_CodeGen && "Must have CodeGen set");
      // We want to skip the intrinsics
      builtinNames.clear();
      for (llvm::Module::const_iterator I = m_Module->begin(),
             E = m_Module->end(); I != E; ++I)
        if (I->isIntrinsic())
          builtinNames.push_back(I->getName().data());

      if (differentContent(m_LLVMModuleFile, m_DiffPair->m_LLVMModuleFile,
                           differences, &builtinNames)) {
        llvm::errs() << "Differences in the llvm Module \n";
        llvm::errs() << differences << "\n";
        differences = "";
      }
    }
    if (differentContent(m_MacrosFile, m_DiffPair->m_MacrosFile, differences)){
      llvm::errs() << "Differences in the Macro Definitions \n";
      llvm::errs() << differences << "\n";
      differences = "";
    }
  }
  void ClangInternalState::compare(const std::string& name) {
    assert(name == m_Name && "Different names!?");
    m_DiffPair.reset(new ClangInternalState(m_ASTContext, m_Preprocessor,
                                            m_Module, m_CodeGen, name));
    std::string differences = "";
    // Ignore the builtins
    typedef llvm::SmallVector<const char*, 1024> Builtins;
    Builtins builtinNames;
    const clang::Builtin::Context& BuiltinCtx = m_ASTContext.BuiltinInfo;
    for (unsigned i = clang::Builtin::NotBuiltin+1;
         i != clang::Builtin::FirstTSBuiltin; ++i) {
      const char* Name = BuiltinCtx.getName(i);
      if (!llvm::StringRef(Name).startswith("__builtin"))
        builtinNames.push_back(Name);
    }

    for (auto&& BuiltinInfo: m_ASTContext.getTargetInfo().getTargetBuiltins()) {
      if (!llvm::StringRef(BuiltinInfo.Name).startswith("__builtin"))
        builtinNames.push_back(BuiltinInfo.Name);
    }

    builtinNames.push_back(".*__builtin.*");

    if (differentContent(m_LookupTablesFile, m_DiffPair->m_LookupTablesFile,
                         differences, &builtinNames)) {
      llvm::errs() << "Differences in the lookup tables\n";
      llvm::errs() << differences << "\n";
      differences = "";
    }
    if (differentContent(m_IncludedFilesFile, m_DiffPair->m_IncludedFilesFile,
                         differences)) {
      llvm::errs() << "Differences in the included files\n";
      llvm::errs() << differences << "\n";
      differences = "";
    }
    if (differentContent(m_ASTFile, m_DiffPair->m_ASTFile, differences)) {
      llvm::errs() << "Differences in the AST \n";
      llvm::errs() << differences << "\n";
      differences = "";
    }
    if (m_Module) {
      assert(m_CodeGen && "Must have CodeGen set");
      // We want to skip the intrinsics
      builtinNames.clear();
      for (llvm::Module::const_iterator I = m_Module->begin(),
             E = m_Module->end(); I != E; ++I)
        if (I->isIntrinsic())
          builtinNames.push_back(I->getName().data());

      if (differentContent(m_LLVMModuleFile, m_DiffPair->m_LLVMModuleFile,
                           differences, &builtinNames)) {
        llvm::errs() << "Differences in the llvm Module \n";
        llvm::errs() << differences << "\n";
        differences = "";
      }
    }
    if (differentContent(m_MacrosFile, m_DiffPair->m_MacrosFile, differences)){
      llvm::errs() << "Differences in the Macro Definitions \n";
      llvm::errs() << differences << "\n";
      differences = "";
    }
  }