[clang] [Clang][Sema] Use correct TemplateName when transforming TemplateSpecializationType (PR #93411)

2024-05-27 Thread Qizhi Hu via cfe-commits
jcsxky wrote: > The problem here is the loss of the qualification on the TemplateNames > > This patch fixes the problem, without taking any workarounds: #93433 > > It also doesn't cause any change in diagnostics in > `clang/test/SemaTemplate/typename-specifier-3.cpp`. I think we should

[clang] [Clang][Sema] Use correct TemplateName when transforming TemplateSpecializationType (PR #93411)

2024-05-26 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky created https://github.com/llvm/llvm-project/pull/93411 Consider the following testcase: ```cpp namespace PR12884_original { template struct A { struct B { ##1 template struct X {}; typedef int arg; }; struct C { typedef B::X x;

[clang] [Clang][Sema] Use correct TemplateName when transforming TemplateSpecializationType (PR #93411)

2024-05-26 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky updated https://github.com/llvm/llvm-project/pull/93411 >From f5f0b14945a70e3e4fd92d5e5cbdb428334fe2b8 Mon Sep 17 00:00:00 2001 From: Qizhi Hu <836744...@qq.com> Date: Sat, 25 May 2024 16:30:27 +0800 Subject: [PATCH 1/2] [Clang][Sema] Use correct TemplateName when

[clang] [Clang][Sema] Use correct TemplateName when transforming TemplateSpecializationType (PR #93411)

2024-05-26 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky updated https://github.com/llvm/llvm-project/pull/93411 >From f5f0b14945a70e3e4fd92d5e5cbdb428334fe2b8 Mon Sep 17 00:00:00 2001 From: Qizhi Hu <836744...@qq.com> Date: Sat, 25 May 2024 16:30:27 +0800 Subject: [PATCH 1/2] [Clang][Sema] Use correct TemplateName when

[clang] [Clang][Sema] Use correct TemplateName when transforming TemplateSpecializationType (PR #93411)

2024-05-30 Thread Qizhi Hu via cfe-commits
jcsxky wrote: > So After we have formed a TemplateSpecializationType, we are done with the > NNS. We keep it around in an ElaboratedType for type sugar only, it should > not be needed to compile the program correctly anymore. > > So I think this solution violates one important aspect of our

[clang] [clang][ASTImporter] Fix possible crash "given incorrect InsertPos for specialization". (PR #89887)

2024-05-25 Thread Qizhi Hu via cfe-commits
jcsxky wrote: > > Could you please show your commands which reproduced this crash? I tested > > locally with the following commands and it runs OK. > > ```c++ > > clang++ -cc1 -std=c++17 -emit-pch -o test.cpp.ast test.cpp > > clang++ -cc1 -x c++ -ast-merge test.cpp.ast /dev/null -ast-dump > >

[clang] [clang][ASTImporter] Fix possible crash "given incorrect InsertPos for specialization". (PR #89887)

2024-05-25 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky approved this pull request. https://github.com/llvm/llvm-project/pull/89887 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][ASTImporter] Fix possible crash "given incorrect InsertPos for specialization". (PR #89887)

2024-05-24 Thread Qizhi Hu via cfe-commits
jcsxky wrote: > A test is needed to make the change acceptable but I could not find an easy > case to provoke the situation. The problem looks to be related to his code: > > ```c++ > using size_t = int; > template class tuple; > > template > struct integral_constant > { > static constexpr

[clang] [clang][ASTImport] fix issue on anonymous enum import (PR #93923)

2024-06-03 Thread Qizhi Hu via cfe-commits
@@ -9674,6 +9674,40 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportInstantiatedFromMember) { EXPECT_TRUE(ImportedPartialSpecialization->getInstantiatedFromMember()); } +AST_MATCHER_P(EnumDecl, hasEnumConstName, StringRef, ConstName) { + for (EnumConstantDecl *D :

[clang] [clang][ASTImport] fix issue on anonymous enum import (PR #93923)

2024-06-03 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky updated https://github.com/llvm/llvm-project/pull/93923 >From 7e602ae8d3c7ca0c3218d8ce9106510c43b6295b Mon Sep 17 00:00:00 2001 From: huqizhi Date: Fri, 31 May 2024 13:12:41 +0800 Subject: [PATCH 1/2] [clang][ASTImport] fix issue on anonymous enum import ---

[clang] [clang][ASTImport] fix issue on anonymous enum import (PR #93923)

2024-06-03 Thread Qizhi Hu via cfe-commits
@@ -9674,6 +9674,40 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportInstantiatedFromMember) { EXPECT_TRUE(ImportedPartialSpecialization->getInstantiatedFromMember()); } +AST_MATCHER_P(EnumDecl, hasEnumConstName, StringRef, ConstName) { + for (EnumConstantDecl *D :

[clang] [clang][ASTImport] fix issue on anonymous enum import (PR #93923)

2024-06-04 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky closed https://github.com/llvm/llvm-project/pull/93923 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libcxx] [Clang] Implement resolution for CWG1835 (PR #92957)

2024-06-04 Thread Qizhi Hu via cfe-commits
@@ -1442,19 +1442,27 @@ SourceLocation CXXUnresolvedConstructExpr::getBeginLoc() const { CXXDependentScopeMemberExpr::CXXDependentScopeMemberExpr( const ASTContext , Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc

[clang] [Clang][Sema] Use correct TemplateName when transforming TemplateSpecializationType (PR #93411)

2024-05-28 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky closed https://github.com/llvm/llvm-project/pull/93411 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libcxx] [clang] Preserve Qualifiers and type sugar in TemplateNames (PR #93433)

2024-05-30 Thread Qizhi Hu via cfe-commits
jcsxky wrote: @mizvekov After I apply you changes in this patch, https://github.com/llvm/llvm-project/issues/91677 is still crash(although it makes sense with `-ast-dump` option). I put it below for explanation clearly: ```cpp template struct t1 { template struct t2 {}; }; template

[clang] [Clang][Sema] qualifier should be transformed (PR #94725)

2024-06-07 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky updated https://github.com/llvm/llvm-project/pull/94725 >From 57576620fc412015bd19a34e12be61f4b81eb655 Mon Sep 17 00:00:00 2001 From: huqizhi Date: Fri, 7 Jun 2024 14:04:52 +0800 Subject: [PATCH] [Clang][Sema] qualifier should be transformed ---

[clang] [Clang][Sema] qualifier should be transformed (PR #94725)

2024-06-07 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky updated https://github.com/llvm/llvm-project/pull/94725 >From 6a90ef0b3947a0de2d6453856c80d8f0fd393548 Mon Sep 17 00:00:00 2001 From: huqizhi Date: Fri, 7 Jun 2024 14:04:52 +0800 Subject: [PATCH] [Clang][Sema] qualifier should be transformed ---

[clang] [Clang][Sema] qualifier should be transformed (PR #94725)

2024-06-07 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky created https://github.com/llvm/llvm-project/pull/94725 None >From 9fc6172cb3ef627eb7d4e939dff6f4504c06150a Mon Sep 17 00:00:00 2001 From: huqizhi Date: Fri, 7 Jun 2024 14:04:52 +0800 Subject: [PATCH] [Clang][Sema] qualifier should be transformed ---

[clang] [Clang][Sema] qualifier should be transformed (PR #94725)

2024-06-07 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky converted_to_draft https://github.com/llvm/llvm-project/pull/94725 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][Sema] qualifier should be transformed (PR #94725)

2024-06-07 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky updated https://github.com/llvm/llvm-project/pull/94725 >From 917cd980ed6a130b9f175492638afa22a1246c5c Mon Sep 17 00:00:00 2001 From: huqizhi Date: Fri, 7 Jun 2024 14:04:52 +0800 Subject: [PATCH] [Clang][Sema] qualifier should be transformed ---

[clang] [Clang][Sema] qualifier should be transformed (PR #94725)

2024-06-07 Thread Qizhi Hu via cfe-commits
jcsxky wrote: crash on trunk assertion. https://github.com/llvm/llvm-project/pull/94725 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][Sema] qualifier should be transformed (PR #94725)

2024-06-07 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky updated https://github.com/llvm/llvm-project/pull/94725 >From 2977f65d503c2a96247705ce50157870aaefa003 Mon Sep 17 00:00:00 2001 From: huqizhi Date: Fri, 7 Jun 2024 14:04:52 +0800 Subject: [PATCH] [Clang][Sema] qualifier should be transformed ---

[clang] [Clang][Sema] qualifier should be transformed (PR #94725)

2024-06-07 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky updated https://github.com/llvm/llvm-project/pull/94725 >From a1754c56a3293cd6529244f9a0f7486f4912e18d Mon Sep 17 00:00:00 2001 From: huqizhi Date: Fri, 7 Jun 2024 14:04:52 +0800 Subject: [PATCH] [Clang][Sema] qualifier should be transformed ---

[clang] [Clang][Sema] qualifier should be transformed (PR #94725)

2024-06-07 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky edited https://github.com/llvm/llvm-project/pull/94725 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][Sema] qualifier should be transformed (PR #94725)

2024-06-07 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky ready_for_review https://github.com/llvm/llvm-project/pull/94725 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][ASTImport] fix issue on anonymous enum import (PR #93923)

2024-05-30 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky created https://github.com/llvm/llvm-project/pull/93923 Don't skip searching in `ToContext` during importing `EnumDecl`. And `IsStructuralMatch` in `StructralEquivalence` can make sure to determine whether the found result is match or not. >From

[clang] [clang][ASTImport] fix issue on anonymous enum import (PR #93923)

2024-05-31 Thread Qizhi Hu via cfe-commits
jcsxky wrote: > Does this work on the following code? > > ``` > struct A { > enum { E1,E2 } x; > enum { E3,E4 } y; > }; > ``` I have updated testcase according to your suggestion to demonstrate this solution works correctly on the testcase above.

[clang] [clang][ASTImport] fix issue on anonymous enum import (PR #93923)

2024-05-31 Thread Qizhi Hu via cfe-commits
@@ -9674,6 +9674,27 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportInstantiatedFromMember) { EXPECT_TRUE(ImportedPartialSpecialization->getInstantiatedFromMember()); } +TEST_P(ASTImporterOptionSpecificTestBase, ImportAnonymousEnum) { + const char *ToCode = + R"(

[clang] [clang][ASTImport] fix issue on anonymous enum import (PR #93923)

2024-05-31 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky updated https://github.com/llvm/llvm-project/pull/93923 >From 7e602ae8d3c7ca0c3218d8ce9106510c43b6295b Mon Sep 17 00:00:00 2001 From: huqizhi Date: Fri, 31 May 2024 13:12:41 +0800 Subject: [PATCH 1/2] [clang][ASTImport] fix issue on anonymous enum import ---

[clang] [Clang][Sema] qualifier should be transformed (PR #94725)

2024-06-13 Thread Qizhi Hu via cfe-commits
jcsxky wrote: > Needs changes as discussed. > Needs changes as discussed. I am really appreciate for your guidance and I will check in the weekend. https://github.com/llvm/llvm-project/pull/94725 ___ cfe-commits mailing list

[clang] [clang] SourceLocIdentKind::Function should not be dependent (PR #94942)

2024-06-13 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky updated https://github.com/llvm/llvm-project/pull/94942 >From 96f4e2a5c82296b61e53189135d88a2d2b0da9f4 Mon Sep 17 00:00:00 2001 From: Qizhi Hu <836744...@qq.com> Date: Mon, 10 Jun 2024 16:53:54 +0800 Subject: [PATCH] [clang] SourceLocIdentKind::Function should not be

[clang] [StructuralEquivalence] improve NTTP and CXXDependentScopeMemberExpr comparison (PR #95190)

2024-06-11 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky updated https://github.com/llvm/llvm-project/pull/95190 >From ba081d51a0cc803188760eec2847bfc73d2192b8 Mon Sep 17 00:00:00 2001 From: huqizhi Date: Wed, 12 Jun 2024 09:47:16 +0800 Subject: [PATCH] [StructuralEquivalence] improve NTTP and CXXDependentScopeMemberExpr

[clang] [StructuralEquivalence] improve NTTP and CXXDependentScopeMemberExpr comparison (PR #95190)

2024-06-11 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky created https://github.com/llvm/llvm-project/pull/95190 improve `ASTStructuralEquivalenceTest`: 1. compare the depth and index of NTTP 2. provide comparison of `CXXDependentScopeMemberExpr` to `StmtCompare`. >From 644c6e8499285e5b3ab17193ec63eed051dae583 Mon Sep 17

[clang] [StructuralEquivalence] improve NTTP and CXXDependentScopeMemberExpr comparison (PR #95190)

2024-06-11 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky updated https://github.com/llvm/llvm-project/pull/95190 >From 157f664408062da41f4d82d20ddc06e0e563fe31 Mon Sep 17 00:00:00 2001 From: huqizhi Date: Wed, 12 Jun 2024 09:47:16 +0800 Subject: [PATCH] [StructuralEquivalence] improve NTTP and CXXDependentScopeMemberExpr

[clang] [clang] SourceLocIdentKind::Function should not be dependent (PR #94942)

2024-06-13 Thread Qizhi Hu via cfe-commits
jcsxky wrote: ```cpp struct BasicPersistent; struct SourceLocation { static constexpr const char* Current(const char * func = __builtin_FUNCTION()) { return func; } }; template BasicPersistent &&__declval(int); template auto declval() ->

[clang] [clang] SourceLocIdentKind::Function should not be dependent (PR #94942)

2024-06-10 Thread Qizhi Hu via cfe-commits
jcsxky wrote: > because we want to make the name of the function and any template parameter refers to the instantiated function rather than that of the function template. Does that mean we should transform the `SourceLocExpr` into a certain function name when instantiating if it is

[clang] [clang] SourceLocIdentKind::Function should not be dependent (PR #94942)

2024-06-10 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky created https://github.com/llvm/llvm-project/pull/94942 Consider the testcase, return type of `construct_at` is ```cpp DecltypeType 0x5570d8c0 'decltype(new struct BasicPersistent(declval()))' sugar dependent |-CXXNewExpr 0x5570d880 'struct BasicPersistent *'

[clang] [clang] SourceLocIdentKind::Function should not be dependent (PR #94942)

2024-06-16 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky closed https://github.com/llvm/llvm-project/pull/94942 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][Sema] Skip checking anonymous enum in using enum declaration (PR #87144)

2024-06-16 Thread Qizhi Hu via cfe-commits
jcsxky wrote: > This change has caused a regression in one of our systems integration tests > that test static analysis for the bstring lib project > (https://github.com/websnarf/bstrlib) with cross translation unit analysis > enabled. Unfortunately I do not have a simple reproducer that

[clang] [clang] SourceLocIdentKind::Function should not be dependent (PR #94942)

2024-06-16 Thread Qizhi Hu via cfe-commits
jcsxky wrote: > So, looked into this more. You are correct that `Function` needs not be > dependent because we only ever show the name of the function unqualified. > However, `FunctionSig` does. Here is an example of what we are trying to > preserve https://godbolt.org/z/M3eTa8nn5 (the clang

[clang] [Clang][Sema] Skip checking anonymous enum in using enum declaration (PR #87144)

2024-06-16 Thread Qizhi Hu via cfe-commits
jcsxky wrote: ```cpp ls bstrwrap.cpp bstrwrap.h ctudir test.cpp test.plist test.sh cat bstrwrap.cpp #include "bstrwrap.h" #include Bstrlib::CBString::CBString () { } cat bstrwrap.h #include namespace Bstrlib { struct CBString { CBString (); }; extern std::istream& getline (void); }

[clang] [Clang][Sema] Skip checking anonymous enum in using enum declaration (PR #87144)

2024-06-16 Thread Qizhi Hu via cfe-commits
jcsxky wrote: > Hi @jcsxky , I fetched and rebased to origin/main just now (6/16/2024 at > 4:30pm Central US time), and rebuilt - and I see the crash. Did you try > rebasing to latest source and rebuilding? > > `$ clang --analyze -Xclang -analyzer-config -Xclang >

[clang] [StructuralEquivalence] improve NTTP and CXXDependentScopeMemberExpr comparison (PR #95190)

2024-06-12 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky closed https://github.com/llvm/llvm-project/pull/95190 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] SourceLocIdentKind::Function should not be dependent (PR #94942)

2024-06-12 Thread Qizhi Hu via cfe-commits
jcsxky wrote: > SourceLocation needs to be dependent because we want to make the name of the > function and any template parameter refers to the instantiated function > rather than that of the function template. This was changed in #78436 > > The issue is that SourceLocation then is a

[clang] [Clang][Sema] qualifier should be transformed (PR #94725)

2024-06-22 Thread Qizhi Hu via cfe-commits
jcsxky wrote: @mizvekov After looking into the code, I think we should transform qualifier in TST. Consider the following code: ```cpp template t1::template t2 f1(); void f2() { f1(); } ``` `TemplateSpecializationType` of `t2` whose `Template` is a `QualifiedTemplateName`(`t1::`) will be

[clang] [Clang][Sema] qualifier should be transformed (PR #94725)

2024-06-22 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky updated https://github.com/llvm/llvm-project/pull/94725 >From 70928fcec829b6cb02fd9fe19b214518c872eea6 Mon Sep 17 00:00:00 2001 From: huqizhi Date: Fri, 7 Jun 2024 14:04:52 +0800 Subject: [PATCH] [Clang][Sema] qualifier should be transformed ---

[clang] [Clang][Sema] qualifier should be transformed (PR #94725)

2024-06-22 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky updated https://github.com/llvm/llvm-project/pull/94725 >From 8327ee1afef04480a1a18eef169f24906e432e87 Mon Sep 17 00:00:00 2001 From: huqizhi Date: Fri, 7 Jun 2024 14:04:52 +0800 Subject: [PATCH] [Clang][Sema] qualifier should be transformed ---

[clang] [Clang][Sema] qualifier should be transformed (PR #94725)

2024-06-22 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky updated https://github.com/llvm/llvm-project/pull/94725 >From 4e9e322a82e636783d2ba0ccda92f3547d557a64 Mon Sep 17 00:00:00 2001 From: huqizhi Date: Fri, 7 Jun 2024 14:04:52 +0800 Subject: [PATCH] [Clang][Sema] qualifier should be transformed ---

[clang] [Clang][Sema] qualifier should be transformed (PR #94725)

2024-06-22 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky updated https://github.com/llvm/llvm-project/pull/94725 >From 8359bac8e59c6b5ebc6500042dc473c3f4245c08 Mon Sep 17 00:00:00 2001 From: huqizhi Date: Fri, 7 Jun 2024 14:04:52 +0800 Subject: [PATCH] [Clang][Sema] qualifier should be transformed ---

[clang] [Clang][Sema] qualifier should be transformed (PR #94725)

2024-06-22 Thread Qizhi Hu via cfe-commits
https://github.com/jcsxky updated https://github.com/llvm/llvm-project/pull/94725 >From 4b1d55c56f969e926645a856ba67e289776326a8 Mon Sep 17 00:00:00 2001 From: huqizhi Date: Fri, 7 Jun 2024 14:04:52 +0800 Subject: [PATCH] [Clang][Sema] qualifier should be transformed ---

[clang] [Clang][Sema] qualifier should be transformed (PR #94725)

2024-06-22 Thread Qizhi Hu via cfe-commits
jcsxky wrote: > I still don't understand why you are saying we didn't or can't build a > DependentTemplateSpecializationType instead. I mean we can transform `QualifiedTemplateName` to `DependentTemplateName` and this is what this patch does. If we build a `DependentTemplateName` instead of

[clang] [Clang][Sema] qualifier should be transformed (PR #94725)

2024-06-23 Thread Qizhi Hu via cfe-commits
jcsxky wrote: > We can't go back from non-dependent into dependent. Sorry, maybe I use the word 'transform' that makes you confused. Actually, what I did in `TransformTemplateName` is transforming a `QualifiedTemplateName` which is dependent due to its qualifier dependency and dependent

<    1   2   3   4   5