Add new -cc1 driver option -analyzer-config, which allows one to specify
a comma separated collection of key:value pairs (which are strings).  This
allows a general way to provide analyzer configuration data from the command line.

No clients yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162827 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/DiagnosticDriverKinds.td b/include/clang/Basic/DiagnosticDriverKinds.td
index bc961ee..724a9a8 100644
--- a/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/include/clang/Basic/DiagnosticDriverKinds.td
@@ -141,5 +141,9 @@
 
 def note_drv_command_failed_diag_msg : Note<
   "diagnostic msg: %0">;
-
+  
+def err_analyzer_config_no_value : Error<
+  "analyzer-config option '%0' has a key but no value">;
+def err_analyzer_config_multiple_values : Error<
+  "analyzer-config option '%0' should contain only one ':'">;
 }
diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td
index 86b9bde..9213d21 100644
--- a/include/clang/Driver/CC1Options.td
+++ b/include/clang/Driver/CC1Options.td
@@ -119,6 +119,11 @@
 def analyzer_checker_help : Flag<"-analyzer-checker-help">,
   HelpText<"Display the list of analyzer checkers that are available">;
 
+def analyzer_config : Separate<"-analyzer-config">,
+  HelpText<"Choose analyzer checkers to enable">;
+def analyzer_config_EQ : Joined<"-analyzer-config=">,
+  Alias<analyzer_config>;
+
 //===----------------------------------------------------------------------===//
 // Migrator Options
 //===----------------------------------------------------------------------===//
diff --git a/include/clang/Frontend/AnalyzerOptions.h b/include/clang/Frontend/AnalyzerOptions.h
index 4e5d7cb..5c508ec 100644
--- a/include/clang/Frontend/AnalyzerOptions.h
+++ b/include/clang/Frontend/AnalyzerOptions.h
@@ -17,6 +17,7 @@
 
 #include <string>
 #include <vector>
+#include "llvm/ADT/StringMap.h"
 
 namespace clang {
 class ASTConsumer;
@@ -78,6 +79,7 @@
 public:
   /// \brief Pair of checker name and enable/disable.
   std::vector<std::pair<std::string, bool> > CheckersControlList;
+  llvm::StringMap<std::string> Config;
   AnalysisStores AnalysisStoreOpt;
   AnalysisConstraints AnalysisConstraintsOpt;
   AnalysisDiagClients AnalysisDiagOpt;
diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h b/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
index 876196b..24218be 100644
--- a/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
+++ b/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
@@ -81,6 +81,11 @@
   /// strategy. We get better code coverage when retry is enabled.
   bool NoRetryExhausted;
 
+  typedef llvm::StringMap<std::string> ConfigTable;
+  
+  /// \brief A key-value table of use-specified configuration values.
+  const ConfigTable &Config;
+  
 public:
   AnalysisManager(ASTContext &ctx,DiagnosticsEngine &diags,
                   const LangOptions &lang,
@@ -88,6 +93,7 @@
                   StoreManagerCreator storemgr,
                   ConstraintManagerCreator constraintmgr, 
                   CheckerManager *checkerMgr,
+                  const ConfigTable &Config,
                   unsigned maxnodes, unsigned maxvisit,
                   bool vizdot, bool vizubi, AnalysisPurgeMode purge,
                   bool eager, bool trim,
diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h b/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
index 478bf71..c260c1b 100644
--- a/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
+++ b/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
@@ -64,6 +64,10 @@
     return Eng.getStoreManager();
   }
 
+  const AnalysisManager::ConfigTable &getConfig() const {
+    return Eng.getAnalysisManager().Config;
+  }
+  
   /// \brief Returns the previous node in the exploded graph, which includes
   /// the state of the program before the checker ran. Note, checkers should
   /// not retain the node in their state since the nodes might get invalidated.