zinovy.nis created this revision.
zinovy.nis added reviewers: alexfh, rsmith.
zinovy.nis added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
zinovy.nis requested review of this revision.
Bug: https://bugs.llvm.org/show_bug.cgi?id=47446


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87627

Files:
  clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp
@@ -19,6 +19,11 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 
'throw(int(int))' is deprecated; consider removing it instead 
[modernize-use-noexcept]
 // CHECK-FIXES: void k() ;
 
+// Shouldn't crash due to llvm_unreachable in canThrow() on EST_Uninstantiated
+template <int> class c { void *operator new(size_t) throw (int);};
+void s() { c<1> doesnt_crash; }
+// CHECK-MESSAGES: :[[@LINE-2]]:53: warning: dynamic exception specification 
'throw (int)' is deprecated; consider removing it instead 
[modernize-use-noexcept]
+
 void foobar() throw(A, B)
 {}
 // CHECK-MESSAGES: :[[@LINE-2]]:15: warning: dynamic exception specification 
'throw(A, B)' is deprecated; consider removing it instead 
[modernize-use-noexcept]
Index: clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
@@ -77,13 +77,16 @@
                   .getExceptionSpecRange();
   }
 
+  assert(FnTy && "FunctionProtoType is null.");
+  if (clang::isUnresolvedExceptionSpec(FnTy->getExceptionSpecType()))
+      return;
+
   assert(Range.isValid() && "Exception Source Range is invalid.");
 
   CharSourceRange CRange = Lexer::makeFileCharRange(
       CharSourceRange::getTokenRange(Range), *Result.SourceManager,
       Result.Context->getLangOpts());
 
-  assert(FnTy && "FunctionProtoType is null.");
   bool IsNoThrow = FnTy->isNothrow();
   StringRef ReplacementStr =
       IsNoThrow


Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-noexcept-opt.cpp
@@ -19,6 +19,11 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 'throw(int(int))' is deprecated; consider removing it instead [modernize-use-noexcept]
 // CHECK-FIXES: void k() ;
 
+// Shouldn't crash due to llvm_unreachable in canThrow() on EST_Uninstantiated
+template <int> class c { void *operator new(size_t) throw (int);};
+void s() { c<1> doesnt_crash; }
+// CHECK-MESSAGES: :[[@LINE-2]]:53: warning: dynamic exception specification 'throw (int)' is deprecated; consider removing it instead [modernize-use-noexcept]
+
 void foobar() throw(A, B)
 {}
 // CHECK-MESSAGES: :[[@LINE-2]]:15: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider removing it instead [modernize-use-noexcept]
Index: clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp
@@ -77,13 +77,16 @@
                   .getExceptionSpecRange();
   }
 
+  assert(FnTy && "FunctionProtoType is null.");
+  if (clang::isUnresolvedExceptionSpec(FnTy->getExceptionSpecType()))
+      return;
+
   assert(Range.isValid() && "Exception Source Range is invalid.");
 
   CharSourceRange CRange = Lexer::makeFileCharRange(
       CharSourceRange::getTokenRange(Range), *Result.SourceManager,
       Result.Context->getLangOpts());
 
-  assert(FnTy && "FunctionProtoType is null.");
   bool IsNoThrow = FnTy->isNothrow();
   StringRef ReplacementStr =
       IsNoThrow
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to