[analyzer] Make the defaults explicit for each of the new config options.

Also, document both new inlining options in IPA.txt.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163551 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/docs/analyzer/IPA.txt b/docs/analyzer/IPA.txt
index 5a6039d..016cea9 100644
--- a/docs/analyzer/IPA.txt
+++ b/docs/analyzer/IPA.txt
@@ -28,12 +28,18 @@
 
 Currently, -analyzer-ipa=dynamic-bifurcate is the default mode.
 
+While -analyzer-ipa determines in general how aggressively the analyzer will try to
+inline functions, several additional options control which types of functions can
+inlined, in an all-or-nothing way. These options use the analyzer's configuration
+table, so they are all specified as follows:
 
-A second setting, c++-inlining, controls which C++ member functions may be
-inlined. This option uses the analyzer's configuration table, so it is specified
-as shown here:
+    -analyzer-config OPTION=VALUE
 
-  -analyzer-config c++-inlining=[none | methods | constructors | destructors]
+### c++-inlining ###
+
+This option controls which C++ member functions may be inlined.
+
+    -analyzer-config c++-inlining=[none | methods | constructors | destructors]
 
 Each of these modes implies that all the previous member function kinds will be
 inlined as well; it doesn't make sense to inline destructors without inlining
@@ -44,6 +50,35 @@
 functions will be inlined under -analyzer-ipa=none or
 -analyzer-ipa=basic-inlining.
 
+### c++-template-inlining ###
+
+This option controls whether C++ templated functions may be inlined.
+
+    -analyzer-config c++-template-inlining=[true | false]
+
+Currently, template functions are considered for inlining by default.
+
+The motivation behind this option is that very generic code can be a source
+of false positives, either by considering paths that the caller considers
+impossible (by some unstated precondition), or by inlining some but not all
+of a deep implementation of a function.
+
+### c++-stdlib-inlining ###
+
+This option controls whether functions from the C++ standard library, including
+methods of the container classes in the Standard Template Library, should be
+considered for inlining.
+
+    -analyzer-config c++-template-inlining=[true | false]
+
+Currently, C++ standard library functions are NOT considered for inlining by default.
+
+The standard library functions and the STL in particular are used ubiquitously
+enough that our tolerance for false positives is even lower here. A false
+positive due to poor modeling of the STL leads to a poor user experience, since
+most users would not be comfortable adding assertions to system headers in order
+to silence analyzer warnings.
+
 
 Basics of Implementation
 -----------------------
diff --git a/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h b/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
index 3065098..eb3f8e4 100644
--- a/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ b/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -169,11 +169,20 @@
   /// Controls which C++ member functions will be considered for inlining.
   CXXInlineableMemberKind CXXMemberInliningMode;
   
+  /// \sa includeTemporaryDtorsInCFG
   llvm::Optional<bool> IncludeTemporaryDtorsInCFG;
+  
+  /// \sa mayInlineCXXStandardLibrary
   llvm::Optional<bool> InlineCXXStandardLibrary;
+  
+  /// \sa mayInlineTemplateFunctions
   llvm::Optional<bool> InlineTemplateFunctions;
   
-  bool getBooleanOption(StringRef Name, bool DefaultVal = false) const;
+  /// Interprets an option's string value as a boolean.
+  ///
+  /// Accepts the strings "true" and "false".
+  /// If an option value is not provided, returns the given \p DefaultVal.
+  bool getBooleanOption(StringRef Name, bool DefaultVal) const;
 
 public:
   /// Returns the option controlling which C++ member functions will be
@@ -187,8 +196,8 @@
   /// Returns whether or not the destructors for C++ temporary objects should
   /// be included in the CFG.
   ///
-  /// This is controlled by the 'cfg-temporary-dtors' config option. Any
-  /// non-empty value is considered to be 'true'.
+  /// This is controlled by the 'cfg-temporary-dtors' config option, which
+  /// accepts the values "true" and "false".
   bool includeTemporaryDtorsInCFG() const;
 
   /// Returns whether or not C++ standard library functions may be considered
diff --git a/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp b/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
index b410890..29e2783 100644
--- a/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ b/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
@@ -60,7 +60,7 @@
 bool AnalyzerOptions::includeTemporaryDtorsInCFG() const {
   if (!IncludeTemporaryDtorsInCFG.hasValue())
     const_cast<llvm::Optional<bool> &>(IncludeTemporaryDtorsInCFG) =
-      getBooleanOption("cfg-temporary-dtors");
+      getBooleanOption("cfg-temporary-dtors", /*Default=*/false);
   
   return *IncludeTemporaryDtorsInCFG;
 }
@@ -68,7 +68,7 @@
 bool AnalyzerOptions::mayInlineCXXStandardLibrary() const {
   if (!InlineCXXStandardLibrary.hasValue())
     const_cast<llvm::Optional<bool> &>(InlineCXXStandardLibrary) =
-      getBooleanOption("c++-stdlib-inlining");
+      getBooleanOption("c++-stdlib-inlining", /*Default=*/false);
   
   return *InlineCXXStandardLibrary;
 }