[PATCH] D22188: clang-tidy/readability-identifier-naming: crash on DependentTemplateSpecializationType

Matthias Gehre via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 9 13:16:50 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL274985: clang-tidy/readability-identifier-naming: crash on… (authored by mgehre).

Changed prior to commit:
  http://reviews.llvm.org/D22188?vs=63397&id=63398#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D22188

Files:
  clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp

Index: clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -656,15 +656,16 @@
 
       SourceRange Range(Ref.getTemplateNameLoc(), Ref.getTemplateNameLoc());
       if (const auto *ClassDecl = dyn_cast<TemplateDecl>(Decl)) {
-        addUsage(NamingCheckFailures, ClassDecl->getTemplatedDecl(), Range);
+        if (const auto *TemplDecl = ClassDecl->getTemplatedDecl())
+          addUsage(NamingCheckFailures, TemplDecl, Range);
         return;
       }
     }
 
     if (const auto &Ref =
             Loc->getAs<DependentTemplateSpecializationTypeLoc>()) {
-      addUsage(NamingCheckFailures, Ref.getTypePtr()->getAsTagDecl(),
-               Loc->getSourceRange());
+      if (const auto *Decl = Ref.getTypePtr()->getAsTagDecl())
+        addUsage(NamingCheckFailures, Decl, Loc->getSourceRange());
       return;
     }
   }
Index: clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp
@@ -344,3 +344,9 @@
 // CHECK-FIXES: {{^}}void MY_TEST_MACRO(function) {}
 }
 }
+
+template <typename t_t> struct a {
+  typename t_t::template b<> c;
+};
+
+template <template <typename> class A> struct b { A<int> c; };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22188.63398.patch
Type: text/x-patch
Size: 1605 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160709/a1053fd8/attachment.bin>


More information about the cfe-commits mailing list