[PATCH] D23780: [analyzer] Fixed crash in StmtDataCollector when analyzing methods of template classes.

Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 23 09:50:19 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL279529: [analyzer] Fix CloneDetector crash on calling methods of class templates. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D23780?vs=68883&id=69007#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23780

Files:
  cfe/trunk/lib/Analysis/CloneDetection.cpp
  cfe/trunk/test/Analysis/copypaste/call.cpp

Index: cfe/trunk/test/Analysis/copypaste/call.cpp
===================================================================
--- cfe/trunk/test/Analysis/copypaste/call.cpp
+++ cfe/trunk/test/Analysis/copypaste/call.cpp
@@ -88,3 +88,15 @@
     return templatePaddingFunc<XX, X>();
   return true;
 }
+
+// Test that we don't crash on member functions of template instantiations.
+
+template<typename T>
+struct A {
+  void foo(T t) {}
+};
+
+void fooTestInstantiation() {
+  A<int> a;
+  a.foo(1);
+}
Index: cfe/trunk/lib/Analysis/CloneDetection.cpp
===================================================================
--- cfe/trunk/lib/Analysis/CloneDetection.cpp
+++ cfe/trunk/lib/Analysis/CloneDetection.cpp
@@ -345,10 +345,9 @@
   DEF_ADD_DATA(CallExpr, {
     // Function pointers don't have a callee and we just skip hashing it.
     if (const FunctionDecl *D = S->getDirectCallee()) {
-      // If the function is a template instantiation, we also need to handle
-      // the template arguments as they are no included in the qualified name.
-      if (D->isTemplateInstantiation()) {
-        auto Args = D->getTemplateSpecializationArgs();
+      // If the function is a template specialization, we also need to handle
+      // the template arguments as they are not included in the qualified name.
+      if (auto Args = D->getTemplateSpecializationArgs()) {
         std::string ArgString;
 
         // Print all template arguments into ArgString


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23780.69007.patch
Type: text/x-patch
Size: 1452 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160823/e9522921/attachment.bin>


More information about the cfe-commits mailing list