bool Bytecode::Finalize(DiagnosticsEngine& diags) { for (std::vector<Fixup>::iterator i=m_fixed_fixups.begin(), end=m_fixed_fixups.end(); i != end; ++i) { if (!i->Finalize(diags, i->isJumpTarget() ? diag::err_too_complex_jump : diag::err_too_complex_expression)) return false; if (i->isJumpTarget() && i->isComplexRelative()) { diags.Report(i->getSource().getBegin(), diag::err_invalid_jump_target); return false; } // Do curpos subtraction for IP-relative flagged values. if (i->isIPRelative()) { Location sub_loc = {this, i->getOffset()}; if (!i->SubRelative(m_container->getSection()->getObject(), sub_loc)) diags.Report(i->getSource().getBegin(), diag::err_too_complex_expression); } } if (m_contents.get() != 0) return m_contents->Finalize(*this, diags); return true; }
std::unique_ptr<CheckerManager> ento::createCheckerManager(AnalyzerOptions &opts, const LangOptions &langOpts, ArrayRef<std::string> plugins, DiagnosticsEngine &diags) { std::unique_ptr<CheckerManager> checkerMgr( new CheckerManager(langOpts, &opts)); SmallVector<CheckerOptInfo, 8> checkerOpts; for (unsigned i = 0, e = opts.CheckersControlList.size(); i != e; ++i) { const std::pair<std::string, bool> &opt = opts.CheckersControlList[i]; checkerOpts.push_back(CheckerOptInfo(opt.first.c_str(), opt.second)); } ClangCheckerRegistry allCheckers(plugins, &diags); allCheckers.initializeManager(*checkerMgr, checkerOpts); checkerMgr->finishedCheckerRegistration(); for (unsigned i = 0, e = checkerOpts.size(); i != e; ++i) { if (checkerOpts[i].isUnclaimed()) { diags.Report(diag::err_unknown_analyzer_checker) << checkerOpts[i].getName(); diags.Report(diag::note_suggest_disabling_all_checkers); } } return checkerMgr; }
bool C2Builder::checkMainFunction(DiagnosticsEngine& Diags) { assert(mainComponent); Decl* mainDecl = 0; const ModuleList& mods = mainComponent->getModules(); for (unsigned m=0; m<mods.size(); m++) { const Module* M = mods[m]; Decl* decl = M->findSymbol("main"); if (decl) { if (mainDecl) { // TODO multiple main functions } else { mainDecl = decl; } } } if (recipe.type == Component::EXECUTABLE) { // bin: must have main if (options.testMode) return true; if (!mainDecl) { Diags.Report(diag::err_main_missing); return false; } } else { // lib: cannot have main if (mainDecl) { Diags.Report(mainDecl->getLocation(), diag::err_lib_has_main); return false; } } return true; }
std::unique_ptr<CheckerManager> ento::createCheckerManager( ASTContext &context, AnalyzerOptions &opts, ArrayRef<std::string> plugins, ArrayRef<std::function<void(CheckerRegistry &)>> checkerRegistrationFns, DiagnosticsEngine &diags) { auto checkerMgr = llvm::make_unique<CheckerManager>(context, opts); SmallVector<CheckerOptInfo, 8> checkerOpts = getCheckerOptList(opts); ClangCheckerRegistry allCheckers(plugins, &diags); for (const auto &Fn : checkerRegistrationFns) Fn(allCheckers); allCheckers.initializeManager(*checkerMgr, checkerOpts); allCheckers.validateCheckerOptions(opts, diags); checkerMgr->finishedCheckerRegistration(); for (unsigned i = 0, e = checkerOpts.size(); i != e; ++i) { if (checkerOpts[i].isUnclaimed()) { diags.Report(diag::err_unknown_analyzer_checker) << checkerOpts[i].getName(); diags.Report(diag::note_suggest_disabling_all_checkers); } } return checkerMgr; }
bool CompilerInstance::InitializeSourceManager(StringRef InputFile, SrcMgr::CharacteristicKind Kind, DiagnosticsEngine &Diags, FileManager &FileMgr, SourceManager &SourceMgr, const FrontendOptions &Opts) { // Figure out where to get and map in the main file. if (InputFile != "-") { const FileEntry *File = FileMgr.getFile(InputFile); if (!File) { Diags.Report(diag::err_fe_error_reading) << InputFile; return false; } SourceMgr.createMainFileID(File, Kind); } else { OwningPtr<llvm::MemoryBuffer> SB; if (llvm::MemoryBuffer::getSTDIN(SB)) { // FIXME: Give ec.message() in this diag. Diags.Report(diag::err_fe_error_reading_stdin); return false; } const FileEntry *File = FileMgr.getVirtualFile(SB->getBufferIdentifier(), SB->getBufferSize(), 0); SourceMgr.createMainFileID(File, Kind); SourceMgr.overrideFileContents(File, SB.take()); } assert(!SourceMgr.getMainFileID().isInvalid() && "Couldn't establish MainFileID!"); return true; }
// Initialize the remapping of files to alternative contents, e.g., // those specified through other files. static void InitializeFileRemapping(DiagnosticsEngine &Diags, SourceManager &SourceMgr, FileManager &FileMgr, const PreprocessorOptions &InitOpts) { // Remap files in the source manager (with buffers). for (PreprocessorOptions::const_remapped_file_buffer_iterator Remap = InitOpts.remapped_file_buffer_begin(), RemapEnd = InitOpts.remapped_file_buffer_end(); Remap != RemapEnd; ++Remap) { // Create the file entry for the file that we're mapping from. const FileEntry *FromFile = FileMgr.getVirtualFile(Remap->first, Remap->second->getBufferSize(), 0); if (!FromFile) { Diags.Report(diag::err_fe_remap_missing_from_file) << Remap->first; if (!InitOpts.RetainRemappedFileBuffers) delete Remap->second; continue; } // Override the contents of the "from" file with the contents of // the "to" file. SourceMgr.overrideFileContents(FromFile, Remap->second, InitOpts.RetainRemappedFileBuffers); } // Remap files in the source manager (with other files). for (PreprocessorOptions::const_remapped_file_iterator Remap = InitOpts.remapped_file_begin(), RemapEnd = InitOpts.remapped_file_end(); Remap != RemapEnd; ++Remap) { // Find the file that we're mapping to. const FileEntry *ToFile = FileMgr.getFile(Remap->second); if (!ToFile) { Diags.Report(diag::err_fe_remap_missing_to_file) << Remap->first << Remap->second; continue; } // Create the file entry for the file that we're mapping from. const FileEntry *FromFile = FileMgr.getVirtualFile(Remap->first, ToFile->getSize(), 0); if (!FromFile) { Diags.Report(diag::err_fe_remap_missing_from_file) << Remap->first; continue; } // Override the contents of the "from" file with the contents of // the "to" file. SourceMgr.overrideFileContents(FromFile, ToFile); } SourceMgr.setOverridenFilesKeepOriginalName( InitOpts.RemappedFilesKeepOriginalName); }
bool CompilerInstance::InitializeSourceManager(const FrontendInputFile &Input, DiagnosticsEngine &Diags, FileManager &FileMgr, SourceManager &SourceMgr, const FrontendOptions &Opts) { SrcMgr::CharacteristicKind Kind = Input.isSystem() ? SrcMgr::C_System : SrcMgr::C_User; if (Input.isBuffer()) { SourceMgr.createMainFileIDForMemBuffer(Input.getBuffer(), Kind); assert(!SourceMgr.getMainFileID().isInvalid() && "Couldn't establish MainFileID!"); return true; } StringRef InputFile = Input.getFile(); // Figure out where to get and map in the main file. if (InputFile != "-") { const FileEntry *File = FileMgr.getFile(InputFile); if (!File) { Diags.Report(diag::err_fe_error_reading) << InputFile; return false; } // The natural SourceManager infrastructure can't currently handle named // pipes, but we would at least like to accept them for the main // file. Detect them here, read them with the more generic MemoryBuffer // function, and simply override their contents as we do for STDIN. if (File->isNamedPipe()) { OwningPtr<llvm::MemoryBuffer> MB; if (llvm::error_code ec = llvm::MemoryBuffer::getFile(InputFile, MB)) { Diags.Report(diag::err_cannot_open_file) << InputFile << ec.message(); return false; } // Create a new virtual file that will have the correct size. File = FileMgr.getVirtualFile(InputFile, MB->getBufferSize(), 0); SourceMgr.overrideFileContents(File, MB.take()); } SourceMgr.createMainFileID(File, Kind); } else { OwningPtr<llvm::MemoryBuffer> SB; if (llvm::MemoryBuffer::getSTDIN(SB)) { // FIXME: Give ec.message() in this diag. Diags.Report(diag::err_fe_error_reading_stdin); return false; } const FileEntry *File = FileMgr.getVirtualFile(SB->getBufferIdentifier(), SB->getBufferSize(), 0); SourceMgr.createMainFileID(File, Kind); SourceMgr.overrideFileContents(File, SB.take()); } assert(!SourceMgr.getMainFileID().isInvalid() && "Couldn't establish MainFileID!"); return true; }
// EmitUnknownDiagWarning - Emit a warning and typo hint for unknown warning opts static void EmitUnknownDiagWarning(DiagnosticsEngine &Diags, StringRef Prefix, StringRef Opt, bool isPositive) { StringRef Suggestion = DiagnosticIDs::getNearestWarningOption(Opt); if (!Suggestion.empty()) Diags.Report(isPositive? diag::warn_unknown_warning_option_suggest : diag::warn_unknown_negative_warning_option_suggest) << (Prefix.str() += Opt) << (Prefix.str() += Suggestion); else Diags.Report(isPositive? diag::warn_unknown_warning_option : diag::warn_unknown_negative_warning_option) << (Prefix.str() += Opt); }
void TextDiagnosticBuffer::FlushDiagnostics(DiagnosticsEngine &Diags) const { SmallVector<char, 64> Buf; // FIXME: Flush the diagnostics in order. for (const_iterator it = err_begin(), ie = err_end(); it != ie; ++it) Diags.Report(Diags.getCustomDiagID(DiagnosticsEngine::Error, escapeDiag(it->second, Buf))); for (const_iterator it = warn_begin(), ie = warn_end(); it != ie; ++it) Diags.Report(Diags.getCustomDiagID(DiagnosticsEngine::Warning, escapeDiag(it->second, Buf))); for (const_iterator it = note_begin(), ie = note_end(); it != ie; ++it) Diags.Report(Diags.getCustomDiagID(DiagnosticsEngine::Note, escapeDiag(it->second, Buf))); }
bool yasm::CalcFloat(APFloat* lhs, Op::Op op, const APFloat& rhs, SourceLocation source, DiagnosticsEngine& diags) { APFloat::opStatus status; switch (op) { case Op::ADD: status = lhs->add(rhs, APFloat::rmNearestTiesToEven); break; case Op::SUB: status = lhs->subtract(rhs, APFloat::rmNearestTiesToEven); break; case Op::MUL: status = lhs->multiply(rhs, APFloat::rmNearestTiesToEven); break; case Op::DIV: case Op::SIGNDIV: status = lhs->divide(rhs, APFloat::rmNearestTiesToEven); break; case Op::MOD: case Op::SIGNMOD: status = lhs->mod(rhs, APFloat::rmNearestTiesToEven); break; default: status = APFloat::opInvalidOp; break; } if (status & APFloat::opInvalidOp) { diags.Report(source, diag::err_float_invalid_op); return false; } if (status & APFloat::opDivByZero) { diags.Report(source, diag::err_divide_by_zero); return false; } if (status & APFloat::opOverflow) diags.Report(source, diag::warn_float_overflow); else if (status & APFloat::opUnderflow) diags.Report(source, diag::warn_float_underflow); else if (status & APFloat::opInexact) diags.Report(source, diag::warn_float_inexact); return true; }
void TextDiagnosticBuffer::FlushDiagnostics(DiagnosticsEngine &Diags) const { // FIXME: Flush the diagnostics in order. for (const_iterator it = err_begin(), ie = err_end(); it != ie; ++it) Diags.Report(Diags.getCustomDiagID(DiagnosticsEngine::Error, "%0")) << it->second; for (const_iterator it = warn_begin(), ie = warn_end(); it != ie; ++it) Diags.Report(Diags.getCustomDiagID(DiagnosticsEngine::Warning, "%0")) << it->second; for (const_iterator it = remark_begin(), ie = remark_end(); it != ie; ++it) Diags.Report(Diags.getCustomDiagID(DiagnosticsEngine::Remark, "%0")) << it->second; for (const_iterator it = note_begin(), ie = note_end(); it != ie; ++it) Diags.Report(Diags.getCustomDiagID(DiagnosticsEngine::Note, "%0")) << it->second; }
/// Takes a list of diagnostics that have been generated but not matched /// by an expected-* directive and produces a diagnostic to the user from this. static unsigned PrintUnexpected(DiagnosticsEngine &Diags, SourceManager *SourceMgr, const_diag_iterator diag_begin, const_diag_iterator diag_end, const char *Kind) { if (diag_begin == diag_end) return 0; SmallString<256> Fmt; llvm::raw_svector_ostream OS(Fmt); for (const_diag_iterator I = diag_begin, E = diag_end; I != E; ++I) { if (I->first.isInvalid() || !SourceMgr) OS << "\n (frontend)"; else { OS << "\n "; if (const FileEntry *File = SourceMgr->getFileEntryForID( SourceMgr->getFileID(I->first))) OS << " File " << File->getName(); OS << " Line " << SourceMgr->getPresumedLineNumber(I->first); } OS << ": " << I->second; } Diags.Report(diag::err_verify_inconsistent_diags).setForceEmit() << Kind << /*Unexpected=*/true << OS.str(); return std::distance(diag_begin, diag_end); }
void clang::EmitBackendOutput(DiagnosticsEngine &Diags, const CodeGenOptions &CGOpts, const clang::TargetOptions &TOpts, const LangOptions &LOpts, const llvm::DataLayout &TDesc, Module *M, BackendAction Action, std::unique_ptr<raw_pwrite_stream> OS) { if (!CGOpts.ThinLTOIndexFile.empty()) { runThinLTOBackend(CGOpts, M, std::move(OS)); return; } EmitAssemblyHelper AsmHelper(Diags, CGOpts, TOpts, LOpts, M); AsmHelper.EmitAssembly(Action, std::move(OS)); // Verify clang's TargetInfo DataLayout against the LLVM TargetMachine's // DataLayout. if (AsmHelper.TM) { std::string DLDesc = M->getDataLayout().getStringRepresentation(); if (DLDesc != TDesc.getStringRepresentation()) { unsigned DiagID = Diags.getCustomDiagID( DiagnosticsEngine::Error, "backend data layout '%0' does not match " "expected target description '%1'"); Diags.Report(DiagID) << DLDesc << TDesc.getStringRepresentation(); } } }
/// Takes a list of diagnostics that were expected to have been generated /// but were not and produces a diagnostic to the user from this. static unsigned PrintExpected(DiagnosticsEngine &Diags, SourceManager &SourceMgr, std::vector<Directive *> &DL, const char *Kind) { if (DL.empty()) return 0; SmallString<256> Fmt; llvm::raw_svector_ostream OS(Fmt); for (const auto *D : DL) { if (D->DiagnosticLoc.isInvalid()) OS << "\n File *"; else OS << "\n File " << SourceMgr.getFilename(D->DiagnosticLoc); if (D->MatchAnyLine) OS << " Line *"; else OS << " Line " << SourceMgr.getPresumedLineNumber(D->DiagnosticLoc); if (D->DirectiveLoc != D->DiagnosticLoc) OS << " (directive at " << SourceMgr.getFilename(D->DirectiveLoc) << ':' << SourceMgr.getPresumedLineNumber(D->DirectiveLoc) << ')'; OS << ": " << D->Text; } Diags.Report(diag::err_verify_inconsistent_diags).setForceEmit() << Kind << /*Unexpected=*/false << OS.str(); return DL.size(); }
bool FileRemapper::report(const Twine &err, DiagnosticsEngine &Diag) { SmallString<128> buf; unsigned ID = Diag.getDiagnosticIDs()->getCustomDiagID(DiagnosticIDs::Error, err.toStringRef(buf)); Diag.Report(ID); return true; }
static void SetUpDiagnosticLog(DiagnosticOptions *DiagOpts, const CodeGenOptions *CodeGenOpts, DiagnosticsEngine &Diags) { std::string ErrorInfo; bool OwnsStream = false; raw_ostream *OS = &llvm::errs(); if (DiagOpts->DiagnosticLogFile != "-") { // Create the output stream. llvm::raw_fd_ostream *FileOS( new llvm::raw_fd_ostream(DiagOpts->DiagnosticLogFile.c_str(), ErrorInfo, llvm::raw_fd_ostream::F_Append)); if (!ErrorInfo.empty()) { Diags.Report(diag::warn_fe_cc_log_diagnostics_failure) << DiagOpts->DumpBuildInformation << ErrorInfo; } else { FileOS->SetUnbuffered(); FileOS->SetUseAtomicWrites(true); OS = FileOS; OwnsStream = true; } } // Chain in the diagnostic client which will log the diagnostics. LogDiagnosticPrinter *Logger = new LogDiagnosticPrinter(*OS, DiagOpts, OwnsStream); if (CodeGenOpts) Logger->setDwarfDebugFlags(CodeGenOpts->DwarfDebugFlags); Diags.setClient(new ChainedDiagnosticConsumer(Diags.takeClient(), Logger)); }
// EmitUnknownDiagWarning - Emit a warning and typo hint for unknown warning // opts static void EmitUnknownDiagWarning(DiagnosticsEngine &Diags, diag::Flavor Flavor, StringRef Prefix, StringRef Opt) { StringRef Suggestion = DiagnosticIDs::getNearestOption(Flavor, Opt); Diags.Report(diag::warn_unknown_diag_option) << (Flavor == diag::Flavor::WarningOrError ? 0 : 1) << (Prefix.str() += Opt) << !Suggestion.empty() << (Prefix.str() += Suggestion); }
bool MipsTargetInfo::validateTarget(DiagnosticsEngine &Diags) const { // microMIPS64R6 backend was removed. if ((getTriple().getArch() == llvm::Triple::mips64 || getTriple().getArch() == llvm::Triple::mips64el) && IsMicromips && (ABI == "n32" || ABI == "n64")) { Diags.Report(diag::err_target_unsupported_cpu_for_micromips) << CPU; return false; } // FIXME: It's valid to use O32 on a 64-bit CPU but the backend can't handle // this yet. It's better to fail here than on the backend assertion. if (processorSupportsGPR64() && ABI == "o32") { Diags.Report(diag::err_target_unsupported_abi) << ABI << CPU; return false; } // 64-bit ABI's require 64-bit CPU's. if (!processorSupportsGPR64() && (ABI == "n32" || ABI == "n64")) { Diags.Report(diag::err_target_unsupported_abi) << ABI << CPU; return false; } // FIXME: It's valid to use O32 on a mips64/mips64el triple but the backend // can't handle this yet. It's better to fail here than on the // backend assertion. if ((getTriple().getArch() == llvm::Triple::mips64 || getTriple().getArch() == llvm::Triple::mips64el) && ABI == "o32") { Diags.Report(diag::err_target_unsupported_abi_for_triple) << ABI << getTriple().str(); return false; } // FIXME: It's valid to use N32/N64 on a mips/mipsel triple but the backend // can't handle this yet. It's better to fail here than on the // backend assertion. if ((getTriple().getArch() == llvm::Triple::mips || getTriple().getArch() == llvm::Triple::mipsel) && (ABI == "n32" || ABI == "n64")) { Diags.Report(diag::err_target_unsupported_abi_for_triple) << ABI << getTriple().str(); return false; } return true; }
/// \brief Return true with a diagnostic if the file that MSVC would have found /// fails to match the one that Clang would have found with MSVC header search /// disabled. static bool checkMSVCHeaderSearch(DiagnosticsEngine &Diags, const FileEntry *MSFE, const FileEntry *FE, SourceLocation IncludeLoc) { if (MSFE && FE != MSFE) { Diags.Report(IncludeLoc, diag::ext_pp_include_search_ms) << MSFE->getName(); return true; } return false; }
void clang::EmitBackendOutput(DiagnosticsEngine &Diags, const HeaderSearchOptions &HeaderOpts, const CodeGenOptions &CGOpts, const clang::TargetOptions &TOpts, const LangOptions &LOpts, const llvm::DataLayout &TDesc, Module *M, BackendAction Action, std::unique_ptr<raw_pwrite_stream> OS) { if (!CGOpts.ThinLTOIndexFile.empty()) { // If we are performing a ThinLTO importing compile, load the function index // into memory and pass it into runThinLTOBackend, which will run the // function importer and invoke LTO passes. Expected<std::unique_ptr<ModuleSummaryIndex>> IndexOrErr = llvm::getModuleSummaryIndexForFile(CGOpts.ThinLTOIndexFile, /*IgnoreEmptyThinLTOIndexFile*/true); if (!IndexOrErr) { logAllUnhandledErrors(IndexOrErr.takeError(), errs(), "Error loading index file '" + CGOpts.ThinLTOIndexFile + "': "); return; } std::unique_ptr<ModuleSummaryIndex> CombinedIndex = std::move(*IndexOrErr); // A null CombinedIndex means we should skip ThinLTO compilation // (LLVM will optionally ignore empty index files, returning null instead // of an error). bool DoThinLTOBackend = CombinedIndex != nullptr; if (DoThinLTOBackend) { runThinLTOBackend(CombinedIndex.get(), M, HeaderOpts, CGOpts, TOpts, LOpts, std::move(OS), CGOpts.SampleProfileFile, Action); return; } } EmitAssemblyHelper AsmHelper(Diags, HeaderOpts, CGOpts, TOpts, LOpts, M); if (CGOpts.ExperimentalNewPassManager) AsmHelper.EmitAssemblyWithNewPassManager(Action, std::move(OS)); else AsmHelper.EmitAssembly(Action, std::move(OS)); // Verify clang's TargetInfo DataLayout against the LLVM TargetMachine's // DataLayout. if (AsmHelper.TM) { std::string DLDesc = M->getDataLayout().getStringRepresentation(); if (DLDesc != TDesc.getStringRepresentation()) { unsigned DiagID = Diags.getCustomDiagID( DiagnosticsEngine::Error, "backend data layout '%0' does not match " "expected target description '%1'"); Diags.Report(DiagID) << DLDesc << TDesc.getStringRepresentation(); } } }
void Directives::Impl::Dir::operator() (StringRef name, DirectiveInfo& info, DiagnosticsEngine& diags) { NameValues& namevals = info.getNameValues(); if ((m_flags & (ARG_REQUIRED|ID_REQUIRED)) && namevals.empty()) { diags.Report(info.getSource(), diag::err_directive_no_args); return; } if (!namevals.empty() && (m_flags & ID_REQUIRED) && !namevals.front().isId()) { diags.Report(info.getSource(), diag::err_value_id) << namevals.front().getValueRange(); return; } m_handler(info, diags); }
bool WebAssemblyTargetInfo::handleTargetFeatures( std::vector<std::string> &Features, DiagnosticsEngine &Diags) { for (const auto &Feature : Features) { if (Feature == "+simd128") { SIMDLevel = std::max(SIMDLevel, SIMD128); continue; } if (Feature == "-simd128") { SIMDLevel = std::min(SIMDLevel, SIMDEnum(SIMD128 - 1)); continue; } if (Feature == "+unimplemented-simd128") { SIMDLevel = std::max(SIMDLevel, SIMDEnum(UnimplementedSIMD128)); continue; } if (Feature == "-unimplemented-simd128") { SIMDLevel = std::min(SIMDLevel, SIMDEnum(UnimplementedSIMD128 - 1)); continue; } if (Feature == "+nontrapping-fptoint") { HasNontrappingFPToInt = true; continue; } if (Feature == "-nontrapping-fptoint") { HasNontrappingFPToInt = false; continue; } if (Feature == "+sign-ext") { HasSignExt = true; continue; } if (Feature == "-sign-ext") { HasSignExt = false; continue; } if (Feature == "+exception-handling") { HasExceptionHandling = true; continue; } if (Feature == "-exception-handling") { HasExceptionHandling = false; continue; } Diags.Report(diag::err_opt_not_valid_with_opt) << Feature << "-target-feature"; return false; } return true; }
// Handle explicit options being passed to the compiler here: if we've // explicitly turned off vsx and turned on any of: // - power8-vector // - direct-move // - float128 // - power9-vector // then go ahead and error since the customer has expressed an incompatible // set of options. static bool ppcUserFeaturesCheck(DiagnosticsEngine &Diags, const std::vector<std::string> &FeaturesVec) { if (std::find(FeaturesVec.begin(), FeaturesVec.end(), "-vsx") != FeaturesVec.end()) { if (std::find(FeaturesVec.begin(), FeaturesVec.end(), "+power8-vector") != FeaturesVec.end()) { Diags.Report(diag::err_opt_not_valid_with_opt) << "-mpower8-vector" << "-mno-vsx"; return false; } if (std::find(FeaturesVec.begin(), FeaturesVec.end(), "+direct-move") != FeaturesVec.end()) { Diags.Report(diag::err_opt_not_valid_with_opt) << "-mdirect-move" << "-mno-vsx"; return false; } if (std::find(FeaturesVec.begin(), FeaturesVec.end(), "+float128") != FeaturesVec.end()) { Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfloat128" << "-mno-vsx"; return false; } if (std::find(FeaturesVec.begin(), FeaturesVec.end(), "+power9-vector") != FeaturesVec.end()) { Diags.Report(diag::err_opt_not_valid_with_opt) << "-mpower9-vector" << "-mno-vsx"; return false; } } return true; }
AtomicallyMovedFile(DiagnosticsEngine &Diagnostics, StringRef Filename, bool &AllWritten) : Diagnostics(Diagnostics), Filename(Filename), AllWritten(AllWritten) { TempFilename = Filename; TempFilename += "-%%%%%%%%"; int FD; if (llvm::sys::fs::unique_file(TempFilename.str(), FD, TempFilename, /*makeAbsolute=*/true, 0664)) { AllWritten = false; Diagnostics.Report(clang::diag::err_unable_to_make_temp) << TempFilename; } else { FileStream.reset(new llvm::raw_fd_ostream(FD, /*shouldClose=*/true)); } }
// Append a #define line to Buf for Macro. Macro should be of the form XXX, // in which case we emit "#define XXX 1" or "XXX=Y z W" in which case we emit // "#define XXX Y z W". To get a #define with no value, use "XXX=". static void DefineBuiltinMacro(MacroBuilder &Builder, StringRef Macro, DiagnosticsEngine &Diags) { std::pair<StringRef, StringRef> MacroPair = Macro.split('='); StringRef MacroName = MacroPair.first; StringRef MacroBody = MacroPair.second; if (MacroName.size() != Macro.size()) { // Per GCC -D semantics, the macro ends at \n if it exists. StringRef::size_type End = MacroBody.find_first_of("\n\r"); if (End != StringRef::npos) Diags.Report(diag::warn_fe_macro_contains_embedded_newline) << MacroName; Builder.defineMacro(MacroName, MacroBody.substr(0, End)); } else { // Push "macroname 1". Builder.defineMacro(Macro); } }
static std::unique_ptr<raw_fd_ostream> getOutputStream(StringRef Path, DiagnosticsEngine &Diags, bool Binary) { // Make sure that the Out file gets unlinked from the disk if we get a // SIGINT. if (Path != "-") sys::RemoveFileOnSignal(Path); std::error_code EC; auto Out = llvm::make_unique<raw_fd_ostream>( Path, EC, (Binary ? sys::fs::F_None : sys::fs::F_Text)); if (EC) { Diags.Report(diag::err_fe_unable_to_open_output) << Path << EC.message(); return nullptr; } return Out; }
bool EquivalenceScope::CheckConnection(DiagnosticsEngine &Diags, Object A, Object B, bool ReportWarnings) { if(A.Obj == B.Obj) { // equivalence (x,x) if(A.Offset != B.Offset) { Diags.Report(B.E->getLocation(), diag::err_equivalence_conflicting_offsets) << A.E->getSourceRange() << B.E->getSourceRange(); ReportWarnings = false; } if(ReportWarnings) { Diags.Report(B.E->getLocation(), diag::warn_equivalence_same_object) << A.E->getSourceRange() << B.E->getSourceRange(); ReportWarnings = false; } } ConnectionFinder Finder(Connections); Finder.FindRelevantConnections(A, B); auto Relevant = Finder.getResults(); if (!Relevant.empty()) { for(auto I : Relevant) { bool same = true; if(B.Obj == I.A.Obj) same = B.Offset == I.A.Offset; else if(B.Obj == I.B.Obj) same = B.Offset == I.B.Offset; if(same) { if(A.Obj == I.A.Obj) same = A.Offset == I.A.Offset; else if(A.Obj == I.B.Obj) same = A.Offset == I.B.Offset; } if(!same) { Diags.Report(B.E->getLocation(), diag::err_equivalence_conflicting_offsets) << A.E->getSourceRange() << B.E->getSourceRange(); Diags.Report(I.A.E->getLocation(), diag::note_equivalence_prev_offset) << I.A.E->getSourceRange() << I.B.E->getSourceRange(); return false; } } if(ReportWarnings) { Diags.Report(B.E->getLocation(), diag::warn_equivalence_redundant) << A.E->getSourceRange() << B.E->getSourceRange(); auto I = Relevant.front(); Diags.Report(I.A.E->getLocation(), diag::note_equivalence_identical_association) << I.A.E->getSourceRange() << I.B.E->getSourceRange(); ReportWarnings = false; } } return true; }
bool HtTpg::areAllSgConnected(DiagnosticsEngine &diag) { // fill in connections where possible bool bProgress; do { bProgress = false; for (size_t i = 0; i < m_sgNameList.size(); i += 1) { for (size_t j = 0; j < m_sgNameList.size(); j += 1) { if (getUrsDelta(i, j) != RS_DELTA_UNKNOWN) continue; for (size_t k = 0; k < m_sgNameList.size(); k += 1) { if (getUrsDelta(i, k) == RS_DELTA_UNKNOWN || getUrsDelta(k, j) == RS_DELTA_UNKNOWN) continue; int delta = getUrsDelta(i, k) + getUrsDelta(k, j); setUrsDelta(i, j, delta); setUrsDelta(j, i, -delta); bProgress = true; break; } } } } while (bProgress); // now check connectivity bool bFullyConnected = true; for (size_t i = 0; i < m_sgNameList.size(); i += 1) { for (size_t j = 0; j < i; j += 1) { if (m_pSgUrsMatrix[j * m_sgNameList.size() + i] == RS_DELTA_UNKNOWN) { bFullyConnected = false; char errorMsg[256]; sprintf(errorMsg, "subgroups of timing path group '%s' are not fully connected (%s and %s)", m_name.c_str(), m_sgNameList[j].c_str(), m_sgNameList[i].c_str()); unsigned DiagID = diag.getCustomDiagID(DiagnosticsEngine::Error, errorMsg); diag.Report(DiagID); } } } return bFullyConnected; }
static void SetupSerializedDiagnostics(DiagnosticOptions *DiagOpts, DiagnosticsEngine &Diags, StringRef OutputFile) { std::string ErrorInfo; OwningPtr<llvm::raw_fd_ostream> OS; OS.reset(new llvm::raw_fd_ostream(OutputFile.str().c_str(), ErrorInfo, llvm::raw_fd_ostream::F_Binary)); if (!ErrorInfo.empty()) { Diags.Report(diag::warn_fe_serialized_diag_failure) << OutputFile << ErrorInfo; return; } DiagnosticConsumer *SerializedConsumer = clang::serialized_diags::create(OS.take(), DiagOpts); Diags.setClient(new ChainedDiagnosticConsumer(Diags.takeClient(), SerializedConsumer)); }
/// \brief Takes a list of diagnostics that have been generated but not matched /// by an expected-* directive and produces a diagnostic to the user from this. static unsigned PrintUnexpected(DiagnosticsEngine &Diags, llvm::SourceMgr *SourceMgr, const_diag_iterator diag_begin, const_diag_iterator diag_end, const char *Kind) { if (diag_begin == diag_end) return 0; SmallString<256> Fmt; llvm::raw_svector_ostream OS(Fmt); for (const_diag_iterator I = diag_begin, E = diag_end; I != E; ++I) { if (!I->first.isValid() || !SourceMgr) OS << "\n (frontend)"; else OS << "\n Line " << SourceMgr->getLineAndColumn(I->first).first; OS << ": " << I->second; } Diags.Report(SourceLocation(), diag::verify_inconsistent_diags) << Kind << /*Unexpected=*/true << OS.str(); return std::distance(diag_begin, diag_end); }