From b8e245ac4f5ad3303ae866e3ad2a5eac7621a410 Mon Sep 17 00:00:00 2001 From: Simeon Ehrig Date: Wed, 13 Nov 2019 09:43:59 +0100 Subject: [PATCH] Add prefix to the diagnostic engine - add the prefix "cling" (normal interpreter error) or "cling-ptx" (ptx interpreter -> just in CUDA mode) to every interpreter error message - example before: error: cannot find CUDA installation. Provide its path via --cuda-path, or pass -nocudainc to build without CUDA includes. error: cannot find libdevice for sm_20. Provide path to different CUDA installation via --cuda-path, or pass -nocudalib to build without linking with libdevice. error: cannot find CUDA installation. Provide its path via --cuda-path, or pass -nocudainc to build without CUDA includes. - example after: cling: error: cannot find CUDA installation. Provide its path via --cuda-path, or pass -nocudainc to build without CUDA includes. cling-ptx: error: cannot find libdevice for sm_20. Provide path to different CUDA installation via --cuda-path, or pass -nocudalib to build without linking with libdevice. cling-ptx: error: cannot find CUDA installation. Provide its path via --cuda-path, or pass -nocudainc to build without CUDA includes. --- lib/Interpreter/CIFactory.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Interpreter/CIFactory.cpp b/lib/Interpreter/CIFactory.cpp index 6022cd29..a24e4bec 100644 --- a/lib/Interpreter/CIFactory.cpp +++ b/lib/Interpreter/CIFactory.cpp @@ -873,7 +873,7 @@ static void stringifyPreprocSetting(PreprocessorOptions& PPOpts, } static llvm::IntrusiveRefCntPtr - SetupDiagnostics(DiagnosticOptions& DiagOpts) { + SetupDiagnostics(DiagnosticOptions& DiagOpts, std::string ExeName) { // The compiler invocation is the owner of the diagnostic options. // Everything else points to them. llvm::IntrusiveRefCntPtr DiagIDs(new DiagnosticIDs()); @@ -881,6 +881,8 @@ static void stringifyPreprocSetting(PreprocessorOptions& PPOpts, std::unique_ptr DiagnosticPrinter(new TextDiagnosticPrinter(cling::errs(), &DiagOpts)); + DiagnosticPrinter->setPrefix(ExeName); + llvm::IntrusiveRefCntPtr Diags(new DiagnosticsEngine(DiagIDs, &DiagOpts, DiagnosticPrinter.get(), /*Owns it*/ true)); @@ -1333,7 +1335,7 @@ static void stringifyPreprocSetting(PreprocessorOptions& PPOpts, // Everything else points to them. DiagnosticOptions& DiagOpts = InvocationPtr->getDiagnosticOpts(); llvm::IntrusiveRefCntPtr Diags = - SetupDiagnostics(DiagOpts); + SetupDiagnostics(DiagOpts, COpts.CUDADevice ? "cling-ptx" : "cling"); if (!Diags) { cling::errs() << "Could not setup diagnostic engine.\n"; return nullptr;