[cfe-commits] r117853 - in /cfe/trunk: lib/Checker/AnalysisConsumer.cpp test/Analysis/misc-ps-region-store.cpp
Zhanyong Wan
wan at google.com
Sat Oct 30 21:22:34 PDT 2010
Author: wan
Date: Sat Oct 30 23:22:34 2010
New Revision: 117853
URL: http://llvm.org/viewvc/llvm-project?rev=117853&view=rev
Log:
Make Clang static analyzer skip function template definitions. This fixes Clang PR 8426, 8427, & 8433. Reviewed by Ted Kremenek and Doug Gregor.
Modified:
cfe/trunk/lib/Checker/AnalysisConsumer.cpp
cfe/trunk/test/Analysis/misc-ps-region-store.cpp
Modified: cfe/trunk/lib/Checker/AnalysisConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/AnalysisConsumer.cpp?rev=117853&r1=117852&r2=117853&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/AnalysisConsumer.cpp (original)
+++ cfe/trunk/lib/Checker/AnalysisConsumer.cpp Sat Oct 30 23:22:34 2010
@@ -211,8 +211,10 @@
case Decl::CXXMethod:
case Decl::Function: {
FunctionDecl* FD = cast<FunctionDecl>(D);
-
- if (FD->isThisDeclarationADefinition()) {
+ // We skip function template definitions, as their semantics is
+ // only determined when they are instantiated.
+ if (FD->isThisDeclarationADefinition() &&
+ !FD->isDependentContext()) {
if (!Opts.AnalyzeSpecificFunction.empty() &&
FD->getDeclName().getAsString() != Opts.AnalyzeSpecificFunction)
break;
Modified: cfe/trunk/test/Analysis/misc-ps-region-store.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps-region-store.cpp?rev=117853&r1=117852&r2=117853&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps-region-store.cpp (original)
+++ cfe/trunk/test/Analysis/misc-ps-region-store.cpp Sat Oct 30 23:22:34 2010
@@ -159,3 +159,50 @@
for (; ; x++) { }
}
+// PR8426 -- this used to crash.
+
+void Use(void* to);
+
+template <class T> class Foo {
+ ~Foo();
+ struct Bar;
+ Bar* bar_;
+};
+
+template <class T> Foo<T>::~Foo() {
+ Use(bar_);
+ T::DoSomething();
+ bar_->Work();
+}
+
+// PR8427 -- this used to crash.
+
+class Dummy {};
+
+bool operator==(Dummy, int);
+
+template <typename T>
+class Foo2 {
+ bool Bar();
+};
+
+template <typename T>
+bool Foo2<T>::Bar() {
+ return 0 == T();
+}
+
+// PR8433 -- this used to crash.
+
+template <typename T>
+class Foo3 {
+ public:
+ void Bar();
+ void Baz();
+ T value_;
+};
+
+template <typename T>
+void Foo3<T>::Bar() {
+ Baz();
+ value_();
+}
More information about the cfe-commits
mailing list