Change AnalyzerOptions::mayInlineCXXMemberFunction to default populate
authorTed Kremenek <kremenek@apple.com>
Tue, 2 Oct 2012 20:31:52 +0000 (20:31 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 2 Oct 2012 20:31:52 +0000 (20:31 +0000)
the config string table.  Also setup a test for dumping the analyzer
configuration for C++.

llvm-svn: 165040

clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
clang/test/Analysis/analyzer-config.cpp [new file with mode: 0644]

index d6dee64..852f8bb 100644 (file)
@@ -204,7 +204,7 @@ public:
   /// This is controlled by the 'c++-inlining' config option.
   ///
   /// \sa CXXMemberInliningMode
-  bool mayInlineCXXMemberFunction(CXXInlineableMemberKind K) const;
+  bool mayInlineCXXMemberFunction(CXXInlineableMemberKind K);
 
   /// Returns true if ObjectiveC inlining is enabled, false otherwise.
   bool mayInlineObjCMethod();
index 7e6013b..bb1acb0 100644 (file)
@@ -19,19 +19,20 @@ using namespace clang;
 using namespace llvm;
 
 bool
-AnalyzerOptions::mayInlineCXXMemberFunction(CXXInlineableMemberKind K) const {
+AnalyzerOptions::mayInlineCXXMemberFunction(CXXInlineableMemberKind K) {
   if (IPAMode < Inlining)
     return false;
 
   if (!CXXMemberInliningMode) {
     static const char *ModeKey = "c++-inlining";
-    std::string ModeStr = Config.lookup(ModeKey);
+    
+    StringRef ModeStr(Config.GetOrCreateValue(ModeKey,
+                                              "methods").getValue());
 
     CXXInlineableMemberKind &MutableMode =
       const_cast<CXXInlineableMemberKind &>(CXXMemberInliningMode);
 
     MutableMode = llvm::StringSwitch<CXXInlineableMemberKind>(ModeStr)
-      .Case("", CIMK_MemberFunctions)
       .Case("constructors", CIMK_Constructors)
       .Case("destructors", CIMK_Destructors)
       .Case("none", CIMK_None)
diff --git a/clang/test/Analysis/analyzer-config.cpp b/clang/test/Analysis/analyzer-config.cpp
new file mode 100644 (file)
index 0000000..32196bf
--- /dev/null
@@ -0,0 +1,20 @@
+// RUN: %clang --analyze %s -o /dev/null -Xclang -analyzer-checker=debug.ConfigDumper > %t 2>&1
+// RUN: FileCheck --input-file=%t %s
+
+void bar() {}
+void foo() { bar(); }
+
+class Foo {
+public:
+       void bar() {}
+       void foo() { bar(); }
+};
+
+// CHECK: [config]
+// CHECK-NEXT: c++-inlining = methods
+// CHECK-NEXT: c++-stdlib-inlining = true
+// CHECK-NEXT: c++-template-inlining = true
+// CHECK-NEXT: cfg-temporary-dtors = false
+// CHECK-NEXT: faux-bodies = true
+// CHECK-NEXT: [stats]
+// CHECK-NEXT: num-entries = 5