[clang] [clang] Use getDefaultArgRange instead of getDefaultArg to retrieve the (PR #79296)

2024-03-06 Thread Haojian Wu via cfe-commits

https://github.com/hokein closed https://github.com/llvm/llvm-project/pull/79296
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Use getDefaultArgRange instead of getDefaultArg to retrieve the (PR #79296)

2024-03-06 Thread Haojian Wu via cfe-commits

https://github.com/hokein edited https://github.com/llvm/llvm-project/pull/79296
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Use getDefaultArgRange instead of getDefaultArg to retrieve the (PR #79296)

2024-02-26 Thread Haojian Wu via cfe-commits

hokein wrote:

> Sorry for missing this!
> 
> Would be nice to have a testcase but I see it's hard to get into the crashing 
> state (maybe even not possible via clang). Seems worthwhile to be robust to 
> such conditions and getDefaultArgRange appears less fragile.

This fix was needed for the initial type-alias CTAD implementation, we don't 
need it anymore in the new implementation :)

We could drop this change, but I think it is worth having it, it is an 
improvement, and make the code more robust.

https://github.com/llvm/llvm-project/pull/79296
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Use getDefaultArgRange instead of getDefaultArg to retrieve the (PR #79296)

2024-02-23 Thread Sam McCall via cfe-commits

https://github.com/sam-mccall approved this pull request.

Sorry for missing this!

Would be nice to have a testcase but I see it's hard to get into the crashing 
state (maybe even not possible via clang).
Seems worthwhile to be robust to such conditions and getDefaultArgRange appears 
less fragile.

https://github.com/llvm/llvm-project/pull/79296
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Use getDefaultArgRange instead of getDefaultArg to retrieve the (PR #79296)

2024-01-29 Thread Haojian Wu via cfe-commits

https://github.com/hokein edited https://github.com/llvm/llvm-project/pull/79296
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Use getDefaultArgRange instead of getDefaultArg to retrieve the (PR #79296)

2024-01-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Haojian Wu (hokein)


Changes

source location in AliasTemplateDeductionGuideTransform.

I don't have a reproducible testcase, but this should be a safe and 
non-functional change. We have checked the `hasDefaultArg` before calling 
getDefaultArg(), but `hasDefaultArg` allows unparsed/uninstantiated default arg 
which is prohibited in getDefaultArg().

Since we're only interested in the source location, we switch to use 
getDefaultArgRange() API.

Context: I hit the "!hasUninstantiatedDefaultArg()" assertion inside the 
getDefaultArg when reusing the "transformFunctionTypeParam" for type alias CTAD 
implementation 
(https://github.com/llvm/llvm-project/pull/77890/commits/f0919914f828daf705f89317081946359f00971a).

---
Full diff: https://github.com/llvm/llvm-project/pull/79296.diff


1 Files Affected:

- (modified) clang/lib/Sema/SemaTemplate.cpp (+1-1) 


``diff
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 9bfa71dc8bcf1db..a5d2afdf4a0bab8 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -2588,7 +2588,7 @@ struct ConvertConstructorToDeductionGuideTransform {
   // placeholder to indicate there is a default argument.
   QualType ParamTy = NewDI->getType();
   NewDefArg = new (SemaRef.Context)
-  OpaqueValueExpr(OldParam->getDefaultArg()->getBeginLoc(),
+  OpaqueValueExpr(OldParam->getDefaultArgRange().getBegin(),
   ParamTy.getNonLValueExprType(SemaRef.Context),
   ParamTy->isLValueReferenceType()   ? VK_LValue
   : ParamTy->isRValueReferenceType() ? VK_XValue

``




https://github.com/llvm/llvm-project/pull/79296
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Use getDefaultArgRange instead of getDefaultArg to retrieve the (PR #79296)

2024-01-24 Thread Haojian Wu via cfe-commits

https://github.com/hokein created 
https://github.com/llvm/llvm-project/pull/79296

source location in AliasTemplateDeductionGuideTransform.

I don't have a reproducible testcase, but this should be a safe and 
non-functional change. We have checked the `hasDefaultArg` before calling 
getDefaultArg(), but `hasDefaultArg` allows unparsed/uninstantiated default arg 
which is prohibited in getDefaultArg().

Since we're only interested in the source location, we switch to use 
getDefaultArgRange() API.

Context: I hit the "!hasUninstantiatedDefaultArg()" assertion inside the 
getDefaultArg when reusing the "transformFunctionTypeParam" for type alias CTAD 
implementation 
(https://github.com/llvm/llvm-project/pull/77890/commits/f0919914f828daf705f89317081946359f00971a).

>From 034810c714dcbebc26b6d6d50c4396c318849327 Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Wed, 24 Jan 2024 14:55:03 +0100
Subject: [PATCH] [clang] Use getDefaultArgRange instead of getDefaultArg to
 retrieve the source location in AliasTemplateDeductionGuideTransform.

I don't have a reproducible testcase, but this should be a safe and 
non-functional change.
We have checked the `hasDefaultArg` before calling getDefaultArg(), but 
`hasDefaultArg`
allows unparsed/uninstantiated default arg which is prohibited in 
getDefaultArg().

Since we're only interested in the source location, we switch to use 
getDefaultArgRange() API.

Context: I hit the "!hasUninstantiatedDefaultArg()" assertion inside the
getDefaultArg when reusing the "transformFunctionTypeParam" for
implementing type alias CTAD.
---
 clang/lib/Sema/SemaTemplate.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 9bfa71dc8bcf1db..a5d2afdf4a0bab8 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -2588,7 +2588,7 @@ struct ConvertConstructorToDeductionGuideTransform {
   // placeholder to indicate there is a default argument.
   QualType ParamTy = NewDI->getType();
   NewDefArg = new (SemaRef.Context)
-  OpaqueValueExpr(OldParam->getDefaultArg()->getBeginLoc(),
+  OpaqueValueExpr(OldParam->getDefaultArgRange().getBegin(),
   ParamTy.getNonLValueExprType(SemaRef.Context),
   ParamTy->isLValueReferenceType()   ? VK_LValue
   : ParamTy->isRValueReferenceType() ? VK_XValue

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