@@ -658,8 +658,10 @@ unsigned int CppCheck::checkClang(const FileWithDetails &file)
658658 mErrorLogger .reportOut (std::string (" Checking " ) + file.spath () + " ..." , Color::FgGreen);
659659
660660 // TODO: get language from FileWithDetails object
661- const std::string analyzerInfo = mSettings .buildDir .empty () ? std::string () : AnalyzerInformation::getAnalyzerInfoFile (mSettings .buildDir , file.spath (), " " );
662- const std::string clangStderr = analyzerInfo + " .clang-stderr" + " ." + std::to_string (mSettings .pid );
661+ std::string clangStderr;
662+ if (!mSettings .buildDir .empty ())
663+ clangStderr = AnalyzerInformation::getAnalyzerInfoFile (mSettings .buildDir , file.spath (), " " ) + " .clang-stderr" ;
664+
663665 std::string exe = mSettings .clangExecutable ;
664666#ifdef _WIN32
665667 // append .exe if it is not a path
@@ -671,7 +673,7 @@ unsigned int CppCheck::checkClang(const FileWithDetails &file)
671673 const std::string args2 = " -fsyntax-only -Xclang -ast-dump -fno-color-diagnostics " +
672674 getClangFlags (Path::identify (file.spath (), mSettings .cppHeaderProbe )) +
673675 file.spath ();
674- const std::string redirect2 = analyzerInfo .empty () ? std::string ( " 2>&1" ) : (" 2> " + clangStderr);
676+ const std::string redirect2 = clangStderr .empty () ? " 2>&1" : (" 2> " + clangStderr);
675677 if (mSettings .verbose && !mSettings .quiet ) {
676678 mErrorLogger .reportOut (exe + " " + args2);
677679 }
@@ -694,20 +696,18 @@ unsigned int CppCheck::checkClang(const FileWithDetails &file)
694696 return 0 ; // TODO: report as failure?
695697 }
696698
699+ const auto reportError = [this ](const ErrorMessage& errorMessage) {
700+ mErrorLogger .reportErr (errorMessage);
701+ };
702+
697703 // Ensure there are not syntax errors...
698704 std::vector<ErrorMessage> compilerWarnings;
699- if (!mSettings . buildDir .empty ()) {
705+ if (!clangStderr .empty ()) {
700706 std::ifstream fin (clangStderr);
701- auto reportError = [this ](const ErrorMessage& errorMessage) {
702- mErrorLogger .reportErr (errorMessage);
703- };
704707 if (reportClangErrors (fin, reportError, compilerWarnings))
705708 return 0 ; // TODO: report as failure?
706709 } else {
707710 std::istringstream istr (output2);
708- auto reportError = [this ](const ErrorMessage& errorMessage) {
709- mErrorLogger .reportErr (errorMessage);
710- };
711711 if (reportClangErrors (istr, reportError, compilerWarnings))
712712 return 0 ; // TODO: report as failure?
713713 }
0 commit comments