@@ -658,8 +658,10 @@ unsigned int CppCheck::checkClang(const FileWithDetails &file)
658
658
mErrorLogger .reportOut (std::string (" Checking " ) + file.spath () + " ..." , Color::FgGreen);
659
659
660
660
// 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
+
663
665
std::string exe = mSettings .clangExecutable ;
664
666
#ifdef _WIN32
665
667
// append .exe if it is not a path
@@ -671,7 +673,7 @@ unsigned int CppCheck::checkClang(const FileWithDetails &file)
671
673
const std::string args2 = " -fsyntax-only -Xclang -ast-dump -fno-color-diagnostics " +
672
674
getClangFlags (Path::identify (file.spath (), mSettings .cppHeaderProbe )) +
673
675
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);
675
677
if (mSettings .verbose && !mSettings .quiet ) {
676
678
mErrorLogger .reportOut (exe + " " + args2);
677
679
}
@@ -694,20 +696,18 @@ unsigned int CppCheck::checkClang(const FileWithDetails &file)
694
696
return 0 ; // TODO: report as failure?
695
697
}
696
698
699
+ const auto reportError = [this ](const ErrorMessage& errorMessage) {
700
+ mErrorLogger .reportErr (errorMessage);
701
+ };
702
+
697
703
// Ensure there are not syntax errors...
698
704
std::vector<ErrorMessage> compilerWarnings;
699
- if (!mSettings . buildDir .empty ()) {
705
+ if (!clangStderr .empty ()) {
700
706
std::ifstream fin (clangStderr);
701
- auto reportError = [this ](const ErrorMessage& errorMessage) {
702
- mErrorLogger .reportErr (errorMessage);
703
- };
704
707
if (reportClangErrors (fin, reportError, compilerWarnings))
705
708
return 0 ; // TODO: report as failure?
706
709
} else {
707
710
std::istringstream istr (output2);
708
- auto reportError = [this ](const ErrorMessage& errorMessage) {
709
- mErrorLogger .reportErr (errorMessage);
710
- };
711
711
if (reportClangErrors (istr, reportError, compilerWarnings))
712
712
return 0 ; // TODO: report as failure?
713
713
}
0 commit comments