@@ -11,7 +11,7 @@ namespace VSPackage.CPPCheckPlugin
1111{
1212 class AnalyzerCppcheck : ICodeAnalyzer
1313 {
14- private string getCPPCheckArgs ( ConfiguredFiles configuredFiles , bool analysisOnSavedFile , bool multipleProjects )
14+ private string getCPPCheckArgs ( ConfiguredFiles configuredFiles , bool analysisOnSavedFile , bool multipleProjects , StreamWriter tempFile )
1515 {
1616 Debug . Assert ( _numCores > 0 ) ;
1717 String cppheckargs = Properties . Settings . Default . DefaultArguments ;
@@ -81,9 +81,11 @@ private string getCPPCheckArgs(ConfiguredFiles configuredFiles, bool analysisOnS
8181 foreach ( SourceFile file in filesToAnalyze )
8282 {
8383 if ( ! matchMasksList ( file . FileName , unitedSuppressionsInfo . SkippedFilesMask ) )
84- cppheckargs += " \" " + file . FilePath + " \" " ;
84+ tempFile . WriteLine ( file . FilePath ) ;
8585 }
8686
87+ cppheckargs += " --file-list=\" " + tempFileName + "\" " ;
88+
8789 if ( ( analysisOnSavedFile && Properties . Settings . Default . FileOnlyCheckCurrentConfig ) ||
8890 ( ! analysisOnSavedFile && Properties . Settings . Default . ProjectOnlyCheckCurrentConfig ) ) // Only checking current macros configuration (for speed)
8991 {
@@ -171,10 +173,12 @@ public override void analyze(List<ConfiguredFiles> allConfiguredFiles, OutputWin
171173 {
172174 if ( ! allConfiguredFiles . Any ( ) )
173175 return ;
174-
176+
177+ StreamWriter tempFile = new StreamWriter ( tempFileName ) ;
178+
175179 List < string > cppheckargs = new List < string > ( ) ;
176180 foreach ( var configuredFiles in allConfiguredFiles )
177- cppheckargs . Add ( getCPPCheckArgs ( configuredFiles , analysisOnSavedFile , allConfiguredFiles . Count > 1 ) ) ;
181+ cppheckargs . Add ( getCPPCheckArgs ( configuredFiles , analysisOnSavedFile , allConfiguredFiles . Count > 1 , tempFile ) ) ;
178182
179183 string analyzerPath = Properties . Settings . Default . CPPcheckPath ;
180184 while ( ! File . Exists ( analyzerPath ) )
@@ -187,6 +191,8 @@ public override void analyze(List<ConfiguredFiles> allConfiguredFiles, OutputWin
187191 analyzerPath = dialog . FileName ;
188192 }
189193
194+ tempFile . Close ( ) ;
195+
190196 Properties . Settings . Default . CPPcheckPath = analyzerPath ;
191197 Properties . Settings . Default . Save ( ) ;
192198
@@ -326,8 +332,13 @@ protected override void analysisFinished()
326332 {
327333 if ( _unfinishedProblem != null )
328334 addProblemToToolwindow ( _unfinishedProblem ) ;
335+
336+ // Delete the temp file. Doesn't throw an exception if the file was never
337+ // created, so we don't need to worry about that.
338+ File . Delete ( tempFileName ) ;
329339 }
330340
331341 private Problem _unfinishedProblem = null ;
342+ string tempFileName = Path . GetTempFileName ( ) ;
332343 }
333344}
0 commit comments