summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Analysis/CloneDetection.cpp7
-rw-r--r--clang/test/Analysis/copypaste/call.cpp12
2 files changed, 15 insertions, 4 deletions
diff --git a/clang/lib/Analysis/CloneDetection.cpp b/clang/lib/Analysis/CloneDetection.cpp
index 9d11dabf964..a91ccaa4d2c 100644
--- a/clang/lib/Analysis/CloneDetection.cpp
+++ b/clang/lib/Analysis/CloneDetection.cpp
@@ -345,10 +345,9 @@ public:
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
diff --git a/clang/test/Analysis/copypaste/call.cpp b/clang/test/Analysis/copypaste/call.cpp
index 46df02280ee..8e95f7cb304 100644
--- a/clang/test/Analysis/copypaste/call.cpp
+++ b/clang/test/Analysis/copypaste/call.cpp
@@ -88,3 +88,15 @@ bool fooTemplatePadding2(int x) {
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);
+}
OpenPOWER on IntegriCloud