[clang-tools-extra] r258356 - Make modernize-use-default tolerant of delayed template parsing; this code was previously causing failed assertions because dyn_cast was being passed a null pointer due to the delay-parsed body.

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 20 14:14:11 PST 2016


Author: aaronballman
Date: Wed Jan 20 16:14:10 2016
New Revision: 258356

URL: http://llvm.org/viewvc/llvm-project?rev=258356&view=rev
Log:
Make modernize-use-default tolerant of delayed template parsing; this code was previously causing failed assertions because dyn_cast was being passed a null pointer due to the delay-parsed body.

Added:
    clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-delayed.cpp
Modified:
    clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp?rev=258356&r1=258355&r2=258356&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp Wed Jan 20 16:14:10 2016
@@ -272,6 +272,7 @@ void UseDefaultCheck::check(const MatchF
   // that are not user-provided (automatically generated).
   if (SpecialFunctionDecl->isDeleted() ||
       SpecialFunctionDecl->isExplicitlyDefaulted() ||
+      SpecialFunctionDecl->isLateTemplateParsed() ||
       !SpecialFunctionDecl->isUserProvided() || !SpecialFunctionDecl->hasBody())
     return;
 

Added: clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-delayed.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-delayed.cpp?rev=258356&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-delayed.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-delayed.cpp Wed Jan 20 16:14:10 2016
@@ -0,0 +1,8 @@
+// RUN: clang-tidy %s -checks=-*,modernize-use-default -- -std=c++11 -fdelayed-template-parsing -fexceptions | count 0
+// Note: this test expects no diagnostics, but FileCheck cannot handle that,
+// hence the use of | count 0.
+
+template <typename Ty>
+struct S {
+  S<Ty>& operator=(const S<Ty>&) { return *this; }
+};




More information about the cfe-commits mailing list