[cfe-commits] r163551 - in /cfe/trunk: docs/analyzer/IPA.txt include/clang/StaticAnalyzer/Core/AnalyzerOptions.h lib/StaticAnalyzer/Core/AnalyzerOptions.cpp

Jordan Rose jordan_rose at apple.com
Mon Sep 10 14:54:24 PDT 2012


Author: jrose
Date: Mon Sep 10 16:54:24 2012
New Revision: 163551

URL: http://llvm.org/viewvc/llvm-project?rev=163551&view=rev
Log:
[analyzer] Make the defaults explicit for each of the new config options.

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

Modified:
    cfe/trunk/docs/analyzer/IPA.txt
    cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
    cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp

Modified: cfe/trunk/docs/analyzer/IPA.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/analyzer/IPA.txt?rev=163551&r1=163550&r2=163551&view=diff
==============================================================================
--- cfe/trunk/docs/analyzer/IPA.txt (original)
+++ cfe/trunk/docs/analyzer/IPA.txt Mon Sep 10 16:54:24 2012
@@ -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
 -----------------------

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h?rev=163551&r1=163550&r2=163551&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Mon Sep 10 16:54:24 2012
@@ -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

Modified: cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp?rev=163551&r1=163550&r2=163551&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp Mon Sep 10 16:54:24 2012
@@ -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;
 }





More information about the cfe-commits mailing list