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, bool verbose) { 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 llvm::SmallVector<llvm::StringRef, 1024> builtinNames; const clang::Builtin::Context& BuiltinCtx = m_ASTContext.BuiltinInfo; for (auto i = clang::Builtin::NotBuiltin+1; i != clang::Builtin::FirstTSBuiltin; ++i) { llvm::StringRef Name(BuiltinCtx.getName(i)); if (Name.startswith("__builtin")) builtinNames.emplace_back(Name); } for (auto&& BuiltinInfo: m_ASTContext.getTargetInfo().getTargetBuiltins()) { llvm::StringRef Name(BuiltinInfo.Name); if (!Name.startswith("__builtin")) builtinNames.emplace_back(Name); #ifndef NDEBUG else // Make sure it's already in the list assert(std::find(builtinNames.begin(), builtinNames.end(), Name) == builtinNames.end() && "Not in list!"); #endif } builtinNames.push_back(".*__builtin.*"); differentContent(m_LookupTablesFile, m_DiffPair->m_LookupTablesFile, "lookup tables", verbose, &builtinNames); differentContent(m_IncludedFilesFile, m_DiffPair->m_IncludedFilesFile, "included files", verbose); differentContent(m_ASTFile, m_DiffPair->m_ASTFile, "AST", verbose); if (m_Module) { assert(m_CodeGen && "Must have CodeGen set"); // We want to skip the intrinsics builtinNames.clear(); for (const auto& Func : m_Module->getFunctionList()) { if (Func.isIntrinsic()) builtinNames.emplace_back(Func.getName()); } differentContent(m_LLVMModuleFile, m_DiffPair->m_LLVMModuleFile, "llvm Module", verbose, &builtinNames); } differentContent(m_MacrosFile, m_DiffPair->m_MacrosFile, "Macro Definitions", verbose); }
void ClangInternalState::compare(ClangInternalState& other) { 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, other.m_LookupTablesFile, differences, &builtinNames)) { llvm::errs() << "Differences in the lookup tables\n"; llvm::errs() << differences << "\n"; differences = ""; } if (differentContent(m_IncludedFilesFile, other.m_IncludedFilesFile, differences)) { llvm::errs() << "Differences in the included files\n"; llvm::errs() << differences << "\n"; differences = ""; } if (differentContent(m_ASTFile, other.m_ASTFile, differences)) { llvm::errs() << "Differences in the AST \n"; llvm::errs() << differences << "\n"; differences = ""; } if (differentContent(m_LLVMModuleFile, other.m_LLVMModuleFile, differences)){ llvm::errs() << "Differences in the llvm Module \n"; llvm::errs() << differences << "\n"; differences = ""; } if (differentContent(m_MacrosFile, other.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 = ""; } }