[PATCH] D148914: [Sema][NFC] add check before using `BuildExpressionFromIntegralTemplateArgument`

2023-04-21 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

See my comment on https://github.com/llvm/llvm-project/issues/62265 for results 
of my debugging.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148914

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148914: [Sema][NFC] add check before using `BuildExpressionFromIntegralTemplateArgument`

2023-04-21 Thread Erich Keane via Phabricator via cfe-commits
erichkeane requested changes to this revision.
erichkeane added a comment.
This revision now requires changes to proceed.

This is the wrong fix here, the crash is appropriate here, else we're not 
getting the type right.  For your example, we need to be setting up the 
template arguments correctly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148914

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148914: [Sema][NFC] add check before using `BuildExpressionFromIntegralTemplateArgument`

2023-04-21 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 created this revision.
Herald added a project: All.
HerrCai0907 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch wants to avoid Sema crash for inline friend decl like

  template  int foo(F1 X);
  template  struct A {
template  friend int foo(F1 X) { return A1; }
  };
  
  template struct A<1>;
  int a = foo(1.0);

But this case is still not fixed


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148914

Files:
  clang/lib/Sema/SemaTemplateInstantiate.cpp


Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1849,7 +1849,7 @@
 assert(!paramType->isDependentType() && "param type still dependent");
 result = SemaRef.BuildExpressionFromDeclTemplateArgument(arg, paramType, 
loc);
 refParam = paramType->isReferenceType();
-  } else {
+  } else if (arg.getKind() == TemplateArgument::Integral) {
 result = SemaRef.BuildExpressionFromIntegralTemplateArgument(arg, loc);
 assert(result.isInvalid() ||
SemaRef.Context.hasSameType(result.get()->getType(),


Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1849,7 +1849,7 @@
 assert(!paramType->isDependentType() && "param type still dependent");
 result = SemaRef.BuildExpressionFromDeclTemplateArgument(arg, paramType, loc);
 refParam = paramType->isReferenceType();
-  } else {
+  } else if (arg.getKind() == TemplateArgument::Integral) {
 result = SemaRef.BuildExpressionFromIntegralTemplateArgument(arg, loc);
 assert(result.isInvalid() ||
SemaRef.Context.hasSameType(result.get()->getType(),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits