[clang] [llvm] [IR] Avoid creating icmp/fcmp constant expressions (PR #92885)
antmox wrote: Hello, some bots are broken after this patch: - https://lab.llvm.org/buildbot/#/builders/245/builds/24889 - https://lab.llvm.org/buildbot/#/builders/188/builds/46161 FAIL: Clang::weak-external.cpp Could you look at this ? https://github.com/llvm/llvm-project/pull/92885 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [PowerPC] Support -fpatchable-function-entry (PR #92997)
llvmbot wrote: @llvm/pr-subscribers-clang-driver Author: Chen Zheng (chenzheng1030) Changes For now only PPC big endian Linux 32 and 64 bit are supported. PPC little endian Linux has XRAY support for 64-bit. PPC AIX has different patchable function entry implementations. Fixes #63220 Fixes #57031 --- Full diff: https://github.com/llvm/llvm-project/pull/92997.diff 10 Files Affected: - (modified) clang/include/clang/Basic/Attr.td (+1-1) - (modified) clang/include/clang/Basic/AttrDocs.td (+2-1) - (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+1-1) - (modified) clang/lib/Driver/ToolChains/Clang.cpp (+3-1) - (modified) clang/lib/Sema/SemaDeclAttr.cpp (+4) - (modified) clang/test/Driver/fpatchable-function-entry.c (+7-2) - (added) clang/test/Sema/patchable-function-entry-attr-aix.cpp (+4) - (modified) clang/test/Sema/patchable-function-entry-attr.cpp (+2) - (modified) llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp (+23-1) - (added) llvm/test/CodeGen/PowerPC/patchable-function-entry.ll (+49) ``diff diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 7008bea483c87..e98d0edb6fca0 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -892,7 +892,7 @@ def PatchableFunctionEntry : InheritableAttr, TargetSpecificAttr> { + "riscv64", "x86", "x86_64", "ppc", "ppc64"]>> { let Spellings = [GCC<"patchable_function_entry">]; let Subjects = SubjectList<[Function, ObjCMethod]>; let Args = [UnsignedArgument<"Count">, DefaultIntArgument<"Offset", 0>]; diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 54197d588eb45..fe566cc25bd0d 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -5799,7 +5799,8 @@ takes precedence over the command line option ``-fpatchable-function-entry=N,M`` ``M`` defaults to 0 if omitted. This attribute is only supported on -aarch64/aarch64-be/loongarch32/loongarch64/riscv32/riscv64/i386/x86-64 targets. +aarch64/aarch64-be/loongarch32/loongarch64/riscv32/riscv64/i386/x86-64/ppc/ppc64 targets. +For ppc/ppc64 targets, AIX is still not supported. }]; } diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 5a32463763aa6..b807eda3862b2 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -3470,7 +3470,7 @@ def err_attr_tlsmodel_arg : Error<"tls_model must be \"global-dynamic\", " def err_attr_codemodel_arg : Error<"code model '%0' is not supported on this target">; -def err_aix_attr_unsupported_tls_model : Error<"TLS model '%0' is not yet supported on AIX">; +def err_aix_attr_unsupported : Error<"%0 attribute is not yet supported on AIX">; def err_tls_var_aligned_over_maximum : Error< "alignment (%0) of thread-local variable %1 is greater than the maximum supported " diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 6d2015b2cd156..c7fa6d9a0ffe8 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -6681,7 +6681,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, StringRef S0 = A->getValue(), S = S0; unsigned Size, Offset = 0; if (!Triple.isAArch64() && !Triple.isLoongArch() && !Triple.isRISCV() && -!Triple.isX86()) +!Triple.isX86() && +!(!Triple.isOSAIX() && (Triple.getArch() == llvm::Triple::ppc || +Triple.getArch() == llvm::Triple::ppc64))) D.Diag(diag::err_drv_unsupported_opt_for_target) << A->getAsString(Args) << TripleStr; else if (S.consumeInteger(10, Size) || diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index ca5938083917f..17c17032ef96b 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -5922,6 +5922,10 @@ static void handleXRayLogArgsAttr(Sema &S, Decl *D, const ParsedAttr &AL) { static void handlePatchableFunctionEntryAttr(Sema &S, Decl *D, const ParsedAttr &AL) { + if (S.Context.getTargetInfo().getTriple().isOSAIX()) { +S.Diag(AL.getLoc(), diag::err_aix_attr_unsupported) << AL; +return; + } uint32_t Count = 0, Offset = 0; if (!checkUInt32Argument(S, AL, AL.getArgAsExpr(0), Count, 0, true)) return; diff --git a/clang/test/Driver/fpatchable-function-entry.c b/clang/test/Driver/fpatchable-function-entry.c index 4d0d609584c8d..8df3311f33b0e 100644 --- a/clang/test/Driver/fpatchable-function-entry.c +++ b/clang/test/Driver/fpatchable-function-entry.c @@ -6,6 +6,8 @@ // RUN: %clang -target loongarch64 %s -fpatchable-function-entry=1,0 -c -### 2>&1 | FileCheck %s // RUN: %clang -target riscv32 %s -fpatchable-function-entry=1,0 -c -### 2>&1 | FileCheck %s // RUN: %clang -ta
[clang] [llvm] [PowerPC] Support -fpatchable-function-entry (PR #92997)
llvmbot wrote: @llvm/pr-subscribers-backend-powerpc Author: Chen Zheng (chenzheng1030) Changes For now only PPC big endian Linux 32 and 64 bit are supported. PPC little endian Linux has XRAY support for 64-bit. PPC AIX has different patchable function entry implementations. Fixes #63220 Fixes #57031 --- Full diff: https://github.com/llvm/llvm-project/pull/92997.diff 10 Files Affected: - (modified) clang/include/clang/Basic/Attr.td (+1-1) - (modified) clang/include/clang/Basic/AttrDocs.td (+2-1) - (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+1-1) - (modified) clang/lib/Driver/ToolChains/Clang.cpp (+3-1) - (modified) clang/lib/Sema/SemaDeclAttr.cpp (+4) - (modified) clang/test/Driver/fpatchable-function-entry.c (+7-2) - (added) clang/test/Sema/patchable-function-entry-attr-aix.cpp (+4) - (modified) clang/test/Sema/patchable-function-entry-attr.cpp (+2) - (modified) llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp (+23-1) - (added) llvm/test/CodeGen/PowerPC/patchable-function-entry.ll (+49) ``diff diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 7008bea483c87..e98d0edb6fca0 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -892,7 +892,7 @@ def PatchableFunctionEntry : InheritableAttr, TargetSpecificAttr> { + "riscv64", "x86", "x86_64", "ppc", "ppc64"]>> { let Spellings = [GCC<"patchable_function_entry">]; let Subjects = SubjectList<[Function, ObjCMethod]>; let Args = [UnsignedArgument<"Count">, DefaultIntArgument<"Offset", 0>]; diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 54197d588eb45..fe566cc25bd0d 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -5799,7 +5799,8 @@ takes precedence over the command line option ``-fpatchable-function-entry=N,M`` ``M`` defaults to 0 if omitted. This attribute is only supported on -aarch64/aarch64-be/loongarch32/loongarch64/riscv32/riscv64/i386/x86-64 targets. +aarch64/aarch64-be/loongarch32/loongarch64/riscv32/riscv64/i386/x86-64/ppc/ppc64 targets. +For ppc/ppc64 targets, AIX is still not supported. }]; } diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 5a32463763aa6..b807eda3862b2 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -3470,7 +3470,7 @@ def err_attr_tlsmodel_arg : Error<"tls_model must be \"global-dynamic\", " def err_attr_codemodel_arg : Error<"code model '%0' is not supported on this target">; -def err_aix_attr_unsupported_tls_model : Error<"TLS model '%0' is not yet supported on AIX">; +def err_aix_attr_unsupported : Error<"%0 attribute is not yet supported on AIX">; def err_tls_var_aligned_over_maximum : Error< "alignment (%0) of thread-local variable %1 is greater than the maximum supported " diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 6d2015b2cd156..c7fa6d9a0ffe8 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -6681,7 +6681,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, StringRef S0 = A->getValue(), S = S0; unsigned Size, Offset = 0; if (!Triple.isAArch64() && !Triple.isLoongArch() && !Triple.isRISCV() && -!Triple.isX86()) +!Triple.isX86() && +!(!Triple.isOSAIX() && (Triple.getArch() == llvm::Triple::ppc || +Triple.getArch() == llvm::Triple::ppc64))) D.Diag(diag::err_drv_unsupported_opt_for_target) << A->getAsString(Args) << TripleStr; else if (S.consumeInteger(10, Size) || diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index ca5938083917f..17c17032ef96b 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -5922,6 +5922,10 @@ static void handleXRayLogArgsAttr(Sema &S, Decl *D, const ParsedAttr &AL) { static void handlePatchableFunctionEntryAttr(Sema &S, Decl *D, const ParsedAttr &AL) { + if (S.Context.getTargetInfo().getTriple().isOSAIX()) { +S.Diag(AL.getLoc(), diag::err_aix_attr_unsupported) << AL; +return; + } uint32_t Count = 0, Offset = 0; if (!checkUInt32Argument(S, AL, AL.getArgAsExpr(0), Count, 0, true)) return; diff --git a/clang/test/Driver/fpatchable-function-entry.c b/clang/test/Driver/fpatchable-function-entry.c index 4d0d609584c8d..8df3311f33b0e 100644 --- a/clang/test/Driver/fpatchable-function-entry.c +++ b/clang/test/Driver/fpatchable-function-entry.c @@ -6,6 +6,8 @@ // RUN: %clang -target loongarch64 %s -fpatchable-function-entry=1,0 -c -### 2>&1 | FileCheck %s // RUN: %clang -target riscv32 %s -fpatchable-function-entry=1,0 -c -### 2>&1 | FileCheck %s // RUN: %clang
[clang] [llvm] [PowerPC] Support -fpatchable-function-entry (PR #92997)
https://github.com/chenzheng1030 created https://github.com/llvm/llvm-project/pull/92997 For now only PPC big endian Linux 32 and 64 bit are supported. PPC little endian Linux has XRAY support for 64-bit. PPC AIX has different patchable function entry implementations. Fixes #63220 Fixes #57031 >From 7bbd096b9024b27359f63c8cc12fb1be4d7e2cbf Mon Sep 17 00:00:00 2001 From: Chen Zheng Date: Wed, 22 May 2024 02:37:04 -0400 Subject: [PATCH] [PowerPC] Support -fpatchable-function-entry For now only PPC big endian Linux is supported. PPC little endian Linux has XRAY support for 64-bit. PPC AIX has different patchable function entry implementations. Fixes #63220 Fixes #57031 --- clang/include/clang/Basic/Attr.td | 2 +- clang/include/clang/Basic/AttrDocs.td | 3 +- .../clang/Basic/DiagnosticSemaKinds.td| 2 +- clang/lib/Driver/ToolChains/Clang.cpp | 4 +- clang/lib/Sema/SemaDeclAttr.cpp | 4 ++ clang/test/Driver/fpatchable-function-entry.c | 9 +++- .../patchable-function-entry-attr-aix.cpp | 4 ++ .../Sema/patchable-function-entry-attr.cpp| 2 + llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp | 24 - .../PowerPC/patchable-function-entry.ll | 49 +++ 10 files changed, 96 insertions(+), 7 deletions(-) create mode 100644 clang/test/Sema/patchable-function-entry-attr-aix.cpp create mode 100644 llvm/test/CodeGen/PowerPC/patchable-function-entry.ll diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 7008bea483c87..e98d0edb6fca0 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -892,7 +892,7 @@ def PatchableFunctionEntry : InheritableAttr, TargetSpecificAttr> { + "riscv64", "x86", "x86_64", "ppc", "ppc64"]>> { let Spellings = [GCC<"patchable_function_entry">]; let Subjects = SubjectList<[Function, ObjCMethod]>; let Args = [UnsignedArgument<"Count">, DefaultIntArgument<"Offset", 0>]; diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 54197d588eb45..fe566cc25bd0d 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -5799,7 +5799,8 @@ takes precedence over the command line option ``-fpatchable-function-entry=N,M`` ``M`` defaults to 0 if omitted. This attribute is only supported on -aarch64/aarch64-be/loongarch32/loongarch64/riscv32/riscv64/i386/x86-64 targets. +aarch64/aarch64-be/loongarch32/loongarch64/riscv32/riscv64/i386/x86-64/ppc/ppc64 targets. +For ppc/ppc64 targets, AIX is still not supported. }]; } diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 5a32463763aa6..b807eda3862b2 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -3470,7 +3470,7 @@ def err_attr_tlsmodel_arg : Error<"tls_model must be \"global-dynamic\", " def err_attr_codemodel_arg : Error<"code model '%0' is not supported on this target">; -def err_aix_attr_unsupported_tls_model : Error<"TLS model '%0' is not yet supported on AIX">; +def err_aix_attr_unsupported : Error<"%0 attribute is not yet supported on AIX">; def err_tls_var_aligned_over_maximum : Error< "alignment (%0) of thread-local variable %1 is greater than the maximum supported " diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 6d2015b2cd156..c7fa6d9a0ffe8 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -6681,7 +6681,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, StringRef S0 = A->getValue(), S = S0; unsigned Size, Offset = 0; if (!Triple.isAArch64() && !Triple.isLoongArch() && !Triple.isRISCV() && -!Triple.isX86()) +!Triple.isX86() && +!(!Triple.isOSAIX() && (Triple.getArch() == llvm::Triple::ppc || +Triple.getArch() == llvm::Triple::ppc64))) D.Diag(diag::err_drv_unsupported_opt_for_target) << A->getAsString(Args) << TripleStr; else if (S.consumeInteger(10, Size) || diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index ca5938083917f..17c17032ef96b 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -5922,6 +5922,10 @@ static void handleXRayLogArgsAttr(Sema &S, Decl *D, const ParsedAttr &AL) { static void handlePatchableFunctionEntryAttr(Sema &S, Decl *D, const ParsedAttr &AL) { + if (S.Context.getTargetInfo().getTriple().isOSAIX()) { +S.Diag(AL.getLoc(), diag::err_aix_attr_unsupported) << AL; +return; + } uint32_t Count = 0, Offset = 0; if (!checkUInt32Argument(S, AL, AL.getArgAsExpr(0), Count, 0, true)) return; diff --git a/clang/test/Driver/fpatchable-function-entry.c b/clang/tes
[clang] [clang] fix(92755): clang/include/clang/AST/Redeclarable.h: 4 * Function parameter should be passed by const reference (PR #92963)
https://github.com/a-tarasyuk updated https://github.com/llvm/llvm-project/pull/92963 >From f33697ce241213136a8d34c2cc32c68f8f827d6a Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Tue, 21 May 2024 22:56:06 +0300 Subject: [PATCH] fix(92755): use const references for operator== and operator!= overloads --- clang/include/clang/AST/Redeclarable.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/AST/Redeclarable.h b/clang/include/clang/AST/Redeclarable.h index 091bb886f2d49..74ccd74ed60d6 100644 --- a/clang/include/clang/AST/Redeclarable.h +++ b/clang/include/clang/AST/Redeclarable.h @@ -281,10 +281,10 @@ class Redeclarable { return tmp; } -friend bool operator==(redecl_iterator x, redecl_iterator y) { +friend bool operator==(const redecl_iterator &x, const redecl_iterator &y) { return x.Current == y.Current; } -friend bool operator!=(redecl_iterator x, redecl_iterator y) { +friend bool operator!=(const redecl_iterator &x, const redecl_iterator &y) { return x.Current != y.Current; } }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 874a5da - [clang] Processing real directories added as virtual ones (#91645)
Author: Ivan Murashko Date: 2024-05-22T07:47:10+01:00 New Revision: 874a5dab419240af0a02a3fc70accd926105aa31 URL: https://github.com/llvm/llvm-project/commit/874a5dab419240af0a02a3fc70accd926105aa31 DIFF: https://github.com/llvm/llvm-project/commit/874a5dab419240af0a02a3fc70accd926105aa31.diff LOG: [clang] Processing real directories added as virtual ones (#91645) The `FileManager` might create a virtual directory that can be used later as a search path. This is the case when we use remapping, as demonstrated in the suggested LIT test. We might encounter a 'false cache miss' and add the same directory twice into `FileManager::SeenDirEntries` if the added record is a real directory that is present on a disk: - Once as a virtual directory - And once as a real one This isn't a problem if the added directories have the same name, as in this case, we will get a cache hit. However, it could lead to compilation errors if the directory names are different but point to the same folder. For example, one might use an absolute name and another a relative one. For instance, the **implicit-module-remap.cpp** LIT test will fail with the following message: ``` /.../implicit-module-remap.cpp.tmp/test.cpp:1:2: fatal error: module 'a' was built in directory '/.../implicit-module-remap.cpp.tmp' but now resides in directory '.' 1 | #include "a.h" | ^ 1 error generated. ``` The suggested fix checks if the added virtual directory is present on the disk and handles it as a real one if that is the case. Added: clang/test/Modules/implicit-module-remap.cpp Modified: clang/include/clang/Basic/FileManager.h clang/lib/Basic/FileManager.cpp Removed: diff --git a/clang/include/clang/Basic/FileManager.h b/clang/include/clang/Basic/FileManager.h index 8b4206e52cd48..e1f33d57a8980 100644 --- a/clang/include/clang/Basic/FileManager.h +++ b/clang/include/clang/Basic/FileManager.h @@ -299,6 +299,8 @@ class FileManager : public RefCountedBase { getBufferForFileImpl(StringRef Filename, int64_t FileSize, bool isVolatile, bool RequiresNullTerminator) const; + DirectoryEntry *&getRealDirEntry(const llvm::vfs::Status &Status); + public: /// Get the 'stat' information for the given \p Path. /// diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index 143c04309d075..1dc51deb82987 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/lib/Basic/FileManager.cpp @@ -82,6 +82,22 @@ getDirectoryFromFile(FileManager &FileMgr, StringRef Filename, return FileMgr.getDirectoryRef(DirName, CacheFailure); } +DirectoryEntry *&FileManager::getRealDirEntry(const llvm::vfs::Status &Status) { + assert(Status.isDirectory() && "The directory should exist!"); + // See if we have already opened a directory with the + // same inode (this occurs on Unix-like systems when one dir is + // symlinked to another, for example) or the same path (on + // Windows). + DirectoryEntry *&UDE = UniqueRealDirs[Status.getUniqueID()]; + + if (!UDE) { +// We don't have this directory yet, add it. We use the string +// key from the SeenDirEntries map as the string. +UDE = new (DirsAlloc.Allocate()) DirectoryEntry(); + } + return UDE; +} + /// Add all ancestors of the given path (pointing to either a file or /// a directory) as virtual directories. void FileManager::addAncestorsAsVirtualDirs(StringRef Path) { @@ -99,10 +115,21 @@ void FileManager::addAncestorsAsVirtualDirs(StringRef Path) { if (NamedDirEnt.second) return; - // Add the virtual directory to the cache. - auto *UDE = new (DirsAlloc.Allocate()) DirectoryEntry(); - NamedDirEnt.second = *UDE; - VirtualDirectoryEntries.push_back(UDE); + // Check to see if the directory exists. + llvm::vfs::Status Status; + auto statError = + getStatValue(DirName, Status, false, nullptr /*directory lookup*/); + if (statError) { +// There's no real directory at the given path. +// Add the virtual directory to the cache. +auto *UDE = new (DirsAlloc.Allocate()) DirectoryEntry(); +NamedDirEnt.second = *UDE; +VirtualDirectoryEntries.push_back(UDE); + } else { +// There is the real directory +DirectoryEntry *&UDE = getRealDirEntry(Status); +NamedDirEnt.second = *UDE; + } // Recursively add the other ancestors. addAncestorsAsVirtualDirs(DirName); @@ -162,17 +189,8 @@ FileManager::getDirectoryRef(StringRef DirName, bool CacheFailure) { return llvm::errorCodeToError(statError); } - // It exists. See if we have already opened a directory with the - // same inode (this occurs on Unix-like systems when one dir is - // symlinked to another, for example) or the same path (on - // Windows). - DirectoryEntry *&UDE = UniqueRealDirs[Status.getUniqueID()]; - - if (!UDE) { -// We don't have this directory yet, add it. We use the string -// key from the
[clang] [clang] Processing real directories added as virtual ones (PR #91645)
https://github.com/ivanmurashko closed https://github.com/llvm/llvm-project/pull/91645 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clangd] Support go-to-definition on type hints. The core part (PR #86629)
@@ -1637,6 +1678,144 @@ TEST(TypeHints, SubstTemplateParameterAliases) { ExpectedHint{": static_vector", "vector_name"}); } +template +void assertTypeLinkHints(StringRef Code, StringRef HintRange, + Labels... ExpectedLabels) { + Annotations Source(Code); + auto HintAt = [&](llvm::ArrayRef InlayHints, +llvm::StringRef Range) { +auto *Hint = llvm::find_if(InlayHints, [&](const InlayHint &InlayHint) { + return InlayHint.range == Source.range(Range); +}); +assert(Hint && "No range was found"); +return llvm::ArrayRef(Hint->label); + }; + + TestTU TU = TestTU::withCode(Source.code()); + TU.ExtraArgs.push_back("-std=c++2c"); + auto AST = TU.build(); + + Config C; + C.InlayHints.TypeNameLimit = 0; + WithContextValue WithCfg(Config::Key, std::move(C)); + + auto Hints = hintsOfKind(AST, InlayHintKind::Type); + EXPECT_THAT(HintAt(Hints, HintRange), + ElementsAre(HintLabelPieceMatcher(ExpectedLabels, Source)...)); +} + +TEST(TypeHints, Links) { + StringRef Source(R"cpp( +$Package[[template +struct Package {]]}; + +$SpecializationOfPackage[[template <> +struct Package {]]}; + +$Container[[template +struct Container {]]}; + +$NttpContainer[[template +struct NttpContainer {]]}; + +enum struct ScopedEnum { + X = 1, +}; + +enum Enum { + E = 2, +}; + +namespace ns { + $Nested[[template + struct Nested { +$NestedClass[[template +struct ]]Class { +}; + ]]}; + + $NestedInt[[using NestedInt = Nested; +} + +void basic() { + auto $1[[C]] = Container>(); + auto $2[[D]] = Container>(); + auto $3[[E]] = Container, long>(); + auto $4[[F]] = NttpContainer(); + auto $5[[G]] = ns::Nested>::Class>(); +} + +void compounds() { + auto $6[[A]] = Container::Class&>(); + auto $7[[B]] = Container::Class&&>(); + auto $8[[C]] = Container::Class> *>(); +} + +namespace nns { + $UsingShadow[[using ns::]]NestedInt; + + void aliases() { +auto $9[[A]] = Container(); +auto $10[[B]] = Container(); + } +} + + )cpp"); + + assertTypeLinkHints(Source, "1", ExpectedHintLabelPiece{": Container<"}, + ExpectedHintLabelPiece{"Package", "Package"}, + ExpectedHintLabelPiece{">"}); + + assertTypeLinkHints( + Source, "2", ExpectedHintLabelPiece{": Container<"}, + ExpectedHintLabelPiece{"Package", "SpecializationOfPackage"}, + ExpectedHintLabelPiece{">"}); + + assertTypeLinkHints(Source, "3", ExpectedHintLabelPiece{": Container<"}, + ExpectedHintLabelPiece{"Container", "Container"}, + ExpectedHintLabelPiece{", long>"}); + + assertTypeLinkHints( + Source, "4", + ExpectedHintLabelPiece{": NttpContainer"}); HighCommander4 wrote: nit: add a TODO comment saying that this could be supported in the future? https://github.com/llvm/llvm-project/pull/86629 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clangd] Support go-to-definition on type hints. The core part (PR #86629)
@@ -55,6 +55,19 @@ struct ExpectedHint { } }; +struct ExpectedHintLabelPiece { + std::string Label; + std::optional PointsTo = std::nullopt; HighCommander4 wrote: It's not immediately clear what this stores, let's add: ``` // Stores the name of a range annotation ``` https://github.com/llvm/llvm-project/pull/86629 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clangd] Support go-to-definition on type hints. The core part (PR #86629)
https://github.com/HighCommander4 commented: Apologies for the long wait. I'm excited about this enhancement, thanks for working on it! I've only looked at the tests so far. Will look at the implementation in the coming days but wanted to share my thoughts so far. https://github.com/llvm/llvm-project/pull/86629 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clangd] Support go-to-definition on type hints. The core part (PR #86629)
@@ -1637,6 +1678,144 @@ TEST(TypeHints, SubstTemplateParameterAliases) { ExpectedHint{": static_vector", "vector_name"}); } +template +void assertTypeLinkHints(StringRef Code, StringRef HintRange, + Labels... ExpectedLabels) { + Annotations Source(Code); + auto HintAt = [&](llvm::ArrayRef InlayHints, +llvm::StringRef Range) { HighCommander4 wrote: This lambda doesn't seem to give us much, it's only called once. Suggestion: inline its contents, so below we have: ```c++ auto Hints = hintsOfKind(AST, InlayHintKind::Type); auto Hint = llvm::find_if(Hints, [&](const InlayHint &InlayHint) { return InlayHint.range == Source.range(HintRange); }); ``` Now we can use gtest facilities to issue a more informative assert message: ```c++ ASSERT_TRUE(Hint != Hints.end()) << "No hint was found at " << HintRange; ``` (Last line then becomes `EXPECT_THAT(Hint->label, ElementsAre(...));`) https://github.com/llvm/llvm-project/pull/86629 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clangd] Support go-to-definition on type hints. The core part (PR #86629)
@@ -1637,6 +1678,144 @@ TEST(TypeHints, SubstTemplateParameterAliases) { ExpectedHint{": static_vector", "vector_name"}); } +template +void assertTypeLinkHints(StringRef Code, StringRef HintRange, + Labels... ExpectedLabels) { + Annotations Source(Code); + auto HintAt = [&](llvm::ArrayRef InlayHints, +llvm::StringRef Range) { +auto *Hint = llvm::find_if(InlayHints, [&](const InlayHint &InlayHint) { + return InlayHint.range == Source.range(Range); +}); +assert(Hint && "No range was found"); +return llvm::ArrayRef(Hint->label); + }; + + TestTU TU = TestTU::withCode(Source.code()); + TU.ExtraArgs.push_back("-std=c++2c"); + auto AST = TU.build(); + + Config C; + C.InlayHints.TypeNameLimit = 0; + WithContextValue WithCfg(Config::Key, std::move(C)); + + auto Hints = hintsOfKind(AST, InlayHintKind::Type); + EXPECT_THAT(HintAt(Hints, HintRange), + ElementsAre(HintLabelPieceMatcher(ExpectedLabels, Source)...)); +} + +TEST(TypeHints, Links) { + StringRef Source(R"cpp( +$Package[[template +struct Package {]]}; + +$SpecializationOfPackage[[template <> +struct Package {]]}; + +$Container[[template +struct Container {]]}; + +$NttpContainer[[template +struct NttpContainer {]]}; + +enum struct ScopedEnum { + X = 1, +}; + +enum Enum { + E = 2, +}; + +namespace ns { + $Nested[[template + struct Nested { +$NestedClass[[template +struct ]]Class { +}; + ]]}; + + $NestedInt[[using NestedInt = Nested; +} + +void basic() { + auto $1[[C]] = Container>(); + auto $2[[D]] = Container>(); + auto $3[[E]] = Container, long>(); + auto $4[[F]] = NttpContainer(); + auto $5[[G]] = ns::Nested>::Class>(); +} + +void compounds() { + auto $6[[A]] = Container::Class&>(); + auto $7[[B]] = Container::Class&&>(); + auto $8[[C]] = Container::Class> *>(); +} + +namespace nns { + $UsingShadow[[using ns::]]NestedInt; + + void aliases() { +auto $9[[A]] = Container(); +auto $10[[B]] = Container(); + } +} + + )cpp"); + + assertTypeLinkHints(Source, "1", ExpectedHintLabelPiece{": Container<"}, HighCommander4 wrote: My preference would be to emit a link for the outer-most types as well. * This feels more consistent (a type gets a link whether or not it's the outer-most) * It also matches how rust-analyzer behaves * I think the links in the type hint are more discoverable than the fact that `auto` has a go-to-def target (e.g. in vscode, just hovering over an inlay hint part causes an underline to appear, whereas hovering over `auto` does not) The fact that there will then be two ways to get to the outer-most type (via `auto` and via the inlay hint part) does not seem problematic to me. https://github.com/llvm/llvm-project/pull/86629 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clangd] Support go-to-definition on type hints. The core part (PR #86629)
@@ -73,6 +86,34 @@ MATCHER_P2(HintMatcher, Expected, Code, llvm::to_string(Expected)) { return true; } +MATCHER_P2(HintLabelPieceMatcher, Expected, Code, llvm::to_string(Expected)) { + llvm::StringRef ExpectedView(Expected.Label); + std::string ResultLabel = arg.value; + if (ResultLabel != ExpectedView) { HighCommander4 wrote: nit: this is the only use of `ExpectedView`, just inline it as `Expected.Label` https://github.com/llvm/llvm-project/pull/86629 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clangd] Support go-to-definition on type hints. The core part (PR #86629)
@@ -1637,6 +1678,144 @@ TEST(TypeHints, SubstTemplateParameterAliases) { ExpectedHint{": static_vector", "vector_name"}); } +template +void assertTypeLinkHints(StringRef Code, StringRef HintRange, + Labels... ExpectedLabels) { + Annotations Source(Code); + auto HintAt = [&](llvm::ArrayRef InlayHints, +llvm::StringRef Range) { +auto *Hint = llvm::find_if(InlayHints, [&](const InlayHint &InlayHint) { + return InlayHint.range == Source.range(Range); +}); +assert(Hint && "No range was found"); +return llvm::ArrayRef(Hint->label); + }; + + TestTU TU = TestTU::withCode(Source.code()); + TU.ExtraArgs.push_back("-std=c++2c"); + auto AST = TU.build(); + + Config C; + C.InlayHints.TypeNameLimit = 0; + WithContextValue WithCfg(Config::Key, std::move(C)); + + auto Hints = hintsOfKind(AST, InlayHintKind::Type); + EXPECT_THAT(HintAt(Hints, HintRange), + ElementsAre(HintLabelPieceMatcher(ExpectedLabels, Source)...)); +} + +TEST(TypeHints, Links) { + StringRef Source(R"cpp( +$Package[[template HighCommander4 wrote: Is there a reason to prefer putting full decl source ranges into `InlayHintLabelPart.location`, rather than single-token source ranges (e.g. just the range `Package`) like in the go-to-definition response? What vscode seems to do is call `textDocument/definition` at the start position of the range, and navigate to the resulting definition location. I guess most of the time that works either with a full source range or a single-token source range as input, but I think a single-token source range might be more robust (less chance for edge cases where the first token of the full source range is claimed by some descendant node, and also less chance for edge cases where the full source range spans macro expansion boundaries). We have [some utilities](https://searchfox.org/llvm/rev/1664610130b88ef168e33eddfe973a3f11bd4261/clang-tools-extra/clangd/XRefs.cpp#414-415) for getting the single-token source range for the go-to-def response, which we could probably reuse. (As a bonus, it makes the tests a bit easier to write and read.) https://github.com/llvm/llvm-project/pull/86629 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clangd] Support go-to-definition on type hints. The core part (PR #86629)
https://github.com/HighCommander4 edited https://github.com/llvm/llvm-project/pull/86629 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [webkit.RefCntblBaseVirtualDtor] Allow CRTP classes without a virtual destructor. (PR #92837)
https://github.com/rniwa updated https://github.com/llvm/llvm-project/pull/92837 >From 9c2ae2b2b14d27270589f3775df95a7547e74c83 Mon Sep 17 00:00:00 2001 From: Ryosuke Niwa Date: Mon, 20 May 2024 16:12:44 -0700 Subject: [PATCH] [webkit.RefCntblBaseVirtualDtor] Allow CRTP classes without a virtual destructor. Exempt CRTP (Curiously Recurring Template Pattern) classes with a delete operation acting on "this" pointer with an appropriate cast from the requirement that a ref-countable superclass must have a virtual destructor. To do this, this PR introduces new DerefAnalysisVisitor, which looks for a delete operation with an explicit cast to the derived class in a base class. This PR also changes the checker so that we only check a given class's immediate base class instead of all ancestor base classes in the class hierarchy. This is sufficient because the checker will eventually see the definition for every class in the class hierarchy and transitively proves every ref-counted base class has a virtual destructor or deref function which casts this pointer back to the derived class before deleting. Without this change, we would keep traversing the same list of base classes whenever we encounter a new subclass, which is wholly unnecessary. It's possible for DerefAnalysisVisitor to come to a conclusoin that there isn't enough information to determine whether a given templated superclass invokes delete operation on a subclass when the template isn't fully specialized for the subclass. In this case, we return std::nullopt in HasSpecializedDelete, and visitCXXRecordDecl will skip this declaration. This is okay because the checker will eventually see a concreate fully specialized class definition if it ever gets instantiated. --- .../WebKit/RefCntblBaseVirtualDtorChecker.cpp | 311 + ...virtual-dtor-ref-deref-on-diff-classes.cpp | 1 + .../ref-cntbl-base-virtual-dtor-templates.cpp | 324 +- 3 files changed, 567 insertions(+), 69 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp index 7f4c3a7b787e8..efb7b4456f2ca 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp @@ -11,16 +11,134 @@ #include "PtrTypesSemantics.h" #include "clang/AST/CXXInheritance.h" #include "clang/AST/RecursiveASTVisitor.h" +#include "clang/AST/StmtVisitor.h" #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/Checker.h" +#include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/SetVector.h" #include using namespace clang; using namespace ento; namespace { + +class DerefAnalysisVisitor +: public ConstStmtVisitor { + // Returns true if any of child statements return true. + bool VisitChildren(const Stmt *S) { +for (const Stmt *Child : S->children()) { + if (Child && Visit(Child)) +return true; +} +return false; + } + + bool VisitBody(const Stmt *Body) { +if (!Body) + return false; + +auto [It, IsNew] = VisitedBody.insert(Body); +if (!IsNew) // This body is recursive + return false; + +return Visit(Body); + } + +public: + DerefAnalysisVisitor(const TemplateArgumentList &ArgList, + const CXXRecordDecl *ClassDecl) + : ArgList(&ArgList), ClassDecl(ClassDecl) {} + + DerefAnalysisVisitor(const CXXRecordDecl *ClassDecl) : ClassDecl(ClassDecl) {} + + std::optional HasSpecializedDelete(CXXMethodDecl *Decl) { +if (auto *Body = Decl->getBody()) + return VisitBody(Body); +if (auto *Tmpl = Decl->getTemplateInstantiationPattern()) + return std::nullopt; // Indeterminate. There was no concrete instance. +return false; + } + + bool VisitCallExpr(const CallExpr *CE) { +auto *Callee = CE->getCallee(); +while (auto *Expr = dyn_cast(Callee)) + Callee = Expr->getSubExpr(); +if (auto *DeclRef = dyn_cast(Callee)) { + auto *Decl = DeclRef->getDecl(); + if (auto *VD = dyn_cast(Decl)) { +if (auto *Init = VD->getInit()) { + if (auto *Lambda = dyn_cast(Init)) +return VisitBody(Lambda->getBody()); +} + } else if (auto *FD = dyn_cast(Decl)) +return VisitBody(FD->getBody()); +} +return false; + } + + bool VisitCXXMemberCallExpr(const CXXMemberCallExpr *MCE) { +auto *Callee = MCE->getMethodDecl(); +if (!Callee) + return false; +return VisitBody(Callee->getBody()); + } + + bool VisitCXXDeleteExpr(const CXXDeleteExpr *E) { +auto *Arg = E->getArgument(); +while (Arg) { + if (auto *Paren = dyn_cast(Arg)) +Arg = Paren->getSubExpr(); + else if (auto *Cast = dyn_ca
[clang] c609c04 - [CodeGen] Use fixed triple in weak-external test (NFC)
Author: Nikita Popov Date: 2024-05-22T08:37:09+02:00 New Revision: c609c04e32ef43f63a6ee54025fadf649c3247cc URL: https://github.com/llvm/llvm-project/commit/c609c04e32ef43f63a6ee54025fadf649c3247cc DIFF: https://github.com/llvm/llvm-project/commit/c609c04e32ef43f63a6ee54025fadf649c3247cc.diff LOG: [CodeGen] Use fixed triple in weak-external test (NFC) The codegen here differs substantially if UseARMMethodPtrABI is enabled. Use a fixed x86 triple to avoid this. Added: Modified: clang/test/CodeGenCXX/weak-external.cpp Removed: diff --git a/clang/test/CodeGenCXX/weak-external.cpp b/clang/test/CodeGenCXX/weak-external.cpp index 587fba36a0ada..02f05bfa7e1ee 100644 --- a/clang/test/CodeGenCXX/weak-external.cpp +++ b/clang/test/CodeGenCXX/weak-external.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple %itanium_abi_triple %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-unknown-linux-gnu %s -emit-llvm -o - | FileCheck %s // PR4262 // CHECK-NOT: _ZNSs12_S_constructIPKcEEPcT_S3_RKSaIcESt20forward_iterator_tag ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [polly] [X86] Remove knl/knm specific ISAs supports (PR #92883)
phoebewang wrote: LGTM but I'd like @RKSimon to take a second look. https://github.com/llvm/llvm-project/pull/92883 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-repl] Extend the C support. (PR #89804)
vgvassilev wrote: @jasonmolenda, I am stuck. I could not find how the bot configures llvm and lldb. I built lldb and ran `make check-lldb` but did not fail in the same way. Can you provide a recipe to reproduce the failure? https://github.com/llvm/llvm-project/pull/89804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix self-capturing `__block` variables (PR #89475)
https://github.com/ChuanqiXu9 commented: Serialization related change looks trivial and good. But I feel better to leave the formal approval to CG part reviewers. https://github.com/llvm/llvm-project/pull/89475 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AMDGPU][Clang] Builtin for GLOBAL_LOAD_LDS on GFX940 (PR #92962)
@@ -240,6 +240,7 @@ TARGET_BUILTIN(__builtin_amdgcn_flat_atomic_fadd_v2bf16, "V2sV2s*0V2s", "t", "at TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fadd_v2bf16, "V2sV2s*1V2s", "t", "atomic-global-pk-add-bf16-inst") TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_v2bf16, "V2sV2s*3V2s", "t", "atomic-ds-pk-add-16-insts") TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_v2f16, "V2hV2h*3V2h", "t", "atomic-ds-pk-add-16-insts") +TARGET_BUILTIN(__builtin_amdgcn_global_load_lds, "vv*1v*3UiiUi", "t", "gfx940-insts") arsenm wrote: clang should really be enforcing the valid immediate values for the size https://github.com/llvm/llvm-project/pull/92962 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [polly] [X86] Remove knl/knm specific ISAs supports (PR #92883)
FreddyLeaf wrote: > Please note it in release notes. [13a0f8d](https://github.com/llvm/llvm-project/pull/92883/commits/13a0f8d87343fd1a6380a66b7986ad1ce34b06fc) https://github.com/llvm/llvm-project/pull/92883 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [polly] [X86] Remove knl/knm specific ISAs supports (PR #92883)
@@ -1,373 +0,0 @@ -# NOTE: Assertions have been autogenerated by utils/update_mca_test_checks.py FreddyLeaf wrote: [13a0f8d](https://github.com/llvm/llvm-project/pull/92883/commits/13a0f8d87343fd1a6380a66b7986ad1ce34b06fc) https://github.com/llvm/llvm-project/pull/92883 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [polly] [X86] Remove knl/knm specific ISAs supports (PR #92883)
@@ -8,16 +8,12 @@ target triple = "x86_64-unknown-linux-gnu" define dso_local i32 @main() local_unnamed_addr #0 !dbg !7 { entry: tail call void @llvm.prefetch(ptr inttoptr (i64 291 to ptr), i32 0, i32 0, i32 1), !dbg !9 - tail call void @llvm.x86.avx512.gatherpf.dpd.512(i8 97, <8 x i32> undef, ptr null, i32 1, i32 2), !dbg !10 ret i32 291, !dbg !11 } ; Function Attrs: inaccessiblemem_or_argmemonly nounwind declare void @llvm.prefetch(ptr nocapture readonly, i32, i32, i32) #1 -; Function Attrs: argmemonly nounwind -declare void @llvm.x86.avx512.gatherpf.dpd.512(i8, <8 x i32>, ptr, i32, i32) #2 - attributes #0 = {"target-cpu"="x86-64" "target-features"="+avx512pf,+sse4.2,+ssse3"} FreddyLeaf wrote: [13a0f8d](https://github.com/llvm/llvm-project/pull/92883/commits/13a0f8d87343fd1a6380a66b7986ad1ce34b06fc) https://github.com/llvm/llvm-project/pull/92883 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AMDGPU] Add amdgpu-as MMRA for fences (PR #78572)
Pierre-vh wrote: > > I thought image memory = private. It's unclear to me, what AS does OpenCL > > IMAGE memory map to in our backend? (But otherwise, yes, MMRA should just > > have the backend names, the mapping of the OpenCL IMAGE to a backend AS > > should be in the device-lib) > > Images are global memory with magical addressing and value interpretation on > load/store. There's nothing private about them So in our case: - OpenCL Image = Global - OpenCL Local = LDS - OpenCL global = Global ? Is that correct? Then I guess the MMRA should just have "global" and "local" for now, we can always add more later if needed. What do you think? https://github.com/llvm/llvm-project/pull/78572 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-repl] Extend the C support. (PR #89804)
vgvassilev wrote: > I reverted in > > ``` > commit dfdf1c5fe45a82b9c578306f3d7627fd251d63f8 > Author: Jason Molenda > Date: Tue May 21 18:00:11 2024 -0700 > > Revert "[clang-repl] Extend the C support. (#89804)" > > This reverts commit 253c28fa829cee0104c2fc59ed1a958980b5138c. > ``` > > to unblock the CI bots until Vassil has a chance to look at it. Thank you! I suspect that this is due to the changes in SemaDecl.cpp (https://github.com/llvm/llvm-project/pull/89804/files#diff-edac6256ac508912a16d0165b2f8cf37123dc2f40a147dca49a34c33f1db13ddR2288) I am trying to build lldb but if you have a hint how to reproduce it outside lldb would be great! https://github.com/llvm/llvm-project/pull/89804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 108575f - [IR] Avoid creating icmp/fcmp constant expressions (#92885)
Author: Nikita Popov Date: 2024-05-22T07:40:08+02:00 New Revision: 108575f02ea9927009ed81231474d3a6f053602f URL: https://github.com/llvm/llvm-project/commit/108575f02ea9927009ed81231474d3a6f053602f DIFF: https://github.com/llvm/llvm-project/commit/108575f02ea9927009ed81231474d3a6f053602f.diff LOG: [IR] Avoid creating icmp/fcmp constant expressions (#92885) Do not create icmp/fcmp constant expressions in IRBuilder etc anymore, i.e. treat them as "undesirable". This is in preparation for removing them entirely. Part of: https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179 Added: Modified: clang/test/Analysis/builtin_signbit.cpp clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c clang/test/CodeGen/constantexpr-fneg.c clang/test/CodeGenCXX/cxx11-thread-local.cpp clang/test/CodeGenCXX/ubsan-nullability-arg.cpp clang/test/CodeGenCXX/weak-external.cpp clang/test/Driver/linker-wrapper-image.c clang/test/OpenMP/threadprivate_codegen.cpp llvm/include/llvm/Analysis/TargetFolder.h llvm/include/llvm/IR/ConstantFolder.h llvm/lib/Analysis/ConstantFolding.cpp llvm/lib/IR/ConstantFold.cpp llvm/test/Assembler/ConstantExprFold.ll llvm/test/Assembler/ConstantExprNoFold.ll llvm/test/Assembler/vector-cmp.ll llvm/test/CodeGen/AMDGPU/lower-ctor-dtor-constexpr-alias.ll llvm/test/CodeGen/AMDGPU/lower-ctor-dtor.ll llvm/test/CodeGen/AMDGPU/lower-multiple-ctor-dtor.ll llvm/test/Instrumentation/MemorySanitizer/check-constant-shadow.ll llvm/test/Instrumentation/SanitizerBinaryMetadata/atomics.ll llvm/test/Transforms/Attributor/value-simplify.ll llvm/test/Transforms/InstCombine/binop-select-cast-of-select-cond.ll llvm/test/Transforms/InstCombine/constant-fold-address-space-pointer.ll llvm/test/Transforms/InstCombine/getelementptr.ll llvm/test/Transforms/InstCombine/hoist-xor-by-constant-from-xor-by-value.ll llvm/test/Transforms/InstCombine/pr33453.ll llvm/test/Transforms/InstCombine/pr83947.ll llvm/test/Transforms/InstCombine/rem.ll llvm/test/Transforms/InstCombine/select-and-or.ll llvm/test/Transforms/InstCombine/select-safe-transforms.ll llvm/test/Transforms/InstSimplify/ConstProp/bitcast.ll llvm/test/Transforms/InstSimplify/ConstProp/icmp-global.ll llvm/test/Transforms/InstSimplify/bitcast-vector-fold.ll llvm/test/Transforms/InstSimplify/compare.ll llvm/test/Transforms/InstSimplify/past-the-end.ll llvm/test/Transforms/JumpThreading/constant-fold-status.ll llvm/test/Transforms/LowerTypeTests/cfi-direct-call1.ll llvm/test/Transforms/LowerTypeTests/function-weak.ll llvm/test/Transforms/SCCP/conditions-ranges.ll llvm/test/Transforms/SimplifyCFG/phi-to-select-constexpr-icmp.ll Removed: diff --git a/clang/test/Analysis/builtin_signbit.cpp b/clang/test/Analysis/builtin_signbit.cpp index 57e6816ce2802..be10f0950f69b 100644 --- a/clang/test/Analysis/builtin_signbit.cpp +++ b/clang/test/Analysis/builtin_signbit.cpp @@ -84,28 +84,30 @@ long double ld = -1.0L; // CHECK-LE-LABEL: define dso_local void @_Z12test_signbitv( // CHECK-LE-SAME: ) #[[ATTR0:[0-9]+]] { // CHECK-LE-NEXT: entry: -// CHECK-LE-NEXT:[[FROMBOOL:%.*]] = zext i1 icmp slt (i64 trunc (i128 bitcast (ppc_fp128 0xM3FF0 to i128) to i64), i64 0) to i8 +// CHECK-LE-NEXT:[[TMP0:%.*]] = icmp slt i64 trunc (i128 bitcast (ppc_fp128 0xM3FF0 to i128) to i64), 0 +// CHECK-LE-NEXT:[[FROMBOOL:%.*]] = zext i1 [[TMP0]] to i8 // CHECK-LE-NEXT:store i8 [[FROMBOOL]], ptr @b, align 1 -// CHECK-LE-NEXT:[[TMP0:%.*]] = load ppc_fp128, ptr @ld, align 16 -// CHECK-LE-NEXT:[[TMP1:%.*]] = bitcast ppc_fp128 [[TMP0]] to i128 -// CHECK-LE-NEXT:[[TMP2:%.*]] = trunc i128 [[TMP1]] to i64 -// CHECK-LE-NEXT:[[TMP3:%.*]] = icmp slt i64 [[TMP2]], 0 -// CHECK-LE-NEXT:[[FROMBOOL1:%.*]] = zext i1 [[TMP3]] to i8 +// CHECK-LE-NEXT:[[TMP1:%.*]] = load ppc_fp128, ptr @ld, align 16 +// CHECK-LE-NEXT:[[TMP2:%.*]] = bitcast ppc_fp128 [[TMP1]] to i128 +// CHECK-LE-NEXT:[[TMP3:%.*]] = trunc i128 [[TMP2]] to i64 +// CHECK-LE-NEXT:[[TMP4:%.*]] = icmp slt i64 [[TMP3]], 0 +// CHECK-LE-NEXT:[[FROMBOOL1:%.*]] = zext i1 [[TMP4]] to i8 // CHECK-LE-NEXT:store i8 [[FROMBOOL1]], ptr @b, align 1 // CHECK-LE-NEXT:store i8 0, ptr @b, align 1 -// CHECK-LE-NEXT:[[TMP4:%.*]] = load double, ptr @d, align 8 -// CHECK-LE-NEXT:[[CONV:%.*]] = fptrunc double [[TMP4]] to float -// CHECK-LE-NEXT:[[TMP5:%.*]] = bitcast float [[CONV]] to i32 -// CHECK-LE-NEXT:[[TMP6:%.*]] = icmp slt i32 [[TMP5]], 0 -// CHECK-LE-NEXT:[[FROMBOOL2:%.*]] = zext i1 [[TMP6]] to i8 +// CHECK-LE-NEXT:[[TMP5:%.*]] = load double, ptr @d, align 8 +// CHECK-LE-NEXT:[[CONV:%.*]] = fptrunc double [[TMP5]] to float +// CHECK-LE-NEXT:[[TMP6:%.*]]
[clang] [llvm] [polly] [X86] Remove knl/knm specific ISAs supports (PR #92883)
@@ -1,373 +0,0 @@ -# NOTE: Assertions have been autogenerated by utils/update_mca_test_checks.py FreddyLeaf wrote: scheduleinfo was removed. Now I think we should keep schedule info for these instructions, will add back. https://github.com/llvm/llvm-project/pull/92883 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [IR] Avoid creating icmp/fcmp constant expressions (PR #92885)
https://github.com/nikic closed https://github.com/llvm/llvm-project/pull/92885 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] MIPS/Clang: Add more false option pairs into validateTarget (PR #91968)
https://github.com/wzssyqa updated https://github.com/llvm/llvm-project/pull/91968 >From cccd9606fd574726c2cde2e473d1e05a62147caf Mon Sep 17 00:00:00 2001 From: YunQiang Su Date: Mon, 13 May 2024 21:46:40 +0800 Subject: [PATCH] MIPS/Clang: Add more false option pairs into validateTarget The option pairs include: -mfpxx -mips1 -msoft-float -mmsa -mmsa -mabi=32 with 32bit pre-R2 CPUs -mfpxx -mmsa -mfp32 -mmsa --- clang/lib/Basic/Targets/Mips.cpp | 28 1 file changed, 28 insertions(+) diff --git a/clang/lib/Basic/Targets/Mips.cpp b/clang/lib/Basic/Targets/Mips.cpp index 3a65f53c52485..174bc9d2ab996 100644 --- a/clang/lib/Basic/Targets/Mips.cpp +++ b/clang/lib/Basic/Targets/Mips.cpp @@ -273,6 +273,34 @@ bool MipsTargetInfo::validateTarget(DiagnosticsEngine &Diags) const { Diags.Report(diag::err_mips_fp64_req) << "-mfp64"; return false; } + // FPXX requires mips2+ + if (FPMode == FPXX && CPU == "mips1") { +Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfpxx" << CPU; +return false; + } + // -mmsa with -msoft-float makes nonsense + if (FloatABI == SoftFloat && HasMSA) { +Diags.Report(diag::err_opt_not_valid_with_opt) << "-msoft-float" + << "-mmsa"; +return false; + } + // Option -mmsa permitted on Mips32 iff revision 2 or higher is present + if (HasMSA && (CPU == "mips1" || CPU == "mips2" || getISARev() < 2) && + ABI == "o32") { +Diags.Report(diag::err_mips_fp64_req) << "-mmsa"; +return false; + } + // MSA requires FP64 + if (FPMode == FPXX && HasMSA) { +Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfpxx" + << "-mmsa"; +return false; + } + if (FPMode == FP32 && HasMSA) { +Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfp32" + << "-mmsa"; +return false; + } return true; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [polly] [X86] Remove knl/knm specific ISAs supports (PR #92883)
@@ -268,30 +268,6 @@ define void @gather_qps(<8 x i64> %ind, <8 x float> %src, ptr %base, ptr %stbuf) ret void } -declare void @llvm.x86.avx512.gatherpf.qps.512(i8, <8 x i64>, ptr , i32, i32); FreddyLeaf wrote: yes, this should be a bug before. https://github.com/llvm/llvm-project/pull/92883 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Introduce `SemaRISCV` (PR #92682)
https://github.com/topperc approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/92682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 130e93c - Reland "[clang] Enable sized deallocation by default in C++14 onwards" (#90373)
Author: Pengcheng Wang Date: 2024-05-22T12:37:27+08:00 New Revision: 130e93cc26ca9d3ac50ec5a92e3109577ca2e702 URL: https://github.com/llvm/llvm-project/commit/130e93cc26ca9d3ac50ec5a92e3109577ca2e702 DIFF: https://github.com/llvm/llvm-project/commit/130e93cc26ca9d3ac50ec5a92e3109577ca2e702.diff LOG: Reland "[clang] Enable sized deallocation by default in C++14 onwards" (#90373) Since C++14 has been released for about nine years and most standard libraries have implemented sized deallocation functions, it's time to make this feature default again. This is another try of https://reviews.llvm.org/D112921. The original commit cf5a8b4 was reverted by 2e5035a due to some failures (see #83774). Fixes #60061 Added: Modified: clang-tools-extra/clangd/unittests/FindTargetTests.cpp clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp clang/docs/ReleaseNotes.rst clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/Darwin.cpp clang/lib/Driver/ToolChains/Darwin.h clang/lib/Driver/ToolChains/ZOS.cpp clang/test/AST/ast-dump-expr-json.cpp clang/test/AST/ast-dump-expr.cpp clang/test/AST/ast-dump-stmt-json.cpp clang/test/Analysis/cxxnewexpr-callback.cpp clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p2.cpp clang/test/CXX/drs/cwg292.cpp clang/test/CXX/expr/expr.unary/expr.new/p14.cpp clang/test/CodeGenCXX/cxx1y-sized-deallocation.cpp clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp clang/test/CodeGenCXX/cxx2a-destroying-delete.cpp clang/test/CodeGenCXX/delete-two-arg.cpp clang/test/CodeGenCXX/delete.cpp clang/test/CodeGenCXX/dllimport.cpp clang/test/CodeGenCXX/new.cpp clang/test/CodeGenCoroutines/coro-aligned-alloc-2.cpp clang/test/CodeGenCoroutines/coro-aligned-alloc.cpp clang/test/CodeGenCoroutines/coro-alloc.cpp clang/test/CodeGenCoroutines/coro-cleanup.cpp clang/test/CodeGenCoroutines/coro-dealloc.cpp clang/test/CodeGenCoroutines/coro-gro.cpp clang/test/CodeGenCoroutines/pr56919.cpp clang/test/Lexer/cxx-features.cpp clang/test/PCH/cxx1z-aligned-alloc.cpp clang/test/SemaCXX/MicrosoftExtensions.cpp clang/test/SemaCXX/builtin-operator-new-delete.cpp clang/test/SemaCXX/cxx1y-sized-deallocation.cpp clang/test/SemaCXX/unavailable_aligned_allocation.cpp clang/tools/clang-repl/CMakeLists.txt clang/unittests/Interpreter/CMakeLists.txt clang/unittests/StaticAnalyzer/CallEventTest.cpp clang/www/cxx_status.html libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp Removed: diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp index 0b2273f0a9a6e..3220a5a6a9825 100644 --- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp +++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp @@ -836,7 +836,9 @@ TEST_F(TargetDeclTest, OverloadExpr) { [[delete]] x; } )cpp"; - EXPECT_DECLS("CXXDeleteExpr", "void operator delete(void *) noexcept"); + // Sized deallocation is enabled by default in C++14 onwards. + EXPECT_DECLS("CXXDeleteExpr", + "void operator delete(void *, unsigned long) noexcept"); } TEST_F(TargetDeclTest, DependentExprs) { diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp b/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp index 78f021144b2e1..f86fe8a4c5b14 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp @@ -12,16 +12,6 @@ struct S { // CHECK-MESSAGES: :[[@LINE+1]]:7: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope void *operator new(size_t size) noexcept(false); -struct T { - // Sized deallocations are not enabled by default, and so this new/delete pair - // does not match. However, we expect only one warning, for the new, because - // the operator delete is a placement delete and we do not warn on mismatching - // placement operations. - // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope - void *operator new(size_t size) noexcept; - void operator delete(void *ptr, size_t) noexcept; // ok only if sized deallocation is enabled -}; - struct U { void *operator new(size_t size) noexcept; void operator delete(void *ptr) noexcept; diff --git a/clang/docs/ReleaseNotes.
[clang] 130e93c - Reland "[clang] Enable sized deallocation by default in C++14 onwards" (#90373)
Author: Pengcheng Wang Date: 2024-05-22T12:37:27+08:00 New Revision: 130e93cc26ca9d3ac50ec5a92e3109577ca2e702 URL: https://github.com/llvm/llvm-project/commit/130e93cc26ca9d3ac50ec5a92e3109577ca2e702 DIFF: https://github.com/llvm/llvm-project/commit/130e93cc26ca9d3ac50ec5a92e3109577ca2e702.diff LOG: Reland "[clang] Enable sized deallocation by default in C++14 onwards" (#90373) Since C++14 has been released for about nine years and most standard libraries have implemented sized deallocation functions, it's time to make this feature default again. This is another try of https://reviews.llvm.org/D112921. The original commit cf5a8b4 was reverted by 2e5035a due to some failures (see #83774). Fixes #60061 Added: Modified: clang-tools-extra/clangd/unittests/FindTargetTests.cpp clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp clang/docs/ReleaseNotes.rst clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/Darwin.cpp clang/lib/Driver/ToolChains/Darwin.h clang/lib/Driver/ToolChains/ZOS.cpp clang/test/AST/ast-dump-expr-json.cpp clang/test/AST/ast-dump-expr.cpp clang/test/AST/ast-dump-stmt-json.cpp clang/test/Analysis/cxxnewexpr-callback.cpp clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p2.cpp clang/test/CXX/drs/cwg292.cpp clang/test/CXX/expr/expr.unary/expr.new/p14.cpp clang/test/CodeGenCXX/cxx1y-sized-deallocation.cpp clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp clang/test/CodeGenCXX/cxx2a-destroying-delete.cpp clang/test/CodeGenCXX/delete-two-arg.cpp clang/test/CodeGenCXX/delete.cpp clang/test/CodeGenCXX/dllimport.cpp clang/test/CodeGenCXX/new.cpp clang/test/CodeGenCoroutines/coro-aligned-alloc-2.cpp clang/test/CodeGenCoroutines/coro-aligned-alloc.cpp clang/test/CodeGenCoroutines/coro-alloc.cpp clang/test/CodeGenCoroutines/coro-cleanup.cpp clang/test/CodeGenCoroutines/coro-dealloc.cpp clang/test/CodeGenCoroutines/coro-gro.cpp clang/test/CodeGenCoroutines/pr56919.cpp clang/test/Lexer/cxx-features.cpp clang/test/PCH/cxx1z-aligned-alloc.cpp clang/test/SemaCXX/MicrosoftExtensions.cpp clang/test/SemaCXX/builtin-operator-new-delete.cpp clang/test/SemaCXX/cxx1y-sized-deallocation.cpp clang/test/SemaCXX/unavailable_aligned_allocation.cpp clang/tools/clang-repl/CMakeLists.txt clang/unittests/Interpreter/CMakeLists.txt clang/unittests/StaticAnalyzer/CallEventTest.cpp clang/www/cxx_status.html libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp Removed: diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp index 0b2273f0a9a6e..3220a5a6a9825 100644 --- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp +++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp @@ -836,7 +836,9 @@ TEST_F(TargetDeclTest, OverloadExpr) { [[delete]] x; } )cpp"; - EXPECT_DECLS("CXXDeleteExpr", "void operator delete(void *) noexcept"); + // Sized deallocation is enabled by default in C++14 onwards. + EXPECT_DECLS("CXXDeleteExpr", + "void operator delete(void *, unsigned long) noexcept"); } TEST_F(TargetDeclTest, DependentExprs) { diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp b/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp index 78f021144b2e1..f86fe8a4c5b14 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp @@ -12,16 +12,6 @@ struct S { // CHECK-MESSAGES: :[[@LINE+1]]:7: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope void *operator new(size_t size) noexcept(false); -struct T { - // Sized deallocations are not enabled by default, and so this new/delete pair - // does not match. However, we expect only one warning, for the new, because - // the operator delete is a placement delete and we do not warn on mismatching - // placement operations. - // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope - void *operator new(size_t size) noexcept; - void operator delete(void *ptr, size_t) noexcept; // ok only if sized deallocation is enabled -}; - struct U { void *operator new(size_t size) noexcept; void operator delete(void *ptr) noexcept; diff --git a/clang/docs/ReleaseNotes.
[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)
https://github.com/wangpc-pp closed https://github.com/llvm/llvm-project/pull/90373 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [libcxx] Reland "[clang] Enable sized deallocation by default in C++14 onwards" (PR #90373)
https://github.com/wangpc-pp updated https://github.com/llvm/llvm-project/pull/90373 >From a18f57e23c0d4fd23647eb2ef610352e402b45f6 Mon Sep 17 00:00:00 2001 From: Pengcheng Wang Date: Fri, 26 Apr 2024 16:59:12 +0800 Subject: [PATCH] [clang] Enable sized deallocation by default in C++14 onwards Since C++14 has been released for about nine years and most standard libraries have implemented sized deallocation functions, it's time to make this feature default again. This is another try of https://reviews.llvm.org/D112921. The original commit cf5a8b4 was reverted by 2e5035a due to some failures (see #83774). Fixes #60061 --- .../clangd/unittests/FindTargetTests.cpp | 4 +- .../checkers/misc/new-delete-overloads.cpp| 10 - clang/docs/ReleaseNotes.rst | 5 + clang/include/clang/Driver/Options.td | 8 +- clang/lib/Driver/ToolChains/Clang.cpp | 13 +- clang/lib/Driver/ToolChains/Darwin.cpp| 58 - clang/lib/Driver/ToolChains/Darwin.h | 4 + clang/lib/Driver/ToolChains/ZOS.cpp | 6 + clang/test/AST/ast-dump-expr-json.cpp | 2 +- clang/test/AST/ast-dump-expr.cpp | 2 +- clang/test/AST/ast-dump-stmt-json.cpp | 244 +- clang/test/Analysis/cxxnewexpr-callback.cpp | 4 +- .../basic.stc.dynamic.deallocation/p2.cpp | 2 +- clang/test/CXX/drs/cwg292.cpp | 17 +- .../test/CXX/expr/expr.unary/expr.new/p14.cpp | 2 +- .../CodeGenCXX/cxx1y-sized-deallocation.cpp | 10 +- .../CodeGenCXX/cxx1z-aligned-allocation.cpp | 6 +- .../CodeGenCXX/cxx2a-destroying-delete.cpp| 4 +- clang/test/CodeGenCXX/delete-two-arg.cpp | 4 +- clang/test/CodeGenCXX/delete.cpp | 12 +- clang/test/CodeGenCXX/dllimport.cpp | 4 +- clang/test/CodeGenCXX/new.cpp | 6 +- .../coro-aligned-alloc-2.cpp | 2 - .../CodeGenCoroutines/coro-aligned-alloc.cpp | 6 +- clang/test/CodeGenCoroutines/coro-alloc.cpp | 6 +- clang/test/CodeGenCoroutines/coro-cleanup.cpp | 6 +- clang/test/CodeGenCoroutines/coro-dealloc.cpp | 2 - clang/test/CodeGenCoroutines/coro-gro.cpp | 3 +- clang/test/CodeGenCoroutines/pr56919.cpp | 9 +- clang/test/Lexer/cxx-features.cpp | 20 +- clang/test/PCH/cxx1z-aligned-alloc.cpp| 10 +- clang/test/SemaCXX/MicrosoftExtensions.cpp| 8 +- .../SemaCXX/builtin-operator-new-delete.cpp | 2 +- .../test/SemaCXX/cxx1y-sized-deallocation.cpp | 2 +- .../unavailable_aligned_allocation.cpp| 15 +- clang/tools/clang-repl/CMakeLists.txt | 43 +++ clang/unittests/Interpreter/CMakeLists.txt| 43 +++ .../StaticAnalyzer/CallEventTest.cpp | 2 +- clang/www/cxx_status.html | 11 +- .../support.dynamic/libcpp_deallocate.sh.cpp | 3 + .../sized_delete_array14.pass.cpp | 8 +- .../new.delete.single/sized_delete14.pass.cpp | 8 +- 42 files changed, 523 insertions(+), 113 deletions(-) diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp index 0b2273f0a9a6e..3220a5a6a9825 100644 --- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp +++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp @@ -836,7 +836,9 @@ TEST_F(TargetDeclTest, OverloadExpr) { [[delete]] x; } )cpp"; - EXPECT_DECLS("CXXDeleteExpr", "void operator delete(void *) noexcept"); + // Sized deallocation is enabled by default in C++14 onwards. + EXPECT_DECLS("CXXDeleteExpr", + "void operator delete(void *, unsigned long) noexcept"); } TEST_F(TargetDeclTest, DependentExprs) { diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp b/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp index 78f021144b2e1..f86fe8a4c5b14 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp @@ -12,16 +12,6 @@ struct S { // CHECK-MESSAGES: :[[@LINE+1]]:7: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope void *operator new(size_t size) noexcept(false); -struct T { - // Sized deallocations are not enabled by default, and so this new/delete pair - // does not match. However, we expect only one warning, for the new, because - // the operator delete is a placement delete and we do not warn on mismatching - // placement operations. - // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope - void *operator new(size_t size) noexcept; - void operator delete(void *ptr, size_t) noexcept; // ok only if sized deallocation is enabled -}; - struct U { void *operator new(size_t size) noexcept; void operator delete(void *ptr) n
[clang] [clang] add unnamed_addr function attribute (PR #92499)
yamt wrote: > That said, the description of the use case is ~3 short sentences. ok. here is a concrete example and a bit longer explanation: https://github.com/yamt/toywasm/blob/9ee6ec86f56723819fd8411866094f72247dba78/lib/insn.c#L515-L527 https://github.com/llvm/llvm-project/pull/92499 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [webkit.RefCntblBaseVirtualDtor] Allow CRTP classes without a virtual destructor. (PR #92837)
https://github.com/rniwa updated https://github.com/llvm/llvm-project/pull/92837 >From 9cbdf8228c8b10f4c8cd4e8770b58921e559a687 Mon Sep 17 00:00:00 2001 From: Ryosuke Niwa Date: Mon, 20 May 2024 16:12:44 -0700 Subject: [PATCH] [webkit.RefCntblBaseVirtualDtor] Allow CRTP classes without a virtual destructor. Exempt CRTP (Curiously Recurring Template Pattern) classes with a delete operation acting on "this" pointer with an appropriate cast from the requirement that a ref-countable superclass must have a virtual destructor. To do this, this PR introduces new DerefAnalysisVisitor, which looks for a delete operation with an explicit cast to the derived class in a base class. This PR also changes the checker so that we only check a given class's immediate base class instead of all ancestor base classes in the class hierarchy. This is sufficient because the checker will eventually see the definition for every class in the class hierarchy and transitively proves every ref-counted base class has a virtual destructor or deref function which casts this pointer back to the derived class before deleting. Without this change, we would keep traversing the same list of base classes whenever we encounter a new subclass, which is wholly unnecessary. It's possible for DerefAnalysisVisitor to come to a conclusoin that there isn't enough information to determine whether a given templated superclass invokes delete operation on a subclass when the template isn't fully specialized for the subclass. In this case, we return std::nullopt in HasSpecializedDelete, and visitCXXRecordDecl will skip this declaration. This is okay because the checker will eventually see a concreate fully specialized class definition if it ever gets instantiated. --- .../WebKit/RefCntblBaseVirtualDtorChecker.cpp | 311 + .../ref-cntbl-base-virtual-dtor-templates.cpp | 324 +- 2 files changed, 566 insertions(+), 69 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp index 7f4c3a7b787e8..efb7b4456f2ca 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RefCntblBaseVirtualDtorChecker.cpp @@ -11,16 +11,134 @@ #include "PtrTypesSemantics.h" #include "clang/AST/CXXInheritance.h" #include "clang/AST/RecursiveASTVisitor.h" +#include "clang/AST/StmtVisitor.h" #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/Checker.h" +#include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/SetVector.h" #include using namespace clang; using namespace ento; namespace { + +class DerefAnalysisVisitor +: public ConstStmtVisitor { + // Returns true if any of child statements return true. + bool VisitChildren(const Stmt *S) { +for (const Stmt *Child : S->children()) { + if (Child && Visit(Child)) +return true; +} +return false; + } + + bool VisitBody(const Stmt *Body) { +if (!Body) + return false; + +auto [It, IsNew] = VisitedBody.insert(Body); +if (!IsNew) // This body is recursive + return false; + +return Visit(Body); + } + +public: + DerefAnalysisVisitor(const TemplateArgumentList &ArgList, + const CXXRecordDecl *ClassDecl) + : ArgList(&ArgList), ClassDecl(ClassDecl) {} + + DerefAnalysisVisitor(const CXXRecordDecl *ClassDecl) : ClassDecl(ClassDecl) {} + + std::optional HasSpecializedDelete(CXXMethodDecl *Decl) { +if (auto *Body = Decl->getBody()) + return VisitBody(Body); +if (auto *Tmpl = Decl->getTemplateInstantiationPattern()) + return std::nullopt; // Indeterminate. There was no concrete instance. +return false; + } + + bool VisitCallExpr(const CallExpr *CE) { +auto *Callee = CE->getCallee(); +while (auto *Expr = dyn_cast(Callee)) + Callee = Expr->getSubExpr(); +if (auto *DeclRef = dyn_cast(Callee)) { + auto *Decl = DeclRef->getDecl(); + if (auto *VD = dyn_cast(Decl)) { +if (auto *Init = VD->getInit()) { + if (auto *Lambda = dyn_cast(Init)) +return VisitBody(Lambda->getBody()); +} + } else if (auto *FD = dyn_cast(Decl)) +return VisitBody(FD->getBody()); +} +return false; + } + + bool VisitCXXMemberCallExpr(const CXXMemberCallExpr *MCE) { +auto *Callee = MCE->getMethodDecl(); +if (!Callee) + return false; +return VisitBody(Callee->getBody()); + } + + bool VisitCXXDeleteExpr(const CXXDeleteExpr *E) { +auto *Arg = E->getArgument(); +while (Arg) { + if (auto *Paren = dyn_cast(Arg)) +Arg = Paren->getSubExpr(); + else if (auto *Cast = dyn_cast(Arg)) { +Arg = Cast->getSubExpr(); +
[clang] [clang][driver] Support `-x` for all languages in CL mode (PR #89772)
https://github.com/huangqinjin edited https://github.com/llvm/llvm-project/pull/89772 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][driver] Support `-x` for all languages in CL mode (PR #89772)
https://github.com/huangqinjin updated https://github.com/llvm/llvm-project/pull/89772 >From bb5ea14cd2efdb8205a1abf39f8ace279e81aa47 Mon Sep 17 00:00:00 2001 From: huangqinjin Date: Tue, 23 Apr 2024 22:18:27 +0800 Subject: [PATCH] [clang][driver] Support `-x` for all languages in CL mode After https://github.com/llvm/llvm-project/pull/68921, clang-cl gained option `-x` but only for CUDA/HIP. This commit simply removes the restriction on parameters to `-x`. Especially, it is able to use `-x c++-module` and `-x c++-system-header` to build C++20 modules and header units with clang-cl. This effectively reverts commit fe082124faa8455cc9a68be5fdf10fc46a4d066c. Closes https://github.com/llvm/llvm-project/issues/88006. --- clang/lib/Driver/Driver.cpp | 11 +-- clang/test/Driver/x-args.c | 4 +--- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index e7335a61b10c5..0f425adfd32a6 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -2636,22 +2636,13 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args, Diag(clang::diag::note_drv_t_option_is_global); } - // CUDA/HIP and their preprocessor expansions can be accepted by CL mode. // Warn -x after last input file has no effect - auto LastXArg = Args.getLastArgValue(options::OPT_x); - const llvm::StringSet<> ValidXArgs = {"cuda", "hip", "cui", "hipi"}; - if (!IsCLMode() || ValidXArgs.contains(LastXArg)) { + { Arg *LastXArg = Args.getLastArgNoClaim(options::OPT_x); Arg *LastInputArg = Args.getLastArgNoClaim(options::OPT_INPUT); if (LastXArg && LastInputArg && LastInputArg->getIndex() < LastXArg->getIndex()) Diag(clang::diag::warn_drv_unused_x) << LastXArg->getValue(); - } else { -// In CL mode suggest /TC or /TP since -x doesn't make sense if passed via -// /clang:. -if (auto *A = Args.getLastArg(options::OPT_x)) - Diag(diag::err_drv_unsupported_opt_with_suggestion) - << A->getAsString(Args) << "/TC' or '/TP"; } for (Arg *A : Args) { diff --git a/clang/test/Driver/x-args.c b/clang/test/Driver/x-args.c index 17bb5d99404da..06c9c7a461565 100644 --- a/clang/test/Driver/x-args.c +++ b/clang/test/Driver/x-args.c @@ -6,6 +6,4 @@ // RUN: %clang -fsyntax-only %s -xc %s -xc++ -fsyntax-only 2>&1 | FileCheck %s // CHECK: '-x c++' after last input file has no effect -// RUN: not %clang_cl /WX /clang:-xc /clang:-E /clang:-dM -- %s 2>&1 | FileCheck --implicit-check-not="error:" -check-prefix=CL %s -// RUN: not %clang_cl /TC /WX /clang:-xc /clang:-E /clang:-dM -- %s 2>&1 | FileCheck --implicit-check-not="error:" -check-prefix=CL %s -// CL: error: unsupported option '-x c'; did you mean '/TC' or '/TP'? +// RUN: %clang_cl -fsyntax-only /WX -xc++ -- %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AMDGPU][Clang] Builtin for GLOBAL_LOAD_LDS on GFX940 (PR #92962)
https://github.com/shiltian closed https://github.com/llvm/llvm-project/pull/92962 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] d53c6cd - [AMDGPU][Clang] Builtin for GLOBAL_LOAD_LDS on GFX940 (#92962)
Author: Shilei Tian Date: 2024-05-22T00:03:59-04:00 New Revision: d53c6cdbc108729ce5dc7d4e9184db025206fefc URL: https://github.com/llvm/llvm-project/commit/d53c6cdbc108729ce5dc7d4e9184db025206fefc DIFF: https://github.com/llvm/llvm-project/commit/d53c6cdbc108729ce5dc7d4e9184db025206fefc.diff LOG: [AMDGPU][Clang] Builtin for GLOBAL_LOAD_LDS on GFX940 (#92962) Fixes: SWDEV-459212 Added: clang/test/CodeGenOpenCL/builtins-amdgcn-gfx940.cl Modified: clang/include/clang/Basic/BuiltinsAMDGPU.def llvm/include/llvm/IR/IntrinsicsAMDGPU.td Removed: diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def b/clang/include/clang/Basic/BuiltinsAMDGPU.def index 3e21a2fe2ac6b..efa652eee9901 100644 --- a/clang/include/clang/Basic/BuiltinsAMDGPU.def +++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def @@ -240,6 +240,7 @@ TARGET_BUILTIN(__builtin_amdgcn_flat_atomic_fadd_v2bf16, "V2sV2s*0V2s", "t", "at TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fadd_v2bf16, "V2sV2s*1V2s", "t", "atomic-global-pk-add-bf16-inst") TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_v2bf16, "V2sV2s*3V2s", "t", "atomic-ds-pk-add-16-insts") TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_v2f16, "V2hV2h*3V2h", "t", "atomic-ds-pk-add-16-insts") +TARGET_BUILTIN(__builtin_amdgcn_global_load_lds, "vv*1v*3UiiUi", "t", "gfx940-insts") //===--===// // Deep learning builtins. diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx940.cl b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx940.cl new file mode 100644 index 0..fc5649d8a41f7 --- /dev/null +++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx940.cl @@ -0,0 +1,52 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// RUN: %clang_cc1 -cl-std=CL2.0 -O0 -triple amdgcn-unknown-unknown -target-cpu gfx940 -emit-llvm -o - %s | FileCheck %s +// REQUIRES: amdgpu-registered-target + +typedef unsigned int u32; +typedef unsigned short u16; +typedef unsigned char u8; + +// CHECK-LABEL: @test_global_load_lds_u32( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[SRC_ADDR:%.*]] = alloca ptr addrspace(1), align 8, addrspace(5) +// CHECK-NEXT:[[DST_ADDR:%.*]] = alloca ptr addrspace(3), align 4, addrspace(5) +// CHECK-NEXT:store ptr addrspace(1) [[SRC:%.*]], ptr addrspace(5) [[SRC_ADDR]], align 8 +// CHECK-NEXT:store ptr addrspace(3) [[DST:%.*]], ptr addrspace(5) [[DST_ADDR]], align 4 +// CHECK-NEXT:[[TMP0:%.*]] = load ptr addrspace(1), ptr addrspace(5) [[SRC_ADDR]], align 8 +// CHECK-NEXT:[[TMP1:%.*]] = load ptr addrspace(3), ptr addrspace(5) [[DST_ADDR]], align 4 +// CHECK-NEXT:call void @llvm.amdgcn.global.load.lds(ptr addrspace(1) [[TMP0]], ptr addrspace(3) [[TMP1]], i32 4, i32 0, i32 0) +// CHECK-NEXT:ret void +// +void test_global_load_lds_u32(global u32* src, local u32 *dst) { + __builtin_amdgcn_global_load_lds(src, dst, /*size=*/4, /*offset=*/0, /*aux=*/0); +} + +// CHECK-LABEL: @test_global_load_lds_u16( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[SRC_ADDR:%.*]] = alloca ptr addrspace(1), align 8, addrspace(5) +// CHECK-NEXT:[[DST_ADDR:%.*]] = alloca ptr addrspace(3), align 4, addrspace(5) +// CHECK-NEXT:store ptr addrspace(1) [[SRC:%.*]], ptr addrspace(5) [[SRC_ADDR]], align 8 +// CHECK-NEXT:store ptr addrspace(3) [[DST:%.*]], ptr addrspace(5) [[DST_ADDR]], align 4 +// CHECK-NEXT:[[TMP0:%.*]] = load ptr addrspace(1), ptr addrspace(5) [[SRC_ADDR]], align 8 +// CHECK-NEXT:[[TMP1:%.*]] = load ptr addrspace(3), ptr addrspace(5) [[DST_ADDR]], align 4 +// CHECK-NEXT:call void @llvm.amdgcn.global.load.lds(ptr addrspace(1) [[TMP0]], ptr addrspace(3) [[TMP1]], i32 2, i32 0, i32 0) +// CHECK-NEXT:ret void +// +void test_global_load_lds_u16(global u16* src, local u16 *dst) { + __builtin_amdgcn_global_load_lds(src, dst, /*size=*/2, /*offset=*/0, /*aux=*/0); +} + +// CHECK-LABEL: @test_global_load_lds_u8( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[SRC_ADDR:%.*]] = alloca ptr addrspace(1), align 8, addrspace(5) +// CHECK-NEXT:[[DST_ADDR:%.*]] = alloca ptr addrspace(3), align 4, addrspace(5) +// CHECK-NEXT:store ptr addrspace(1) [[SRC:%.*]], ptr addrspace(5) [[SRC_ADDR]], align 8 +// CHECK-NEXT:store ptr addrspace(3) [[DST:%.*]], ptr addrspace(5) [[DST_ADDR]], align 4 +// CHECK-NEXT:[[TMP0:%.*]] = load ptr addrspace(1), ptr addrspace(5) [[SRC_ADDR]], align 8 +// CHECK-NEXT:[[TMP1:%.*]] = load ptr addrspace(3), ptr addrspace(5) [[DST_ADDR]], align 4 +// CHECK-NEXT:call void @llvm.amdgcn.global.load.lds(ptr addrspace(1) [[TMP0]], ptr addrspace(3) [[TMP1]], i32 1, i32 0, i32 0) +// CHECK-NEXT:ret void +// +void test_global_load_lds_u8(global u8* src, local u8 *dst) { + __builtin_amdgcn_global_load_lds(src, dst, /*size=*/1, /*offset=*/0, /*aux=*/0); +} diff --git a/llvm/include/llvm/IR/Int
[libcxxabi] [libunwind] [WebAssembly] __USING_WASM_EXCEPTIONS__ -> __WASM_EXCEPTIONS__ (PR #92840)
https://github.com/aheejin closed https://github.com/llvm/llvm-project/pull/92840 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] 64f6406 - [WebAssembly] __USING_WASM_EXCEPTIONS__ -> __WASM_EXCEPTIONS__ (#92840)
Author: Heejin Ahn Date: 2024-05-21T21:01:36-07:00 New Revision: 64f640680f7b1ddc8d2015eac75865f231166f8c URL: https://github.com/llvm/llvm-project/commit/64f640680f7b1ddc8d2015eac75865f231166f8c DIFF: https://github.com/llvm/llvm-project/commit/64f640680f7b1ddc8d2015eac75865f231166f8c.diff LOG: [WebAssembly] __USING_WASM_EXCEPTIONS__ -> __WASM_EXCEPTIONS__ (#92840) We've decided to change `__USING_WASM_EXCEPTIONS__` preprocessor to `__WASM_EXCEPTIONS__` given that it's more concise. Added: Modified: libcxxabi/include/cxxabi.h libcxxabi/src/cxa_exception.cpp libcxxabi/src/cxa_exception.h libcxxabi/src/cxa_personality.cpp libunwind/src/Unwind-wasm.c libunwind/src/libunwind.cpp Removed: diff --git a/libcxxabi/include/cxxabi.h b/libcxxabi/include/cxxabi.h index d0701181751c5..9d9beecf751fc 100644 --- a/libcxxabi/include/cxxabi.h +++ b/libcxxabi/include/cxxabi.h @@ -53,7 +53,7 @@ __cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXAB // 2.4.3 Throwing the Exception Object extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_throw(void *thrown_exception, std::type_info *tinfo, -#ifdef __USING_WASM_EXCEPTIONS__ +#ifdef __WASM_EXCEPTIONS__ // In Wasm, a destructor returns its argument void *(_LIBCXXABI_DTOR_FUNC *dest)(void *)); #else diff --git a/libcxxabi/src/cxa_exception.cpp b/libcxxabi/src/cxa_exception.cpp index 65e9f4504ddad..3141d50a6bb92 100644 --- a/libcxxabi/src/cxa_exception.cpp +++ b/libcxxabi/src/cxa_exception.cpp @@ -267,7 +267,7 @@ will call terminate, assuming that there was no handler for the exception. */ void -#ifdef __USING_WASM_EXCEPTIONS__ +#ifdef __WASM_EXCEPTIONS__ // In Wasm, a destructor returns its argument __cxa_throw(void *thrown_object, std::type_info *tinfo, void *(_LIBCXXABI_DTOR_FUNC *dest)(void *)) { #else diff --git a/libcxxabi/src/cxa_exception.h b/libcxxabi/src/cxa_exception.h index 10712f6f47bb5..7800b940b83f7 100644 --- a/libcxxabi/src/cxa_exception.h +++ b/libcxxabi/src/cxa_exception.h @@ -43,7 +43,7 @@ struct _LIBCXXABI_HIDDEN __cxa_exception { // Manage the exception object itself. std::type_info *exceptionType; -#ifdef __USING_WASM_EXCEPTIONS__ +#ifdef __WASM_EXCEPTIONS__ // In Wasm, a destructor returns its argument void *(_LIBCXXABI_DTOR_FUNC *exceptionDestructor)(void *); #else diff --git a/libcxxabi/src/cxa_personality.cpp b/libcxxabi/src/cxa_personality.cpp index d95d781319401..843a18a4cbd8a 100644 --- a/libcxxabi/src/cxa_personality.cpp +++ b/libcxxabi/src/cxa_personality.cpp @@ -70,7 +70,7 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, +--+--+-+-++--+ | callSiteTableLength | (ULEB128) | Call Site Table length, used to find Action table | +-+---+---+ -#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__USING_WASM_EXCEPTIONS__) +#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__WASM_EXCEPTIONS__) +-+---++ | Beginning of Call Site TableThe current ip lies within the | | ... (start, length) range of one of these| @@ -84,7 +84,7 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, | +-+-+--+ | | ... | +--+ -#else // __USING_SJLJ_EXCEPTIONS__ || __USING_WASM_EXCEPTIONS__ +#else // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__ +-+---++ | Beginning of Call Site TableThe current ip is a 1-based index into | | ... this table. Or it is -1 meaning no | @@ -97,7 +97,7 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, | +-+-+--+ | | ... | +--+ -#endif // __USING_SJLJ_EXCEPTIONS__ || __USING_WASM_EXCEPTIONS__ +#endif // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__ +-+ | Beginning of Action Table ttypeIndex == 0 : cleanup | | ... ttypeIndex > 0 : catch | @@ -547,7 +547,7 @@ void set_registers(_Unwind_Exception* unwind_exception, _Unwind_C
[libcxxabi] [libunwind] [WebAssembly] __USING_WASM_EXCEPTIONS__ -> __WASM_EXCEPTIONS__ (PR #92840)
aheejin wrote: The other CI failure doesn't seem to be related. Merging. https://github.com/llvm/llvm-project/pull/92840 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AMDGPU][Clang] Builtin for GLOBAL_LOAD_LDS on GFX940 (PR #92962)
https://github.com/rampitec approved this pull request. https://github.com/llvm/llvm-project/pull/92962 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Implement resolution for CWG1835 (PR #92957)
@@ -618,7 +618,6 @@ namespace cwg141 { // cwg141: 3.1 // FIXME: we issue a useful diagnostic first, then some bogus ones. mizvekov wrote: It looks like this FIXME is fixed as per change below. https://github.com/llvm/llvm-project/pull/92957 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Implement resolution for CWG1835 (PR #92957)
@@ -2893,6 +2893,8 @@ class TreeTransform { CXXScopeSpec SS; SS.Adopt(QualifierLoc); +if (FirstQualifierInScope) + SS.setFoundFirstQualifierInScope(FirstQualifierInScope); mizvekov wrote: It looks like adding 'FirstQualifierInScope' as a property to SS makes it so keeping and passing both around is redundant. https://github.com/llvm/llvm-project/pull/92957 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Implement resolution for CWG1835 (PR #92957)
@@ -55,15 +55,21 @@ namespace PR11856 { template T *end(T*); - class X { }; + struct X { }; + struct Y { +int end; + }; template void Foo2() { T it1; -if (it1->end < it1->end) { -} +if (it1->end < it1->end) { } X *x; -if (x->end < 7) { // expected-error{{no member named 'end' in 'PR11856::X'}} -} +if (x->end < 7) { } // expected-error{{expected '>'}} +// expected-note@-1{{to match this '<'}} +// expected-error@-2{{expected unqualified-id}} mizvekov wrote: This doesn't look expected to me, what is going on? https://github.com/llvm/llvm-project/pull/92957 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Implement resolution for CWG1835 (PR #92957)
@@ -397,22 +397,32 @@ NamedDecl *Sema::FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS) { while (NNS->getPrefix()) NNS = NNS->getPrefix(); - if (NNS->getKind() != NestedNameSpecifier::Identifier) -return nullptr; - - LookupResult Found(*this, NNS->getAsIdentifier(), SourceLocation(), - LookupNestedNameSpecifierName); + // FIXME: This is a rather nasty hack! Ideally we should get the results + // from LookupTemplateName/BuildCXXNestedNameSpecifier. + const IdentifierInfo *II = NNS->getAsIdentifier(); + if (!II) { +if (const auto *DTST = +dyn_cast_if_present( +NNS->getAsType())) + II = DTST->getIdentifier(); +else + return nullptr; + } mizvekov wrote: I am not sure why you think this is a nasty hack, this looks legitimate to me. I think this looks ugly because of the lack of a NNS kind for an Identifier with template arguments, so we abuse a type kind storing a DependentTemplateSpecializationType with no qualifier. https://github.com/llvm/llvm-project/pull/92957 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Implement resolution for CWG1835 (PR #92957)
https://github.com/mizvekov edited https://github.com/llvm/llvm-project/pull/92957 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Implement resolution for CWG1835 (PR #92957)
@@ -720,7 +720,7 @@ Parser::DeclGroupPtrTy Parser::ParseUsingDeclaration( return nullptr; } CXXScopeSpec SS; -if (ParseOptionalCXXScopeSpecifier(SS, /*ParsedType=*/nullptr, +if (ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/nullptr, mizvekov wrote: Land this cleanup separately as well. https://github.com/llvm/llvm-project/pull/92957 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Implement resolution for CWG1835 (PR #92957)
@@ -6891,7 +6891,7 @@ class Sema final : public SemaBase { const TemplateArgumentListInfo *TemplateArgs); ExprResult ActOnMemberAccessExpr(Scope *S, Expr *Base, SourceLocation OpLoc, - tok::TokenKind OpKind, CXXScopeSpec &SS, + bool IsArrow, CXXScopeSpec &SS, mizvekov wrote: You could land this refactoring straight away on an NFC commit, to clean up for the review a bit. https://github.com/llvm/llvm-project/pull/92957 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Implement resolution for CWG1835 (PR #92957)
@@ -47,8 +47,8 @@ template void DerivedT::Inner() { Derived1T::Foo(); Derived2T::Member = 42; - this->Derived1T::Foo(); - this->Derived2T::Member = 42; + this->Derived1T::Foo(); // expected-error{{use 'template' keyword to treat 'Derived1T' as a dependent template name}} + this->Derived2T::Member = 42; // expected-error{{use 'template' keyword to treat 'Derived2T' as a dependent template name}} mizvekov wrote: This is an access control test: ```suggestion this->template Derived1T::Foo(); this->template Derived2T::Member = 42; ``` https://github.com/llvm/llvm-project/pull/92957 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Implement resolution for CWG1835 (PR #92957)
https://github.com/mizvekov commented: I think overall this looks like the right direction to me. https://github.com/llvm/llvm-project/pull/92957 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [polly] [X86] Remove knl/knm specific ISAs supports (PR #92883)
@@ -23,7 +23,7 @@ br i1 %6, label %4, label %5, !llvm.loop !9 } - attributes #0 = { nofree norecurse nosync nounwind uwtable writeonly mustprogress "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+x87,-aes,-avx,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxvnni,-f16c,-fma,-fma4,-gfni,-kl,-pclmul,-sha,-sse,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-vaes,-vpclmulqdq,-widekl,-xop" "tune-cpu"="generic" } + attributes #0 = { nofree norecurse nosync nounwind uwtable writeonly mustprogress "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+x87,-aes,-avx,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxvnni,-f16c,-fma,-fma4,-gfni,-kl,-pclmul,-sha,-sse,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-vaes,-vpclmulqdq,-widekl,-xop" "tune-cpu"="generic" } FreddyLeaf wrote: Here target-cpu is `x86-64`, but the target-features are not strictly equal to `x86-64`'s features https://github.com/llvm/llvm-project/pull/92883 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver] Fix enabling strict alising by default when the environment is MSVC (PR #91689)
https://github.com/MaxEW707 edited https://github.com/llvm/llvm-project/pull/91689 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][C++20] Implement constexpr std::bit_cast for bit-fields (PR #74775)
frederick-vs-ja wrote: This PR should fix #54018. https://github.com/llvm/llvm-project/pull/74775 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add /Zc:__STDC__ flag to clang-cl (PR #68690)
https://github.com/MaxEW707 edited https://github.com/llvm/llvm-project/pull/68690 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add /Zc:__STDC__ flag to clang-cl (PR #68690)
@@ -8065,6 +8069,9 @@ void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType, CmdArgs.push_back("-fno-wchar"); } + if (!types::isCXX(InputType) && Args.hasArg(options::OPT_fms_define_stdc)) + CmdArgs.push_back("-fms-define-stdc"); MaxEW707 wrote: This can be deleted. Since `/Zc:__STDC__` is aliased to `fms-define-stdc` this is already handled in the code above. `AddClangCLArgs` is intended to handle cl.exe options that are not aliased. If you want `-fms-define-stdc` to be usable when in CL mode then you can add `CLOption` to the visibility as I mentioned above in `Options.td`. My preference is to remove this code and just add `CLOption`. See `Option::accept` inside `Option.cpp` for where aliased args are turned into the argument they alias. https://github.com/llvm/llvm-project/pull/68690 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add space after a word token (PR #92741)
owenca wrote: See #92880. https://github.com/llvm/llvm-project/pull/92741 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Correctly annotate C++ alternative operators in C (PR #92880)
https://github.com/owenca closed https://github.com/llvm/llvm-project/pull/92880 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] a6d97de - [clang-format] Correctly annotate C++ alternative operators in C (#92880)
Author: Owen Pan Date: 2024-05-21T19:16:39-07:00 New Revision: a6d97dec899b880f0c3f674d6b3361a70b68ca09 URL: https://github.com/llvm/llvm-project/commit/a6d97dec899b880f0c3f674d6b3361a70b68ca09 DIFF: https://github.com/llvm/llvm-project/commit/a6d97dec899b880f0c3f674d6b3361a70b68ca09.diff LOG: [clang-format] Correctly annotate C++ alternative operators in C (#92880) PR #90161 uncovered a bug that annotates C++ xor as UnaryOperator if followed by a binary operator. This patch fixes that and all other C++ alternative operator keywords when followed by a binary operator in C. Fixes #92688. Added: Modified: clang/lib/Format/UnwrappedLineParser.cpp clang/unittests/Format/FormatTest.cpp clang/unittests/Format/TokenAnnotatorTest.cpp Removed: diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 3dd10f6bd2b31..b6f7567adc140 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -1410,6 +1410,13 @@ void UnwrappedLineParser::readTokenWithJavaScriptASI() { } } +static bool isAltOperator(const FormatToken &Tok) { + return isalpha(Tok.TokenText[0]) && + Tok.isOneOf(tok::ampamp, tok::ampequal, tok::amp, tok::pipe, + tok::tilde, tok::exclaim, tok::exclaimequal, tok::pipepipe, + tok::pipeequal, tok::caret, tok::caretequal); +} + void UnwrappedLineParser::parseStructuralElement( const FormatToken *OpeningBrace, IfStmtKind *IfKind, FormatToken **IfLeftBrace, bool *HasDoWhile, bool *HasLabel) { @@ -1689,9 +1696,15 @@ void UnwrappedLineParser::parseStructuralElement( break; } - const bool InRequiresExpression = - OpeningBrace && OpeningBrace->is(TT_RequiresExpressionLBrace); - do { + for (const bool InRequiresExpression = + OpeningBrace && OpeningBrace->is(TT_RequiresExpressionLBrace); + !eof();) { +if (IsCpp && isAltOperator(*FormatTok)) { + if (auto *Next = Tokens->peekNextToken(/*SkipComment=*/true); + Next && Next->isBinaryOperator()) { +FormatTok->Tok.setKind(tok::identifier); + } +} const FormatToken *Previous = FormatTok->Previous; switch (FormatTok->Tok.getKind()) { case tok::at: @@ -2122,7 +2135,7 @@ void UnwrappedLineParser::parseStructuralElement( nextToken(); break; } - } while (!eof()); + } } bool UnwrappedLineParser::tryToParsePropertyAccessor() { diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 2f0c0f0266774..a9df994189f00 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -17340,12 +17340,14 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeAssignmentOperators) { verifyFormat("int a = 5;"); verifyFormat("a += 42;"); verifyFormat("a or_eq 8;"); + verifyFormat("xor = foo;"); FormatStyle Spaces = getLLVMStyle(); Spaces.SpaceBeforeAssignmentOperators = false; verifyFormat("int a= 5;", Spaces); verifyFormat("a+= 42;", Spaces); verifyFormat("a or_eq 8;", Spaces); + verifyFormat("xor= foo;", Spaces); } TEST_F(FormatTest, ConfigurableSpaceBeforeColon) { diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index 45c1554308c9b..6ea9c4a241dc5 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -3015,6 +3015,60 @@ TEST_F(TokenAnnotatorTest, SwitchExpression) { EXPECT_TOKEN(Tokens[20], tok::arrow, TT_CaseLabelArrow); } +TEST_F(TokenAnnotatorTest, CppAltOperatorKeywords) { + auto Tokens = annotate("a = b and c;"); + ASSERT_EQ(Tokens.size(), 7u); + EXPECT_TOKEN(Tokens[3], tok::ampamp, TT_BinaryOperator); + + Tokens = annotate("a = b and_eq c;"); + ASSERT_EQ(Tokens.size(), 7u); + EXPECT_TOKEN(Tokens[3], tok::ampequal, TT_BinaryOperator); + + Tokens = annotate("a = b bitand c;"); + ASSERT_EQ(Tokens.size(), 7u); + EXPECT_TOKEN(Tokens[3], tok::amp, TT_BinaryOperator); + + Tokens = annotate("a = b bitor c;"); + ASSERT_EQ(Tokens.size(), 7u); + EXPECT_TOKEN(Tokens[3], tok::pipe, TT_BinaryOperator); + + Tokens = annotate("a = b compl c;"); + ASSERT_EQ(Tokens.size(), 7u); + EXPECT_TOKEN(Tokens[3], tok::tilde, TT_UnaryOperator); + + Tokens = annotate("a = b not c;"); + ASSERT_EQ(Tokens.size(), 7u); + EXPECT_TOKEN(Tokens[3], tok::exclaim, TT_UnaryOperator); + + Tokens = annotate("a = b not_eq c;"); + ASSERT_EQ(Tokens.size(), 7u); + EXPECT_TOKEN(Tokens[3], tok::exclaimequal, TT_BinaryOperator); + + Tokens = annotate("a = b or c;"); + ASSERT_EQ(Tokens.size(), 7u); + EXPECT_TOKEN(Tokens[3], tok::pipepipe, TT_BinaryOperator); + + Tokens = annotate("a = b or_eq c;"); + ASSERT_EQ(Tokens.size(), 7u); + EXPECT_TOKEN(Tokens[3], tok::pipeequal, TT_BinaryOperator); + + Tokens = annotate
[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)
@@ -0,0 +1,19 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: not llc -mtriple=x86_64 %s 2>&1 | FileCheck %s --check-prefix=ERR +; RUN: llc -mtriple=x86_64 -mattr=+egpr < %s | FileCheck %s --check-prefix=EGPR +; RUN: llc -mtriple=x86_64 -mattr=+egpr,+inline-asm-use-gpr32 < %s | FileCheck %s --check-prefix=EGPRUSEGPR32 + +; ERR: error: inline assembly requires more registers than available + +define void @constraint_jR_test() nounwind "frame-pointer"="all" { +; EGPR-LABEL: constraint_jR_test: +; EGPR:addq %r16, %rax +; +; EGPRUSEGPR32-LABEL: constraint_jR_test: +; EGPRUSEGPR32:addq %r16, %rax FreddyLeaf wrote: 0bb6794 https://github.com/llvm/llvm-project/pull/92338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)
@@ -0,0 +1,29 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: not llc -mtriple=x86_64 < %s 2>&1 | FileCheck %s --check-prefix=ERR +; RUN: not llc -mtriple=x86_64 -mattr=+egpr < %s 2>&1 | FileCheck %s --check-prefix=ERR +; RUN: llc -mtriple=x86_64 -mattr=+egpr,+inline-asm-use-gpr32 < %s | FileCheck %s --check-prefix=USEGPR32 + +; ERR: error: inline assembly requires more registers than available + +define void @constraint_r_test() nounwind "frame-pointer"="all" { +; USEGPR32-LABEL: constraint_r_test: +; USEGPR32:addq %r16, %rax +entry: + %reg = alloca i64, align 8 + %0 = load i64, ptr %reg, align 8 + call void asm sideeffect "add $0, %rax", "r,~{rax},~{rbx},~{rcx},~{rdx},~{rdi},~{rsi},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{dirflag},~{fpsr},~{flags}"(i64 %0) + ret void +} + +define void @constraint_jR_test() nounwind "frame-pointer"="all" { +; EGPR-LABEL: constraint_jR_test: +; EGPR:addq %r16, %rax +; +; EGPRUSEGPR32-LABEL: constraint_jR_test: +; EGPRUSEGPR32:addq %r16, %rax FreddyLeaf wrote: 0bb6794 https://github.com/llvm/llvm-project/pull/92338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)
https://github.com/FreddyLeaf updated https://github.com/llvm/llvm-project/pull/92338 >From 41fbc18c7a4a26b11bc4b772bbe2e384ad9d9dbc Mon Sep 17 00:00:00 2001 From: Freddy Ye Date: Fri, 10 May 2024 16:29:55 +0800 Subject: [PATCH 1/7] [X86] Support EGPR for inline assembly. "jR": explictly enables EGPR "r": enables/disables EGPR w/wo -mapx-inline-asm-use-gpr32 -mapx-inline-asm-use-gpr32 will also define a new Macro: __APX_INLINE_ASM_USE_GPR32__ --- clang/include/clang/Driver/Options.td | 2 + clang/lib/Basic/Targets/X86.cpp | 26 + clang/lib/Basic/Targets/X86.h | 1 + clang/lib/Driver/ToolChains/Arch/X86.cpp | 2 + .../Driver/x86-apx-inline-asm-use-gpr32.cpp | 3 + clang/test/Preprocessor/x86_target_features.c | 3 + llvm/lib/Target/X86/X86.td| 3 + llvm/lib/Target/X86/X86ISelLowering.cpp | 57 +-- .../CodeGen/X86/inline-asm-jR-constraint.ll | 19 +++ .../CodeGen/X86/inline-asm-r-constraint.ll| 16 ++ 10 files changed, 127 insertions(+), 5 deletions(-) create mode 100644 clang/test/Driver/x86-apx-inline-asm-use-gpr32.cpp create mode 100644 llvm/test/CodeGen/X86/inline-asm-jR-constraint.ll create mode 100644 llvm/test/CodeGen/X86/inline-asm-r-constraint.ll diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 73a2518480e9b..20a7c482bbf06 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -6281,6 +6281,8 @@ def mno_apx_features_EQ : CommaJoined<["-"], "mno-apx-features=">, Group, Alias, AliasArgs<["egpr","push2pop2","ppx", "ndd"]>; def mno_apxf : Flag<["-"], "mno-apxf">, Alias, AliasArgs<["egpr","push2pop2","ppx","ndd"]>; +def mapx_inline_asm_use_gpr32 : Flag<["-"], "mapx-inline-asm-use-gpr32">, Group, +HelpText<"Enable use of GPR32 in inline assembly for APX">; } // let Flags = [TargetSpecific] // VE feature flags diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp index 67e2126cf766b..9e61b6e6d6441 100644 --- a/clang/lib/Basic/Targets/X86.cpp +++ b/clang/lib/Basic/Targets/X86.cpp @@ -450,6 +450,8 @@ bool X86TargetInfo::handleTargetFeatures(std::vector &Features, HasFullBFloat16 = true; } else if (Feature == "+egpr") { HasEGPR = true; +} else if (Feature == "+inline-asm-use-gpr32") { + HasInlineAsmUseGPR32 = true; } else if (Feature == "+push2pop2") { HasPush2Pop2 = true; } else if (Feature == "+ppx") { @@ -974,6 +976,8 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts, // Condition here is aligned with the feature set of mapxf in Options.td if (HasEGPR && HasPush2Pop2 && HasPPX && HasNDD) Builder.defineMacro("__APX_F__"); + if (HasInlineAsmUseGPR32) +Builder.defineMacro("__APX_INLINE_ASM_USE_GPR32__"); // Each case falls through to the previous one here. switch (SSELevel) { @@ -1493,6 +1497,15 @@ bool X86TargetInfo::validateAsmConstraint( case 'C': // SSE floating point constant. case 'G': // x87 floating point constant. return true; + case 'j': +Name++; +switch (*Name) { +default: + return false; +case 'R': + Info.setAllowsRegister(); + return true; +} case '@': // CC condition changes. if (auto Len = matchAsmCCConstraint(Name)) { @@ -1764,6 +1777,19 @@ std::string X86TargetInfo::convertConstraint(const char *&Constraint) const { // to the next constraint. return std::string("^") + std::string(Constraint++, 2); } + case 'j': +switch (Constraint[1]) { +default: + // Break from inner switch and fall through (copy single char), + // continue parsing after copying the current constraint into + // the return string. + break; +case 'R': + // "^" hints llvm that this is a 2 letter constraint. + // "Constraint++" is used to promote the string iterator + // to the next constraint. + return std::string("^") + std::string(Constraint++, 2); +} [[fallthrough]]; default: return std::string(1, *Constraint); diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h index c14e4d5f433d8..69c68ee80f3ba 100644 --- a/clang/lib/Basic/Targets/X86.h +++ b/clang/lib/Basic/Targets/X86.h @@ -174,6 +174,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo { bool HasNDD = false; bool HasCCMP = false; bool HasCF = false; + bool HasInlineAsmUseGPR32 = false; protected: llvm::X86::CPUKind CPU = llvm::X86::CK_None; diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp b/clang/lib/Driver/ToolChains/Arch/X86.cpp index 53e26a9f8e229..085ff4824a9b0 100644 --- a/clang/lib/Driver/ToolChains/Arch/X86.cpp +++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp @@ -309,4 +309,6 @@ void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple, Features.push_back("+prefer-no-gathe
[clang] [clang] Distinguish unresolved templates in UnresolvedLookupExpr (PR #89019)
zyn0217 wrote: > It seems this change cause https://godbolt.org/z/311nb6xYe to fail. Could you > please take look? > Also: > https://godbolt.org/z/bYs7Y9v11 I don't see any justification that these examples should compile: the first example is a typical one handled by #90152 (from the release note): ```rst - Clang now looks up members of the current instantiation in the template definition context if the current instantiation has no dependent base classes. template struct A { int f() { return this->x; // error: no member named 'x' in 'A' } }; ``` and the second one would also be rejected by GCC once the inner class `b` gets instantiated. This earlier diagnostic is probably also triggered by #90152, but I'm not sure. @sdkrystian, is this behavior intended and from your recent patches? https://github.com/llvm/llvm-project/pull/89019 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add /Zc:__STDC__ flag to clang-cl (PR #68690)
https://github.com/MaxEW707 edited https://github.com/llvm/llvm-project/pull/68690 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [IR] Avoid creating icmp/fcmp constant expressions (PR #92885)
https://github.com/nhaehnle approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/92885 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [IR] Avoid creating icmp/fcmp constant expressions (PR #92885)
@@ -84,28 +84,30 @@ long double ld = -1.0L; // CHECK-LE-LABEL: define dso_local void @_Z12test_signbitv( // CHECK-LE-SAME: ) #[[ATTR0:[0-9]+]] { // CHECK-LE-NEXT: entry: -// CHECK-LE-NEXT:[[FROMBOOL:%.*]] = zext i1 icmp slt (i64 trunc (i128 bitcast (ppc_fp128 0xM3FF0 to i128) to i64), i64 0) to i8 +// CHECK-LE-NEXT:[[TMP0:%.*]] = icmp slt i64 trunc (i128 bitcast (ppc_fp128 0xM3FF0 to i128) to i64), 0 +// CHECK-LE-NEXT:[[FROMBOOL:%.*]] = zext i1 [[TMP0]] to i8 // CHECK-LE-NEXT:store i8 [[FROMBOOL]], ptr @b, align 1 -// CHECK-LE-NEXT:[[TMP0:%.*]] = load ppc_fp128, ptr @ld, align 16 -// CHECK-LE-NEXT:[[TMP1:%.*]] = bitcast ppc_fp128 [[TMP0]] to i128 -// CHECK-LE-NEXT:[[TMP2:%.*]] = trunc i128 [[TMP1]] to i64 -// CHECK-LE-NEXT:[[TMP3:%.*]] = icmp slt i64 [[TMP2]], 0 -// CHECK-LE-NEXT:[[FROMBOOL1:%.*]] = zext i1 [[TMP3]] to i8 +// CHECK-LE-NEXT:[[TMP1:%.*]] = load ppc_fp128, ptr @ld, align 16 nhaehnle wrote: That diff is awful. We should make `update_cc_test_checks.py` use `collect_original_check_lines` :) https://github.com/llvm/llvm-project/pull/92885 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [IR] Avoid creating icmp/fcmp constant expressions (PR #92885)
https://github.com/nhaehnle edited https://github.com/llvm/llvm-project/pull/92885 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add /Zc:__STDC__ flag to clang-cl (PR #68690)
@@ -2934,6 +2934,10 @@ def fms_compatibility : Flag<["-"], "fms-compatibility">, Group, Visibility<[ClangOption, CC1Option, CLOption]>, HelpText<"Enable full Microsoft Visual C++ compatibility">, MarshallingInfoFlag>; +def fms_define_stdc : Flag<["-"], "fms-define-stdc">, Group, + Visibility<[ClangOption, CC1Option]>, MaxEW707 wrote: ```suggestion Visibility<[ClangOption, CC1Option, CLOption]>, ``` In my opinion similar to `-fms-compatibility` and `-fms-extensions` we should allow users to do `-fms-define-stdc` when in the cl driver mode. https://github.com/llvm/llvm-project/pull/68690 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] [lldb] [llvm] [mlir] [BOLT][BAT] Add entries for deleted basic blocks (PR #91906)
https://github.com/rafaelauler approved this pull request. Could you elaborate a bit better on why do we need a deleted block to be present in the table? My memory fails me, aren't we using the translation table just to map samples collected on the bolted binary? Where do the deleted blocks become a problem? Other than the motivation, the implementation itself looks good to me. https://github.com/llvm/llvm-project/pull/91906 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clang] NFCI: use TemplateArgumentLoc for NTTP DefaultArgument (PR #92852)
https://github.com/mizvekov edited https://github.com/llvm/llvm-project/pull/92852 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Distinguish unresolved templates in UnresolvedLookupExpr (PR #89019)
jyu2-git wrote: Hi @zyn0217, I am not sure. But if I revert your patch, two tests compiles. https://github.com/llvm/llvm-project/pull/89019 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-repl] Extend the C support. (PR #89804)
jasonmolenda wrote: I reverted in ``` commit dfdf1c5fe45a82b9c578306f3d7627fd251d63f8 Author: Jason Molenda Date: Tue May 21 18:00:11 2024 -0700 Revert "[clang-repl] Extend the C support. (#89804)" This reverts commit 253c28fa829cee0104c2fc59ed1a958980b5138c. ``` to unblock the CI bots until Vassil has a chance to look at it. https://github.com/llvm/llvm-project/pull/89804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] dfdf1c5 - Revert "[clang-repl] Extend the C support. (#89804)"
Author: Jason Molenda Date: 2024-05-21T18:04:38-07:00 New Revision: dfdf1c5fe45a82b9c578306f3d7627fd251d63f8 URL: https://github.com/llvm/llvm-project/commit/dfdf1c5fe45a82b9c578306f3d7627fd251d63f8 DIFF: https://github.com/llvm/llvm-project/commit/dfdf1c5fe45a82b9c578306f3d7627fd251d63f8.diff LOG: Revert "[clang-repl] Extend the C support. (#89804)" This reverts commit 253c28fa829cee0104c2fc59ed1a958980b5138c. This commit is causing failures on the lldb CI bots, e.g. https://ci.swift.org/view/all/job/llvm.org/view/LLDB/job/as-lldb-cmake/4307/ On my local macOS desktop build, ``` bin/lldb-dotest -p TestImportBuiltinFileID.py Assertion failed: (D->getLexicalDeclContext() == this && "Decl inserted into wrong lexical context"), function addHiddenDecl, file DeclBase.cpp, line 1692. 6 libsystem_c.dylib0x000185f0b8d0 abort + 128 7 libsystem_c.dylib0x000185f0abc8 err + 0 8 liblldb.19.0.0git.dylib 0x0001311e5800 clang::DeclContext::addHiddenDecl(clang::Decl*) + 120 9 liblldb.19.0.0git.dylib 0x0001311e5978 clang::DeclContext::addDecl(clang::Decl*) + 32 10 liblldb.19.0.0git.dylib 0x00012f617b48 clang::Sema::ActOnStartTopLevelStmtDecl(clang::Scope*) + 64 11 liblldb.19.0.0git.dylib 0x00012eaf76c8 clang::Parser::ParseTopLevelStmtDecl() + 208 12 liblldb.19.0.0git.dylib 0x00012ec051fc clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) + 3412 13 liblldb.19.0.0git.dylib 0x00012ec03274 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) + 2020 14 liblldb.19.0.0git.dylib 0x00012eaca860 clang::ParseAST(clang::Sema&, bool, bool) + 604 15 liblldb.19.0.0git.dylib 0x00012e8554c0 clang::ASTFrontendAction::ExecuteAction() + 308 16 liblldb.19.0.0git.dylib 0x00012e854c78 clang::FrontendAction::Execute() + 124 17 liblldb.19.0.0git.dylib 0x00012e76dcfc clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 984 18 liblldb.19.0.0git.dylib 0x00012e784500 compileModuleImpl(clang::CompilerInstance&, clang::SourceLocation, llvm::StringRef, clang::FrontendInputFile, llvm::StringRef, llvm::StringRef, llvm::function_ref, llvm::function_ref)::$_1::operator()() const + 52 ``` Reverting until Vassil has a chance to look int oit. Added: Modified: clang/lib/Interpreter/IncrementalParser.cpp clang/lib/Sema/SemaDecl.cpp Removed: clang/test/Interpreter/execute.c diff --git a/clang/lib/Interpreter/IncrementalParser.cpp b/clang/lib/Interpreter/IncrementalParser.cpp index 5bc8385d874a1..ef90fe9e6f545 100644 --- a/clang/lib/Interpreter/IncrementalParser.cpp +++ b/clang/lib/Interpreter/IncrementalParser.cpp @@ -387,7 +387,8 @@ std::unique_ptr IncrementalParser::GenModule() { void IncrementalParser::CleanUpPTU(PartialTranslationUnit &PTU) { TranslationUnitDecl *MostRecentTU = PTU.TUPart; - if (StoredDeclsMap *Map = MostRecentTU->getPrimaryContext()->getLookupPtr()) { + TranslationUnitDecl *FirstTU = MostRecentTU->getFirstDecl(); + if (StoredDeclsMap *Map = FirstTU->getPrimaryContext()->getLookupPtr()) { for (auto &&[Key, List] : *Map) { DeclContextLookupResult R = List.getLookupResult(); std::vector NamedDeclsToRemove; @@ -406,16 +407,6 @@ void IncrementalParser::CleanUpPTU(PartialTranslationUnit &PTU) { } } } - - // FIXME: We should de-allocate MostRecentTU - for (Decl *D : MostRecentTU->decls()) { -auto *ND = dyn_cast(D); -if (!ND) - continue; -// Check if we need to clean up the IdResolver chain. -if (ND->getDeclName().getFETokenInfo()) - getCI()->getSema().IdResolver.RemoveDecl(ND); - } } llvm::StringRef IncrementalParser::GetMangledName(GlobalDecl GD) const { diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 6e60ec761b253..8049ddfed872c 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -2282,13 +2282,9 @@ void Sema::ActOnPopScope(SourceLocation Loc, Scope *S) { if (LabelDecl *LD = dyn_cast(D)) CheckPoppedLabel(LD, *this, addDiag); -// Partial translation units that are created in incremental processing must -// not clean up the IdResolver because PTUs should take into account the -// declarations that came from previous PTUs. -if (!PP.isIncrementalProcessingEnabled()) - IdResolver.RemoveDecl(D); - -// Warn on it if we are shadowing a declaration. +// Remove this name from our lexical scope, and warn on it if we haven't +// already. +IdResolver.RemoveDecl(D); auto ShadowI = ShadowingDecls.find(D); if (ShadowI != ShadowingDecls.end()) { if (const auto *FD = dyn_cast(ShadowI->second)) { diff --git a/clang/test/Interpreter/execute.c b/clang/test/Interpreter/execute.c deleted file mode 100644 index 44a3a32c93011..0 --- a/cl
[clang] [clang] Distinguish unresolved templates in UnresolvedLookupExpr (PR #89019)
zyn0217 wrote: @jyu2-git Are you sure this is the patch you’re looking for? The diagnostic there is completely unrelated and I think the right patch is https://github.com/llvm/llvm-project/pull/90152. https://github.com/llvm/llvm-project/pull/89019 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
@@ -86,6 +86,23 @@ struct A { }; } +namespace cwg1458 { // cwg1458: 3.1 +#if __cplusplus >= 201103L +struct A; + +void f() { + constexpr A* a = nullptr; + constexpr int p = &*a; + // expected-error@-1 {{cannot initialize a variable of type 'const int' with an rvalue of type 'A *'}} + constexpr A *p2 = &*a; Endilll wrote: We are documenting that our constant evaluator doesn't consider this UB. https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
@@ -451,6 +463,25 @@ static_assert(!__is_nothrow_constructible(D4, int), ""); #endif } // namespace cwg1350 +namespace cwg1352 { // cwg1352: 3.0 +struct A { +#if __cplusplus >= 201103L + int a = sizeof(A); Endilll wrote: > It also mentions in the body of member function Yeah, that is worth adding. I'll prepare a PR. https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
@@ -451,6 +463,25 @@ static_assert(!__is_nothrow_constructible(D4, int), ""); #endif } // namespace cwg1350 +namespace cwg1352 { // cwg1352: 3.0 +struct A { +#if __cplusplus >= 201103L + int a = sizeof(A); Endilll wrote: It's not going to fail for static member initializers because of (I suspect) subsequent changes that were made to the wording: http://eel.is/c++draft/class.mem.general#8.5 https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Distinguish unresolved templates in UnresolvedLookupExpr (PR #89019)
jyu2-git wrote: Hi @zyn0217. It seems this change cause https://godbolt.org/z/311nb6xYe to fail. Could you please take look? Thanks. https://github.com/llvm/llvm-project/pull/89019 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add /Zc:__STDC__ flag to clang-cl (PR #68690)
@@ -291,6 +291,7 @@ LANGOPT(HIPStdParInterposeAlloc, 1, 0, "Replace allocations / deallocations with LANGOPT(OpenACC , 1, 0, "OpenACC Enabled") +LANGOPT(MSVCEnableStdcMacro , 1, 0, "Define __STDC__ with '-fms-compatability'") MaxEW707 wrote: ```suggestion LANGOPT(MSVCEnableStdcMacro , 1, 0, "Define __STDC__ with '-fms-compatibility'") ``` https://github.com/llvm/llvm-project/pull/68690 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][driver] Support `-x` for all languages in CL mode (PR #89772)
MaxEW707 wrote: @huangqinjin The error is "fatal error C1060: compiler is out of heap space" which is unrelated. I haven't figured out how to resend the event to trigger a build retry without pushing an empty commit. I usually just do `git commit -m "rebuild" --allow-empty` and then push that up to trigger a build retry. Give that shot to get CI green :). https://github.com/llvm/llvm-project/pull/89772 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-repl] Extend the C support. (PR #89804)
mysterymath wrote: We've started seeing crashes in Fuchsia's Mac tooclhain's LLDB test suite: https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-mac-x64/b8747305520511321169/overview This is the only PR in the blamelist that looks plausible, but there isn't a clear connection to me (or a clear reason why it would be Mac-only). Does anything jump out, or am I barking up the wrong tree? Stack trace follows: ``` Assertion failed: (D->getLexicalDeclContext() == this && "Decl inserted into wrong lexical context"), function addHiddenDecl, file DeclBase.cpp, line 1692. PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. Stack dump: 0. /Volumes/Work/s/w/ir/cache/macos_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSZone.h:32:1 : at annotation token #0 0x000111461238 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/Volumes/Work/s/w/ir/x/w/llvm_build/lib/liblldb.19.0.0git.dylib+0x8ab238) #1 0x00011145f179 llvm::sys::RunSignalHandlers() (/Volumes/Work/s/w/ir/x/w/llvm_build/lib/liblldb.19.0.0git.dylib+0x8a9179) #2 0x000111461900 SignalHandler(int) (/Volumes/Work/s/w/ir/x/w/llvm_build/lib/liblldb.19.0.0git.dylib+0x8ab900) #3 0x7ff807c915ed (/usr/lib/system/libsystem_platform.dylib+0x7ff8004255ed) #4 0x700014de4c40 #5 0x7ff807b8ab45 (/usr/lib/system/libsystem_c.dylib+0x7ff80031eb45) #6 0x7ff807b89e5e (/usr/lib/system/libsystem_c.dylib+0x7ff80031de5e) #7 0x000114a4ae54 clang::DeclContext::addHiddenDecl(clang::Decl*) (/Volumes/Work/s/w/ir/x/w/llvm_build/lib/liblldb.19.0.0git.dylib+0x3e94e54) #8 0x000114a4aeae clang::DeclContext::addDecl(clang::Decl*) (/Volumes/Work/s/w/ir/x/w/llvm_build/lib/liblldb.19.0.0git.dylib+0x3e94eae) #9 0x000113edeb81 clang::Sema::ActOnStartTopLevelStmtDecl(clang::Scope*) (/Volumes/Work/s/w/ir/x/w/llvm_build/lib/liblldb.19.0.0git.dylib+0x3328b81) #10 0x000113a31ccf clang::Parser::ParseTopLevelStmtDecl() (/Volumes/Work/s/w/ir/x/w/llvm_build/lib/liblldb.19.0.0git.dylib+0x2e7bccf) #11 0x000113a6d231 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/Volumes/Work/s/w/ir/x/w/llvm_build/lib/liblldb.19.0.0git.dylib+0x2eb7231) #12 0x000113a45202 clang::Parser::ParseLinkage(clang::ParsingDeclSpec&, clang::DeclaratorContext) (/Volumes/Work/s/w/ir/x/w/llvm_build/lib/liblldb.19.0.0git.dylib+0x2e8f202) #13 0x000113a6f037 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/Volumes/Work/s/w/ir/x/w/llvm_build/lib/liblldb.19.0.0git.dylib+0x2eb9037) #14 0x000113a6e8a5 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/Volumes/Work/s/w/ir/x/w/llvm_build/lib/liblldb.19.0.0git.dylib+0x2eb88a5) #15 0x000113a6cfd4 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/Volumes/Work/s/w/ir/x/w/llvm_build/lib/liblldb.19.0.0git.dylib+0x2eb6fd4) #16 0x000113a6ad37 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/Volumes/Work/s/w/ir/x/w/llvm_build/lib/liblldb.19.0.0git.dylib+0x2eb4d37) #17 0x000113a6a501 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/Volumes/Work/s/w/ir/x/w/llvm_build/lib/liblldb.19.0.0git.dylib+0x2eb4501) #18 0x000113956acb clang::ParseAST(clang::Sema&, bool, bool) (/Volumes/Work/s/w/ir/x/w/llvm_build/lib/liblldb.19.0.0git.dylib+0x2da0acb) #19 0x000113721a53 clang::FrontendAction::Execute() (/Volumes/Work/s/w/ir/x/w/llvm_build/lib/liblldb.19.0.0git.dylib+0x2b6ba53) #20 0x00011369068d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/Volumes/Work/s/w/ir/x/w/llvm_build/lib/liblldb.19.0.0git.dylib+0x2ada68d) #21 0x00011369cd24 void llvm::function_ref::callback_fn, llvm::function_ref)::$_1>(long) (/Volumes/Work/s/w/ir/x/w/llvm_build/lib/liblldb.19.0.0git.dylib+0x2ae6d24) #22 0x00011145c0fe llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/Volumes/Work/s/w/ir/x/w/llvm_build/lib/liblldb.19.0.0git.dylib+0x8a60fe) #23 0x00011145c220 RunSafelyOnThread_Dispatch(void*) (/Volumes/Work/s/w/ir/x/w/llvm_build/lib/liblldb.19.0.0git.dylib+0x8a6220) #24 0x00011145c23f void* llvm::thread::ThreadProxy>(void*) (/Volumes/Work/s/w/ir/x/w/llvm_build/lib/liblldb.19.0.0git.dylib+0x8a623f) #25 0x7ff807c641d3 (/usr/lib/system/libsystem_pthread.dylib+0x7ff8003f81d3) #26 0x7ff807c5fbd3 (/usr/lib/system/libsystem_pthread.dylib+0x7ff8003f3bd3) ``` https://github.com/llvm/llvm-project/pull/89804 ___ cfe-commits mailing
[clang] [clang-tools-extra] [clang] NFCI: use TemplateArgumentLoc for NTTP DefaultArgument (PR #92852)
https://github.com/mizvekov updated https://github.com/llvm/llvm-project/pull/92852 >From 229cb63b95bb3b0db8d73947a40dede945b8b378 Mon Sep 17 00:00:00 2001 From: Matheus Izvekov Date: Mon, 20 May 2024 00:39:55 -0300 Subject: [PATCH] [clang] NFCI: use TemplateArgumentLoc for NTTP DefaultArgument This is an enabler for a future patch. --- clang-tools-extra/clangd/Hover.cpp| 3 +- clang/include/clang/AST/ASTNodeTraverser.h| 6 +-- clang/include/clang/AST/DeclTemplate.h| 11 +++-- clang/include/clang/AST/RecursiveASTVisitor.h | 2 +- clang/lib/AST/ASTContext.cpp | 6 ++- clang/lib/AST/ASTDiagnostic.cpp | 2 +- clang/lib/AST/ASTImporter.cpp | 5 +- clang/lib/AST/DeclPrinter.cpp | 4 +- clang/lib/AST/DeclTemplate.cpp| 15 -- clang/lib/AST/JSONNodeDumper.cpp | 2 +- clang/lib/AST/ODRDiagsEmitter.cpp | 7 ++- clang/lib/AST/ODRHash.cpp | 2 +- clang/lib/AST/TypePrinter.cpp | 5 +- clang/lib/ExtractAPI/DeclarationFragments.cpp | 5 +- clang/lib/Index/IndexDecl.cpp | 3 +- clang/lib/Sema/HLSLExternalSemaSource.cpp | 10 ++-- clang/lib/Sema/SemaTemplate.cpp | 46 +-- clang/lib/Sema/SemaTemplateDeduction.cpp | 10 ++-- .../lib/Sema/SemaTemplateInstantiateDecl.cpp | 7 +-- clang/lib/Serialization/ASTReaderDecl.cpp | 3 +- clang/lib/Serialization/ASTWriterDecl.cpp | 2 +- clang/test/AST/ast-dump-decl.cpp | 4 +- clang/test/SemaTemplate/deduction-guide.cpp | 6 +-- clang/tools/libclang/CIndex.cpp | 5 +- clang/unittests/AST/ASTImporterTest.cpp | 2 +- 25 files changed, 99 insertions(+), 74 deletions(-) diff --git a/clang-tools-extra/clangd/Hover.cpp b/clang-tools-extra/clangd/Hover.cpp index 2ec0994e846e9..de103e011c708 100644 --- a/clang-tools-extra/clangd/Hover.cpp +++ b/clang-tools-extra/clangd/Hover.cpp @@ -262,7 +262,8 @@ fetchTemplateParameters(const TemplateParameterList *Params, if (NTTP->hasDefaultArgument()) { P.Default.emplace(); llvm::raw_string_ostream Out(*P.Default); -NTTP->getDefaultArgument()->printPretty(Out, nullptr, PP); +NTTP->getDefaultArgument().getArgument().print(PP, Out, + /*IncludeType=*/false); } } else if (const auto *TTPD = dyn_cast(Param)) { P.Type = printType(TTPD, PP); diff --git a/clang/include/clang/AST/ASTNodeTraverser.h b/clang/include/clang/AST/ASTNodeTraverser.h index 98db1cb578990..616f92691ec32 100644 --- a/clang/include/clang/AST/ASTNodeTraverser.h +++ b/clang/include/clang/AST/ASTNodeTraverser.h @@ -704,9 +704,9 @@ class ASTNodeTraverser if (const auto *E = D->getPlaceholderTypeConstraint()) Visit(E); if (D->hasDefaultArgument()) - Visit(D->getDefaultArgument(), SourceRange(), -D->getDefaultArgStorage().getInheritedFrom(), -D->defaultArgumentWasInherited() ? "inherited from" : "previous"); + dumpTemplateArgumentLoc( + D->getDefaultArgument(), D->getDefaultArgStorage().getInheritedFrom(), + D->defaultArgumentWasInherited() ? "inherited from" : "previous"); } void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D) { diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index 07b08b5ed43ca..5b6a6b40b28ef 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -1360,7 +1360,8 @@ class NonTypeTemplateParmDecl final /// The default template argument, if any, and whether or not /// it was inherited. - using DefArgStorage = DefaultArgStorage; + using DefArgStorage = + DefaultArgStorage; DefArgStorage DefaultArgument; // FIXME: Collapse this into TemplateParamPosition; or, just move depth/index @@ -1430,7 +1431,10 @@ class NonTypeTemplateParmDecl final bool hasDefaultArgument() const { return DefaultArgument.isSet(); } /// Retrieve the default argument, if any. - Expr *getDefaultArgument() const { return DefaultArgument.get(); } + const TemplateArgumentLoc &getDefaultArgument() const { +static const TemplateArgumentLoc NoneLoc; +return DefaultArgument.isSet() ? *DefaultArgument.get() : NoneLoc; + } /// Retrieve the location of the default argument, if any. SourceLocation getDefaultArgumentLoc() const; @@ -1444,7 +1448,8 @@ class NonTypeTemplateParmDecl final /// Set the default argument for this template parameter, and /// whether that default argument was inherited from another /// declaration. - void setDefaultArgument(Expr *DefArg) { DefaultArgument.set(DefArg); } + void setDefaultArgument(const ASTContext &C, + const TemplateArgumentLoc &DefArg); void setInheritedDefaultArgument(const ASTContext &C,
[clang] [clang-tools-extra] [clang] NFCI: use TemplateArgumentLoc for NTTP DefaultArgument (PR #92852)
https://github.com/mizvekov updated https://github.com/llvm/llvm-project/pull/92852 >From 984ac614f6d6e3196961690fa957df6a03f37782 Mon Sep 17 00:00:00 2001 From: Matheus Izvekov Date: Mon, 20 May 2024 00:39:55 -0300 Subject: [PATCH] [clang] NFCI: use TemplateArgumentLoc for NTTP DefaultArgument This is an enabler for a future patch. --- clang-tools-extra/clangd/Hover.cpp| 3 +- clang/include/clang/AST/ASTNodeTraverser.h| 6 +-- clang/include/clang/AST/DeclTemplate.h| 11 +++-- clang/include/clang/AST/RecursiveASTVisitor.h | 2 +- clang/lib/AST/ASTContext.cpp | 6 ++- clang/lib/AST/ASTDiagnostic.cpp | 2 +- clang/lib/AST/ASTImporter.cpp | 5 +- clang/lib/AST/DeclPrinter.cpp | 4 +- clang/lib/AST/DeclTemplate.cpp| 15 -- clang/lib/AST/JSONNodeDumper.cpp | 2 +- clang/lib/AST/ODRDiagsEmitter.cpp | 7 ++- clang/lib/AST/ODRHash.cpp | 2 +- clang/lib/AST/TypePrinter.cpp | 5 +- clang/lib/ExtractAPI/DeclarationFragments.cpp | 5 +- clang/lib/Index/IndexDecl.cpp | 3 +- clang/lib/Sema/HLSLExternalSemaSource.cpp | 10 ++-- clang/lib/Sema/SemaTemplate.cpp | 46 +-- clang/lib/Sema/SemaTemplateDeduction.cpp | 10 ++-- .../lib/Sema/SemaTemplateInstantiateDecl.cpp | 7 +-- clang/lib/Serialization/ASTReaderDecl.cpp | 3 +- clang/lib/Serialization/ASTWriterDecl.cpp | 2 +- clang/test/AST/ast-dump-decl.cpp | 4 +- clang/test/SemaTemplate/deduction-guide.cpp | 6 +-- clang/tools/libclang/CIndex.cpp | 5 +- clang/unittests/AST/ASTImporterTest.cpp | 2 +- 25 files changed, 99 insertions(+), 74 deletions(-) diff --git a/clang-tools-extra/clangd/Hover.cpp b/clang-tools-extra/clangd/Hover.cpp index 2ec0994e846e9..de103e011c708 100644 --- a/clang-tools-extra/clangd/Hover.cpp +++ b/clang-tools-extra/clangd/Hover.cpp @@ -262,7 +262,8 @@ fetchTemplateParameters(const TemplateParameterList *Params, if (NTTP->hasDefaultArgument()) { P.Default.emplace(); llvm::raw_string_ostream Out(*P.Default); -NTTP->getDefaultArgument()->printPretty(Out, nullptr, PP); +NTTP->getDefaultArgument().getArgument().print(PP, Out, + /*IncludeType=*/false); } } else if (const auto *TTPD = dyn_cast(Param)) { P.Type = printType(TTPD, PP); diff --git a/clang/include/clang/AST/ASTNodeTraverser.h b/clang/include/clang/AST/ASTNodeTraverser.h index 98db1cb578990..616f92691ec32 100644 --- a/clang/include/clang/AST/ASTNodeTraverser.h +++ b/clang/include/clang/AST/ASTNodeTraverser.h @@ -704,9 +704,9 @@ class ASTNodeTraverser if (const auto *E = D->getPlaceholderTypeConstraint()) Visit(E); if (D->hasDefaultArgument()) - Visit(D->getDefaultArgument(), SourceRange(), -D->getDefaultArgStorage().getInheritedFrom(), -D->defaultArgumentWasInherited() ? "inherited from" : "previous"); + dumpTemplateArgumentLoc( + D->getDefaultArgument(), D->getDefaultArgStorage().getInheritedFrom(), + D->defaultArgumentWasInherited() ? "inherited from" : "previous"); } void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D) { diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index 07b08b5ed43ca..5b6a6b40b28ef 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -1360,7 +1360,8 @@ class NonTypeTemplateParmDecl final /// The default template argument, if any, and whether or not /// it was inherited. - using DefArgStorage = DefaultArgStorage; + using DefArgStorage = + DefaultArgStorage; DefArgStorage DefaultArgument; // FIXME: Collapse this into TemplateParamPosition; or, just move depth/index @@ -1430,7 +1431,10 @@ class NonTypeTemplateParmDecl final bool hasDefaultArgument() const { return DefaultArgument.isSet(); } /// Retrieve the default argument, if any. - Expr *getDefaultArgument() const { return DefaultArgument.get(); } + const TemplateArgumentLoc &getDefaultArgument() const { +static const TemplateArgumentLoc NoneLoc; +return DefaultArgument.isSet() ? *DefaultArgument.get() : NoneLoc; + } /// Retrieve the location of the default argument, if any. SourceLocation getDefaultArgumentLoc() const; @@ -1444,7 +1448,8 @@ class NonTypeTemplateParmDecl final /// Set the default argument for this template parameter, and /// whether that default argument was inherited from another /// declaration. - void setDefaultArgument(Expr *DefArg) { DefaultArgument.set(DefArg); } + void setDefaultArgument(const ASTContext &C, + const TemplateArgumentLoc &DefArg); void setInheritedDefaultArgument(const ASTContext &C,
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
@@ -451,6 +463,25 @@ static_assert(!__is_nothrow_constructible(D4, int), ""); #endif } // namespace cwg1350 +namespace cwg1352 { // cwg1352: 3.0 +struct A { +#if __cplusplus >= 201103L + int a = sizeof(A); shafik wrote: It also mentions in the body of member function https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
@@ -86,6 +86,23 @@ struct A { }; } +namespace cwg1458 { // cwg1458: 3.1 +#if __cplusplus >= 201103L +struct A; + +void f() { + constexpr A* a = nullptr; + constexpr int p = &*a; + // expected-error@-1 {{cannot initialize a variable of type 'const int' with an rvalue of type 'A *'}} + constexpr A *p2 = &*a; shafik wrote: So the DR says it is "unspecified" so are we documenting here that this will always be the behavior? Maybe worth a comment? https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
@@ -451,6 +463,25 @@ static_assert(!__is_nothrow_constructible(D4, int), ""); #endif } // namespace cwg1350 +namespace cwg1352 { // cwg1352: 3.0 +struct A { +#if __cplusplus >= 201103L + int a = sizeof(A); shafik wrote: I think it might be worth it to see that this fails for a `static member` since the DR specifically says `non-static` so we should cover both. https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
https://github.com/shafik edited https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
https://github.com/shafik commented: LGTM w/ a few nitpicks https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #92855)
https://github.com/mizvekov edited https://github.com/llvm/llvm-project/pull/92855 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clang] NFCI: use TemplateArgumentLoc for type-param DefaultArgument (PR #92854)
https://github.com/mizvekov closed https://github.com/llvm/llvm-project/pull/92854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] e42b799 - [clang] NFCI: use TemplateArgumentLoc for type-param DefaultArgument (#92854)
Author: Matheus Izvekov Date: 2024-05-21T20:27:50-03:00 New Revision: e42b799bb28815431f2c5a95f7e13fde3f1b36a1 URL: https://github.com/llvm/llvm-project/commit/e42b799bb28815431f2c5a95f7e13fde3f1b36a1 DIFF: https://github.com/llvm/llvm-project/commit/e42b799bb28815431f2c5a95f7e13fde3f1b36a1.diff LOG: [clang] NFCI: use TemplateArgumentLoc for type-param DefaultArgument (#92854) This is an enabler for a future patch. This allows an type-parameter default argument to be set as an arbitrary TemplateArgument, not just a type. This allows template parameter packs to have default arguments in the AST, even though the language proper doesn't support the syntax for it. This will be used in a later patch which synthesizes template parameter lists with arbitrary default arguments taken from template specializations. There are a few places we used SubsType, because we only had a type, now we use SubstTemplateArgument. SubstTemplateArgument was missing arguments for setting Instantiation location and entity names. Adding those is needed so we don't regress in diagnostics. Added: Modified: clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp clang-tools-extra/clang-tidy/bugprone/IncorrectEnableIfCheck.cpp clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp clang-tools-extra/clangd/Hover.cpp clang/include/clang/AST/ASTNodeTraverser.h clang/include/clang/AST/DeclTemplate.h clang/include/clang/AST/RecursiveASTVisitor.h clang/include/clang/Sema/Sema.h clang/lib/AST/ASTContext.cpp clang/lib/AST/ASTImporter.cpp clang/lib/AST/DeclPrinter.cpp clang/lib/AST/DeclTemplate.cpp clang/lib/AST/JSONNodeDumper.cpp clang/lib/AST/ODRDiagsEmitter.cpp clang/lib/AST/ODRHash.cpp clang/lib/AST/TypePrinter.cpp clang/lib/ExtractAPI/DeclarationFragments.cpp clang/lib/Index/IndexDecl.cpp clang/lib/Sema/HLSLExternalSemaSource.cpp clang/lib/Sema/SemaTemplate.cpp clang/lib/Sema/SemaTemplateDeduction.cpp clang/lib/Sema/SemaTemplateInstantiate.cpp clang/lib/Sema/SemaTemplateInstantiateDecl.cpp clang/lib/Serialization/ASTReaderDecl.cpp clang/lib/Serialization/ASTWriterDecl.cpp clang/tools/libclang/CIndex.cpp clang/unittests/AST/ASTImporterTest.cpp Removed: diff --git a/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp index 36687a8e761e8..c87b3ea7e2616 100644 --- a/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp @@ -54,7 +54,9 @@ AST_MATCHER(QualType, isEnableIf) { AST_MATCHER_P(TemplateTypeParmDecl, hasDefaultArgument, clang::ast_matchers::internal::Matcher, TypeMatcher) { return Node.hasDefaultArgument() && - TypeMatcher.matches(Node.getDefaultArgument(), Finder, Builder); + TypeMatcher.matches( + Node.getDefaultArgument().getArgument().getAsType(), Finder, + Builder); } AST_MATCHER(TemplateDecl, hasAssociatedConstraints) { return Node.hasAssociatedConstraints(); diff --git a/clang-tools-extra/clang-tidy/bugprone/IncorrectEnableIfCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/IncorrectEnableIfCheck.cpp index 09aaf3e31d5dd..75f1107904fce 100644 --- a/clang-tools-extra/clang-tidy/bugprone/IncorrectEnableIfCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/IncorrectEnableIfCheck.cpp @@ -19,10 +19,11 @@ namespace { AST_MATCHER_P(TemplateTypeParmDecl, hasUnnamedDefaultArgument, ast_matchers::internal::Matcher, InnerMatcher) { if (Node.getIdentifier() != nullptr || !Node.hasDefaultArgument() || - Node.getDefaultArgumentInfo() == nullptr) + Node.getDefaultArgument().getArgument().isNull()) return false; - TypeLoc DefaultArgTypeLoc = Node.getDefaultArgumentInfo()->getTypeLoc(); + TypeLoc DefaultArgTypeLoc = + Node.getDefaultArgument().getTypeSourceInfo()->getTypeLoc(); return InnerMatcher.matches(DefaultArgTypeLoc, Finder, Builder); } diff --git a/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp index 7a021fe14436a..ea4d99586c711 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp @@ -177,9 +177,11 @@ matchTrailingTemplateParam(const FunctionTemplateDecl *FunctionTemplate) { dyn_cast(LastParam)) { if (LastTemplateParam->hasDefaultArgument() && LastTemplateParam->getIdentifier() == nullptr) { - return {matchEnableIfSpecialization( - LastTemplateParam->getDefaultArgumentInfo()->getTypeLoc()), - LastTemplateParam}; + return { + matchEnableIfSp
[clang] [Clang] Implement CWG2351 `void{}` (PR #78060)
https://github.com/zygoloid approved this pull request. LG https://github.com/llvm/llvm-project/pull/78060 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clang] NFCI: use TemplateArgumentLoc for type-param DefaultArgument (PR #92854)
https://github.com/mizvekov updated https://github.com/llvm/llvm-project/pull/92854 >From 142c3f394e1b34dcefcaf0887a6fd4711b78eeb3 Mon Sep 17 00:00:00 2001 From: Matheus Izvekov Date: Mon, 20 May 2024 16:30:46 -0300 Subject: [PATCH] [clang] NFCI: use TemplateArgumentLoc for type-param DefaultArgument This is an enabler for a future patch. --- .../ForwardingReferenceOverloadCheck.cpp | 4 +- .../bugprone/IncorrectEnableIfCheck.cpp | 5 +- .../modernize/UseConstraintsCheck.cpp | 8 ++- clang-tools-extra/clangd/Hover.cpp| 8 ++- clang/include/clang/AST/ASTNodeTraverser.h| 2 +- clang/include/clang/AST/DeclTemplate.h| 17 ++--- clang/include/clang/AST/RecursiveASTVisitor.h | 2 +- clang/include/clang/Sema/Sema.h | 4 +- clang/lib/AST/ASTContext.cpp | 3 +- clang/lib/AST/ASTImporter.cpp | 6 +- clang/lib/AST/DeclPrinter.cpp | 3 +- clang/lib/AST/DeclTemplate.cpp| 17 +++-- clang/lib/AST/JSONNodeDumper.cpp | 2 +- clang/lib/AST/ODRDiagsEmitter.cpp | 12 ++-- clang/lib/AST/ODRHash.cpp | 2 +- clang/lib/AST/TypePrinter.cpp | 4 +- clang/lib/ExtractAPI/DeclarationFragments.cpp | 8 +-- clang/lib/Index/IndexDecl.cpp | 3 +- clang/lib/Sema/HLSLExternalSemaSource.cpp | 48 +++-- clang/lib/Sema/SemaTemplate.cpp | 69 ++- clang/lib/Sema/SemaTemplateDeduction.cpp | 10 +-- clang/lib/Sema/SemaTemplateInstantiate.cpp| 11 +-- .../lib/Sema/SemaTemplateInstantiateDecl.cpp | 9 ++- clang/lib/Serialization/ASTReaderDecl.cpp | 3 +- clang/lib/Serialization/ASTWriterDecl.cpp | 2 +- clang/tools/libclang/CIndex.cpp | 7 +- clang/unittests/AST/ASTImporterTest.cpp | 2 +- 27 files changed, 144 insertions(+), 127 deletions(-) diff --git a/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp index 36687a8e761e8..c87b3ea7e2616 100644 --- a/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp @@ -54,7 +54,9 @@ AST_MATCHER(QualType, isEnableIf) { AST_MATCHER_P(TemplateTypeParmDecl, hasDefaultArgument, clang::ast_matchers::internal::Matcher, TypeMatcher) { return Node.hasDefaultArgument() && - TypeMatcher.matches(Node.getDefaultArgument(), Finder, Builder); + TypeMatcher.matches( + Node.getDefaultArgument().getArgument().getAsType(), Finder, + Builder); } AST_MATCHER(TemplateDecl, hasAssociatedConstraints) { return Node.hasAssociatedConstraints(); diff --git a/clang-tools-extra/clang-tidy/bugprone/IncorrectEnableIfCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/IncorrectEnableIfCheck.cpp index 09aaf3e31d5dd..75f1107904fce 100644 --- a/clang-tools-extra/clang-tidy/bugprone/IncorrectEnableIfCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/IncorrectEnableIfCheck.cpp @@ -19,10 +19,11 @@ namespace { AST_MATCHER_P(TemplateTypeParmDecl, hasUnnamedDefaultArgument, ast_matchers::internal::Matcher, InnerMatcher) { if (Node.getIdentifier() != nullptr || !Node.hasDefaultArgument() || - Node.getDefaultArgumentInfo() == nullptr) + Node.getDefaultArgument().getArgument().isNull()) return false; - TypeLoc DefaultArgTypeLoc = Node.getDefaultArgumentInfo()->getTypeLoc(); + TypeLoc DefaultArgTypeLoc = + Node.getDefaultArgument().getTypeSourceInfo()->getTypeLoc(); return InnerMatcher.matches(DefaultArgTypeLoc, Finder, Builder); } diff --git a/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp index 7a021fe14436a..ea4d99586c711 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp @@ -177,9 +177,11 @@ matchTrailingTemplateParam(const FunctionTemplateDecl *FunctionTemplate) { dyn_cast(LastParam)) { if (LastTemplateParam->hasDefaultArgument() && LastTemplateParam->getIdentifier() == nullptr) { - return {matchEnableIfSpecialization( - LastTemplateParam->getDefaultArgumentInfo()->getTypeLoc()), - LastTemplateParam}; + return { + matchEnableIfSpecialization(LastTemplateParam->getDefaultArgument() + .getTypeSourceInfo() + ->getTypeLoc()), + LastTemplateParam}; } } return {}; diff --git a/clang-tools-extra/clangd/Hover.cpp b/clang-tools-extra/clangd/Hover.cpp index 06b949bc4a2b5..2ec0994e846e9 100644 --- a/clang-tools-extra/clangd/Hover.cpp +++ b/clang-tools-extra/clangd/Hover.cpp @@ -247,8 +247,12 @@ fet
[clang] [clang-tools-extra] [clang] NFCI: use TemplateArgumentLoc for type-param DefaultArgument (PR #92854)
https://github.com/mizvekov edited https://github.com/llvm/llvm-project/pull/92854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxxabi] [libunwind] [WebAssembly] __USING_WASM_EXCEPTIONS__ -> __WASM_EXCEPTIONS__ (PR #92840)
https://github.com/aheejin updated https://github.com/llvm/llvm-project/pull/92840 >From e04e685a8fbf3e7915a9eaff3798fe77d15aab0c Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Sat, 18 May 2024 01:55:29 + Subject: [PATCH] [WebAssembly] __USING_WASM_EXCEPTIONS__ -> __WASM_EXCEPTIONS__ We've decided to change `__USING_WASM_EXCEPTIONS__` preprocessor to `__WASM_EXCEPTIONS__` given that it's more concise. --- libcxxabi/include/cxxabi.h| 2 +- libcxxabi/src/cxa_exception.cpp | 2 +- libcxxabi/src/cxa_exception.h | 2 +- libcxxabi/src/cxa_personality.cpp | 36 +++ libunwind/src/Unwind-wasm.c | 4 ++-- libunwind/src/libunwind.cpp | 4 ++-- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/libcxxabi/include/cxxabi.h b/libcxxabi/include/cxxabi.h index d0701181751c5..9d9beecf751fc 100644 --- a/libcxxabi/include/cxxabi.h +++ b/libcxxabi/include/cxxabi.h @@ -53,7 +53,7 @@ __cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXAB // 2.4.3 Throwing the Exception Object extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_throw(void *thrown_exception, std::type_info *tinfo, -#ifdef __USING_WASM_EXCEPTIONS__ +#ifdef __WASM_EXCEPTIONS__ // In Wasm, a destructor returns its argument void *(_LIBCXXABI_DTOR_FUNC *dest)(void *)); #else diff --git a/libcxxabi/src/cxa_exception.cpp b/libcxxabi/src/cxa_exception.cpp index 65e9f4504ddad..3141d50a6bb92 100644 --- a/libcxxabi/src/cxa_exception.cpp +++ b/libcxxabi/src/cxa_exception.cpp @@ -267,7 +267,7 @@ will call terminate, assuming that there was no handler for the exception. */ void -#ifdef __USING_WASM_EXCEPTIONS__ +#ifdef __WASM_EXCEPTIONS__ // In Wasm, a destructor returns its argument __cxa_throw(void *thrown_object, std::type_info *tinfo, void *(_LIBCXXABI_DTOR_FUNC *dest)(void *)) { #else diff --git a/libcxxabi/src/cxa_exception.h b/libcxxabi/src/cxa_exception.h index 10712f6f47bb5..7800b940b83f7 100644 --- a/libcxxabi/src/cxa_exception.h +++ b/libcxxabi/src/cxa_exception.h @@ -43,7 +43,7 @@ struct _LIBCXXABI_HIDDEN __cxa_exception { // Manage the exception object itself. std::type_info *exceptionType; -#ifdef __USING_WASM_EXCEPTIONS__ +#ifdef __WASM_EXCEPTIONS__ // In Wasm, a destructor returns its argument void *(_LIBCXXABI_DTOR_FUNC *exceptionDestructor)(void *); #else diff --git a/libcxxabi/src/cxa_personality.cpp b/libcxxabi/src/cxa_personality.cpp index d95d781319401..843a18a4cbd8a 100644 --- a/libcxxabi/src/cxa_personality.cpp +++ b/libcxxabi/src/cxa_personality.cpp @@ -70,7 +70,7 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, +--+--+-+-++--+ | callSiteTableLength | (ULEB128) | Call Site Table length, used to find Action table | +-+---+---+ -#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__USING_WASM_EXCEPTIONS__) +#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__WASM_EXCEPTIONS__) +-+---++ | Beginning of Call Site TableThe current ip lies within the | | ... (start, length) range of one of these| @@ -84,7 +84,7 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, | +-+-+--+ | | ... | +--+ -#else // __USING_SJLJ_EXCEPTIONS__ || __USING_WASM_EXCEPTIONS__ +#else // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__ +-+---++ | Beginning of Call Site TableThe current ip is a 1-based index into | | ... this table. Or it is -1 meaning no | @@ -97,7 +97,7 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, | +-+-+--+ | | ... | +--+ -#endif // __USING_SJLJ_EXCEPTIONS__ || __USING_WASM_EXCEPTIONS__ +#endif // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__ +-+ | Beginning of Action Table ttypeIndex == 0 : cleanup | | ... ttypeIndex > 0 : catch | @@ -547,7 +547,7 @@ void set_registers(_Unwind_Exception* unwind_exception, _Unwind_Context* context, const scan_results& results) { -#
[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)
https://github.com/JDevlieghere approved this pull request. https://github.com/llvm/llvm-project/pull/92953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits