[PATCH] D117391: [AST] Ignore implicit nodes in CastExpr::getConversionFunction

Kim Gräsman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 2 11:29:44 PST 2022


kimgr added a comment.

Alright, with this diff:

  diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
  index d502b3f1e93e..1716ac0be7ef 100644
  --- a/clang/lib/AST/Expr.cpp
  +++ b/clang/lib/AST/Expr.cpp
  @@ -1908,6 +1908,9 @@ namespace {
       if (auto *Binder = dyn_cast<CXXBindTemporaryExpr>(E))
         E = Binder->getSubExpr();
   
  +    if (auto *Full = dyn_cast<FullExpr>(E))
  +      E = Full->getSubExpr();
  +
       return E;
     }
   }
  @@ -1944,7 +1947,6 @@ NamedDecl *CastExpr::getConversionFunction() const {
   
     for (const CastExpr *E = this; E; E = dyn_cast<ImplicitCastExpr>(SubExpr)) {
       SubExpr = skipImplicitTemporary(E->getSubExpr());
  -    SubExpr = SubExpr->IgnoreImplicit();
   
       if (E->getCastKind() == CK_ConstructorConversion)
         return cast<CXXConstructExpr>(SubExpr)->getConstructor();

I get these test failures for `ninja check-clang`:

  FAIL: Clang :: SemaCXX/cxx2a-consteval.cpp (71 of 970)
  ******************** TEST 'Clang :: SemaCXX/cxx2a-consteval.cpp' FAILED ********************
  Script:
  --
  : 'RUN: at line 1';   /home/kimgr/code/llvm-project/out/main/bin/clang -cc1 -internal-isystem /home/kimgr/code/llvm-project/out/main/lib/clang/15.0.0/include -nostdsysteminc -std=c++2a -emit-llvm-only -Wno-unused-value /home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp -verify
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  error: 'error' diagnostics seen but not expected: 
    File /home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp Line 362: call to consteval function 'alloc::to_lvalue_ref' is not a constant expression
    File /home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp Line 364: call to consteval function 'alloc::A::ret_a' is not a constant expression
    File /home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp Line 370: call to consteval function 'alloc::A::ret_a' is not a constant expression
    File /home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp Line 371: call to consteval function 'alloc::A::ret_a' is not a constant expression
    File /home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp Line 377: call to consteval function 'alloc::A::ret_a' is not a constant expression
  error: 'note' diagnostics seen but not expected: 
    File /home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp Line 362: reference to temporary is not a constant expression
    File /home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp Line 364: pointer to heap-allocated object is not a constant expression
    File /home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp Line 370: pointer to heap-allocated object is not a constant expression
    File /home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp Line 371: pointer to heap-allocated object is not a constant expression
    File /home/kimgr/code/llvm-project/clang/test/SemaCXX/cxx2a-consteval.cpp Line 377: pointer to heap-allocated object is not a constant expression
  10 errors generated.

I'm going to dive in and see if I can judge who is right, tests or code.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117391/new/

https://reviews.llvm.org/D117391



More information about the cfe-commits mailing list