forked from OSchip/llvm-project
				
			Hook up the Plist diagnostic client to the driver.
Fix Plist output. llvm-svn: 58652
This commit is contained in:
		
							parent
							
								
									f33f8a8606
								
							
						
					
					
						commit
						14f18653f6
					
				| 
						 | 
					@ -15,10 +15,6 @@
 | 
				
			||||||
#define ANALYSIS(NAME, CMDFLAG, DESC, SCOPE)
 | 
					#define ANALYSIS(NAME, CMDFLAG, DESC, SCOPE)
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef ANALYSIS_STORE
 | 
					 | 
				
			||||||
#define ANALYSIS_STORE(NAME, CMDFLAG, DESC)
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
ANALYSIS(CFGDump, "cfg-dump",
 | 
					ANALYSIS(CFGDump, "cfg-dump",
 | 
				
			||||||
         "Display Control-Flow Graphs", Code)
 | 
					         "Display Control-Flow Graphs", Code)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -52,8 +48,22 @@ ANALYSIS(CheckerCFRef, "checker-cfref",
 | 
				
			||||||
         "Run the [Core] Foundation reference count checker", Code)
 | 
					         "Run the [Core] Foundation reference count checker", Code)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef ANALYSIS_STORE
 | 
				
			||||||
 | 
					#define ANALYSIS_STORE(NAME, CMDFLAG, DESC)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ANALYSIS_STORE(BasicStore, "basic", "Use basic analyzer store")
 | 
					ANALYSIS_STORE(BasicStore, "basic", "Use basic analyzer store")
 | 
				
			||||||
ANALYSIS_STORE(RegionStore, "region", "Use region-based analyzer store")
 | 
					ANALYSIS_STORE(RegionStore, "region", "Use region-based analyzer store")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef ANALYSIS_DIAGNOSTICS
 | 
				
			||||||
 | 
					#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ANALYSIS_DIAGNOSTICS(HTML,  "html",  "Output analysis results using HTML",   CreateHTMLDiagnosticClient)
 | 
				
			||||||
 | 
					ANALYSIS_DIAGNOSTICS(PLIST, "plist", "Output analysis results using Plists", CreatePlistDiagnosticClient)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#undef ANALYSIS
 | 
					#undef ANALYSIS
 | 
				
			||||||
#undef ANALYSIS_STORE
 | 
					#undef ANALYSIS_STORE
 | 
				
			||||||
 | 
					#undef ANALYSIS_DIAGNOSTICS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -75,20 +75,21 @@ namespace {
 | 
				
			||||||
    llvm::OwningPtr<PathDiagnosticClient> PD;
 | 
					    llvm::OwningPtr<PathDiagnosticClient> PD;
 | 
				
			||||||
    bool AnalyzeAll;  
 | 
					    bool AnalyzeAll;  
 | 
				
			||||||
    AnalysisStores SM;
 | 
					    AnalysisStores SM;
 | 
				
			||||||
 | 
					    AnalysisDiagClients DC;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    AnalysisConsumer(Diagnostic &diags, Preprocessor* pp,
 | 
					    AnalysisConsumer(Diagnostic &diags, Preprocessor* pp,
 | 
				
			||||||
                     PreprocessorFactory* ppf,
 | 
					                     PreprocessorFactory* ppf,
 | 
				
			||||||
                     const LangOptions& lopts,
 | 
					                     const LangOptions& lopts,
 | 
				
			||||||
                     const std::string& fname,
 | 
					                     const std::string& fname,
 | 
				
			||||||
                     const std::string& htmldir,
 | 
					                     const std::string& htmldir,
 | 
				
			||||||
                     AnalysisStores sm,
 | 
					                     AnalysisStores sm, AnalysisDiagClients dc,
 | 
				
			||||||
                     bool visgraphviz, bool visubi, bool trim, bool analyzeAll) 
 | 
					                     bool visgraphviz, bool visubi, bool trim, bool analyzeAll) 
 | 
				
			||||||
      : VisGraphviz(visgraphviz), VisUbigraph(visubi), TrimGraph(trim),
 | 
					      : VisGraphviz(visgraphviz), VisUbigraph(visubi), TrimGraph(trim),
 | 
				
			||||||
        LOpts(lopts), Diags(diags),
 | 
					        LOpts(lopts), Diags(diags),
 | 
				
			||||||
        Ctx(0), PP(pp), PPF(ppf),
 | 
					        Ctx(0), PP(pp), PPF(ppf),
 | 
				
			||||||
        HTMLDir(htmldir),
 | 
					        HTMLDir(htmldir),
 | 
				
			||||||
        FName(fname),
 | 
					        FName(fname),
 | 
				
			||||||
        AnalyzeAll(analyzeAll), SM(sm) {}
 | 
					        AnalyzeAll(analyzeAll), SM(sm), DC(dc) {}
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    void addCodeAction(CodeAction action) {
 | 
					    void addCodeAction(CodeAction action) {
 | 
				
			||||||
      FunctionActions.push_back(action);
 | 
					      FunctionActions.push_back(action);
 | 
				
			||||||
| 
						 | 
					@ -165,9 +166,14 @@ case NAME##Model: return Create##NAME##Manager;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    virtual PathDiagnosticClient* getPathDiagnosticClient() {
 | 
					    virtual PathDiagnosticClient* getPathDiagnosticClient() {
 | 
				
			||||||
      if (C.PD.get() == 0 && !C.HTMLDir.empty())
 | 
					      if (C.PD.get() == 0 && !C.HTMLDir.empty()) {
 | 
				
			||||||
        C.PD.reset(CreateHTMLDiagnosticClient(C.HTMLDir, C.PP, C.PPF));
 | 
					        switch (C.DC) {
 | 
				
			||||||
      
 | 
					          default:
 | 
				
			||||||
 | 
					#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN)\
 | 
				
			||||||
 | 
					case PD_##NAME: C.PD.reset(CREATEFN(C.HTMLDir, C.PP, C.PPF)); break;
 | 
				
			||||||
 | 
					#include "Analyses.def"
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
      return C.PD.get();      
 | 
					      return C.PD.get();      
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
| 
						 | 
					@ -449,6 +455,7 @@ static void ActionWarnObjCMethSigs(AnalysisManager& mgr) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ASTConsumer* clang::CreateAnalysisConsumer(Analyses* Beg, Analyses* End,
 | 
					ASTConsumer* clang::CreateAnalysisConsumer(Analyses* Beg, Analyses* End,
 | 
				
			||||||
                                           AnalysisStores SM,
 | 
					                                           AnalysisStores SM,
 | 
				
			||||||
 | 
					                                           AnalysisDiagClients DC,
 | 
				
			||||||
                                           Diagnostic &diags, Preprocessor* pp,
 | 
					                                           Diagnostic &diags, Preprocessor* pp,
 | 
				
			||||||
                                           PreprocessorFactory* ppf,
 | 
					                                           PreprocessorFactory* ppf,
 | 
				
			||||||
                                           const LangOptions& lopts,
 | 
					                                           const LangOptions& lopts,
 | 
				
			||||||
| 
						 | 
					@ -459,7 +466,7 @@ ASTConsumer* clang::CreateAnalysisConsumer(Analyses* Beg, Analyses* End,
 | 
				
			||||||
                                           bool analyzeAll) {
 | 
					                                           bool analyzeAll) {
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  llvm::OwningPtr<AnalysisConsumer>
 | 
					  llvm::OwningPtr<AnalysisConsumer>
 | 
				
			||||||
  C(new AnalysisConsumer(diags, pp, ppf, lopts, fname, htmldir, SM,
 | 
					  C(new AnalysisConsumer(diags, pp, ppf, lopts, fname, htmldir, SM, DC,
 | 
				
			||||||
                         VisGraphviz, VisUbi, trim, analyzeAll));
 | 
					                         VisGraphviz, VisUbi, trim, analyzeAll));
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  for ( ; Beg != End ; ++Beg)
 | 
					  for ( ; Beg != End ; ++Beg)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,9 +27,15 @@ enum AnalysisStores {
 | 
				
			||||||
#include "Analyses.def"
 | 
					#include "Analyses.def"
 | 
				
			||||||
NumStores
 | 
					NumStores
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					enum AnalysisDiagClients {
 | 
				
			||||||
 | 
					#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATFN) PD_##NAME,
 | 
				
			||||||
 | 
					#include "Analyses.def"
 | 
				
			||||||
 | 
					NUM_ANALYSIS_DIAG_CLIENTS
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ASTConsumer* CreateAnalysisConsumer(Analyses* Beg, Analyses* End,
 | 
					ASTConsumer* CreateAnalysisConsumer(Analyses* Beg, Analyses* End,
 | 
				
			||||||
                                    AnalysisStores SM,
 | 
					                                    AnalysisStores SM, AnalysisDiagClients DC,
 | 
				
			||||||
                                    Diagnostic &diags, Preprocessor* pp,
 | 
					                                    Diagnostic &diags, Preprocessor* pp,
 | 
				
			||||||
                                    PreprocessorFactory* ppf,
 | 
					                                    PreprocessorFactory* ppf,
 | 
				
			||||||
                                    const LangOptions& lopts,
 | 
					                                    const LangOptions& lopts,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -220,6 +220,15 @@ clEnumValN(NAME##Model, "analyzer-store-" CMDFLAG, DESC),
 | 
				
			||||||
#include "Analyses.def"
 | 
					#include "Analyses.def"
 | 
				
			||||||
clEnumValEnd));
 | 
					clEnumValEnd));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static llvm::cl::opt<AnalysisDiagClients>
 | 
				
			||||||
 | 
					AnalysisDiagOpt(llvm::cl::desc("SCA Output Options:"),
 | 
				
			||||||
 | 
					                llvm::cl::init(PD_HTML),
 | 
				
			||||||
 | 
					                llvm::cl::values(
 | 
				
			||||||
 | 
					#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATFN)\
 | 
				
			||||||
 | 
					clEnumValN(PD_##NAME, "analyzer-output-" CMDFLAG, DESC),
 | 
				
			||||||
 | 
					#include "Analyses.def"
 | 
				
			||||||
 | 
					clEnumValEnd));                                
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//===----------------------------------------------------------------------===//
 | 
					//===----------------------------------------------------------------------===//
 | 
				
			||||||
// Language Options
 | 
					// Language Options
 | 
				
			||||||
//===----------------------------------------------------------------------===//
 | 
					//===----------------------------------------------------------------------===//
 | 
				
			||||||
| 
						 | 
					@ -1224,7 +1233,7 @@ static ASTConsumer* CreateASTConsumer(const std::string& InFile,
 | 
				
			||||||
      assert (!AnalysisList.empty());
 | 
					      assert (!AnalysisList.empty());
 | 
				
			||||||
      return CreateAnalysisConsumer(&AnalysisList[0],
 | 
					      return CreateAnalysisConsumer(&AnalysisList[0],
 | 
				
			||||||
                                    &AnalysisList[0]+AnalysisList.size(),
 | 
					                                    &AnalysisList[0]+AnalysisList.size(),
 | 
				
			||||||
                                    AnalysisStoreOpt,
 | 
					                                    AnalysisStoreOpt, AnalysisDiagOpt,
 | 
				
			||||||
                                    Diag, PP, PPF, LangOpts,
 | 
					                                    Diag, PP, PPF, LangOpts,
 | 
				
			||||||
                                    AnalyzeSpecificFunction,
 | 
					                                    AnalyzeSpecificFunction,
 | 
				
			||||||
                                    OutputFile, VisualizeEGDot, VisualizeEGUbi,
 | 
					                                    OutputFile, VisualizeEGDot, VisualizeEGUbi,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,7 +26,9 @@ PathDiagnosticClient* CreateHTMLDiagnosticClient(const std::string& prefix,
 | 
				
			||||||
                                                 Preprocessor* PP,
 | 
					                                                 Preprocessor* PP,
 | 
				
			||||||
                                                 PreprocessorFactory* PPF);
 | 
					                                                 PreprocessorFactory* PPF);
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
PathDiagnosticClient* CreatePlistDiagnosticClient(const std::string& prefix);
 | 
					PathDiagnosticClient* CreatePlistDiagnosticClient(const std::string& prefix,
 | 
				
			||||||
 | 
					                                                  Preprocessor* PP,
 | 
				
			||||||
 | 
					                                                  PreprocessorFactory* PPF);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,6 +24,11 @@
 | 
				
			||||||
using namespace clang;
 | 
					using namespace clang;
 | 
				
			||||||
typedef llvm::DenseMap<unsigned,unsigned> FIDMap;
 | 
					typedef llvm::DenseMap<unsigned,unsigned> FIDMap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace clang {
 | 
				
			||||||
 | 
					  class Preprocessor;
 | 
				
			||||||
 | 
					  class PreprocessorFactory;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace {
 | 
					namespace {
 | 
				
			||||||
  class VISIBILITY_HIDDEN PlistDiagnostics : public PathDiagnosticClient {
 | 
					  class VISIBILITY_HIDDEN PlistDiagnostics : public PathDiagnosticClient {
 | 
				
			||||||
    llvm::sys::Path Directory, FilePrefix;
 | 
					    llvm::sys::Path Directory, FilePrefix;
 | 
				
			||||||
| 
						 | 
					@ -40,7 +45,9 @@ PlistDiagnostics::PlistDiagnostics(const std::string& prefix)
 | 
				
			||||||
  FilePrefix.appendComponent("report"); // All Plist files begin with "report" 
 | 
					  FilePrefix.appendComponent("report"); // All Plist files begin with "report" 
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PathDiagnosticClient* clang::CreatePlistDiagnosticClient(const std::string& s) {
 | 
					PathDiagnosticClient*
 | 
				
			||||||
 | 
					clang::CreatePlistDiagnosticClient(const std::string& s,
 | 
				
			||||||
 | 
					                                   Preprocessor*, PreprocessorFactory*) {
 | 
				
			||||||
  return new PlistDiagnostics(s);
 | 
					  return new PlistDiagnostics(s);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -118,7 +125,7 @@ static void ReportDiag(llvm::raw_ostream& o, const PathDiagnosticPiece& P,
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  // Output the text.
 | 
					  // Output the text.
 | 
				
			||||||
  Indent(o, indent) << "<key>message</key>\n";
 | 
					  Indent(o, indent) << "<key>message</key>\n";
 | 
				
			||||||
  Indent(o, indent) << "<string>" << P.getString() << "</string>";
 | 
					  Indent(o, indent) << "<string>" << P.getString() << "</string>\n";
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  // Output the hint.
 | 
					  // Output the hint.
 | 
				
			||||||
  Indent(o, indent) << "<key>displayhint</key>\n";
 | 
					  Indent(o, indent) << "<key>displayhint</key>\n";
 | 
				
			||||||
| 
						 | 
					@ -222,9 +229,9 @@ void PlistDiagnostics::HandlePathDiagnostic(const PathDiagnostic* D) {
 | 
				
			||||||
  o << " </array>\n";
 | 
					  o << " </array>\n";
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
  // Output the bug type and bug category.  
 | 
					  // Output the bug type and bug category.  
 | 
				
			||||||
  o << " <key>description</key><string>" << D->getDescription() << "</string>\n"
 | 
					  o << " <key>description</key>\n <string>" << D->getDescription() << "</string>\n"
 | 
				
			||||||
       " <key>category</key><string>" << D->getCategory() << "</string>\n";
 | 
					       " <key>category</key>\n <string>" << D->getCategory() << "</string>\n";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Finish.
 | 
					  // Finish.
 | 
				
			||||||
  o << "</dict>\n";
 | 
					  o << "</dict>\n</plist>";
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue