[PATCH] D121498: let EST_Uninstantiated in FunctionProtoType::canThrow return CT_Dependent

zhouyizhou via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 11 15:15:21 PST 2022


zhouyizhou created this revision.
zhouyizhou added reviewers: rsmith, erichkeane, CornedBee.
Herald added a project: All.
zhouyizhou requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When compile following code without -std=c++17, clang will abort by llvm_unreachable:

- code begin ---

template<class T>
void foo() noexcept(T::value);

struct S {

  static const bool value;

};

const bool S::value = 0;

template<class... Args, bool is_noexcept>
constexpr bool is_noexcept_function(void(Args...) noexcept(is_noexcept)) {

  return is_noexcept;

}

void fn()
{

  is_noexcept_function(foo<S>);

}

- code end ---

So, my solution is to let EST_Uninstantiated in FunctionProtoType::canThrow return CT_Dependent

Thanks
Zhouyi Zhou <zhouzhouyi at gmail.com>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121498

Files:
  clang/lib/AST/Type.cpp


Index: clang/lib/AST/Type.cpp
===================================================================
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -3320,8 +3320,9 @@
   switch (getExceptionSpecType()) {
   case EST_Unparsed:
   case EST_Unevaluated:
-  case EST_Uninstantiated:
     llvm_unreachable("should not call this with unresolved exception specs");
+  case EST_Uninstantiated:
+    return CT_Dependent;
 
   case EST_DynamicNone:
   case EST_BasicNoexcept:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121498.414761.patch
Type: text/x-patch
Size: 473 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220311/b5bfdd2a/attachment.bin>


More information about the cfe-commits mailing list