[clang] b37233a - [C++20][Modules] Complete implementation of module.import p7.

2023-06-25 Thread Iain Sandoe via cfe-commits

Author: Iain Sandoe
Date: 2023-06-25T08:33:39+01:00
New Revision: b37233a253f30e4bd5f040d598826df443293bee

URL: 
https://github.com/llvm/llvm-project/commit/b37233a253f30e4bd5f040d598826df443293bee
DIFF: 
https://github.com/llvm/llvm-project/commit/b37233a253f30e4bd5f040d598826df443293bee.diff

LOG: [C++20][Modules] Complete implementation of module.import p7.

The following test fails to compile TU b.cpp because we are not making the 
transitively imported modules visible (per [module.import]/p7)

```
a.cppm:
export module a;

export int foo() {
   return 42;
}

b.cppm:
export module b;
import a;

export int bar();

b.cpp:
module b;

int bar() {
   return foo();
}

clang++ -c -std=c++2b -fmodule-output a.cppm
clang++ -c -std=c++2b -fmodule-output -fprebuilt-module-path=. b.cppm
clang++ -c -std=c++2b -fprebuilt-module-path=. b.cpp
b.cpp:4:12: error: declaration of 'foo' must be imported from module 'a' before 
it is required
   return foo();
```

This is fixed by the following patch (which also addresses a FIXME in 
basic.def.odr/p6.cppm).

Differential Revision: https://reviews.llvm.org/D152746

Added: 
clang/test/CXX/module/module.import/p7.cpp

Modified: 
clang/include/clang/Basic/Module.h
clang/lib/Basic/Module.cpp
clang/lib/Sema/SemaModule.cpp
clang/test/CXX/module/basic/basic.def.odr/p6.cppm

Removed: 




diff  --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 399ed92a325e5..b3b5376160107 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -822,6 +822,11 @@ class VisibleModuleSet {
   ConflictCallback Cb = [](ArrayRef, Module *,
StringRef) {});
 
+  /// Make transitive imports visible for [module.import]/7.
+  void makeTransitiveImportsVisible(
+  Module *M, SourceLocation Loc, VisibleCallback Vis = [](Module *) {},
+  ConflictCallback Cb = [](ArrayRef, Module *, StringRef) {});
+
 private:
   /// Import locations for each visible module. Indexed by the module's
   /// VisibilityID.

diff  --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index 3f9b8d0c775b9..2bdbe8d2b110d 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -695,6 +695,14 @@ void VisibleModuleSet::setVisible(Module *M, 
SourceLocation Loc,
   VisitModule({M, nullptr});
 }
 
+void VisibleModuleSet::makeTransitiveImportsVisible(Module *M,
+SourceLocation Loc,
+VisibleCallback Vis,
+ConflictCallback Cb) {
+  for (auto *I : M->Imports)
+setVisible(I, Loc, Vis, Cb);
+}
+
 ASTSourceDescriptor::ASTSourceDescriptor(Module &M)
 : Signature(M.Signature), ClangModule(&M) {
   if (M.Directory)

diff  --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index 9b2982e7fa4df..2ffb0dbddd537 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -397,6 +397,7 @@ Sema::ActOnModuleDecl(SourceLocation StartLoc, 
SourceLocation ModuleLoc,
   if (Interface) {
 
 VisibleModules.setVisible(Interface, ModuleLoc);
+VisibleModules.makeTransitiveImportsVisible(Interface, ModuleLoc);
 
 // Make the import decl for the interface in the impl module.
 ImportDecl *Import = ImportDecl::Create(Context, CurContext, ModuleLoc,

diff  --git a/clang/test/CXX/module/basic/basic.def.odr/p6.cppm 
b/clang/test/CXX/module/basic/basic.def.odr/p6.cppm
index d84c05ce32cda..8e7917dc63ea5 100644
--- a/clang/test/CXX/module/basic/basic.def.odr/p6.cppm
+++ b/clang/test/CXX/module/basic/basic.def.odr/p6.cppm
@@ -17,9 +17,8 @@
 //
 // RUN: %clang_cc1 -std=c++20 %t/module-vs-module.cpp -fmodule-file=M=%t/M.pcm 
-emit-module-interface -o %t/N.pcm -DMODULE_INTERFACE -DNO_ERRORS
 // RUN: %clang_cc1 -std=c++20 %t/module-vs-module.cpp -fmodule-file=M=%t/M.pcm 
-fmodule-file=N=%t/N.pcm -verify
-// FIXME: Once we start importing "import" declarations properly, this should
-// be rejected (-verify should be added to the following line).
-// RUN: %clang_cc1 -std=c++20 %t/module-vs-module.cpp -fmodule-file=M=%t/M.pcm 
-fmodule-file=N=%t/N.pcm -DNO_IMPORT
+//
+// RUN: %clang_cc1 -std=c++20 %t/module-vs-module.cpp -fmodule-file=M=%t/M.pcm 
-fmodule-file=N=%t/N.pcm -DNO_IMPORT -verify
 //
 // RUN: %clang_cc1 -std=c++20 %t/module-vs-module.cpp -fmodule-file=M=%t/M.pcm 
-emit-module-interface -o %t/N-no-M.pcm -DMODULE_INTERFACE -DNO_ERRORS 
-DNO_IMPORT
 // RUN: %clang_cc1 -std=c++20 %t/module-vs-module.cpp -fmodule-file=M=%t/M.pcm 
-fmodule-file=N=%t/N-no-M.pcm -verify

diff  --git a/clang/test/CXX/module/module.import/p7.cpp 
b/clang/test/CXX/module/module.import/p7.cpp
new file mode 100644
index 0..2de6f0bd65c27
--- /dev/null
+++ b/clang/test/CXX/module/module.import/p7.cpp
@@ -0,0 +

[clang] 5421057 - [Clang][NFC] Add feature test macro checks for C++2c

2023-06-25 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2023-06-25T10:27:42+02:00
New Revision: 54210573ae918f6e0cab59bc5955a66bc34b5f6c

URL: 
https://github.com/llvm/llvm-project/commit/54210573ae918f6e0cab59bc5955a66bc34b5f6c
DIFF: 
https://github.com/llvm/llvm-project/commit/54210573ae918f6e0cab59bc5955a66bc34b5f6c.diff

LOG: [Clang][NFC] Add feature test macro checks for C++2c

Added: 


Modified: 
clang/test/Lexer/cxx-features.cpp

Removed: 




diff  --git a/clang/test/Lexer/cxx-features.cpp 
b/clang/test/Lexer/cxx-features.cpp
index 6d4cb25044c62..1b6c793e1defb 100644
--- a/clang/test/Lexer/cxx-features.cpp
+++ b/clang/test/Lexer/cxx-features.cpp
@@ -4,6 +4,8 @@
 // RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -verify %s
 // RUN: %clang_cc1 -std=c++20 -fcxx-exceptions -fsized-deallocation -verify %s
 // RUN: %clang_cc1 -std=c++23 -fcxx-exceptions -fsized-deallocation -verify %s
+// RUN: %clang_cc1 -std=c++2c -fcxx-exceptions -fsized-deallocation -verify %s
+
 //
 // RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation 
-frelaxed-template-template-args -DRELAXED_TEMPLATE_TEMPLATE_ARGS=1 -verify %s
 // RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation 
-DCONCEPTS_TS=1 -verify %s
@@ -15,151 +17,155 @@
 
 // FIXME using `defined` in a macro has undefined behavior.
 #if __cplusplus < 201103L
-#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23) (cxx98 == 0 ? 
defined(__cpp_##macro) : __cpp_##macro != cxx98)
+#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23, cxx26) (cxx98 
== 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx98)
 #elif __cplusplus < 201402L
-#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23) (cxx11 == 0 ? 
defined(__cpp_##macro) : __cpp_##macro != cxx11)
+#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23, cxx26) (cxx11 
== 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx11)
 #elif __cplusplus < 201703L
-#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23) (cxx14 == 0 ? 
defined(__cpp_##macro) : __cpp_##macro != cxx14)
+#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23, cxx26) (cxx14 
== 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx14)
 #elif __cplusplus < 202002L
-#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23) (cxx17 == 0 ? 
defined(__cpp_##macro) : __cpp_##macro != cxx17)
-#elif __cplusplus == 202002L
-#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23) (cxx20 == 0 ? 
defined(__cpp_##macro) : __cpp_##macro != cxx20)
+#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23, cxx26) (cxx17 
== 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx17)
+#elif __cplusplus < 202302L
+#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23, cxx26) (cxx20 
== 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx20)
+#elif __cplusplus == 202302L
+#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23, cxx26) (cxx23 
== 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx23)
 #else
-#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23) (cxx23 == 0 ? 
defined(__cpp_##macro) : __cpp_##macro != cxx23)
+#define check(macro, cxx98, cxx11, cxx14, cxx17, cxx20, cxx23, cxx26) (cxx26 
== 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx26)
 #endif
 
+// --- C++26 features ---
+
 // --- C++23 features ---
 
-#if check(implicit_move, 0, 0, 0, 0, 0, 202011)
+#if check(implicit_move, 0, 0, 0, 0, 0, 202011, 202011)
 #error "wrong value for __cpp_implicit_move"
 #endif
 
-#if check(size_t_suffix, 0, 0, 0, 0, 0, 202011)
+#if check(size_t_suffix, 0, 0, 0, 0, 0, 202011, 202011)
 #error "wrong value for __cpp_size_t_suffix"
 #endif
 
-#if check(if_consteval, 0, 0, 0, 0, 0, 202106)
+#if check(if_consteval, 0, 0, 0, 0, 0, 202106, 202106)
 #error "wrong value for __cpp_if_consteval"
 #endif
 
-#if check(multidimensional_subscript, 0, 0, 0, 0, 0, 202211)
+#if check(multidimensional_subscript, 0, 0, 0, 0, 0, 202211, 202211)
 #error "wrong value for __cpp_multidimensional_subscript"
 #endif
 
-#if check(static_call_operator, 0, 202207, 202207, 202207, 202207, 202207)
+#if check(static_call_operator, 0, 202207, 202207, 202207, 202207, 202207, 
202207)
 #error "wrong value for __cpp_static_call_operator"
 #endif
 
-#if check(named_character_escapes, 202207, 202207, 202207, 202207, 202207, 
202207)
+#if check(named_character_escapes, 202207, 202207, 202207, 202207, 202207, 
202207, 202207)
 #error "wrong value for __cpp_named_character_escapes"
 #endif
 
-#if check(explicit_this_parameter, 0, 0, 0, 0, 0, 0)
+#if check(explicit_this_parameter, 0, 0, 0, 0, 0, 0, 0)
 #error "wrong value for __cpp_explicit_this_parameter"
 #endif
 
 // --- C++20 features ---
 
-#if check(aggregate_paren_init, 0, 0, 0, 0, 201902, 201902)
+#if check(aggregate_paren_init, 0, 0, 0, 0, 201902, 201902, 201902)
 #error "wrong value for __cpp_aggregate_paren_init"
 #endif
 
-#if defined(CHAR8_T) ? check(char8_t, 202207, 202207, 

[clang-tools-extra] b0abd48 - [llvm] Add missing StringExtras.h includes

2023-06-25 Thread Elliot Goodrich via cfe-commits

Author: Elliot Goodrich
Date: 2023-06-25T15:42:22+01:00
New Revision: b0abd4893fa1bfae7f71b6b6e98770c9b1c07620

URL: 
https://github.com/llvm/llvm-project/commit/b0abd4893fa1bfae7f71b6b6e98770c9b1c07620
DIFF: 
https://github.com/llvm/llvm-project/commit/b0abd4893fa1bfae7f71b6b6e98770c9b1c07620.diff

LOG: [llvm] Add missing StringExtras.h includes

In preparation for removing the `#include "llvm/ADT/StringExtras.h"`
from the header to source file of `llvm/Support/Error.h`, first add in
all the missing includes that were previously included transitively
through this header.

Added: 


Modified: 
clang-tools-extra/clangd/ConfigCompile.cpp
clang-tools-extra/clangd/FileDistance.cpp
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/index/SymbolID.cpp
clang-tools-extra/clangd/unittests/TestIndex.cpp
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/JSONNodeDumper.cpp
clang/lib/Basic/Sarif.cpp
clang/lib/Driver/Job.cpp
clang/lib/Driver/ToolChains/AIX.cpp
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/Sema/SemaCast.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaModule.cpp
clang/lib/Sema/SemaStmt.cpp
clang/lib/Sema/SemaStmtAsm.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/StaticAnalyzer/Core/CheckerContext.cpp
clang/tools/clang-offload-packager/ClangOffloadPackager.cpp
clang/tools/driver/cc1as_main.cpp
lld/COFF/Chunks.cpp
lld/COFF/DebugTypes.cpp
lld/COFF/DriverUtils.cpp
lld/Common/Strings.cpp
lld/Common/Timer.cpp
lld/ELF/AArch64ErrataFix.cpp
lld/ELF/InputSection.h
lld/ELF/Target.h
lld/wasm/WriterUtils.cpp
llvm/examples/OrcV2Examples/LLJITWithRemoteDebugging/RemoteJITUtils.cpp
llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h
llvm/include/llvm/Debuginfod/HTTPClient.h
llvm/include/llvm/ProfileData/GCOV.h
llvm/lib/Analysis/AliasSetTracker.cpp
llvm/lib/Analysis/CallGraphSCCPass.cpp
llvm/lib/Analysis/InlineAdvisor.cpp
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
llvm/lib/CodeGen/MachineBasicBlock.cpp
llvm/lib/CodeGen/MachineCheckDebugify.cpp
llvm/lib/CodeGen/RegisterBankInfo.cpp
llvm/lib/DWARFLinker/DWARFLinker.cpp
llvm/lib/DWARFLinker/DWARFLinkerCompileUnit.cpp
llvm/lib/DWARFLinkerParallel/DWARFLinkerUnit.h
llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp
llvm/lib/DebugInfo/PDB/Native/InputFile.cpp
llvm/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp
llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp
llvm/lib/DebugInfo/PDB/Native/NativeSourceFile.cpp
llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFAArch64.h
llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFThumb.h
llvm/lib/FileCheck/FileCheck.cpp
llvm/lib/IR/DIBuilder.cpp
llvm/lib/MC/ELFObjectWriter.cpp
llvm/lib/MC/MCAsmInfo.cpp
llvm/lib/MC/MCParser/ELFAsmParser.cpp
llvm/lib/MC/MCParser/WasmAsmParser.cpp
llvm/lib/ObjCopy/COFF/COFFObjcopy.cpp
llvm/lib/Object/Decompressor.cpp
llvm/lib/Object/ELF.cpp
llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
llvm/lib/Remarks/YAMLRemarkParser.cpp
llvm/lib/Support/BinaryStreamWriter.cpp
llvm/lib/Support/DataExtractor.cpp
llvm/lib/Support/JSON.cpp
llvm/lib/Support/Path.cpp
llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp
llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.h
llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp
llvm/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.cpp
llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.cpp
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
llvm/lib/Target/X86/X86MCInstLower.cpp
llvm/lib/Target/X86/X86PreAMXConfig.cpp
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
llvm/lib/Transforms/Vectorize/VPlan.cpp
llvm/tools/ll

[PATCH] D153716: [ASTMatchers] Add argumentCountAtLeast narrowing matcher

2023-06-25 Thread Mike Crowe via Phabricator via cfe-commits
mikecrowe added inline comments.



Comment at: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp:1671
+  notMatches("void x(int, int = 1) { x(0); }",
+ traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(

I'm not sure if this is the best way to trigger testing of the ignoring default 
argument path in the implementation of `argumentCountAtLeast`, but it does seem 
to work. I added explicit `TK_AsIs` to the tests above to make it clear that 
they are not testing that path.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153716

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


[PATCH] D150848: [clang-format] Respect ColumnLimit 0 line breaks in inline asm

2023-06-25 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:4626-4627
+  verifyFormat(Code1, Style);
+  EXPECT_EQ(Code2, format(Code2, Style));
+  EXPECT_EQ(Code3, format(Code3, Style));
+

We have `verifyNoChange` now. See D153109.



Comment at: clang/unittests/Format/FormatTest.cpp:4630-4632
+  EXPECT_EQ(Code2, format(Code1, Style));
+  EXPECT_EQ(Code2, format(Code2, Style));
+  EXPECT_EQ(Code2, format(Code3, Style));




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150848

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


[PATCH] D151634: [clang] Add test for CWG253

2023-06-25 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill added inline comments.



Comment at: clang/test/CXX/drs/dr0xx.cpp:1022
 
-namespace dr78 { // dr78: sup 
+namespace dr78 { // dr78: no
   // Under DR78, this is valid, because 'k' has static storage duration, so is

shafik wrote:
> Endill wrote:
> > shafik wrote:
> > > shafik wrote:
> > > > This is [issue 1380](https://github.com/cplusplus/papers/issues/1380) 
> > > > and the issue is whether we want static initialization to happen before 
> > > > constant initialization or whether constant initialization excludes 
> > > > zero-init. 
> > > > 
> > > > I think dr77 is now part of [cwg 
> > > > 2536](https://cplusplus.github.io/CWG/issues/2536.html) and we need to 
> > > > wait for the resolution of that in order to know what to do here. 
> > > I was mistaken and completely missed: 
> > > https://eel.is/c++draft/dcl.init#general-8.sentence-2
> > > 
> > > DR 78 is just repeating what we have in: 
> > > https://eel.is/c++draft/basic.start#static
> > > 
> > > The wording has changed a lot since DR 78.
> > Can you please elaborate how does your conclusion affect this patch? 
> > Because I feel a bit lost at this point.
> > Was my initial analysis correct, and we should say that this DR is not 
> > available in Clang?
> No, so this DR was just clarifying that static objects will not have an 
> indeterminate value if they don't have an initializer. So we can consider 
> this NA or you can add a test with a static global w/o an init and show it 
> has zero value.
I'd like to focus on the following points:
1) test case is correct, because we're not supposed to issue a diagnostics for 
static objects without initializers
2) when we stop issuing a diagnostics, we should write a codegen test that 
ensures `k` is initialized with 0
3) this DR is not superseded, so we should mark it as `no`

Do you agree with everything above?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151634

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


[PATCH] D153707: [Clang][LoongArch] Consume and check -mabi and -mfpu even if -m*-float is present

2023-06-25 Thread WÁNG Xuěruì via Phabricator via cfe-commits
xen0n updated this revision to Diff 534325.
xen0n added a comment.

Refactored to reduce duplication of flag processing logic and save one level of 
indent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153707

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
  clang/test/Driver/loongarch-mdouble-float.c
  clang/test/Driver/loongarch-msingle-float.c
  clang/test/Driver/loongarch-msoft-float.c

Index: clang/test/Driver/loongarch-msoft-float.c
===
--- clang/test/Driver/loongarch-msoft-float.c
+++ clang/test/Driver/loongarch-msoft-float.c
@@ -1,12 +1,16 @@
 // RUN: %clang --target=loongarch64 -msoft-float -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefix=CC1
+// RUN: %clang --target=loongarch64 -msoft-float -mfpu=0 -mabi=lp64s -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefixes=CC1,NOWARN
 // RUN: %clang --target=loongarch64 -msoft-float -mfpu=64 -mabi=lp64d -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefixes=CC1,WARN
 // RUN: %clang --target=loongarch64 -msoft-float -S -emit-llvm %s -o - | \
 // RUN:   FileCheck %s --check-prefix=IR
 
-// WARN: warning: argument unused during compilation: '-mfpu=64'
-// WARN: warning: argument unused during compilation: '-mabi=lp64d'
+// NOWARN-NOT: warning: argument unused during compilation: '-mfpu=0'
+// NOWARN-NOT: warning: argument unused during compilation: '-mabi=lp64s'
+// WARN: warning: the -mabi setting 'lp64d' conflicts with that implied by -m*-float (lp64s); using lp64s
+// WARN: warning: the -mfpu setting '64' conflicts with that implied by -m*-float (0); using 0
 
 // CC1: "-target-feature" "-f"{{.*}} "-target-feature" "-d"
 // CC1: "-target-abi" "lp64s"
Index: clang/test/Driver/loongarch-msingle-float.c
===
--- clang/test/Driver/loongarch-msingle-float.c
+++ clang/test/Driver/loongarch-msingle-float.c
@@ -1,12 +1,16 @@
 // RUN: %clang --target=loongarch64 -msingle-float -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefix=CC1
+// RUN: %clang --target=loongarch64 -msingle-float -mfpu=32 -mabi=lp64f -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefixes=CC1,NOWARN
 // RUN: %clang --target=loongarch64 -msingle-float -mfpu=0 -mabi=lp64s -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefixes=CC1,WARN
 // RUN: %clang --target=loongarch64 -msingle-float -S -emit-llvm %s -o - | \
 // RUN:   FileCheck %s --check-prefix=IR
 
-// WARN: warning: argument unused during compilation: '-mfpu=0'
-// WARN: warning: argument unused during compilation: '-mabi=lp64s'
+// NOWARN-NOT: warning: argument unused during compilation: '-mfpu=32'
+// NOWARN-NOT: warning: argument unused during compilation: '-mabi=lp64f'
+// WARN: warning: the -mabi setting 'lp64s' conflicts with that implied by -m*-float (lp64f); using lp64f
+// WARN: warning: the -mfpu setting '0' conflicts with that implied by -m*-float (32); using 32
 
 // CC1: "-target-feature" "+f"{{.*}} "-target-feature" "-d"
 // CC1: "-target-abi" "lp64f"
Index: clang/test/Driver/loongarch-mdouble-float.c
===
--- clang/test/Driver/loongarch-mdouble-float.c
+++ clang/test/Driver/loongarch-mdouble-float.c
@@ -1,12 +1,16 @@
 // RUN: %clang --target=loongarch64 -mdouble-float -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefix=CC1
+// RUN: %clang --target=loongarch64 -mdouble-float -mfpu=64 -mabi=lp64d -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefixes=CC1,NOWARN
 // RUN: %clang --target=loongarch64 -mdouble-float -mfpu=0 -mabi=lp64s -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefixes=CC1,WARN
 // RUN: %clang --target=loongarch64 -mdouble-float -S -emit-llvm %s -o - | \
 // RUN:   FileCheck %s --check-prefix=IR
 
-// WARN: warning: argument unused during compilation: '-mfpu=0'
-// WARN: warning: argument unused during compilation: '-mabi=lp64s'
+// NOWARN-NOT: warning: argument unused during compilation: '-mfpu=64'
+// NOWARN-NOT: warning: argument unused during compilation: '-mabi=lp64d'
+// WARN: warning: the -mabi setting 'lp64s' conflicts with that implied by -m*-float (lp64d); using lp64d
+// WARN: warning: the -mfpu setting '0' conflicts with that implied by -m*-float (64); using 64
 
 // CC1: "-target-feature" "+f"{{.*}} "-target-feature" "+d"
 // CC1: "-target-abi" "lp64d"
Index: clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
===
--- clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
+++ clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
@@ -26,32 +26,71 @@
  "Unexpected triple");
   bool IsLA32 = Triple.getArch() == llvm::Triple::loongarch32;
 
+  // Record -mabi v

[PATCH] D153716: [ASTMatchers] Add argumentCountAtLeast narrowing matcher

2023-06-25 Thread Mike Crowe via Phabricator via cfe-commits
mikecrowe created this revision.
mikecrowe added a reviewer: PiotrZSL.
Herald added a project: All.
mikecrowe requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
mikecrowe added inline comments.



Comment at: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp:1671
+  notMatches("void x(int, int = 1) { x(0); }",
+ traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(

I'm not sure if this is the best way to trigger testing of the ignoring default 
argument path in the implementation of `argumentCountAtLeast`, but it does seem 
to work. I added explicit `TK_AsIs` to the tests above to make it clear that 
they are not testing that path.


This will be used by the modernize-use-std-print clang-tidy check and
related checks later.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153716

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1640,6 +1640,95 @@
  cxxConversionDecl(isExplicit(;
 }
 
+TEST_P(ASTMatchersTest, ArgumentCountAtLeast_CallExpr) {
+  StatementMatcher Call2PlusArgs = callExpr(argumentCountAtLeast(2));
+
+  EXPECT_TRUE(notMatches("void x(void) { x(); }", Call2PlusArgs));
+  EXPECT_TRUE(notMatches("void x(int) { x(0); }", Call2PlusArgs));
+  EXPECT_TRUE(matches("void x(int, int) { x(0, 0); }", Call2PlusArgs));
+  EXPECT_TRUE(matches("void x(int, int, int) { x(0, 0, 0); }", Call2PlusArgs));
+
+  if (!GetParam().isCXX()) {
+return;
+  }
+
+  EXPECT_TRUE(
+  notMatches("void x(int = 1) { x(); }", traverse(TK_AsIs, Call2PlusArgs)));
+  EXPECT_TRUE(matches("void x(int, int = 1) { x(0); }",
+  traverse(TK_AsIs, Call2PlusArgs)));
+  EXPECT_TRUE(matches("void x(int, int = 1, int = 1) { x(0); }",
+  traverse(TK_AsIs, Call2PlusArgs)));
+  EXPECT_TRUE(matches("void x(int, int, int = 1) { x(0, 0); }",
+  traverse(TK_AsIs, Call2PlusArgs)));
+  EXPECT_TRUE(matches("void x(int, int, int, int = 1) { x(0, 0, 0); }",
+  traverse(TK_AsIs, Call2PlusArgs)));
+
+  EXPECT_TRUE(
+  notMatches("void x(int = 1) { x(); }",
+ traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(
+  notMatches("void x(int, int = 1) { x(0); }",
+ traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(
+  notMatches("void x(int, int = 1, int = 1) { x(0); }",
+ traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(matches("void x(int, int, int = 1) { x(0, 0); }",
+  traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(matches("void x(int, int, int, int = 1) { x(0, 0, 0); }",
+  traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+}
+
+TEST_P(ASTMatchersTest, ArgumentCountAtLeast_CallExpr_CXX) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+
+  StatementMatcher Call2PlusArgs = callExpr(argumentCountAtLeast(2));
+  EXPECT_TRUE(notMatches("class X { void x() { x(); } };", Call2PlusArgs));
+  EXPECT_TRUE(notMatches("class X { void x(int) { x(0); } };", Call2PlusArgs));
+  EXPECT_TRUE(
+  matches("class X { void x(int, int) { x(0, 0); } };", Call2PlusArgs));
+  EXPECT_TRUE(matches("class X { void x(int, int, int) { x(0, 0, 0); } };",
+  Call2PlusArgs));
+
+  EXPECT_TRUE(notMatches("class X { void x(int = 1) { x(0); } };",
+ traverse(TK_AsIs, Call2PlusArgs)));
+  EXPECT_TRUE(matches("class X { void x(int, int = 1) { x(0); } };",
+  traverse(TK_AsIs, Call2PlusArgs)));
+  EXPECT_TRUE(matches("class X { void x(int, int = 1, int = 1) { x(0); } };",
+  traverse(TK_AsIs, Call2PlusArgs)));
+  EXPECT_TRUE(matches("class X { void x(int, int, int = 1) { x(0, 0); } };",
+  traverse(TK_AsIs, Call2PlusArgs)));
+  EXPECT_TRUE(
+  matches("class X { void x(int, int, int, int = 1) { x(0, 0, 0); } };",
+  traverse(TK_AsIs, Call2PlusArgs)));
+
+  EXPECT_TRUE(
+  notMatches("class X { void x(int = 1) { x(0); } };",
+ traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(
+  notMatches("class X { void x(int, int = 1) { x(0); } };",
+ traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(
+  notMatches("class X { void x(int, int = 1, int = 1) { x(0); } };",
+ traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(matches("cl

[PATCH] D153510: [Clang][RISCV] Check type support for local variable declaration of RVV type

2023-06-25 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 534317.
eopXD added a comment.
Herald added a subscriber: MaskRay.

Add check for RVV boolean types and simplify if-condition under 
checkRVVTypeSupport.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153510

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-intrinsic-datatypes.cpp
  clang/test/Sema/riscv-types.c
  clang/test/Sema/riscv-vector-float16-check.c
  clang/test/Sema/riscv-vector-float32-check.c
  clang/test/Sema/riscv-vector-float64-check.c
  clang/test/Sema/riscv-vector-int64-check.c
  clang/test/Sema/riscv-vector-zve32x-check.c

Index: clang/test/Sema/riscv-vector-zve32x-check.c
===
--- /dev/null
+++ clang/test/Sema/riscv-vector-zve32x-check.c
@@ -0,0 +1,107 @@
+// RUN: %clang_cc1 -triple riscv64 \
+// RUN:   -disable-O0-optnone -o - -fsyntax-only %s -verify 
+// REQUIRES: riscv-registered-target
+
+__rvv_int8m1_t foo8() { /* expected-error {{RISC-V type '__rvv_int8m1_t' requires the 'zve32x' extension}} */
+  __rvv_int8m1_t i8m1; /* expected-error {{RISC-V type '__rvv_int8m1_t' requires the 'zve32x' extension}} */
+
+  (void)i8m1; /* expected-error {{RISC-V type '__rvv_int8m1_t' requires the 'zve32x' extension}} */
+
+  return i8m1; /* expected-error {{RISC-V type '__rvv_int8m1_t' requires the 'zve32x' extension}} */
+}
+
+__rvv_int16m1_t foo16() { /* expected-error {{RISC-V type '__rvv_int16m1_t' requires the 'zve32x' extension}} */
+  __rvv_int16m1_t i16m1; /* expected-error {{RISC-V type '__rvv_int16m1_t' requires the 'zve32x' extension}} */
+
+  (void)i16m1; /* expected-error {{RISC-V type '__rvv_int16m1_t' requires the 'zve32x' extension}} */
+
+  return i16m1; /* expected-error {{RISC-V type '__rvv_int16m1_t' requires the 'zve32x' extension}} */
+}
+
+__rvv_int32m1_t foo32() { /* expected-error {{RISC-V type '__rvv_int32m1_t' requires the 'zve32x' extension}} */
+  __rvv_int32m1_t i32m1; /* expected-error {{RISC-V type '__rvv_int32m1_t' requires the 'zve32x' extension}} */
+
+  (void)i32m1; /* expected-error {{RISC-V type '__rvv_int32m1_t' requires the 'zve32x' extension}} */
+
+  return i32m1; /* expected-error {{RISC-V type '__rvv_int32m1_t' requires the 'zve32x' extension}} */
+}
+
+__rvv_int8m1x2_t bar8() { /* expected-error {{RISC-V type '__rvv_int8m1x2_t' requires the 'zve32x' extension}} */
+  __rvv_int8m1x2_t i8m1x2; /* expected-error {{RISC-V type '__rvv_int8m1x2_t' requires the 'zve32x' extension}} */
+
+  (void)i8m1x2; /* expected-error {{RISC-V type '__rvv_int8m1x2_t' requires the 'zve32x' extension}} */
+
+  return i8m1x2; /* expected-error {{RISC-V type '__rvv_int8m1x2_t' requires the 'zve32x' extension}} */
+}
+
+__rvv_int16m1x2_t bar16() { /* expected-error {{RISC-V type '__rvv_int16m1x2_t' requires the 'zve32x' extension}} */
+  __rvv_int16m1x2_t i16m1x2; /* expected-error {{RISC-V type '__rvv_int16m1x2_t' requires the 'zve32x' extension}} */
+
+  (void)i16m1x2; /* expected-error {{RISC-V type '__rvv_int16m1x2_t' requires the 'zve32x' extension}} */
+
+  return i16m1x2; /* expected-error {{RISC-V type '__rvv_int16m1x2_t' requires the 'zve32x' extension}} */
+}
+
+__rvv_int32m1x2_t bar32() { /* expected-error {{RISC-V type '__rvv_int32m1x2_t' requires the 'zve32x' extension}} */
+  __rvv_int32m1x2_t i32m1x2; /* expected-error {{RISC-V type '__rvv_int32m1x2_t' requires the 'zve32x' extension}} */
+
+  (void)i32m1x2; /* expected-error {{RISC-V type '__rvv_int32m1x2_t' requires the 'zve32x' extension}} */
+
+  return i32m1x2; /* expected-error {{RISC-V type '__rvv_int32m1x2_t' requires the 'zve32x' extension}} */
+}
+
+__rvv_bool1_t vbool1 () { /* expected-error {{RISC-V type '__rvv_bool1_t' requires the 'zve32x' extension}} */
+  __rvv_bool1_t b1; /* expected-error {{RISC-V type '__rvv_bool1_t' requires the 'zve32x' extension}} */
+
+  (void)b1; /* expected-error {{RISC-V type '__rvv_bool1_t' requires the 'zve32x' extension}} */
+
+  return b1; /* expected-error {{RISC-V type '__rvv_bool1_t' requires the 'zve32x' extension}} */
+}
+
+__rvv_bool2_t vbool2 () { /* expected-error {{RISC-V type '__rvv_bool2_t' requires the 'zve32x' extension}} */
+  __rvv_bool2_t b2; /* expected-error {{RISC-V type '__rvv_bool2_t' requires the 'zve32x' extension}} */
+
+  (void)b2; /* expected-error {{RISC-V type '__rvv_bool2_t' requires the 'zve32x' extension}} */
+
+  return b2; /* expected-error {{RISC-V type '__rvv_bool2_t' requires the 'zve32x' extension}} */
+}
+
+__rvv_bool4_t vbool4 () { /* expected-error {{RISC-V type '__rvv_bool4_t' requires the 'zve32x' extension}} */
+  __rvv_bool4_t b4; /* expected-error {{RISC-V type '__rvv_bool4_t' requires the 'zve32x' extension}} */
+
+  (void)b4; /* expected-error {{RISC-V type '__rvv_bool

[PATCH] D153707: [Clang][LoongArch] Consume and check -mabi and -mfpu even if -m*-float is present

2023-06-25 Thread Lu Weining via Phabricator via cfe-commits
SixWeining accepted this revision.
SixWeining added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.




Comment at: clang/lib/Driver/ToolChains/Arch/LoongArch.cpp:64
+// conflicts with the higher-priority settings implied by -m*-float.
+if (!ImpliedABI.empty()) {
+  if (const Arg *A = Args.getLastArg(options::OPT_mabi_EQ)) {

Seems that this condition is always `true`.



Comment at: clang/lib/Driver/ToolChains/Arch/LoongArch.cpp:85
   // Select abi based on -mfpu=xx.
-  if (const Arg *A = Args.getLastArg(options::OPT_mfpu_EQ)) {
-StringRef FPU = A->getValue();
-if (FPU == "64")
-  return IsLA32 ? "ilp32d" : "lp64d";
-if (FPU == "32")
-  return IsLA32 ? "ilp32f" : "lp64f";
-if (FPU == "0" || FPU == "none")
-  return IsLA32 ? "ilp32s" : "lp64s";
-D.Diag(diag::err_drv_loongarch_invalid_mfpu_EQ) << FPU;
+  switch (FPU) {
+  case 64:

Without `default`, there may be compiling warning?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153707

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


[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-06-25 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/Sema/SemaInit.cpp:15
 #include "clang/AST/DeclObjC.h"
+#include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"

ychen wrote:
> shafik wrote:
> > I saw your adding headers. How did you figure out which ones were missing?
> Added headers provide APIs for the new code. I guess many of them are 
> included already indirectly (SmallVector for example). But I thought the best 
> practice is not relying on that, so I added these.
I think it's easier fore reviewers not to add things are are not needed, I 
would suggest trying to keep the change to the list of includes to the minimum


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

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


[PATCH] D153510: [Clang][RISCV] Check type support for local variable declaration of RVV type

2023-06-25 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD marked an inline comment as done.
eopXD added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:4967
 
+void Sema::checkRVVTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D) {
+  const TargetInfo &TI = Context.getTargetInfo();

craig.topper wrote:
> craig.topper wrote:
> > What about the bool types? Is it sufficient to check Zve32x is enabled 
> > after all the other checks? The caller already checked for it being an RVV 
> > type so if we are in the function the type is RVV.
> I don't think this comment was addressed
Sorry I misread and only added checks for `vint{8/16/32}*_t`.


Added checks to bool and coverage under `riscv-vector-zve32x-check.c`.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153510

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


[PATCH] D153228: [clang-format] Fixed bad performance with enabled qualifier fixer.

2023-06-25 Thread Sedenion via Phabricator via cfe-commits
Sedeniono marked an inline comment as done.
Sedeniono added a comment.

In D153228#4446523 , @MyDeveloperDay 
wrote:

> For us to land this for you we'll need your name and email

Please use: `Sedenion <39583823+sedeni...@users.noreply.github.com>`
Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153228

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


[PATCH] D153707: [Clang][LoongArch] Consume and check -mabi and -mfpu even if -m*-float is present

2023-06-25 Thread WÁNG Xuěruì via Phabricator via cfe-commits
xen0n added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/LoongArch.cpp:64
+// conflicts with the higher-priority settings implied by -m*-float.
+if (!ImpliedABI.empty()) {
+  if (const Arg *A = Args.getLastArg(options::OPT_mabi_EQ)) {

SixWeining wrote:
> Seems that this condition is always `true`.
Yes you're right. I'll simplify it (and add comment detailing why it's safe to 
assume non-emptiness) shortly.



Comment at: clang/lib/Driver/ToolChains/Arch/LoongArch.cpp:85
   // Select abi based on -mfpu=xx.
-  if (const Arg *A = Args.getLastArg(options::OPT_mfpu_EQ)) {
-StringRef FPU = A->getValue();
-if (FPU == "64")
-  return IsLA32 ? "ilp32d" : "lp64d";
-if (FPU == "32")
-  return IsLA32 ? "ilp32f" : "lp64f";
-if (FPU == "0" || FPU == "none")
-  return IsLA32 ? "ilp32s" : "lp64s";
-D.Diag(diag::err_drv_loongarch_invalid_mfpu_EQ) << FPU;
+  switch (FPU) {
+  case 64:

SixWeining wrote:
> Without `default`, there may be compiling warning?
I didn't remember seeing such warnings; plus the case's body would be empty 
anyway...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153707

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


[PATCH] D153707: [Clang][LoongArch] Consume and check -mabi and -mfpu even if -m*-float is present

2023-06-25 Thread WÁNG Xuěruì via Phabricator via cfe-commits
xen0n updated this revision to Diff 534326.
xen0n marked an inline comment as done.
xen0n added a comment.

Grammatical fix of comment text ("is" -> "are").


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153707

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
  clang/test/Driver/loongarch-mdouble-float.c
  clang/test/Driver/loongarch-msingle-float.c
  clang/test/Driver/loongarch-msoft-float.c

Index: clang/test/Driver/loongarch-msoft-float.c
===
--- clang/test/Driver/loongarch-msoft-float.c
+++ clang/test/Driver/loongarch-msoft-float.c
@@ -1,12 +1,16 @@
 // RUN: %clang --target=loongarch64 -msoft-float -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefix=CC1
+// RUN: %clang --target=loongarch64 -msoft-float -mfpu=0 -mabi=lp64s -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefixes=CC1,NOWARN
 // RUN: %clang --target=loongarch64 -msoft-float -mfpu=64 -mabi=lp64d -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefixes=CC1,WARN
 // RUN: %clang --target=loongarch64 -msoft-float -S -emit-llvm %s -o - | \
 // RUN:   FileCheck %s --check-prefix=IR
 
-// WARN: warning: argument unused during compilation: '-mfpu=64'
-// WARN: warning: argument unused during compilation: '-mabi=lp64d'
+// NOWARN-NOT: warning: argument unused during compilation: '-mfpu=0'
+// NOWARN-NOT: warning: argument unused during compilation: '-mabi=lp64s'
+// WARN: warning: the -mabi setting 'lp64d' conflicts with that implied by -m*-float (lp64s); using lp64s
+// WARN: warning: the -mfpu setting '64' conflicts with that implied by -m*-float (0); using 0
 
 // CC1: "-target-feature" "-f"{{.*}} "-target-feature" "-d"
 // CC1: "-target-abi" "lp64s"
Index: clang/test/Driver/loongarch-msingle-float.c
===
--- clang/test/Driver/loongarch-msingle-float.c
+++ clang/test/Driver/loongarch-msingle-float.c
@@ -1,12 +1,16 @@
 // RUN: %clang --target=loongarch64 -msingle-float -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefix=CC1
+// RUN: %clang --target=loongarch64 -msingle-float -mfpu=32 -mabi=lp64f -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefixes=CC1,NOWARN
 // RUN: %clang --target=loongarch64 -msingle-float -mfpu=0 -mabi=lp64s -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefixes=CC1,WARN
 // RUN: %clang --target=loongarch64 -msingle-float -S -emit-llvm %s -o - | \
 // RUN:   FileCheck %s --check-prefix=IR
 
-// WARN: warning: argument unused during compilation: '-mfpu=0'
-// WARN: warning: argument unused during compilation: '-mabi=lp64s'
+// NOWARN-NOT: warning: argument unused during compilation: '-mfpu=32'
+// NOWARN-NOT: warning: argument unused during compilation: '-mabi=lp64f'
+// WARN: warning: the -mabi setting 'lp64s' conflicts with that implied by -m*-float (lp64f); using lp64f
+// WARN: warning: the -mfpu setting '0' conflicts with that implied by -m*-float (32); using 32
 
 // CC1: "-target-feature" "+f"{{.*}} "-target-feature" "-d"
 // CC1: "-target-abi" "lp64f"
Index: clang/test/Driver/loongarch-mdouble-float.c
===
--- clang/test/Driver/loongarch-mdouble-float.c
+++ clang/test/Driver/loongarch-mdouble-float.c
@@ -1,12 +1,16 @@
 // RUN: %clang --target=loongarch64 -mdouble-float -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefix=CC1
+// RUN: %clang --target=loongarch64 -mdouble-float -mfpu=64 -mabi=lp64d -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefixes=CC1,NOWARN
 // RUN: %clang --target=loongarch64 -mdouble-float -mfpu=0 -mabi=lp64s -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefixes=CC1,WARN
 // RUN: %clang --target=loongarch64 -mdouble-float -S -emit-llvm %s -o - | \
 // RUN:   FileCheck %s --check-prefix=IR
 
-// WARN: warning: argument unused during compilation: '-mfpu=0'
-// WARN: warning: argument unused during compilation: '-mabi=lp64s'
+// NOWARN-NOT: warning: argument unused during compilation: '-mfpu=64'
+// NOWARN-NOT: warning: argument unused during compilation: '-mabi=lp64d'
+// WARN: warning: the -mabi setting 'lp64s' conflicts with that implied by -m*-float (lp64d); using lp64d
+// WARN: warning: the -mfpu setting '0' conflicts with that implied by -m*-float (64); using 64
 
 // CC1: "-target-feature" "+f"{{.*}} "-target-feature" "+d"
 // CC1: "-target-abi" "lp64d"
Index: clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
===
--- clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
+++ clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
@@ -26,32 +26,71 @@
  "Unexpected triple");
   bool IsLA32 = Triple.getArch() == llvm::Triple::loongarch32;
 
+  // Record -mabi v

[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

2023-06-25 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 534329.
cor3ntin marked 2 inline comments as done.
cor3ntin added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153536

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/IdentifierTable.h
  clang/include/clang/Sema/Lookup.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/Lexer/unicode.c
  clang/test/SemaCXX/cxx2c-placeholder-vars.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -145,7 +145,7 @@
  
   Placeholder variables with no name
   https://wg21.link/P2169R4";>P2169R4
-  No
+  Clang 17
  
 
 
Index: clang/test/SemaCXX/cxx2c-placeholder-vars.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx2c-placeholder-vars.cpp
@@ -0,0 +1,98 @@
+// RUN: %clang -cc1 -fsyntax-only -verify -std=c++2c -Wunused-parameter -Wunused %s
+
+void static_var() {
+static int _; // expected-note {{previous definition is here}} \
+  // expected-note {{candidate}}
+static int _; // expected-error {{redefinition of '_'}}
+int _;// expected-warning {{placeholder variables are a C++2c extension}} \
+  // expected-note {{candidate}}
+_++; // expected-error{{reference to '_' is ambiguous}}
+}
+
+void static_var_2() {
+int _; // expected-note {{previous definition is here}}
+static int _; // expected-error {{redefinition of '_'}}
+}
+
+void bindings() {
+int arr[4] = {0, 1, 2, 3};
+auto [_, _, _, _] = arr; // expected-warning 3{{placeholder variables are a C++2c extension}} \
+ // expected-note 4{{placeholder declared here}}
+_ == 42; // expected-error {{referring to placeholder '_' is not allowed}}
+{
+auto [_, a, b, c] = arr;
+auto [_, _, _, _] = arr; // expected-warning 4{{placeholder variables are a C++2c extension}}
+}
+}
+
+void lambda() {
+(void)[_ = 0, _ = 1] { // expected-warning {{placeholder variables are a C++2c extension}} \
+   // expected-note 4{{placeholder declared here}} \\
+   // expected-warning 2{{placeholder variable has no side effect}}
+(void)_++; // expected-error {{referring to placeholder '_' is not allowed}}
+};
+}
+
+namespace global_var {
+int _; // expected-note {{previous definition is here}}
+int _; // expected-error {{redefinition of '_'}}
+}
+
+namespace global_fun {
+void _();
+void _();
+
+void _() {} // expected-note {{previous definition is here}}
+void _() {} // expected-error {{redefinition of '_'}}
+void _(int){};
+}
+
+void extern_test() {
+extern int _;
+extern int _; // expected-note {{candidate}}
+int _; //expected-note {{candidate}}
+_++; // expected-error {{reference to '_' is ambiguous}}
+}
+
+
+struct Members {
+int _; // expected-note {{placeholder declared here}}
+int _; // expected-warning{{placeholder variables are a C++2c extension}} \
+   // expected-note {{placeholder declared here}}
+void f() {
+_++; // expected-error {{referring to placeholder '_' is not allowed}}
+}
+};
+
+namespace using_ {
+int _; // expected-note {{target of using declaration}}
+void f() {
+int _; // expected-note {{conflicting declaration}}
+_ = 0;
+using using_::_; // expected-error {{target of using declaration conflicts with declaration already in scope}}
+}
+}
+
+
+void call(int);
+void test_param(int _) {}
+void test_params(int _, int _); // expected-error {{redefinition of parameter '_'}} \
+// expected-note {{previous declaration is here}}
+
+template  // expected-error {{declaration of '_' shadows template parameter}} \
+  // expected-note  {{template parameter is declared here}}
+auto i = 0;
+
+template 
+concept C = requires(T _, T _) {  // expected-error {{redefinition of parameter '_'}} \
+// expected-note {{previous declaration is here}}
+T{};
+};
+
+struct S {
+int a;
+};
+
+void f(S a, S _) { // expected-warning {{unused parameter 'a'}}
+
+}
Index: clang/test/Lexer/unicode.c
===
--- clang/test/Lexer/unicode.c
+++ clang/test/Lexer/unicode.c
@@ -27,7 +27,7 @@
 CHECK 

[PATCH] D153702: [Clang] Implement P2738R1 - constexpr cast from void*

2023-06-25 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 534328.
cor3ntin added a comment.

Rebase and update feature macro tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153702

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/CXX/expr/expr.const/p5-26.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -125,7 +125,7 @@
  
   constexpr cast from void*
   https://wg21.link/P2738R1";>P2738R1
-  No
+  Clang 17
  
  
   On the ignorability of standard attributes
Index: clang/test/Lexer/cxx-features.cpp
===
--- clang/test/Lexer/cxx-features.cpp
+++ clang/test/Lexer/cxx-features.cpp
@@ -300,7 +300,7 @@
 #error "wrong value for __cpp_lambdas"
 #endif
 
-#if check(constexpr, 0, 200704, 201304, 201603, 201907, 202211, 202211)
+#if check(constexpr, 0, 200704, 201304, 201603, 201907, 202211, 202306)
 #error "wrong value for __cpp_constexpr"
 #endif
 
Index: clang/test/CXX/expr/expr.const/p5-26.cpp
===
--- /dev/null
+++ clang/test/CXX/expr/expr.const/p5-26.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++2c -verify %s
+
+struct S {};
+struct T : S {} t;
+
+consteval void test() {
+void* a = &t;
+const void* b = &t;
+volatile void* c = &t;
+(void)static_cast(a);
+(void)static_cast(a);
+(void)static_cast(a);
+
+(void)(T*)(a);
+(void)(const T*)(a);
+(void)(volatile T*)(a);
+
+(void)static_cast(b); // expected-error {{static_cast from 'const void *' to 'T *' casts away qualifiers}}
+(void)static_cast(b); // expected-error {{static_cast from 'const void *' to 'volatile T *' casts away qualifiers}}
+(void)static_cast(b);
+(void)static_cast(b);
+
+(void)static_cast(c); // expected-error{{static_cast from 'volatile void *' to 'T *' casts away qualifiers}}
+(void)static_cast(c);
+(void)static_cast(b);
+(void)static_cast(b);
+}
+
+void err() {
+constexpr void* a = &t;
+constexpr auto err1 = static_cast(a); // expected-error{{constexpr variable 'err1' must be initialized by a constant expression}} \
+// expected-note {{cast from 'void *' is not allowed in a constant expression because the pointed object type 'T' is not similar to the target type 'int'}}
+constexpr auto err2 = static_cast(a);   // expected-error{{constexpr variable 'err2' must be initialized by a constant expression}} \
+// expected-note {{cast from 'void *' is not allowed in a constant expression because the pointed object type 'T' is not similar to the target type 'S'}}
+}
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -611,7 +611,8 @@
 Builder.defineMacro("__cpp_unicode_literals", "200710L");
 Builder.defineMacro("__cpp_user_defined_literals", "200809L");
 Builder.defineMacro("__cpp_lambdas", "200907L");
-Builder.defineMacro("__cpp_constexpr", LangOpts.CPlusPlus23   ? "202211L"
+Builder.defineMacro("__cpp_constexpr", LangOpts.CPlusPlus26   ? "202306L"
+   : LangOpts.CPlusPlus23 ? "202211L"
: LangOpts.CPlusPlus20 ? "201907L"
: LangOpts.CPlusPlus17 ? "201603L"
: LangOpts.CPlusPlus14 ? "201304L"
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -8896,9 +8896,10 @@
 if (!E->getType()->isVoidPointerType()) {
   // In some circumstances, we permit casting from void* to cv1 T*, when the
   // actual pointee object is actually a cv2 T.
+  bool HasValidResult = !Result.InvalidBase && !Result.Designator.Invalid &&
+!Result.IsNullPtr;
   bool VoidPtrCastMaybeOK =
-  !Result.InvalidBase && !Result.Designator.Invalid &&
-  !Result.IsNullPtr &&
+  HasValidResult &&
   Info.Ctx.hasSameUnqualifiedType(Result.Designator.getType(Info.Ctx),
   E->getType()->getPointeeType());
   // 1. We'll allow it in std::allocator::allocate, and anything which that
@@ -8910,16 +8911,23 @@
   //that back to `const __impl*` in its body.
   if (VoidPtrCastMaybeOK &&
   (Info.getStdAllocatorCalle

[PATCH] D153229: [llvm] Move StringExtras.h include from Error.h to Error.cpp

2023-06-25 Thread Elliot Goodrich via Phabricator via cfe-commits
IncludeGuardian added a comment.

@MaskRay good idea, I have split into 2 commits and pushed to the `main`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153229

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


[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-25 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks tests on Mac: http://45.33.8.238/macm1/63504/step_7.txt

Please take a look and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

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


[clang] 409a809 - [clang][Diagnostics] Provide parameter source range to arity-mismatch notes

2023-06-25 Thread Takuya Shimizu via cfe-commits

Author: Takuya Shimizu
Date: 2023-06-26T00:27:15+09:00
New Revision: 409a8097c5c728607eb6b05efb1744bf5f9096e1

URL: 
https://github.com/llvm/llvm-project/commit/409a8097c5c728607eb6b05efb1744bf5f9096e1
DIFF: 
https://github.com/llvm/llvm-project/commit/409a8097c5c728607eb6b05efb1744bf5f9096e1.diff

LOG: [clang][Diagnostics] Provide parameter source range to arity-mismatch notes

Consider the following piece of code:
```
void func( int aa,
   int bb,
   int cc) {}

void arity_mismatch() {
  func(2, 4);
}
```
BEFORE:
```
source.cpp:6:3: error: no matching function for call to 'func'
6 |   func(2, 4);
  |   ^~~~
source.cpp:1:6: note: candidate function not viable: requires 3 arguments, but 
2 were provided
1 | void func( int aa,
  |  ^
```
AFTER:
```
source.cpp:6:3: error: no matching function for call to 'func'
6 |   func(2, 4);
  |   ^~~~
source.cpp:1:6: note: candidate function not viable: requires 3 arguments, but 
2 were provided
1 | void func( int aa,
  |  ^ ~~~
2 |int bb,
  |~~~
3 |int cc) {}
  |~~
```

Reviewed By: cjdb, aaron.ballman

Differential Revision: https://reviews.llvm.org/D153267

Added: 
clang/test/Misc/diag-func-call-ranges.c
clang/test/Misc/diag-func-call-ranges.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaOverload.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ff9f8da044db5..43f80bddce3ff 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -364,6 +364,8 @@ Improvements to Clang's diagnostics
 - The Fix-It emitted for unused labels used to expand to the next line, which 
caused
   visual oddities now that Clang shows more than one line of code snippet. 
This has
   been fixed and the Fix-It now only spans to the end of the ``:``.
+- Clang now underlines the parameter list of function declaration when emitting
+  a note about the mismatch in the number of arguments.
 
 Bug Fixes in This Version
 -

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 45056f0d56075..528b76518ff3a 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -6459,7 +6459,8 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
 
   // Emit the location of the prototype.
   if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
-Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
+Diag(FDecl->getLocation(), diag::note_callee_decl)
+<< FDecl << FDecl->getParametersSourceRange();
 
   return true;
 }
@@ -6504,7 +6505,8 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
 
   // Emit the location of the prototype.
   if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
-Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
+Diag(FDecl->getLocation(), diag::note_callee_decl)
+<< FDecl << FDecl->getParametersSourceRange();
 
   // This deletes the extra arguments.
   Call->shrinkNumArgs(NumParams);

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 108e2cf47437a..d4f1c61259c03 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -11037,11 +11037,13 @@ static void DiagnoseArityMismatch(Sema &S, NamedDecl 
*Found, Decl *D,
   if (modeCount == 1 && Fn->getParamDecl(0)->getDeclName())
 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_arity_one)
 << (unsigned)FnKindPair.first << (unsigned)FnKindPair.second
-<< Description << mode << Fn->getParamDecl(0) << NumFormalArgs;
+<< Description << mode << Fn->getParamDecl(0) << NumFormalArgs
+<< Fn->getParametersSourceRange();
   else
 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_arity)
 << (unsigned)FnKindPair.first << (unsigned)FnKindPair.second
-<< Description << mode << modeCount << NumFormalArgs;
+<< Description << mode << modeCount << NumFormalArgs
+<< Fn->getParametersSourceRange();
 
   MaybeEmitInheritedConstructorNote(S, Found);
 }

diff  --git a/clang/test/Misc/diag-func-call-ranges.c 
b/clang/test/Misc/diag-func-call-ranges.c
new file mode 100644
index 0..c1ad687acb146
--- /dev/null
+++ b/clang/test/Misc/diag-func-call-ranges.c
@@ -0,0 +1,11 @@
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info %s 
2>&1 | FileCheck %s --strict-whitespace
+
+// CHECK:  :{9:3-9:7}: error: too few arguments
+// CHECK:  :{7:12-7:26}: note: 'func' declared here
+// CHECK:  :{10:3-10:7}{10:13-10:17}: error: too many arguments
+// CHECK:  :{7:12-7:26}: note: 'func' declared here
+void func( int aa, int bb) {}
+void arity_mismatch() {
+  func(3

[PATCH] D153699: [clang] Fix pretty-printing for variables declared in a for-loop condition

2023-06-25 Thread Fangrui Song via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdf8d6d95ca64: [clang] Fix pretty-printing for variables 
declared in a for-loop condition (authored by vaithak, committed by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153699

Files:
  clang/lib/AST/StmtPrinter.cpp
  clang/test/PCH/for-loop-init-ternary-operator-statement.cpp
  clang/test/SemaCXX/ast-print.cpp


Index: clang/test/SemaCXX/ast-print.cpp
===
--- clang/test/SemaCXX/ast-print.cpp
+++ clang/test/SemaCXX/ast-print.cpp
@@ -21,12 +21,14 @@
 // CHECK: if (int a = 1)
 // CHECK:  while (int a = 1)
 // CHECK:  switch (int a = 1)
+// CHECK:  for (; int a = 1;)
 
 void test2()
 {
 if (int a = 1) { }
 while (int a = 1) { }
 switch (int a = 1) { }
+for(; int a = 1; ) { }
 }
 
 // CHECK: new (1) int;
Index: clang/test/PCH/for-loop-init-ternary-operator-statement.cpp
===
--- clang/test/PCH/for-loop-init-ternary-operator-statement.cpp
+++ clang/test/PCH/for-loop-init-ternary-operator-statement.cpp
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -x ast -ast-print %t | FileCheck %s
 
 int f() {
-  // CHECK: for (int i = 0; x; i++) {
+  // CHECK: for (int i = 0; int x = i < 2 ? 1 : 0; i++) {
   for (int i = 0; int x = i < 2 ? 1 : 0; i++) {
 return x;
   }
Index: clang/lib/AST/StmtPrinter.cpp
===
--- clang/lib/AST/StmtPrinter.cpp
+++ clang/lib/AST/StmtPrinter.cpp
@@ -400,7 +400,9 @@
 PrintInitStmt(Node->getInit(), 5);
   else
 OS << (Node->getCond() ? "; " : ";");
-  if (Node->getCond())
+  if (const DeclStmt *DS = Node->getConditionVariableDeclStmt())
+PrintRawDeclStmt(DS);
+  else if (Node->getCond())
 PrintExpr(Node->getCond());
   OS << ";";
   if (Node->getInc()) {


Index: clang/test/SemaCXX/ast-print.cpp
===
--- clang/test/SemaCXX/ast-print.cpp
+++ clang/test/SemaCXX/ast-print.cpp
@@ -21,12 +21,14 @@
 // CHECK: if (int a = 1)
 // CHECK:  while (int a = 1)
 // CHECK:  switch (int a = 1)
+// CHECK:  for (; int a = 1;)
 
 void test2()
 {
 if (int a = 1) { }
 while (int a = 1) { }
 switch (int a = 1) { }
+for(; int a = 1; ) { }
 }
 
 // CHECK: new (1) int;
Index: clang/test/PCH/for-loop-init-ternary-operator-statement.cpp
===
--- clang/test/PCH/for-loop-init-ternary-operator-statement.cpp
+++ clang/test/PCH/for-loop-init-ternary-operator-statement.cpp
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -x ast -ast-print %t | FileCheck %s
 
 int f() {
-  // CHECK: for (int i = 0; x; i++) {
+  // CHECK: for (int i = 0; int x = i < 2 ? 1 : 0; i++) {
   for (int i = 0; int x = i < 2 ? 1 : 0; i++) {
 return x;
   }
Index: clang/lib/AST/StmtPrinter.cpp
===
--- clang/lib/AST/StmtPrinter.cpp
+++ clang/lib/AST/StmtPrinter.cpp
@@ -400,7 +400,9 @@
 PrintInitStmt(Node->getInit(), 5);
   else
 OS << (Node->getCond() ? "; " : ";");
-  if (Node->getCond())
+  if (const DeclStmt *DS = Node->getConditionVariableDeclStmt())
+PrintRawDeclStmt(DS);
+  else if (Node->getCond())
 PrintExpr(Node->getCond());
   OS << ";";
   if (Node->getInc()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152746: [C++20][Modules] Complete implementation of module.import p7.

2023-06-25 Thread Iain Sandoe via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb37233a253f3: [C++20][Modules] Complete implementation of 
module.import p7. (authored by iains).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152746

Files:
  clang/include/clang/Basic/Module.h
  clang/lib/Basic/Module.cpp
  clang/lib/Sema/SemaModule.cpp
  clang/test/CXX/module/basic/basic.def.odr/p6.cppm
  clang/test/CXX/module/module.import/p7.cpp

Index: clang/test/CXX/module/module.import/p7.cpp
===
--- /dev/null
+++ clang/test/CXX/module/module.import/p7.cpp
@@ -0,0 +1,49 @@
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+
+// All of the following should build without diagnostics.
+//
+// RUN: %clang_cc1 -std=c++20 %t/a.cpp  -emit-module-interface -o %t/a.pcm
+// R U N: %clang_cc1 -std=c++20 %t/a.pcm  -emit-obj -o %t/a.o
+//
+// RUN: %clang_cc1 -std=c++20 %t/b.cpp  -emit-module-interface -o %t/b.pcm \
+// RUN: -fprebuilt-module-path=%t 
+// R U N: %clang_cc1 -std=c++20 %t/b.pcm  -emit-obj -o %t/b.o
+//
+// RUN: %clang_cc1 -std=c++20 %t/b-impl.cpp -emit-obj -o %t/b-impl.o \
+// RUN: -fprebuilt-module-path=%t
+//
+// RUN: %clang_cc1 -std=c++20 %t/ab-main.cpp  -fsyntax-only \
+// RUN: -fprebuilt-module-path=%t
+
+//--- a.cpp
+
+export module a;
+
+export int foo() {
+   return 42;
+}
+
+//--- b.cpp
+
+export module b;
+import a;
+
+export int bar();
+
+//--- b-impl.cpp
+
+module b;
+
+int bar() {
+   return foo();
+}
+
+//--- ab-main.cpp
+
+import b;
+
+int main() {
+   return bar();
+}
+
Index: clang/test/CXX/module/basic/basic.def.odr/p6.cppm
===
--- clang/test/CXX/module/basic/basic.def.odr/p6.cppm
+++ clang/test/CXX/module/basic/basic.def.odr/p6.cppm
@@ -17,9 +17,8 @@
 //
 // RUN: %clang_cc1 -std=c++20 %t/module-vs-module.cpp -fmodule-file=M=%t/M.pcm -emit-module-interface -o %t/N.pcm -DMODULE_INTERFACE -DNO_ERRORS
 // RUN: %clang_cc1 -std=c++20 %t/module-vs-module.cpp -fmodule-file=M=%t/M.pcm -fmodule-file=N=%t/N.pcm -verify
-// FIXME: Once we start importing "import" declarations properly, this should
-// be rejected (-verify should be added to the following line).
-// RUN: %clang_cc1 -std=c++20 %t/module-vs-module.cpp -fmodule-file=M=%t/M.pcm -fmodule-file=N=%t/N.pcm -DNO_IMPORT
+//
+// RUN: %clang_cc1 -std=c++20 %t/module-vs-module.cpp -fmodule-file=M=%t/M.pcm -fmodule-file=N=%t/N.pcm -DNO_IMPORT -verify
 //
 // RUN: %clang_cc1 -std=c++20 %t/module-vs-module.cpp -fmodule-file=M=%t/M.pcm -emit-module-interface -o %t/N-no-M.pcm -DMODULE_INTERFACE -DNO_ERRORS -DNO_IMPORT
 // RUN: %clang_cc1 -std=c++20 %t/module-vs-module.cpp -fmodule-file=M=%t/M.pcm -fmodule-file=N=%t/N-no-M.pcm -verify
Index: clang/lib/Sema/SemaModule.cpp
===
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -397,6 +397,7 @@
   if (Interface) {
 
 VisibleModules.setVisible(Interface, ModuleLoc);
+VisibleModules.makeTransitiveImportsVisible(Interface, ModuleLoc);
 
 // Make the import decl for the interface in the impl module.
 ImportDecl *Import = ImportDecl::Create(Context, CurContext, ModuleLoc,
Index: clang/lib/Basic/Module.cpp
===
--- clang/lib/Basic/Module.cpp
+++ clang/lib/Basic/Module.cpp
@@ -695,6 +695,14 @@
   VisitModule({M, nullptr});
 }
 
+void VisibleModuleSet::makeTransitiveImportsVisible(Module *M,
+SourceLocation Loc,
+VisibleCallback Vis,
+ConflictCallback Cb) {
+  for (auto *I : M->Imports)
+setVisible(I, Loc, Vis, Cb);
+}
+
 ASTSourceDescriptor::ASTSourceDescriptor(Module &M)
 : Signature(M.Signature), ClangModule(&M) {
   if (M.Directory)
Index: clang/include/clang/Basic/Module.h
===
--- clang/include/clang/Basic/Module.h
+++ clang/include/clang/Basic/Module.h
@@ -822,6 +822,11 @@
   ConflictCallback Cb = [](ArrayRef, Module *,
StringRef) {});
 
+  /// Make transitive imports visible for [module.import]/7.
+  void makeTransitiveImportsVisible(
+  Module *M, SourceLocation Loc, VisibleCallback Vis = [](Module *) {},
+  ConflictCallback Cb = [](ArrayRef, Module *, StringRef) {});
+
 private:
   /// Import locations for each visible module. Indexed by the module's
   /// VisibilityID.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153229: [llvm] Move StringExtras.h include from Error.h to Error.cpp

2023-06-25 Thread Elliot Goodrich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2fa0dbd7bf35: [llvm] Move StringExtras.h include from 
Error.h to Error.cpp (authored by IncludeGuardian).

Changed prior to commit:
  https://reviews.llvm.org/D153229?vs=533989&id=534347#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153229

Files:
  llvm/include/llvm/Support/Error.h
  llvm/lib/Support/Error.cpp


Index: llvm/lib/Support/Error.cpp
===
--- llvm/lib/Support/Error.cpp
+++ llvm/lib/Support/Error.cpp
@@ -7,6 +7,8 @@
 
//===--===//
 
 #include "llvm/Support/Error.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/ErrorHandling.h"
 #include 
@@ -70,6 +72,15 @@
   });
 }
 
+/// Write all error messages (if any) in E to a string. The newline character
+/// is used to separate error messages.
+std::string toString(Error E) {
+  SmallVector Errors;
+  handleAllErrors(std::move(E), [&Errors](const ErrorInfoBase &EI) {
+Errors.push_back(EI.message());
+  });
+  return join(Errors.begin(), Errors.end(), "\n");
+}
 
 std::error_code ErrorList::convertToErrorCode() const {
   return std::error_code(static_cast(ErrorErrorCode::MultipleErrors),
Index: llvm/include/llvm/Support/Error.h
===
--- llvm/include/llvm/Support/Error.h
+++ llvm/include/llvm/Support/Error.h
@@ -14,8 +14,6 @@
 #define LLVM_SUPPORT_ERROR_H
 
 #include "llvm-c/Error.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Config/abi-breaking.h"
 #include "llvm/Support/AlignOf.h"
@@ -1025,13 +1023,7 @@
 
 /// Write all error messages (if any) in E to a string. The newline character
 /// is used to separate error messages.
-inline std::string toString(Error E) {
-  SmallVector Errors;
-  handleAllErrors(std::move(E), [&Errors](const ErrorInfoBase &EI) {
-Errors.push_back(EI.message());
-  });
-  return join(Errors.begin(), Errors.end(), "\n");
-}
+std::string toString(Error E);
 
 /// Consume a Error without doing anything. This method should be used
 /// only where an error can be considered a reasonable and expected return


Index: llvm/lib/Support/Error.cpp
===
--- llvm/lib/Support/Error.cpp
+++ llvm/lib/Support/Error.cpp
@@ -7,6 +7,8 @@
 //===--===//
 
 #include "llvm/Support/Error.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/ErrorHandling.h"
 #include 
@@ -70,6 +72,15 @@
   });
 }
 
+/// Write all error messages (if any) in E to a string. The newline character
+/// is used to separate error messages.
+std::string toString(Error E) {
+  SmallVector Errors;
+  handleAllErrors(std::move(E), [&Errors](const ErrorInfoBase &EI) {
+Errors.push_back(EI.message());
+  });
+  return join(Errors.begin(), Errors.end(), "\n");
+}
 
 std::error_code ErrorList::convertToErrorCode() const {
   return std::error_code(static_cast(ErrorErrorCode::MultipleErrors),
Index: llvm/include/llvm/Support/Error.h
===
--- llvm/include/llvm/Support/Error.h
+++ llvm/include/llvm/Support/Error.h
@@ -14,8 +14,6 @@
 #define LLVM_SUPPORT_ERROR_H
 
 #include "llvm-c/Error.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Config/abi-breaking.h"
 #include "llvm/Support/AlignOf.h"
@@ -1025,13 +1023,7 @@
 
 /// Write all error messages (if any) in E to a string. The newline character
 /// is used to separate error messages.
-inline std::string toString(Error E) {
-  SmallVector Errors;
-  handleAllErrors(std::move(E), [&Errors](const ErrorInfoBase &EI) {
-Errors.push_back(EI.message());
-  });
-  return join(Errors.begin(), Errors.end(), "\n");
-}
+std::string toString(Error E);
 
 /// Consume a Error without doing anything. This method should be used
 /// only where an error can be considered a reasonable and expected return
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153267: [clang][Diagnostics] Provide parameter source range to arity-mismatch notes

2023-06-25 Thread Takuya Shimizu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG409a8097c5c7: [clang][Diagnostics] Provide parameter source 
range to arity-mismatch notes (authored by hazohelet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153267

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/Misc/diag-func-call-ranges.c
  clang/test/Misc/diag-func-call-ranges.cpp


Index: clang/test/Misc/diag-func-call-ranges.cpp
===
--- /dev/null
+++ clang/test/Misc/diag-func-call-ranges.cpp
@@ -0,0 +1,14 @@
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info %s 
2>&1 | FileCheck %s --strict-whitespace
+
+// CHECK: error: no matching function for call to 'func'
+
+// CHECK:  :{[[@LINE+1]]:12-[[@LINE+1]]:18}: note: {{.*}} requires single 
argument
+void func( int aa ) {}
+// CHECK:  :{[[@LINE+1]]:12-[[@LINE+3]]:18}: note: {{.*}} requires 3 
arguments
+void func( int aa,
+   int bb,
+   int cc) {}
+
+void arity_mismatch() {
+  func(2, 4);
+}
Index: clang/test/Misc/diag-func-call-ranges.c
===
--- /dev/null
+++ clang/test/Misc/diag-func-call-ranges.c
@@ -0,0 +1,11 @@
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info %s 
2>&1 | FileCheck %s --strict-whitespace
+
+// CHECK:  :{9:3-9:7}: error: too few arguments
+// CHECK:  :{7:12-7:26}: note: 'func' declared here
+// CHECK:  :{10:3-10:7}{10:13-10:17}: error: too many arguments
+// CHECK:  :{7:12-7:26}: note: 'func' declared here
+void func( int aa, int bb) {}
+void arity_mismatch() {
+  func(3);
+  func(3, 4,5, 6);
+}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -11037,11 +11037,13 @@
   if (modeCount == 1 && Fn->getParamDecl(0)->getDeclName())
 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_arity_one)
 << (unsigned)FnKindPair.first << (unsigned)FnKindPair.second
-<< Description << mode << Fn->getParamDecl(0) << NumFormalArgs;
+<< Description << mode << Fn->getParamDecl(0) << NumFormalArgs
+<< Fn->getParametersSourceRange();
   else
 S.Diag(Fn->getLocation(), diag::note_ovl_candidate_arity)
 << (unsigned)FnKindPair.first << (unsigned)FnKindPair.second
-<< Description << mode << modeCount << NumFormalArgs;
+<< Description << mode << modeCount << NumFormalArgs
+<< Fn->getParametersSourceRange();
 
   MaybeEmitInheritedConstructorNote(S, Found);
 }
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6459,7 +6459,8 @@
 
   // Emit the location of the prototype.
   if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
-Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
+Diag(FDecl->getLocation(), diag::note_callee_decl)
+<< FDecl << FDecl->getParametersSourceRange();
 
   return true;
 }
@@ -6504,7 +6505,8 @@
 
   // Emit the location of the prototype.
   if (!TC && FDecl && !FDecl->getBuiltinID() && !IsExecConfig)
-Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
+Diag(FDecl->getLocation(), diag::note_callee_decl)
+<< FDecl << FDecl->getParametersSourceRange();
 
   // This deletes the extra arguments.
   Call->shrinkNumArgs(NumParams);
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -364,6 +364,8 @@
 - The Fix-It emitted for unused labels used to expand to the next line, which 
caused
   visual oddities now that Clang shows more than one line of code snippet. 
This has
   been fixed and the Fix-It now only spans to the end of the ``:``.
+- Clang now underlines the parameter list of function declaration when emitting
+  a note about the mismatch in the number of arguments.
 
 Bug Fixes in This Version
 -


Index: clang/test/Misc/diag-func-call-ranges.cpp
===
--- /dev/null
+++ clang/test/Misc/diag-func-call-ranges.cpp
@@ -0,0 +1,14 @@
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s --strict-whitespace
+
+// CHECK: error: no matching function for call to 'func'
+
+// CHECK:  :{[[@LINE+1]]:12-[[@LINE+1]]:18}: note: {{.*}} requires single argument
+void func( int aa ) {}
+// CHECK:  :{[[@LINE+1]]:12-[[@LINE+3]]:18}: note: {{.*}} requires 3 arguments
+void func( int aa,
+   int bb,
+  

[PATCH] D153716: [ASTMatchers] Add argumentCountAtLeast narrowing matcher

2023-06-25 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL accepted this revision.
PiotrZSL added a comment.
This revision is now accepted and ready to land.

LGTM, Personally probably I would extract this to this level, and I would leave 
it private to a check, but it's fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153716

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


[PATCH] D149280: [clang-tidy] Add modernize-printf-to-std-print check

2023-06-25 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL accepted this revision.
PiotrZSL added a comment.

Consider delivering this check. I do not think that it will become much better 
with more refactoring.




Comment at: clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp:202-203
+  assert(FormatExpr);
+  if (!FormatExpr->isOrdinary())
+return; // No wide string support yet
+  PrintfFormatString = FormatExpr->getString();

this check for isOrdinary could be done on matcher level, just add anonymous 
matcher, and use it there, you can still use it also here, but my idea is to 
reduce amount of calls to check method.
```
AST_MATCHER(StringLiteral, isOrdinary) {
  return Node.isOrdinary();
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149280

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


[PATCH] D153724: [clang] Fix a crash on invalid destructor

2023-06-25 Thread Younan Zhang via Phabricator via cfe-commits
zyounan created this revision.
zyounan added reviewers: royjacobson, aaron.ballman, erichkeane, shafik.
Herald added a project: All.
zyounan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is a follow-up patch to D126194  in 
order to
fix https://github.com/llvm/llvm-project/issues/63503.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153724

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/virtuals.cpp


Index: clang/test/SemaCXX/virtuals.cpp
===
--- clang/test/SemaCXX/virtuals.cpp
+++ clang/test/SemaCXX/virtuals.cpp
@@ -52,6 +52,19 @@
   };
 }
 
+namespace issue63503 {
+struct Base {
+  virtual ~Base() = default;
+};
+
+struct Derived final : Base {
+  using Base::Base;
+  virtual ~Derived() = defaul; // #62
+} do_not_crash;
+// expected-error@#62 {{initializer on function does not look like a 
pure-specifier}}
+// expected-error@#62 {{use of undeclared identifier 'defaul'}}
+}
+
 namespace VirtualFriend {
   // DR (filed but no number yet): reject meaningless pure-specifier on a 
friend declaration.
   struct A { virtual int f(); };
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -15807,7 +15807,11 @@
 return;
 
   CXXDestructorDecl *Destructor = LookupDestructor(ClassDecl);
-
+  // The result of `LookupDestructor` might be nullptr if the destructor is
+  // invalid, in which case it is not marked as `IsEligibleOrSelected` and
+  // will not be selected by `CXXRecordDecl::getDestructor()`.
+  if (!Destructor)
+return;
   // If this is an array, we'll require the destructor during initialization, 
so
   // we can skip over this. We still want to emit exit-time destructor warnings
   // though.
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -521,21 +521,23 @@
   (`#50534 `_).
 - CallExpr built for C error-recovery now is always type-dependent. Fixes a
   crash when we encounter a unresolved TypoExpr during diagnostic emission.
-  (`#50244 _`).
+  (`#50244 `_).
 - Apply ``-fmacro-prefix-map`` to anonymous tags in template arguments
   (`#63219 `_).
 - Clang now properly diagnoses format string mismatches involving scoped
   enumeration types. A scoped enumeration type is not promoted to an integer
   type by the default argument promotions, and thus this is UB. Clang's
   behavior now matches GCC's behavior in C++.
-  (`#38717 _`).
+  (`#38717 `_).
 - Fixed a failing assertion when implicitly defining a function within a GNU
   statement expression that appears outside of a function block scope. The
   assertion was benign outside of asserts builds and would only fire in C.
-  (`#48579 _`).
+  (`#48579 `_).
 - Fixed a failing assertion when applying an attribute to an anonymous union.
   The assertion was benign outside of asserts builds and would only fire in 
C++.
-  (`#48512 _`).
+  (`#48512 `_).
+- Fixed a failing assertion when parsing incomplete destructor.
+  (`#63503 `_)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaCXX/virtuals.cpp
===
--- clang/test/SemaCXX/virtuals.cpp
+++ clang/test/SemaCXX/virtuals.cpp
@@ -52,6 +52,19 @@
   };
 }
 
+namespace issue63503 {
+struct Base {
+  virtual ~Base() = default;
+};
+
+struct Derived final : Base {
+  using Base::Base;
+  virtual ~Derived() = defaul; // #62
+} do_not_crash;
+// expected-error@#62 {{initializer on function does not look like a pure-specifier}}
+// expected-error@#62 {{use of undeclared identifier 'defaul'}}
+}
+
 namespace VirtualFriend {
   // DR (filed but no number yet): reject meaningless pure-specifier on a friend declaration.
   struct A { virtual int f(); };
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -15807,7 +15807,11 @@
 return;
 
   CXXDestructorDecl *Destructor = LookupDestructor(ClassDecl);
-
+  // The result of `LookupDestructor` might be nullptr if the dest

[PATCH] D153724: [clang] Fix a crash on invalid destructor

2023-06-25 Thread Younan Zhang via Phabricator via cfe-commits
zyounan added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:524
   crash when we encounter a unresolved TypoExpr during diagnostic emission.
-  (`#50244 _`).
+  (`#50244 `_).
 - Apply ``-fmacro-prefix-map`` to anonymous tags in template arguments

These underscores are not placed correctly so I revised them as well. Hope you 
don't mind. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153724

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


[PATCH] D153707: [Clang][LoongArch] Consume and check -mabi and -mfpu even if -m*-float is present

2023-06-25 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay requested changes to this revision.
MaskRay added inline comments.
This revision now requires changes to proceed.



Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:732
+def warn_drv_loongarch_conflicting_mabi : Warning<
+  "the -mabi setting '%0' conflicts with that implied by -m*-float (%1); using 
%1">,
+  InGroup;

This is not called `setting`. Use `value`

It seems that `ignoring -mabi value '%0' as it conflicts ...` is more 
conventional.



Comment at: clang/test/Driver/loongarch-msingle-float.c:10
 
-// WARN: warning: argument unused during compilation: '-mfpu=0'
-// WARN: warning: argument unused during compilation: '-mabi=lp64s'
+// NOWARN-NOT: warning: argument unused during compilation: '-mfpu=32'
+// NOWARN-NOT: warning: argument unused during compilation: '-mabi=lp64f'

Just use `NOWARN-NOT: warning:` to assert that there is no diagnostic


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153707

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


[PATCH] D149280: [clang-tidy] Add modernize-printf-to-std-print check

2023-06-25 Thread Mike Crowe via Phabricator via cfe-commits
mikecrowe added inline comments.



Comment at: clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp:64
+  if (MaybeHeaderToInclude)
+Options.store(Opts, "PrintHeader", *MaybeHeaderToInclude);
+}

This is going to write the default value set in the constructor if 
`ReplacementPrintFunction` is `std::print` or `ReplacementPrintlnFunction` is 
`std::println` even if `PrintHeader` was not specified in the configuration. I 
don't know how much of a problem this is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149280

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


[PATCH] D153724: [clang] Fix a crash on invalid destructor

2023-06-25 Thread Younan Zhang via Phabricator via cfe-commits
zyounan updated this revision to Diff 534359.
zyounan added a comment.

And this


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153724

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/virtuals.cpp


Index: clang/test/SemaCXX/virtuals.cpp
===
--- clang/test/SemaCXX/virtuals.cpp
+++ clang/test/SemaCXX/virtuals.cpp
@@ -52,6 +52,19 @@
   };
 }
 
+namespace issue63503 {
+struct Base {
+  virtual ~Base() = default;
+};
+
+struct Derived final : Base {
+  using Base::Base;
+  virtual ~Derived() = defaul; // #62
+} do_not_crash;
+// expected-error@#62 {{initializer on function does not look like a 
pure-specifier}}
+// expected-error@#62 {{use of undeclared identifier 'defaul'}}
+}
+
 namespace VirtualFriend {
   // DR (filed but no number yet): reject meaningless pure-specifier on a 
friend declaration.
   struct A { virtual int f(); };
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -15807,7 +15807,11 @@
 return;
 
   CXXDestructorDecl *Destructor = LookupDestructor(ClassDecl);
-
+  // The result of `LookupDestructor` might be nullptr if the destructor is
+  // invalid, in which case it is not marked as `IsEligibleOrSelected` and
+  // will not be selected by `CXXRecordDecl::getDestructor()`.
+  if (!Destructor)
+return;
   // If this is an array, we'll require the destructor during initialization, 
so
   // we can skip over this. We still want to emit exit-time destructor warnings
   // though.
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -469,7 +469,7 @@
 - Fix crash when redefining a variable with an invalid type again with an
   invalid type. (`#62447 `_)
 - Fix a stack overflow issue when evaluating ``consteval`` default arguments.
-  (`#60082` `_)
+  (`#60082 `_)
 - Fix the assertion hit when generating code for global variable initializer of
   _BitInt(1) type.
   (`#62207 `_)
@@ -521,21 +521,23 @@
   (`#50534 `_).
 - CallExpr built for C error-recovery now is always type-dependent. Fixes a
   crash when we encounter a unresolved TypoExpr during diagnostic emission.
-  (`#50244 _`).
+  (`#50244 `_).
 - Apply ``-fmacro-prefix-map`` to anonymous tags in template arguments
   (`#63219 `_).
 - Clang now properly diagnoses format string mismatches involving scoped
   enumeration types. A scoped enumeration type is not promoted to an integer
   type by the default argument promotions, and thus this is UB. Clang's
   behavior now matches GCC's behavior in C++.
-  (`#38717 _`).
+  (`#38717 `_).
 - Fixed a failing assertion when implicitly defining a function within a GNU
   statement expression that appears outside of a function block scope. The
   assertion was benign outside of asserts builds and would only fire in C.
-  (`#48579 _`).
+  (`#48579 `_).
 - Fixed a failing assertion when applying an attribute to an anonymous union.
   The assertion was benign outside of asserts builds and would only fire in 
C++.
-  (`#48512 _`).
+  (`#48512 `_).
+- Fixed a failing assertion when parsing incomplete destructor.
+  (`#63503 `_)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaCXX/virtuals.cpp
===
--- clang/test/SemaCXX/virtuals.cpp
+++ clang/test/SemaCXX/virtuals.cpp
@@ -52,6 +52,19 @@
   };
 }
 
+namespace issue63503 {
+struct Base {
+  virtual ~Base() = default;
+};
+
+struct Derived final : Base {
+  using Base::Base;
+  virtual ~Derived() = defaul; // #62
+} do_not_crash;
+// expected-error@#62 {{initializer on function does not look like a pure-specifier}}
+// expected-error@#62 {{use of undeclared identifier 'defaul'}}
+}
+
 namespace VirtualFriend {
   // DR (filed but no number yet): reject meaningless pure-specifier on a friend declaration.
   struct A { virtual int f(); };
Index: clang/lib/Sema/SemaDeclC

[PATCH] D153716: [ASTMatchers] Add argumentCountAtLeast narrowing matcher

2023-06-25 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

NOTE: Registry.cpp were not changed, I will add it there during commit if all 
tests locally pass. If tests fail, I will just add this matcher as private in 
clang-tidy check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153716

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


[PATCH] D153725: [clang] Make amdgpu-arch tool work on Windows

2023-06-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
Herald added subscribers: kerbowa, tpr, dstuttard, jvesely, kzhuravl.
Herald added a project: All.
yaxunl requested review of this revision.
Herald added subscribers: jplehr, sstefan1, wdng.
Herald added a reviewer: jdoerfert.

Currently amdgpu-arch tool detects AMD GPU by dynamically
loading HSA runtime shared library and using HSA API's,
which is not available on Windows.

This patch makes it work on Windows by dynamically loading
HIP runtime dll and using HIP API's.


https://reviews.llvm.org/D153725

Files:
  clang/tools/amdgpu-arch/AMDGPUArch.cpp
  clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp
  clang/tools/amdgpu-arch/AMDGPUArchByHSA.cpp
  clang/tools/amdgpu-arch/CMakeLists.txt

Index: clang/tools/amdgpu-arch/CMakeLists.txt
===
--- clang/tools/amdgpu-arch/CMakeLists.txt
+++ clang/tools/amdgpu-arch/CMakeLists.txt
@@ -8,6 +8,6 @@
 
 set(LLVM_LINK_COMPONENTS Support)
 
-add_clang_tool(amdgpu-arch AMDGPUArch.cpp)
+add_clang_tool(amdgpu-arch AMDGPUArch.cpp AMDGPUArchByHSA.cpp AMDGPUArchByHIP.cpp)
 
 target_link_libraries(amdgpu-arch PRIVATE clangBasic)
Index: clang/tools/amdgpu-arch/AMDGPUArchByHSA.cpp
===
--- /dev/null
+++ clang/tools/amdgpu-arch/AMDGPUArchByHSA.cpp
@@ -0,0 +1,121 @@
+//===- AMDGPUArchLinux.cpp - list AMDGPU installed --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements a tool for detecting name of AMDGPU installed in system
+// using HSA on Linux. This tool is used by AMDGPU OpenMP and HIP driver.
+//
+//===--===//
+
+#include "clang/Basic/Version.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/DynamicLibrary.h"
+#include "llvm/Support/Error.h"
+#include 
+#include 
+#include 
+
+using namespace llvm;
+
+typedef enum {
+  HSA_STATUS_SUCCESS = 0x0,
+} hsa_status_t;
+
+typedef enum {
+  HSA_DEVICE_TYPE_CPU = 0,
+  HSA_DEVICE_TYPE_GPU = 1,
+} hsa_device_type_t;
+
+typedef enum {
+  HSA_AGENT_INFO_NAME = 0,
+  HSA_AGENT_INFO_DEVICE = 17,
+} hsa_agent_info_t;
+
+typedef struct hsa_agent_s {
+  uint64_t handle;
+} hsa_agent_t;
+
+hsa_status_t (*hsa_init)();
+hsa_status_t (*hsa_shut_down)();
+hsa_status_t (*hsa_agent_get_info)(hsa_agent_t, hsa_agent_info_t, void *);
+hsa_status_t (*hsa_iterate_agents)(hsa_status_t (*)(hsa_agent_t, void *),
+   void *);
+
+constexpr const char *DynamicHSAPath = "libhsa-runtime64.so";
+
+llvm::Error loadHSA() {
+  std::string ErrMsg;
+  auto DynlibHandle = std::make_unique(
+  llvm::sys::DynamicLibrary::getPermanentLibrary(DynamicHSAPath, &ErrMsg));
+  if (!DynlibHandle->isValid()) {
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "Failed to 'dlopen' %s", DynamicHSAPath);
+  }
+#define DYNAMIC_INIT(SYMBOL)   \
+  {\
+void *SymbolPtr = DynlibHandle->getAddressOfSymbol(#SYMBOL);   \
+if (!SymbolPtr)\
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),   \
+ "Failed to 'dlsym' " #SYMBOL);\
+SYMBOL = reinterpret_cast(SymbolPtr);\
+  }
+  DYNAMIC_INIT(hsa_init);
+  DYNAMIC_INIT(hsa_shut_down);
+  DYNAMIC_INIT(hsa_agent_get_info);
+  DYNAMIC_INIT(hsa_iterate_agents);
+#undef DYNAMIC_INIT
+  return llvm::Error::success();
+}
+
+static hsa_status_t iterateAgentsCallback(hsa_agent_t Agent, void *Data) {
+  hsa_device_type_t DeviceType;
+  hsa_status_t Status =
+  hsa_agent_get_info(Agent, HSA_AGENT_INFO_DEVICE, &DeviceType);
+
+  // continue only if device type if GPU
+  if (Status != HSA_STATUS_SUCCESS || DeviceType != HSA_DEVICE_TYPE_GPU) {
+return Status;
+  }
+
+  std::vector *GPUs =
+  static_cast *>(Data);
+  char GPUName[64];
+  Status = hsa_agent_get_info(Agent, HSA_AGENT_INFO_NAME, GPUName);
+  if (Status != HSA_STATUS_SUCCESS) {
+return Status;
+  }
+  GPUs->push_back(GPUName);
+  return HSA_STATUS_SUCCESS;
+}
+
+int printGPUsByHSA() {
+  // Attempt to load the HSA runtime.
+  if (llvm::Error Err = loadHSA()) {
+logAllUnhandledErrors(std::move(Err), llvm::errs());
+return 1;
+  }
+
+  hsa_status_t Status = hsa_init();
+  if (Status != HSA_STATUS_SUCCESS) {
+return 1;
+  }
+
+  std::vector GPUs;
+  Status = hsa_iterate_agents(iterateAgentsCallback, &GPUs);
+  if (Status != HSA_STATUS_SUC

[PATCH] D153724: [clang] Fix a crash on invalid destructor

2023-06-25 Thread Younan Zhang via Phabricator via cfe-commits
zyounan updated this revision to Diff 534362.
zyounan added a comment.

Typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153724

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/virtuals.cpp


Index: clang/test/SemaCXX/virtuals.cpp
===
--- clang/test/SemaCXX/virtuals.cpp
+++ clang/test/SemaCXX/virtuals.cpp
@@ -52,6 +52,19 @@
   };
 }
 
+namespace issue63503 {
+struct Base {
+  virtual ~Base() = default;
+};
+
+struct Derived final : Base {
+  using Base::Base;
+  virtual ~Derived() = defaul; // #62
+} do_not_crash;
+// expected-error@#62 {{initializer on function does not look like a 
pure-specifier}}
+// expected-error@#62 {{use of undeclared identifier 'defaul'}}
+}
+
 namespace VirtualFriend {
   // DR (filed but no number yet): reject meaningless pure-specifier on a 
friend declaration.
   struct A { virtual int f(); };
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -15807,7 +15807,11 @@
 return;
 
   CXXDestructorDecl *Destructor = LookupDestructor(ClassDecl);
-
+  // The result of `LookupDestructor` might be nullptr if the destructor is
+  // invalid, in which case it is marked as `IneligibleOrNotSelected` and
+  // will not be selected by `CXXRecordDecl::getDestructor()`.
+  if (!Destructor)
+return;
   // If this is an array, we'll require the destructor during initialization, 
so
   // we can skip over this. We still want to emit exit-time destructor warnings
   // though.
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -469,7 +469,7 @@
 - Fix crash when redefining a variable with an invalid type again with an
   invalid type. (`#62447 `_)
 - Fix a stack overflow issue when evaluating ``consteval`` default arguments.
-  (`#60082` `_)
+  (`#60082 `_)
 - Fix the assertion hit when generating code for global variable initializer of
   _BitInt(1) type.
   (`#62207 `_)
@@ -521,21 +521,23 @@
   (`#50534 `_).
 - CallExpr built for C error-recovery now is always type-dependent. Fixes a
   crash when we encounter a unresolved TypoExpr during diagnostic emission.
-  (`#50244 _`).
+  (`#50244 `_).
 - Apply ``-fmacro-prefix-map`` to anonymous tags in template arguments
   (`#63219 `_).
 - Clang now properly diagnoses format string mismatches involving scoped
   enumeration types. A scoped enumeration type is not promoted to an integer
   type by the default argument promotions, and thus this is UB. Clang's
   behavior now matches GCC's behavior in C++.
-  (`#38717 _`).
+  (`#38717 `_).
 - Fixed a failing assertion when implicitly defining a function within a GNU
   statement expression that appears outside of a function block scope. The
   assertion was benign outside of asserts builds and would only fire in C.
-  (`#48579 _`).
+  (`#48579 `_).
 - Fixed a failing assertion when applying an attribute to an anonymous union.
   The assertion was benign outside of asserts builds and would only fire in 
C++.
-  (`#48512 _`).
+  (`#48512 `_).
+- Fixed a failing assertion when parsing incomplete destructor.
+  (`#63503 `_)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaCXX/virtuals.cpp
===
--- clang/test/SemaCXX/virtuals.cpp
+++ clang/test/SemaCXX/virtuals.cpp
@@ -52,6 +52,19 @@
   };
 }
 
+namespace issue63503 {
+struct Base {
+  virtual ~Base() = default;
+};
+
+struct Derived final : Base {
+  using Base::Base;
+  virtual ~Derived() = defaul; // #62
+} do_not_crash;
+// expected-error@#62 {{initializer on function does not look like a pure-specifier}}
+// expected-error@#62 {{use of undeclared identifier 'defaul'}}
+}
+
 namespace VirtualFriend {
   // DR (filed but no number yet): reject meaningless pure-specifier on a friend declaration.
   struct A { virtual int f(); };
Index: clang/lib/Sema/SemaDeclCXX.cp

[PATCH] D144829: [WIP][BPF] Add a few new insns under cpu=v4

2023-06-25 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 534361.
yonghong-song added a comment.

- added support of new instructions in inline assembly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144829

Files:
  clang/lib/Basic/Targets/BPF.cpp
  clang/lib/Basic/Targets/BPF.h
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp
  llvm/lib/Target/BPF/BPF.td
  llvm/lib/Target/BPF/BPFISelDAGToDAG.cpp
  llvm/lib/Target/BPF/BPFISelLowering.cpp
  llvm/lib/Target/BPF/BPFInstrFormats.td
  llvm/lib/Target/BPF/BPFInstrInfo.td
  llvm/lib/Target/BPF/BPFMIPeephole.cpp
  llvm/lib/Target/BPF/BPFMISimplifyPatchable.cpp
  llvm/lib/Target/BPF/BPFSubtarget.cpp
  llvm/lib/Target/BPF/BPFSubtarget.h
  llvm/lib/Target/BPF/Disassembler/BPFDisassembler.cpp
  llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp
  llvm/lib/Target/BPF/MCTargetDesc/BPFInstPrinter.cpp
  llvm/lib/Target/BPF/MCTargetDesc/BPFMCCodeEmitter.cpp
  llvm/lib/Target/BPF/MCTargetDesc/BPFMCFixups.h
  llvm/lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.cpp
  llvm/test/CodeGen/BPF/bswap.ll
  llvm/test/CodeGen/BPF/sdiv_smod.ll
  llvm/test/CodeGen/BPF/sext_ld.ll
  llvm/test/CodeGen/BPF/sext_mov.ll

Index: llvm/test/CodeGen/BPF/sext_mov.ll
===
--- /dev/null
+++ llvm/test/CodeGen/BPF/sext_mov.ll
@@ -0,0 +1,109 @@
+; RUN: llc -march=bpfel -mcpu=v4 -verify-machineinstrs -show-mc-encoding < %s | FileCheck %s
+; Source:
+;  short f1(int a) {
+;return (char)a;
+;  }
+;  int f2(int a) {
+;return (char)a;
+;  }
+;  long f3(int a) {
+;return (char)a;
+;  }
+;  int f4(int a) {
+;return (short)a;
+;  }
+;  long f5(int a) {
+;return (short)a;
+;  }
+;  long f6(long a) {
+;return (int)a;
+;  }
+; Compilation flags:
+;   clang -target bpf -O2 -S -emit-llvm -Xclang -disable-llvm-passes t.c
+
+; Function Attrs: nounwind
+define dso_local i16 @f1(i32 noundef %a) #0 {
+entry:
+  %a.addr = alloca i32, align 4
+  store i32 %a, ptr %a.addr, align 4, !tbaa !3
+  %0 = load i32, ptr %a.addr, align 4, !tbaa !3
+  %conv = trunc i32 %0 to i8
+  %conv1 = sext i8 %conv to i16
+  ret i16 %conv1
+}
+; CHECK: w0 = (s8)w1  # encoding: [0xbc,0x10,0x08,0x00,0x00,0x00,0x00,0x00]
+
+; Function Attrs: nounwind
+define dso_local i32 @f2(i32 noundef %a) #0 {
+entry:
+  %a.addr = alloca i32, align 4
+  store i32 %a, ptr %a.addr, align 4, !tbaa !3
+  %0 = load i32, ptr %a.addr, align 4, !tbaa !3
+  %conv = trunc i32 %0 to i8
+  %conv1 = sext i8 %conv to i32
+  ret i32 %conv1
+}
+; CHECK: w0 = (s8)w1  # encoding: [0xbc,0x10,0x08,0x00,0x00,0x00,0x00,0x00]
+
+; Function Attrs: nounwind
+define dso_local i64 @f3(i32 noundef %a) #0 {
+entry:
+  %a.addr = alloca i32, align 4
+  store i32 %a, ptr %a.addr, align 4, !tbaa !3
+  %0 = load i32, ptr %a.addr, align 4, !tbaa !3
+  %conv = trunc i32 %0 to i8
+  %conv1 = sext i8 %conv to i64
+  ret i64 %conv1
+}
+; CHECK: r0 = (s8)r1  # encoding: [0xbf,0x10,0x08,0x00,0x00,0x00,0x00,0x00]
+
+; Function Attrs: nounwind
+define dso_local i32 @f4(i32 noundef %a) #0 {
+entry:
+  %a.addr = alloca i32, align 4
+  store i32 %a, ptr %a.addr, align 4, !tbaa !3
+  %0 = load i32, ptr %a.addr, align 4, !tbaa !3
+  %conv = trunc i32 %0 to i16
+  %conv1 = sext i16 %conv to i32
+  ret i32 %conv1
+}
+; CHECK: w0 = (s16)w1  # encoding: [0xbc,0x10,0x10,0x00,0x00,0x00,0x00,0x00]
+
+; Function Attrs: nounwind
+define dso_local i64 @f5(i32 noundef %a) #0 {
+entry:
+  %a.addr = alloca i32, align 4
+  store i32 %a, ptr %a.addr, align 4, !tbaa !3
+  %0 = load i32, ptr %a.addr, align 4, !tbaa !3
+  %conv = trunc i32 %0 to i16
+  %conv1 = sext i16 %conv to i64
+  ret i64 %conv1
+}
+; CHECK: r0 = (s16)r1  # encoding: [0xbf,0x10,0x10,0x00,0x00,0x00,0x00,0x00]
+
+; Function Attrs: nounwind
+define dso_local i64 @f6(i64 noundef %a) #0 {
+entry:
+  %a.addr = alloca i64, align 8
+  store i64 %a, ptr %a.addr, align 8, !tbaa !7
+  %0 = load i64, ptr %a.addr, align 8, !tbaa !7
+  %conv = trunc i64 %0 to i32
+  %conv1 = sext i32 %conv to i64
+  ret i64 %conv1
+}
+; CHECK: r0 = (s32)r1  # encoding: [0xbf,0x10,0x20,0x00,0x00,0x00,0x00,0x00]
+
+attributes #0 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
+
+!llvm.module.flags = !{!0, !1}
+!llvm.ident = !{!2}
+
+!0 = !{i32 1, !"wchar_size", i32 4}
+!1 = !{i32 7, !"frame-pointer", i32 2}
+!2 = !{!"clang version 17.0.0 (https://github.com/llvm/llvm-project.git 569bd3b841e3167ddd7c6ceeddb282d3c280e761)"}
+!3 = !{!4, !4, i64 0}
+!4 = !{!"int", !5, i64 0}
+!5 = !{!"omnipotent char", !6, i64 0}
+!6 = !{!"Simple C/C++ TBAA"}
+!7 = !{!8, !8, i64 0}
+!8 = !{!"long", !5, i64 0}
Index: llvm/test/CodeGen/BPF/sext_ld.ll
===
--- /dev/null
+++ llvm/test/CodeGen/BPF/sext_ld.ll
@@ -0,0 +1,104 @@
+; RUN: llc -march=bpfel -mcpu=v4 -verify-machineinstrs -show-mc-encoding < %s

[PATCH] D153716: [ASTMatchers] Add argumentCountAtLeast narrowing matcher

2023-06-25 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL updated this revision to Diff 534363.
PiotrZSL added a comment.

Rebase + Added change to Registry.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153716

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1640,6 +1640,95 @@
  cxxConversionDecl(isExplicit(;
 }
 
+TEST_P(ASTMatchersTest, ArgumentCountAtLeast_CallExpr) {
+  StatementMatcher Call2PlusArgs = callExpr(argumentCountAtLeast(2));
+
+  EXPECT_TRUE(notMatches("void x(void) { x(); }", Call2PlusArgs));
+  EXPECT_TRUE(notMatches("void x(int) { x(0); }", Call2PlusArgs));
+  EXPECT_TRUE(matches("void x(int, int) { x(0, 0); }", Call2PlusArgs));
+  EXPECT_TRUE(matches("void x(int, int, int) { x(0, 0, 0); }", Call2PlusArgs));
+
+  if (!GetParam().isCXX()) {
+return;
+  }
+
+  EXPECT_TRUE(
+  notMatches("void x(int = 1) { x(); }", traverse(TK_AsIs, Call2PlusArgs)));
+  EXPECT_TRUE(matches("void x(int, int = 1) { x(0); }",
+  traverse(TK_AsIs, Call2PlusArgs)));
+  EXPECT_TRUE(matches("void x(int, int = 1, int = 1) { x(0); }",
+  traverse(TK_AsIs, Call2PlusArgs)));
+  EXPECT_TRUE(matches("void x(int, int, int = 1) { x(0, 0); }",
+  traverse(TK_AsIs, Call2PlusArgs)));
+  EXPECT_TRUE(matches("void x(int, int, int, int = 1) { x(0, 0, 0); }",
+  traverse(TK_AsIs, Call2PlusArgs)));
+
+  EXPECT_TRUE(
+  notMatches("void x(int = 1) { x(); }",
+ traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(
+  notMatches("void x(int, int = 1) { x(0); }",
+ traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(
+  notMatches("void x(int, int = 1, int = 1) { x(0); }",
+ traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(matches("void x(int, int, int = 1) { x(0, 0); }",
+  traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(matches("void x(int, int, int, int = 1) { x(0, 0, 0); }",
+  traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+}
+
+TEST_P(ASTMatchersTest, ArgumentCountAtLeast_CallExpr_CXX) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+
+  StatementMatcher Call2PlusArgs = callExpr(argumentCountAtLeast(2));
+  EXPECT_TRUE(notMatches("class X { void x() { x(); } };", Call2PlusArgs));
+  EXPECT_TRUE(notMatches("class X { void x(int) { x(0); } };", Call2PlusArgs));
+  EXPECT_TRUE(
+  matches("class X { void x(int, int) { x(0, 0); } };", Call2PlusArgs));
+  EXPECT_TRUE(matches("class X { void x(int, int, int) { x(0, 0, 0); } };",
+  Call2PlusArgs));
+
+  EXPECT_TRUE(notMatches("class X { void x(int = 1) { x(0); } };",
+ traverse(TK_AsIs, Call2PlusArgs)));
+  EXPECT_TRUE(matches("class X { void x(int, int = 1) { x(0); } };",
+  traverse(TK_AsIs, Call2PlusArgs)));
+  EXPECT_TRUE(matches("class X { void x(int, int = 1, int = 1) { x(0); } };",
+  traverse(TK_AsIs, Call2PlusArgs)));
+  EXPECT_TRUE(matches("class X { void x(int, int, int = 1) { x(0, 0); } };",
+  traverse(TK_AsIs, Call2PlusArgs)));
+  EXPECT_TRUE(
+  matches("class X { void x(int, int, int, int = 1) { x(0, 0, 0); } };",
+  traverse(TK_AsIs, Call2PlusArgs)));
+
+  EXPECT_TRUE(
+  notMatches("class X { void x(int = 1) { x(0); } };",
+ traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(
+  notMatches("class X { void x(int, int = 1) { x(0); } };",
+ traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(
+  notMatches("class X { void x(int, int = 1, int = 1) { x(0); } };",
+ traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(matches("class X { void x(int, int, int = 1) { x(0, 0); } };",
+  traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(
+  matches("class X { void x(int, int, int, int = 1) { x(0, 0, 0); } };",
+  traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+
+  EXPECT_TRUE(
+  notMatches("class X { static void x() { x(); } };", Call2PlusArgs));
+  EXPECT_TRUE(
+  notMatches("class X { static void x(int) { x(0); } };", Call2PlusArgs));
+  EXPECT_TRUE(matches("class X { static void x(int, int) { x(0, 0); } };",
+  Call2PlusArgs));
+  EXPECT_TRUE(
+  matches("class 

[PATCH] D153707: [Clang][LoongArch] Consume and check -mabi and -mfpu even if -m*-float is present

2023-06-25 Thread WÁNG Xuěruì via Phabricator via cfe-commits
xen0n updated this revision to Diff 534365.
xen0n added a comment.

Address @MaskRay's review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153707

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
  clang/test/Driver/loongarch-mdouble-float.c
  clang/test/Driver/loongarch-msingle-float.c
  clang/test/Driver/loongarch-msoft-float.c

Index: clang/test/Driver/loongarch-msoft-float.c
===
--- clang/test/Driver/loongarch-msoft-float.c
+++ clang/test/Driver/loongarch-msoft-float.c
@@ -1,12 +1,15 @@
 // RUN: %clang --target=loongarch64 -msoft-float -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefix=CC1
+// RUN: %clang --target=loongarch64 -msoft-float -mfpu=0 -mabi=lp64s -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefixes=CC1,NOWARN
 // RUN: %clang --target=loongarch64 -msoft-float -mfpu=64 -mabi=lp64d -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefixes=CC1,WARN
 // RUN: %clang --target=loongarch64 -msoft-float -S -emit-llvm %s -o - | \
 // RUN:   FileCheck %s --check-prefix=IR
 
-// WARN: warning: argument unused during compilation: '-mfpu=64'
-// WARN: warning: argument unused during compilation: '-mabi=lp64d'
+// NOWARN-NOT: warning:
+// WARN: warning: ignoring -mabi value 'lp64d' as it conflicts with that implied by -m*-float (lp64s)
+// WARN: warning: ignoring -mfpu value '64' as it conflicts with that implied by -m*-float (0)
 
 // CC1: "-target-feature" "-f"{{.*}} "-target-feature" "-d"
 // CC1: "-target-abi" "lp64s"
Index: clang/test/Driver/loongarch-msingle-float.c
===
--- clang/test/Driver/loongarch-msingle-float.c
+++ clang/test/Driver/loongarch-msingle-float.c
@@ -1,12 +1,15 @@
 // RUN: %clang --target=loongarch64 -msingle-float -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefix=CC1
+// RUN: %clang --target=loongarch64 -msingle-float -mfpu=32 -mabi=lp64f -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefixes=CC1,NOWARN
 // RUN: %clang --target=loongarch64 -msingle-float -mfpu=0 -mabi=lp64s -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefixes=CC1,WARN
 // RUN: %clang --target=loongarch64 -msingle-float -S -emit-llvm %s -o - | \
 // RUN:   FileCheck %s --check-prefix=IR
 
-// WARN: warning: argument unused during compilation: '-mfpu=0'
-// WARN: warning: argument unused during compilation: '-mabi=lp64s'
+// NOWARN-NOT: warning:
+// WARN: warning: ignoring -mabi value 'lp64s' as it conflicts with that implied by -m*-float (lp64f)
+// WARN: warning: ignoring -mfpu value '0' as it conflicts with that implied by -m*-float (32)
 
 // CC1: "-target-feature" "+f"{{.*}} "-target-feature" "-d"
 // CC1: "-target-abi" "lp64f"
Index: clang/test/Driver/loongarch-mdouble-float.c
===
--- clang/test/Driver/loongarch-mdouble-float.c
+++ clang/test/Driver/loongarch-mdouble-float.c
@@ -1,12 +1,15 @@
 // RUN: %clang --target=loongarch64 -mdouble-float -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefix=CC1
+// RUN: %clang --target=loongarch64 -mdouble-float -mfpu=64 -mabi=lp64d -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefixes=CC1,NOWARN
 // RUN: %clang --target=loongarch64 -mdouble-float -mfpu=0 -mabi=lp64s -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefixes=CC1,WARN
 // RUN: %clang --target=loongarch64 -mdouble-float -S -emit-llvm %s -o - | \
 // RUN:   FileCheck %s --check-prefix=IR
 
-// WARN: warning: argument unused during compilation: '-mfpu=0'
-// WARN: warning: argument unused during compilation: '-mabi=lp64s'
+// NOWARN-NOT: warning:
+// WARN: warning: ignoring -mabi value 'lp64s' as it conflicts with that implied by -m*-float (lp64d)
+// WARN: warning: ignoring -mfpu value '0' as it conflicts with that implied by -m*-float (64)
 
 // CC1: "-target-feature" "+f"{{.*}} "-target-feature" "+d"
 // CC1: "-target-abi" "lp64d"
Index: clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
===
--- clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
+++ clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
@@ -26,32 +26,71 @@
  "Unexpected triple");
   bool IsLA32 = Triple.getArch() == llvm::Triple::loongarch32;
 
+  // Record -mabi value for later use.
+  StringRef MABIValue;
+  if (const Arg *A = Args.getLastArg(options::OPT_mabi_EQ))
+MABIValue = A->getValue();
+
+  // Parse -mfpu value for later use.
+  int FPU = -1;
+  if (const Arg *A = Args.getLastArg(options::OPT_mfpu_EQ)) {
+StringRef V = A->getValue();
+if (V == "64")
+  FPU = 64;
+else if (V == "32")
+  FPU = 32;
+else if (V == "0" || V == "none")
+  FPU = 0;
+e

[PATCH] D153707: [Clang][LoongArch] Consume and check -mabi and -mfpu even if -m*-float is present

2023-06-25 Thread WÁNG Xuěruì via Phabricator via cfe-commits
xen0n marked 2 inline comments as done.
xen0n added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:732
+def warn_drv_loongarch_conflicting_mabi : Warning<
+  "the -mabi setting '%0' conflicts with that implied by -m*-float (%1); using 
%1">,
+  InGroup;

MaskRay wrote:
> This is not called `setting`. Use `value`
> 
> It seems that `ignoring -mabi value '%0' as it conflicts ...` is more 
> conventional.
Sounds reasonable. I've checked other similar diagnostics text and it seems 
your suggestion is stylistically more consistent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153707

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


[clang] b851308 - Revert "[COFF] Support -gsplit-dwarf for COFF on Windows"

2023-06-25 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2023-06-25T14:32:36-04:00
New Revision: b851308b870a67ccb606d0d33f159a70fd3522c7

URL: 
https://github.com/llvm/llvm-project/commit/b851308b870a67ccb606d0d33f159a70fd3522c7
DIFF: 
https://github.com/llvm/llvm-project/commit/b851308b870a67ccb606d0d33f159a70fd3522c7.diff

LOG: Revert "[COFF] Support -gsplit-dwarf for COFF on Windows"

This reverts commit 3eee5aa528abd67bb6d057e25ce1980d0d38c445.

Breaks tests on mac, see https://reviews.llvm.org/D152785#4447118

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/split-debug.c
llvm/include/llvm/MC/MCWinCOFFObjectWriter.h
llvm/lib/MC/MCAsmBackend.cpp
llvm/lib/MC/WinCOFFObjectWriter.cpp

Removed: 
llvm/test/DebugInfo/COFF/dwarf-headers.ll
llvm/test/DebugInfo/COFF/fission-cu.ll
llvm/test/DebugInfo/COFF/fission-sections.ll



diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 77dcef9c73b9e..bb3d487886eb7 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3434,13 +3434,11 @@ defm column_info : BoolOption<"g", "column-info",
   CodeGenOpts<"DebugColumnInfo">, DefaultTrue,
   NegFlag, PosFlag, BothFlags<[CoreOption]>>,
   Group;
-def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group,
-  Flags<[CoreOption]>;
+def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group;
 def gsplit_dwarf_EQ : Joined<["-"], "gsplit-dwarf=">, Group,
-  Flags<[CoreOption]>, HelpText<"Set DWARF fission mode">,
+  HelpText<"Set DWARF fission mode">,
   Values<"split,single">;
-def gno_split_dwarf : Flag<["-"], "gno-split-dwarf">, Group,
-  Flags<[CoreOption]>;
+def gno_split_dwarf : Flag<["-"], "gno-split-dwarf">, Group;
 def gsimple_template_names : Flag<["-"], "gsimple-template-names">, 
Group;
 def gsimple_template_names_EQ
 : Joined<["-"], "gsimple-template-names=">,

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 1580f092bcde0..696db21d97c51 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -3925,13 +3925,12 @@ void Driver::handleArguments(Compilation &C, 
DerivedArgList &Args,
 // `-dumpdir x-` to cc1. If -o is unspecified, use
 // stem(getDefaultImageName()) (usually stem("a.out") = "a").
 if (!Args.hasArg(options::OPT_dumpdir)) {
-  Arg *FinalOutput = Args.getLastArg(options::OPT_o, 
options::OPT__SLASH_o);
   Arg *Arg = Args.MakeSeparateArg(
   nullptr, getOpts().getOption(options::OPT_dumpdir),
-  Args.MakeArgString(
-  (FinalOutput ? FinalOutput->getValue()
-   : llvm::sys::path::stem(getDefaultImageName())) +
-  "-"));
+  Args.MakeArgString(Args.getLastArgValue(
+ options::OPT_o,
+ llvm::sys::path::stem(getDefaultImageName())) 
+
+ "-"));
   Arg->claim();
   Args.append(Arg);
 }

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 82e135012d6c9..de22ea4455fa7 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5647,8 +5647,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // can propagate it to the backend.
   bool SplitDWARF = (DwarfFission != DwarfFissionKind::None) &&
 (TC.getTriple().isOSBinFormatELF() ||
- TC.getTriple().isOSBinFormatWasm() ||
- TC.getTriple().isOSBinFormatCOFF()) &&
+ TC.getTriple().isOSBinFormatWasm()) &&
 (isa(JA) || isa(JA) ||
  isa(JA));
   if (SplitDWARF) {

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 61b26cf1d3d19..4afe3cc1f7a6e 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1278,7 +1278,7 @@ const char *tools::SplitDebugName(const JobAction &JA, 
const ArgList &Args,
   if (const Arg *A = Args.getLastArg(options::OPT_dumpdir)) {
 T = A->getValue();
   } else {
-Arg *FinalOutput = Args.getLastArg(options::OPT_o, options::OPT__SLASH_o);
+Arg *FinalOutput = Args.getLastArg(options::OPT_o);
 if (FinalOutput && Args.hasArg(options::OPT_c)) {
   T = FinalOutput->getValue();
   llvm::sys::path::remove_filename(T);

diff  --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c
index a19f4e1fc3b51..e45d2e19bb81e 100644
--- a/clang/test/Driver/split-debug.c
+++ b/clang/test/Driver/split-debug.c
@@ -16,7 +16,6 @@
 
 // RUN: %clang -### -c -target wasm32 -gsplit-dwarf -g %s 2>&1 | FileCheck %s 
--check-prefix=SPLIT
 // RUN: %clang -### -c

[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-25 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Reverted in b851308b870a67ccb606d0d33f159a70fd3522c7 for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

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


[clang] 2ae8a4a - [ASTMatchers] Add argumentCountAtLeast narrowing matcher

2023-06-25 Thread Piotr Zegar via cfe-commits

Author: Mike Crowe
Date: 2023-06-25T18:41:55Z
New Revision: 2ae8a4a17888f739c1082f52eed56887c2004908

URL: 
https://github.com/llvm/llvm-project/commit/2ae8a4a17888f739c1082f52eed56887c2004908
DIFF: 
https://github.com/llvm/llvm-project/commit/2ae8a4a17888f739c1082f52eed56887c2004908.diff

LOG: [ASTMatchers] Add argumentCountAtLeast narrowing matcher

This will be used by the modernize-use-std-print clang-tidy check and
related checks later.

Reviewed By: PiotrZSL

Differential Revision: https://reviews.llvm.org/D153716

Added: 


Modified: 
clang/docs/LibASTMatchersReference.html
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/lib/ASTMatchers/Dynamic/Registry.cpp
clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Removed: 




diff  --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index 571dfc3f21b81..e6b8c771f1a39 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -3036,6 +3036,18 @@ Narrowing Matchers
 
 
 
+MatcherCXXConstructExpr>argumentCountAtLeastunsigned 
N
+Checks that a 
call expression or a constructor call expression has
+at least the specified number of arguments (including absent default 
arguments).
+
+Example matches f(0, 0) and g(0, 0, 0) (matcher = 
callExpr(argumentCountAtLeast(2)))
+  void f(int x, int y);
+  void g(int x, int y, int z);
+  f(0, 0);
+  g(0, 0, 0);
+
+
+
 MatcherCXXConstructExpr>argumentCountIsunsigned N
 Checks that a call 
expression or a constructor call expression has
 a specific number of arguments (including absent default arguments).
@@ -3693,6 +3705,18 @@ Narrowing Matchers
 
 
 
+MatcherCXXUnresolvedConstructExpr>argumentCountAtLeastunsigned 
N
+Checks that a 
call expression or a constructor call expression has
+at least the specified number of arguments (including absent default 
arguments).
+
+Example matches f(0, 0) and g(0, 0, 0) (matcher = 
callExpr(argumentCountAtLeast(2)))
+  void f(int x, int y);
+  void g(int x, int y, int z);
+  f(0, 0);
+  g(0, 0, 0);
+
+
+
 MatcherCXXUnresolvedConstructExpr>argumentCountIsunsigned N
 Checks that a call 
expression or a constructor call expression has
 a specific number of arguments (including absent default arguments).
@@ -3703,6 +3727,18 @@ Narrowing Matchers
 
 
 
+MatcherCallExpr>argumentCountAtLeastunsigned 
N
+Checks that a 
call expression or a constructor call expression has
+at least the specified number of arguments (including absent default 
arguments).
+
+Example matches f(0, 0) and g(0, 0, 0) (matcher = 
callExpr(argumentCountAtLeast(2)))
+  void f(int x, int y);
+  void g(int x, int y, int z);
+  f(0, 0);
+  g(0, 0, 0);
+
+
+
 MatcherCallExpr>argumentCountIsunsigned N
 Checks that a call 
expression or a constructor call expression has
 a specific number of arguments (including absent default arguments).
@@ -4860,6 +4896,18 @@ Narrowing Matchers
 
 
 
+MatcherObjCMessageExpr>argumentCountAtLeastunsigned 
N
+Checks that a 
call expression or a constructor call expression has
+at least the specified number of arguments (including absent default 
arguments).
+
+Example matches f(0, 0) and g(0, 0, 0) (matcher = 
callExpr(argumentCountAtLeast(2)))
+  void f(int x, int y);
+  void g(int x, int y, int z);
+  f(0, 0);
+  g(0, 0, 0);
+
+
+
 MatcherObjCMessageExpr>argumentCountIsunsigned N
 Checks that a call 
expression or a constructor call expression has
 a specific number of arguments (including absent default arguments).

diff  --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 628533f94a8ae..b698365f949bf 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4431,6 +4431,33 @@ AST_POLYMORPHIC_MATCHER_P(argumentCountIs,
   return NumArgs == N;
 }
 
+/// Checks that a call expression or a constructor call expression has at least
+/// the specified number of arguments (including absent default arguments).
+///
+/// Example matches f(0, 0) and g(0, 0, 0)
+/// (matcher = callExpr(argumentCountAtLeast(2)))
+/// \code
+///   void f(int x, int y);
+///   void g(int x, int y, int z);
+///   f(0, 0);
+///   g(0, 0, 0);
+/// \endcode
+AST_POLYMORPHIC_MATCHER_P(argumentCountAtLeast,
+  AST_POLYMORPHIC_SUPPORTED_TYPES(
+  

[PATCH] D153716: [ASTMatchers] Add argumentCountAtLeast narrowing matcher

2023-06-25 Thread Piotr Zegar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2ae8a4a17888: [ASTMatchers] Add argumentCountAtLeast 
narrowing matcher (authored by mikecrowe, committed by PiotrZSL).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153716

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1640,6 +1640,95 @@
  cxxConversionDecl(isExplicit(;
 }
 
+TEST_P(ASTMatchersTest, ArgumentCountAtLeast_CallExpr) {
+  StatementMatcher Call2PlusArgs = callExpr(argumentCountAtLeast(2));
+
+  EXPECT_TRUE(notMatches("void x(void) { x(); }", Call2PlusArgs));
+  EXPECT_TRUE(notMatches("void x(int) { x(0); }", Call2PlusArgs));
+  EXPECT_TRUE(matches("void x(int, int) { x(0, 0); }", Call2PlusArgs));
+  EXPECT_TRUE(matches("void x(int, int, int) { x(0, 0, 0); }", Call2PlusArgs));
+
+  if (!GetParam().isCXX()) {
+return;
+  }
+
+  EXPECT_TRUE(
+  notMatches("void x(int = 1) { x(); }", traverse(TK_AsIs, Call2PlusArgs)));
+  EXPECT_TRUE(matches("void x(int, int = 1) { x(0); }",
+  traverse(TK_AsIs, Call2PlusArgs)));
+  EXPECT_TRUE(matches("void x(int, int = 1, int = 1) { x(0); }",
+  traverse(TK_AsIs, Call2PlusArgs)));
+  EXPECT_TRUE(matches("void x(int, int, int = 1) { x(0, 0); }",
+  traverse(TK_AsIs, Call2PlusArgs)));
+  EXPECT_TRUE(matches("void x(int, int, int, int = 1) { x(0, 0, 0); }",
+  traverse(TK_AsIs, Call2PlusArgs)));
+
+  EXPECT_TRUE(
+  notMatches("void x(int = 1) { x(); }",
+ traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(
+  notMatches("void x(int, int = 1) { x(0); }",
+ traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(
+  notMatches("void x(int, int = 1, int = 1) { x(0); }",
+ traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(matches("void x(int, int, int = 1) { x(0, 0); }",
+  traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(matches("void x(int, int, int, int = 1) { x(0, 0, 0); }",
+  traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+}
+
+TEST_P(ASTMatchersTest, ArgumentCountAtLeast_CallExpr_CXX) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+
+  StatementMatcher Call2PlusArgs = callExpr(argumentCountAtLeast(2));
+  EXPECT_TRUE(notMatches("class X { void x() { x(); } };", Call2PlusArgs));
+  EXPECT_TRUE(notMatches("class X { void x(int) { x(0); } };", Call2PlusArgs));
+  EXPECT_TRUE(
+  matches("class X { void x(int, int) { x(0, 0); } };", Call2PlusArgs));
+  EXPECT_TRUE(matches("class X { void x(int, int, int) { x(0, 0, 0); } };",
+  Call2PlusArgs));
+
+  EXPECT_TRUE(notMatches("class X { void x(int = 1) { x(0); } };",
+ traverse(TK_AsIs, Call2PlusArgs)));
+  EXPECT_TRUE(matches("class X { void x(int, int = 1) { x(0); } };",
+  traverse(TK_AsIs, Call2PlusArgs)));
+  EXPECT_TRUE(matches("class X { void x(int, int = 1, int = 1) { x(0); } };",
+  traverse(TK_AsIs, Call2PlusArgs)));
+  EXPECT_TRUE(matches("class X { void x(int, int, int = 1) { x(0, 0); } };",
+  traverse(TK_AsIs, Call2PlusArgs)));
+  EXPECT_TRUE(
+  matches("class X { void x(int, int, int, int = 1) { x(0, 0, 0); } };",
+  traverse(TK_AsIs, Call2PlusArgs)));
+
+  EXPECT_TRUE(
+  notMatches("class X { void x(int = 1) { x(0); } };",
+ traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(
+  notMatches("class X { void x(int, int = 1) { x(0); } };",
+ traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(
+  notMatches("class X { void x(int, int = 1, int = 1) { x(0); } };",
+ traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(matches("class X { void x(int, int, int = 1) { x(0, 0); } };",
+  traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+  EXPECT_TRUE(
+  matches("class X { void x(int, int, int, int = 1) { x(0, 0, 0); } };",
+  traverse(TK_IgnoreUnlessSpelledInSource, Call2PlusArgs)));
+
+  EXPECT_TRUE(
+  notMatches("class X { static void x() { x(); } };", Call2PlusArgs));
+  EXPECT_TRUE(
+  notMatches("class X { static void x(int) { x(0); } };", Call2PlusArgs));
+  EXPECT_TRUE(matches("class X { static void x(int, i

[PATCH] D151753: [Clang][Sema] Do not try to analyze dependent alignment during -Wcast-align

2023-06-25 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

Gentle ping :-)


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

https://reviews.llvm.org/D151753

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


[PATCH] D117929: [XRay] Add support for RISCV

2023-06-25 Thread Ashwin Poduval via Phabricator via cfe-commits
ashwin98 added a comment.

In D117929#4445858 , @MaskRay wrote:

> I am still interested in a RISC-V XRay port :)

Sorry - lost track of this, things have been hectic for the last few months, 
but we also seem to have got custom events working with riscv64. Should 
hopefully be able to get back to this by some time in August.


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

https://reviews.llvm.org/D117929

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


[PATCH] D149280: [clang-tidy] Add modernize-printf-to-std-print check

2023-06-25 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This breaks tests on windows: http://45.33.8.238/win/80283/step_8.txt

Please take a look and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149280

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


[PATCH] D149280: [clang-tidy] Add modernize-printf-to-std-print check

2023-06-25 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL reopened this revision.
PiotrZSL added a comment.
This revision is now accepted and ready to land.

@thakis Thank you.




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print.cpp:9-15
+#include 
+#include 
+#include 
+// CHECK-FIXES: #include 
+#include 
+#include 
+#include 

Those includes need to be removed. We cannot use system includes, some dummy 
one can be used only.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149280

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


[PATCH] D149280: [clang-tidy] Add modernize-printf-to-std-print check

2023-06-25 Thread Mike Crowe via Phabricator via cfe-commits
mikecrowe added a comment.

In D149280#4447363 , @thakis wrote:

> This breaks tests on windows: http://45.33.8.238/win/80283/step_8.txt
>
> Please take a look and revert for now if it takes a while to fix.

Thanks for letting me know, I thought I could get away with including 
 from a test since it is a compiler header rather than a libc 
header.

I've added a potential fix, but I don't have a Windows machine (or many other 
targets) to test it on. Is there a way to get this change to run through the 
buildbots without landing it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149280

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


[PATCH] D149280: [clang-tidy] Add modernize-printf-to-std-print check

2023-06-25 Thread Mike Crowe via Phabricator via cfe-commits
mikecrowe marked an inline comment as done.
mikecrowe added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print.cpp:9-15
+#include 
+#include 
+#include 
+// CHECK-FIXES: #include 
+#include 
+#include 
+#include 

PiotrZSL wrote:
> Those includes need to be removed. We cannot use system includes, some dummy 
> one can be used only.
I believe that `` is the only one that isn't present in 
`test/clang-tidy/checkers/Inputs/Headers/`. Hopefully adding it will have been 
sufficient.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149280

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


[PATCH] D151047: [clang-format] Fix indentation for selective formatting.

2023-06-25 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D151047#4396727 , @Sedeniono wrote:

> So, the new patch basically just reverts the original fix of 
> https://reviews.llvm.org/D129064 (i.e. it re-introduces the `resize()` in 
> `LevelIndentTracker::nextLine()`). The other changes are just cosmetics and 
> additional tests.

Perhaps we should have two separate patches: the first one that just reverts 
D129064 , and the second for the new tests. 
That would be much easier to follow, IMO.




Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:104
+  assert(Line.Level < IndentForLevel.size());
+  if ((!Line.First->is(tok::comment) || IndentForLevel[Line.Level] == -1))
+IndentForLevel[Line.Level] = LevelIndent;




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151047

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


[PATCH] D153728: [llvm] Move AttributeMask to a separate header

2023-06-25 Thread Elliot Goodrich via Phabricator via cfe-commits
IncludeGuardian created this revision.
IncludeGuardian added a reviewer: aaron.ballman.
Herald added subscribers: mtrofin, Enna1, ormris, foad, jdoerfert, kerbowa, 
hiraditya, jvesely, arsenm, qcolombet, MatzeB.
Herald added a project: All.
IncludeGuardian requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Move `AttributeMask` out of `llvm/IR/Attributes.h` to a new file
`llvm/IR/AttributeMask.h`.  After doing this we can remove the
`#include ` and `#include ` directives from `Attributes.h`.
Since there are many headers including `Attributes.h`, but not needing
the definition of `AttributeMask`, this causes unnecessary bloating of
the translation units and slows down compilation.

Additionally, the `llvm/ADT/SmallString.h` include directive was not
needed and has been removed.

This commit adds the include directive for `llvm/IR/AttributeMask.h`
to the handful of source files that need to see the definition.

This reduces the total number of preprocessing tokens across the LLVM
source files in lib from (roughly) 1,917,509,187 to 1,902,982,273 - a
reduction of ~0.76%. This should result in a small improvement in
compilation time.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153728

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  llvm/include/llvm/IR/AttributeMask.h
  llvm/include/llvm/IR/Attributes.h
  llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/CodeGen/MLRegallocEvictAdvisor.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/Instruction.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp
  llvm/lib/Target/DirectX/DXILPrepare.cpp
  llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
  llvm/lib/Transforms/IPO/SCCP.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
  llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
  llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
  llvm/tools/llvm-reduce/deltas/ReduceInstructions.cpp
  llvm/unittests/IR/AttributesTest.cpp

Index: llvm/unittests/IR/AttributesTest.cpp
===
--- llvm/unittests/IR/AttributesTest.cpp
+++ llvm/unittests/IR/AttributesTest.cpp
@@ -8,6 +8,7 @@
 
 #include "llvm/IR/Attributes.h"
 #include "llvm/AsmParser/Parser.h"
+#include "llvm/IR/AttributeMask.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/InstrTypes.h"
 #include "llvm/IR/LLVMContext.h"
Index: llvm/tools/llvm-reduce/deltas/ReduceInstructions.cpp
===
--- llvm/tools/llvm-reduce/deltas/ReduceInstructions.cpp
+++ llvm/tools/llvm-reduce/deltas/ReduceInstructions.cpp
@@ -14,6 +14,7 @@
 #include "ReduceInstructions.h"
 #include "Utils.h"
 #include "llvm/IR/Constants.h"
+#include 
 
 using namespace llvm;
 
Index: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
===
--- llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Analysis/Loads.h"
 #include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/Analysis/ValueTracking.h"
+#include "llvm/IR/AttributeMask.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/IRBuilder.h"
Index: llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
===
--- llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
+++ llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
@@ -14,6 +14,7 @@
 #include "llvm/Transforms/Utils/CallPromotionUtils.h"
 #include "llvm/Analysis/Loads.h"
 #include "llvm/Analysis/TypeMetadataUtils.h"
+#include "llvm/IR/AttributeMask.h"
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
Index: llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
===
--- llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -27,6 +27,7 @@
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/IR/Argument.h"
+#include "llvm/IR/AttributeMask.h"
 #include "llvm/IR/Attributes.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/CallingConv.h"
Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -160,6 +160,7 @@
 #include "llvm/Analysis/TargetLibraryInfo.h"
 

[PATCH] D153728: [llvm] Move AttributeMask to a separate header

2023-06-25 Thread Elliot Goodrich via Phabricator via cfe-commits
IncludeGuardian added a comment.

This was found with IncludeGuardian 0.0.8 and the recommendation was given here 
https://gist.github.com/IncludeGuardian/4132d5149576a55e0560fae6f8ff4a38#file-before-yaml-L4053-L4055

The estimates of token count were run before and after this commit and can be 
seen here before.yaml (1,917,509,187) 

  and after.yaml (1,902,982,273) 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153728

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


[PATCH] D149280: [clang-tidy] Add modernize-printf-to-std-print check

2023-06-25 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

None i know of, but given the bot's already red, you won't make it worse :)

Tests shouldn't include any headers generally, not even inttypes.h (unless the 
test tests that header).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149280

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


[PATCH] D153131: [clang analysis][thread-safety] Handle return-by-reference...

2023-06-25 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticGroups.td:1046
 def ThreadSafetyPrecise: DiagGroup<"thread-safety-precise">;
 def ThreadSafetyReference  : DiagGroup<"thread-safety-reference">;
+def ThreadSafetyReturn : DiagGroup<"thread-safety-return">;

courbet wrote:
> aaronpuchert wrote:
> > Why not under `-Wthread-safety-reference`, as it's return-by-reference that 
> > you're warning on? This seems too small for a separate flag to me.
> The main reason it so that we provide a soft transition period for users: If 
> we put that in `-Wthread-safety-reference`, we'll start breaking compile for 
> people who use `-Werror`, while a separate flag allows a transition period 
> where people opt into the new feature.
Transition flags can end up resulting in more churn, assuming that we 
eventually want to put this under `-Wthread-safety-reference`, because then you 
have two categories of users:
* those that opted in will eventually have to remove the flag again, and
* those that didn't will get hard errors on updating the compiler at that point.
Of course you might argue that the latter case can be prevented by carefully 
reading the release notes, but we know how often that happens.

I'd argue that if you're using `-Wthread-safety-reference`, you're already 
opting into warnings on escaping references, and not warning on `return` is a 
false negative.

A separate flag would make sense to me if we want to keep it, for example 
because this produces a substantial amount of false positives under some 
circumstances. Did you try this on a larger code base that's using the 
annotations? I could try it on our code, and maybe we can get some Googler to 
test it on theirs, which is also heavily using Thread Safety Analysis. (Though 
I'm not sure whether they use `-Wthread-safety-reference`.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153131

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


[PATCH] D148131: Avoid unnecessarily aggressive line-breaking when using "LambdaBodyIndentation: OuterScope" with argument bin-packing.

2023-06-25 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D148131#4304960 , @jp4a50 wrote:

> Hey @MyDeveloperDay @owenpan . I'd appreciate if you guys have time to 
> consider this change. It's the last significant issue my team and I are 
> tracking that's blocking our adoption of clang-format for multiple codebases 
> that use KJ 
>  :)

We probably should fix https://github.com/llvm/llvm-project/issues/44486 first.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148131

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


[PATCH] D153092: [Clang][CodeGen]`vtable`, `typeinfo` et al. are globals

2023-06-25 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx updated this revision to Diff 534380.
AlexVlx added a comment.

Fixed issue found via internal testing (thanks @yaxunl).


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

https://reviews.llvm.org/D153092

Files:
  clang/lib/CodeGen/CGVTT.cpp
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/vtable-align-address-space.cpp
  clang/test/CodeGenCXX/vtable-assume-load-address-space.cpp
  clang/test/CodeGenCXX/vtable-consteval-address-space.cpp
  clang/test/CodeGenCXX/vtable-constexpr-address-space.cpp
  clang/test/CodeGenCXX/vtable-key-function-address-space.cpp
  clang/test/CodeGenCXX/vtable-layout-extreme-address-space.cpp
  clang/test/CodeGenCXX/vtable-linkage-address-space.cpp
  clang/test/CodeGenCXX/vtable-pointer-initialization-address-space.cpp
  clang/test/CodeGenCXX/vtt-address-space.cpp
  clang/test/CodeGenCXX/vtt-layout-address-space.cpp
  clang/test/Headers/hip-header.hip

Index: clang/test/Headers/hip-header.hip
===
--- clang/test/Headers/hip-header.hip
+++ clang/test/Headers/hip-header.hip
@@ -60,9 +60,8 @@
 __device__ void test_vf() {
 derived d;
 }
-// CHECK: @_ZTV7derived = linkonce_odr unnamed_addr addrspace(1) constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr null, ptr @_ZN7derived2pvEv, ptr @__cxa_deleted_virtual] }, comdat, align 8
-// CHECK: @_ZTV4base = linkonce_odr unnamed_addr addrspace(1) constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr null, ptr @__cxa_pure_virtual, ptr @__cxa_deleted_virtual] }, comdat, align 8
-
+// CHECK: @_ZTV7derived = linkonce_odr unnamed_addr addrspace(1) constant { [4 x ptr addrspace(1)] } { [4 x ptr addrspace(1)] [ptr addrspace(1) null, ptr addrspace(1) null, ptr addrspace(1) addrspacecast (ptr @_ZN7derived2pvEv to ptr addrspace(1)), ptr addrspace(1) addrspacecast (ptr @__cxa_deleted_virtual to ptr addrspace(1))] }, comdat, align 8
+// CHECK: @_ZTV4base = linkonce_odr unnamed_addr addrspace(1) constant { [4 x ptr addrspace(1)] } { [4 x ptr addrspace(1)] [ptr addrspace(1) null, ptr addrspace(1) null, ptr addrspace(1) addrspacecast (ptr @__cxa_pure_virtual to ptr addrspace(1)), ptr addrspace(1) addrspacecast (ptr @__cxa_deleted_virtual to ptr addrspace(1))] }, comdat, align 8
 // CHECK: define{{.*}}void @__cxa_pure_virtual()
 // CHECK: define{{.*}}void @__cxa_deleted_virtual()
 
Index: clang/test/CodeGenCXX/vtt-layout-address-space.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/vtt-layout-address-space.cpp
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -std=c++11 -emit-llvm -o - | FileCheck %s
+
+// Test1::B should just have a single entry in its VTT, which points to the vtable.
+namespace Test1 {
+struct A { };
+
+struct B : virtual A {
+  virtual void f();
+};
+
+void B::f() { }
+}
+
+// Check that we don't add a secondary virtual pointer for Test2::A, since Test2::A doesn't have any virtual member functions or bases.
+namespace Test2 {
+  struct A { };
+
+  struct B : A { virtual void f(); };
+  struct C : virtual B { };
+
+  C c;
+}
+
+// This is the sample from the C++ Itanium ABI, p2.6.2.
+namespace Test3 {
+  class A1 { int i; };
+  class A2 { int i; virtual void f(); };
+  class V1 : public A1, public A2 { int i; };
+  class B1 { int i; };
+  class B2 { int i; };
+  class V2 : public B1, public B2, public virtual V1 { int i; };
+  class V3 {virtual void g(); };
+  class C1 : public virtual V1 { int i; };
+  class C2 : public virtual V3, virtual V2 { int i; };
+  class X1 { int i; };
+  class C3 : public X1 { int i; };
+  class D : public C1, public C2, public C3 { int i;  };
+
+  D d;
+}
+
+// This is the sample from the C++ Itanium ABI, p2.6.2, with the change suggested
+// (making A2 a virtual base of V1)
+namespace Test4 {
+  class A1 { int i; };
+  class A2 { int i; virtual void f(); };
+  class V1 : public A1, public virtual A2 { int i; };
+  class B1 { int i; };
+  class B2 { int i; };
+  class V2 : public B1, public B2, public virtual V1 { int i; };
+  class V3 {virtual void g(); };
+  class C1 : public virtual V1 { int i; };
+  class C2 : public virtual V3, virtual V2 { int i; };
+  class X1 { int i; };
+  class C3 : public X1 { int i; };
+  class D : public C1, public C2, public C3 { int i;  };
+
+  D d;
+}
+
+namespace Test5 {
+  struct A {
+virtual void f() = 0;
+virtual void anchor();
+  };
+
+  void A::anchor() {
+  }
+}
+
+namespace Test6 {
+  struct A {
+virtual void f() = delete;
+virtual void anchor();
+  };
+
+  void A::anchor() {
+  }
+}
+
+// CHECK: @_ZTTN5Test11BE ={{.*}} unnamed_addr addrspace(1) constant [1 x ptr addrspace(1)] [ptr addrspace(1) getelementptr inbounds ({ [4 x ptr addrspace(1)] }, ptr addrspace(1) @_ZTVN5Test11BE, i32 0, inrange i32 0, i32 3)]
+// CHECK: @_ZTVN5Test51AE ={{.*}} unnamed_addr addrspace(1) constant { [4 x ptr addrspace(1)] } { 

[PATCH] D153724: [clang] Fix a crash on invalid destructor

2023-06-25 Thread Younan Zhang via Phabricator via cfe-commits
zyounan updated this revision to Diff 534386.
zyounan added a comment.

Simplify test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153724

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/virtuals.cpp


Index: clang/test/SemaCXX/virtuals.cpp
===
--- clang/test/SemaCXX/virtuals.cpp
+++ clang/test/SemaCXX/virtuals.cpp
@@ -52,6 +52,18 @@
   };
 }
 
+namespace issue63503 {
+struct Base {
+  virtual ~Base() = default;
+};
+
+struct Derived final : Base {
+  virtual ~Derived() = defaul; // #62
+} do_not_crash;
+// expected-error@#62 {{initializer on function does not look like a 
pure-specifier}}
+// expected-error@#62 {{use of undeclared identifier 'defaul'}}
+}
+
 namespace VirtualFriend {
   // DR (filed but no number yet): reject meaningless pure-specifier on a 
friend declaration.
   struct A { virtual int f(); };
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -15807,7 +15807,11 @@
 return;
 
   CXXDestructorDecl *Destructor = LookupDestructor(ClassDecl);
-
+  // The result of `LookupDestructor` might be nullptr if the destructor is
+  // invalid, in which case it is marked as `IneligibleOrNotSelected` and
+  // will not be selected by `CXXRecordDecl::getDestructor()`.
+  if (!Destructor)
+return;
   // If this is an array, we'll require the destructor during initialization, 
so
   // we can skip over this. We still want to emit exit-time destructor warnings
   // though.
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -469,7 +469,7 @@
 - Fix crash when redefining a variable with an invalid type again with an
   invalid type. (`#62447 `_)
 - Fix a stack overflow issue when evaluating ``consteval`` default arguments.
-  (`#60082` `_)
+  (`#60082 `_)
 - Fix the assertion hit when generating code for global variable initializer of
   _BitInt(1) type.
   (`#62207 `_)
@@ -521,21 +521,23 @@
   (`#50534 `_).
 - CallExpr built for C error-recovery now is always type-dependent. Fixes a
   crash when we encounter a unresolved TypoExpr during diagnostic emission.
-  (`#50244 _`).
+  (`#50244 `_).
 - Apply ``-fmacro-prefix-map`` to anonymous tags in template arguments
   (`#63219 `_).
 - Clang now properly diagnoses format string mismatches involving scoped
   enumeration types. A scoped enumeration type is not promoted to an integer
   type by the default argument promotions, and thus this is UB. Clang's
   behavior now matches GCC's behavior in C++.
-  (`#38717 _`).
+  (`#38717 `_).
 - Fixed a failing assertion when implicitly defining a function within a GNU
   statement expression that appears outside of a function block scope. The
   assertion was benign outside of asserts builds and would only fire in C.
-  (`#48579 _`).
+  (`#48579 `_).
 - Fixed a failing assertion when applying an attribute to an anonymous union.
   The assertion was benign outside of asserts builds and would only fire in 
C++.
-  (`#48512 _`).
+  (`#48512 `_).
+- Fixed a failing assertion when parsing incomplete destructor.
+  (`#63503 `_)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaCXX/virtuals.cpp
===
--- clang/test/SemaCXX/virtuals.cpp
+++ clang/test/SemaCXX/virtuals.cpp
@@ -52,6 +52,18 @@
   };
 }
 
+namespace issue63503 {
+struct Base {
+  virtual ~Base() = default;
+};
+
+struct Derived final : Base {
+  virtual ~Derived() = defaul; // #62
+} do_not_crash;
+// expected-error@#62 {{initializer on function does not look like a pure-specifier}}
+// expected-error@#62 {{use of undeclared identifier 'defaul'}}
+}
+
 namespace VirtualFriend {
   // DR (filed but no number yet): reject meaningless pure-specifier on a friend declaration.
   struct A { virtual int f(); };
Index: clang/lib/Sema/SemaDeclCXX.cpp
==

[PATCH] D153724: [clang] Fix a crash on invalid destructor

2023-06-25 Thread Younan Zhang via Phabricator via cfe-commits
zyounan updated this revision to Diff 534387.
zyounan added a comment.

.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153724

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/virtuals.cpp


Index: clang/test/SemaCXX/virtuals.cpp
===
--- clang/test/SemaCXX/virtuals.cpp
+++ clang/test/SemaCXX/virtuals.cpp
@@ -52,6 +52,18 @@
   };
 }
 
+namespace issue63503 {
+struct Base {
+  virtual ~Base() = default;
+};
+
+struct Derived final : Base {
+  virtual ~Derived() = defaul; // #default
+} do_not_crash;
+// expected-error@#default {{initializer on function does not look like a 
pure-specifier}}
+// expected-error@#default {{use of undeclared identifier 'defaul'}}
+}
+
 namespace VirtualFriend {
   // DR (filed but no number yet): reject meaningless pure-specifier on a 
friend declaration.
   struct A { virtual int f(); };
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -15807,7 +15807,11 @@
 return;
 
   CXXDestructorDecl *Destructor = LookupDestructor(ClassDecl);
-
+  // The result of `LookupDestructor` might be nullptr if the destructor is
+  // invalid, in which case it is marked as `IneligibleOrNotSelected` and
+  // will not be selected by `CXXRecordDecl::getDestructor()`.
+  if (!Destructor)
+return;
   // If this is an array, we'll require the destructor during initialization, 
so
   // we can skip over this. We still want to emit exit-time destructor warnings
   // though.
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -469,7 +469,7 @@
 - Fix crash when redefining a variable with an invalid type again with an
   invalid type. (`#62447 `_)
 - Fix a stack overflow issue when evaluating ``consteval`` default arguments.
-  (`#60082` `_)
+  (`#60082 `_)
 - Fix the assertion hit when generating code for global variable initializer of
   _BitInt(1) type.
   (`#62207 `_)
@@ -521,21 +521,23 @@
   (`#50534 `_).
 - CallExpr built for C error-recovery now is always type-dependent. Fixes a
   crash when we encounter a unresolved TypoExpr during diagnostic emission.
-  (`#50244 _`).
+  (`#50244 `_).
 - Apply ``-fmacro-prefix-map`` to anonymous tags in template arguments
   (`#63219 `_).
 - Clang now properly diagnoses format string mismatches involving scoped
   enumeration types. A scoped enumeration type is not promoted to an integer
   type by the default argument promotions, and thus this is UB. Clang's
   behavior now matches GCC's behavior in C++.
-  (`#38717 _`).
+  (`#38717 `_).
 - Fixed a failing assertion when implicitly defining a function within a GNU
   statement expression that appears outside of a function block scope. The
   assertion was benign outside of asserts builds and would only fire in C.
-  (`#48579 _`).
+  (`#48579 `_).
 - Fixed a failing assertion when applying an attribute to an anonymous union.
   The assertion was benign outside of asserts builds and would only fire in 
C++.
-  (`#48512 _`).
+  (`#48512 `_).
+- Fixed a failing assertion when parsing incomplete destructor.
+  (`#63503 `_)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaCXX/virtuals.cpp
===
--- clang/test/SemaCXX/virtuals.cpp
+++ clang/test/SemaCXX/virtuals.cpp
@@ -52,6 +52,18 @@
   };
 }
 
+namespace issue63503 {
+struct Base {
+  virtual ~Base() = default;
+};
+
+struct Derived final : Base {
+  virtual ~Derived() = defaul; // #default
+} do_not_crash;
+// expected-error@#default {{initializer on function does not look like a pure-specifier}}
+// expected-error@#default {{use of undeclared identifier 'defaul'}}
+}
+
 namespace VirtualFriend {
   // DR (filed but no number yet): reject meaningless pure-specifier on a friend declaration.
   struct A { virtual int f(); };
Index: clang/lib/Sema/SemaDeclCXX.cpp
=

[PATCH] D153724: [clang] Fix a crash on invalid destructor

2023-06-25 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.
This revision is now accepted and ready to land.

Make sense to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153724

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


[clang] 76d72a7 - [clang] Fix a crash on invalid destructor

2023-06-25 Thread Younan Zhang via cfe-commits

Author: Younan Zhang
Date: 2023-06-26T09:35:12+08:00
New Revision: 76d72a715038ae3bce711ddc372e7e273a5c2b6b

URL: 
https://github.com/llvm/llvm-project/commit/76d72a715038ae3bce711ddc372e7e273a5c2b6b
DIFF: 
https://github.com/llvm/llvm-project/commit/76d72a715038ae3bce711ddc372e7e273a5c2b6b.diff

LOG: [clang] Fix a crash on invalid destructor

This is a follow-up patch to D126194 in order to
fix https://github.com/llvm/llvm-project/issues/63503.

Reviewed By: shafik

Differential Revision: https://reviews.llvm.org/D153724

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaCXX/virtuals.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 43f80bddce3ff..13c587228bb1e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -471,7 +471,7 @@ Bug Fixes in This Version
 - Fix crash when redefining a variable with an invalid type again with an
   invalid type. (`#62447 `_)
 - Fix a stack overflow issue when evaluating ``consteval`` default arguments.
-  (`#60082` `_)
+  (`#60082 `_)
 - Fix the assertion hit when generating code for global variable initializer of
   _BitInt(1) type.
   (`#62207 `_)
@@ -523,21 +523,23 @@ Bug Fixes in This Version
   (`#50534 `_).
 - CallExpr built for C error-recovery now is always type-dependent. Fixes a
   crash when we encounter a unresolved TypoExpr during diagnostic emission.
-  (`#50244 _`).
+  (`#50244 `_).
 - Apply ``-fmacro-prefix-map`` to anonymous tags in template arguments
   (`#63219 `_).
 - Clang now properly diagnoses format string mismatches involving scoped
   enumeration types. A scoped enumeration type is not promoted to an integer
   type by the default argument promotions, and thus this is UB. Clang's
   behavior now matches GCC's behavior in C++.
-  (`#38717 _`).
+  (`#38717 `_).
 - Fixed a failing assertion when implicitly defining a function within a GNU
   statement expression that appears outside of a function block scope. The
   assertion was benign outside of asserts builds and would only fire in C.
-  (`#48579 _`).
+  (`#48579 `_).
 - Fixed a failing assertion when applying an attribute to an anonymous union.
   The assertion was benign outside of asserts builds and would only fire in 
C++.
-  (`#48512 _`).
+  (`#48512 `_).
+- Fixed a failing assertion when parsing incomplete destructor.
+  (`#63503 `_)
 
 Bug Fixes to Compiler Builtins
 ^^

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 1b4beec2e93b7..1222e4330a6e9 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -15807,7 +15807,11 @@ void Sema::FinalizeVarWithDestructor(VarDecl *VD, 
const RecordType *Record) {
 return;
 
   CXXDestructorDecl *Destructor = LookupDestructor(ClassDecl);
-
+  // The result of `LookupDestructor` might be nullptr if the destructor is
+  // invalid, in which case it is marked as `IneligibleOrNotSelected` and
+  // will not be selected by `CXXRecordDecl::getDestructor()`.
+  if (!Destructor)
+return;
   // If this is an array, we'll require the destructor during initialization, 
so
   // we can skip over this. We still want to emit exit-time destructor warnings
   // though.

diff  --git a/clang/test/SemaCXX/virtuals.cpp b/clang/test/SemaCXX/virtuals.cpp
index f8180745bd3ba..2a22ab9fc2b09 100644
--- a/clang/test/SemaCXX/virtuals.cpp
+++ b/clang/test/SemaCXX/virtuals.cpp
@@ -52,6 +52,18 @@ namespace pr8264 {
   };
 }
 
+namespace issue63503 {
+struct Base {
+  virtual ~Base() = default;
+};
+
+struct Derived final : Base {
+  virtual ~Derived() = defaul; // #default
+} do_not_crash;
+// expected-error@#default {{initializer on function does not look like a 
pure-specifier}}
+// expected-error@#default {{use of undeclared identifier 'defaul'}}
+}
+
 namespace VirtualFriend {
   // DR (filed but no number yet): reject meaningless pure-specifier on a 
friend declaration.
   struct A { virtual int f(); };



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
ht

[PATCH] D153724: [clang] Fix a crash on invalid destructor

2023-06-25 Thread Younan Zhang via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG76d72a715038: [clang] Fix a crash on invalid destructor 
(authored by zyounan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153724

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/virtuals.cpp


Index: clang/test/SemaCXX/virtuals.cpp
===
--- clang/test/SemaCXX/virtuals.cpp
+++ clang/test/SemaCXX/virtuals.cpp
@@ -52,6 +52,18 @@
   };
 }
 
+namespace issue63503 {
+struct Base {
+  virtual ~Base() = default;
+};
+
+struct Derived final : Base {
+  virtual ~Derived() = defaul; // #default
+} do_not_crash;
+// expected-error@#default {{initializer on function does not look like a 
pure-specifier}}
+// expected-error@#default {{use of undeclared identifier 'defaul'}}
+}
+
 namespace VirtualFriend {
   // DR (filed but no number yet): reject meaningless pure-specifier on a 
friend declaration.
   struct A { virtual int f(); };
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -15807,7 +15807,11 @@
 return;
 
   CXXDestructorDecl *Destructor = LookupDestructor(ClassDecl);
-
+  // The result of `LookupDestructor` might be nullptr if the destructor is
+  // invalid, in which case it is marked as `IneligibleOrNotSelected` and
+  // will not be selected by `CXXRecordDecl::getDestructor()`.
+  if (!Destructor)
+return;
   // If this is an array, we'll require the destructor during initialization, 
so
   // we can skip over this. We still want to emit exit-time destructor warnings
   // though.
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -471,7 +471,7 @@
 - Fix crash when redefining a variable with an invalid type again with an
   invalid type. (`#62447 `_)
 - Fix a stack overflow issue when evaluating ``consteval`` default arguments.
-  (`#60082` `_)
+  (`#60082 `_)
 - Fix the assertion hit when generating code for global variable initializer of
   _BitInt(1) type.
   (`#62207 `_)
@@ -523,21 +523,23 @@
   (`#50534 `_).
 - CallExpr built for C error-recovery now is always type-dependent. Fixes a
   crash when we encounter a unresolved TypoExpr during diagnostic emission.
-  (`#50244 _`).
+  (`#50244 `_).
 - Apply ``-fmacro-prefix-map`` to anonymous tags in template arguments
   (`#63219 `_).
 - Clang now properly diagnoses format string mismatches involving scoped
   enumeration types. A scoped enumeration type is not promoted to an integer
   type by the default argument promotions, and thus this is UB. Clang's
   behavior now matches GCC's behavior in C++.
-  (`#38717 _`).
+  (`#38717 `_).
 - Fixed a failing assertion when implicitly defining a function within a GNU
   statement expression that appears outside of a function block scope. The
   assertion was benign outside of asserts builds and would only fire in C.
-  (`#48579 _`).
+  (`#48579 `_).
 - Fixed a failing assertion when applying an attribute to an anonymous union.
   The assertion was benign outside of asserts builds and would only fire in 
C++.
-  (`#48512 _`).
+  (`#48512 `_).
+- Fixed a failing assertion when parsing incomplete destructor.
+  (`#63503 `_)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaCXX/virtuals.cpp
===
--- clang/test/SemaCXX/virtuals.cpp
+++ clang/test/SemaCXX/virtuals.cpp
@@ -52,6 +52,18 @@
   };
 }
 
+namespace issue63503 {
+struct Base {
+  virtual ~Base() = default;
+};
+
+struct Derived final : Base {
+  virtual ~Derived() = defaul; // #default
+} do_not_crash;
+// expected-error@#default {{initializer on function does not look like a pure-specifier}}
+// expected-error@#default {{use of undeclared identifier 'defaul'}}
+}
+
 namespace VirtualFriend {
   // DR (filed but no num

[PATCH] D152671: [doc][LoongArch] Add missed release note about `ual` feature addition

2023-06-25 Thread Lu Weining via Phabricator via cfe-commits
SixWeining added inline comments.



Comment at: llvm/docs/ReleaseNotes.rst:163
 * The ``lp64s`` ABI is supported now and has been tested on Rust bare-matal 
target.
+* An target feature ``ual`` is introduced to allow unaligned memory accesses 
and
+  this feature is enabled by default on generic 64bit processors.

xen0n wrote:
> nit: "A" (the following sound is not a vowel)
Thanks. I will modify it later.



Comment at: llvm/docs/ReleaseNotes.rst:164
+* An target feature ``ual`` is introduced to allow unaligned memory accesses 
and
+  this feature is enabled by default on generic 64bit processors.
 

MaskRay wrote:
> xen0n wrote:
> > nit: "for generic 64-bit"
> > 
> > Here "for" (compared to "on") is to signify it's controlled by target 
> > instead of host spec.
> Target feature is internal and mentioning it in release notes may be 
> excessive (if we do, there are too many to enumerate ...). I think we can 
> omit mentioning the target feature. Focusing on the behavior about the 
> user-facing `-m[no-]unaligned-access` is more useful.
I think it depends on the different users we are targeting. Command line 
options like `-m[no-]unaligned-access` are targeting clang users while target 
features are targeting llvm users.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152671

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


[PATCH] D152671: [doc][LoongArch] Add missed release note about `ual` feature addition

2023-06-25 Thread Lu Weining via Phabricator via cfe-commits
SixWeining updated this revision to Diff 534404.
SixWeining added a comment.

Address xen0n's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152671

Files:
  clang/docs/ReleaseNotes.rst
  llvm/docs/ReleaseNotes.rst


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -173,6 +173,8 @@
 
 
 * The ``lp64s`` ABI is supported now and has been tested on Rust bare-matal 
target.
+* A target feature ``ual`` is introduced to allow unaligned memory accesses and
+  this feature is enabled by default for generic 64-bit processors.
 
 Changes to the MIPS Backend
 ---
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -678,6 +678,8 @@
 
 - Patchable function entry (``-fpatchable-function-entry``) is now supported
   on LoongArch.
+- Unaligned memory accesses can be toggled by ``-m[no-]unaligned-access`` or 
the
+  aliases ``-m[no-]strict-align``.
 
 RISC-V Support
 ^^


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -173,6 +173,8 @@
 
 
 * The ``lp64s`` ABI is supported now and has been tested on Rust bare-matal target.
+* A target feature ``ual`` is introduced to allow unaligned memory accesses and
+  this feature is enabled by default for generic 64-bit processors.
 
 Changes to the MIPS Backend
 ---
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -678,6 +678,8 @@
 
 - Patchable function entry (``-fpatchable-function-entry``) is now supported
   on LoongArch.
+- Unaligned memory accesses can be toggled by ``-m[no-]unaligned-access`` or the
+  aliases ``-m[no-]strict-align``.
 
 RISC-V Support
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153542: [C++20][Modules] Implement P2615R1 exported specialization diagnostics.

2023-06-25 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11275-11278
+def err_export_partial_specialization : Error<
+  "partial %select{class|variable}0 specialization %1 cannot be exported">;
+def err_export_explicit_specialization : Error<
+  "explicit specialization %0 cannot be exported">;

According to #[dcl.pre] in 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2615r1.html, the 
export for explicit instantiation is also allowed.



Comment at: clang/lib/Sema/SemaModule.cpp:831-832
 
+  if (isa(D) ||
+  isa(D)) {
+// C++20 [module.interface]p1:

nit



Comment at: clang/lib/Sema/SemaModule.cpp:834
+// C++20 [module.interface]p1:
+//   [...] shall not declare a partial specialization.
+int Kind = isa(D) ? 0 : 1;

nit



Comment at: clang/lib/Sema/SemaModule.cpp:836
+int Kind = isa(D) ? 0 : 1;
+auto *ND = dyn_cast(D);
+S.Diag(ND->getLocation(), diag::err_export_partial_specialization)





Comment at: clang/lib/Sema/SemaModule.cpp:845-846
+//   export-declaration.
+bool BadExport = isa(ND) ||
+ isa(ND);
+if (auto *FD = dyn_cast(D)) {





Comment at: clang/lib/Sema/SemaModule.cpp:847-848
+ isa(ND);
+if (auto *FD = dyn_cast(D)) {
+  if (FD->getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
+BadExport = true;

nit



Comment at: clang/lib/Sema/SemaModule.cpp:848-849
+if (auto *FD = dyn_cast(D)) {
+  if (FD->getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
+BadExport = true;
+} else if (auto *VD = dyn_cast(D)) {

Given P2615R1 doesn't allow explicit-instantiation in export block too.



Comment at: clang/lib/Sema/SemaModule.cpp:851
+} else if (auto *VD = dyn_cast(D)) {
+  if (VD->getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
+BadExport = true;

ditto



Comment at: clang/test/CXX/temp/temp.explicit/p2-p2615r1.cpp:20
+int C;  // expected-error {{explicit specialization 'C' cannot be 
exported}}
+

Let's add another case for explicit instantiation.



Comment at: clang/test/Modules/merge-var-template-spec-cxx-modules.cppm:35-36
-};
-export template <> constexpr Int zero = {0};
-export template  constexpr T* zero = nullptr;
-

It should be good enough to remove the "export" in the template specialization.



Comment at: clang/test/Modules/pr59780.cppm:18-19
-
-export template<>
-int x = 0;
-

It should be good to remove the "export" in the template specialization.



Comment at: clang/test/Modules/pr60890.cppm:21
 
-export template struct a;
-

The specialization is meaningful here to test the serializer/deserializer can 
handle the merge well. It is OK to remove the `export` here in this patch and 
I'll try to update the tests to make its semantics more clear.



Comment at: clang/test/Modules/pr62796.cppm:42-43
-
-template constexpr unsigned long Cache<10ul>;
 }
 

In case it is not allowed to **export** the explicit instantiations, we should 
move it out of the export block instead of removing it.



Comment at: clang/test/Modules/template-function-specialization.cpp:42
 
-export template <>
-void foo4() {

ditto



Comment at: clang/unittests/Serialization/VarDeclConstantInitTest.cpp:89
 
-  template constexpr unsigned long Cache<10ul>;
 }

Same as above, in this case we should move it instead of removing it.



Comment at: clang/unittests/Serialization/VarDeclConstantInitTest.cpp:118
 import Fibonacci.Cache;
+template constexpr unsigned long Fibonacci::Cache<10ul>;
 )cpp",

We don't need this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153542

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


[PATCH] D153542: [C++20][Modules] Implement P2615R1 exported specialization diagnostics.

2023-06-25 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

BTW, since this will break existing code. Let's mention this in ReleaseNotes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153542

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


[PATCH] D151625: [clang] Add `clang::equality_operator_compares_members_lexicographically`

2023-06-25 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik added a comment.

@aaron.ballman Do you have any opinion here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151625

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


[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

2023-06-25 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/lib/Serialization/ASTWriterDecl.cpp:2043
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
-  Abv->Add(BitCodeAbbrevOp(0));   // StorageKind
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsPlaceholder
+  Abv->Add(BitCodeAbbrevOp(0)); // StorageKind

In case `IsPlaceholder` must be 0 when use the abbreviation for FieldDecl, it 
is better to use `Abv->Add(BitCodeAbbrevOp(0));` here.



Comment at: clang/lib/Serialization/ASTWriterDecl.cpp:2077
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isMutable
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsPlaceholder
   Abv->Add(BitCodeAbbrevOp(0));   // InitStyle

ditto



Comment at: clang/lib/Serialization/ASTWriterDecl.cpp:2233
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isARCPseudoStrong
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsPlaceholder
   Abv->Add(BitCodeAbbrevOp(0));   // Linkage

ditto



Comment at: clang/lib/Serialization/ASTWriterDecl.cpp:2311
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isARCPseudoStrong
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsPlaceholder
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // 
IsThisDeclarationADemotedDefinition

ditto.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153536

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


[clang] d0a32b0 - [doc][LoongArch] Add missed release note about `ual` feature addition

2023-06-25 Thread Weining Lu via cfe-commits

Author: Weining Lu
Date: 2023-06-26T10:37:29+08:00
New Revision: d0a32b0273b9e5d881417cc668e944e35e55c845

URL: 
https://github.com/llvm/llvm-project/commit/d0a32b0273b9e5d881417cc668e944e35e55c845
DIFF: 
https://github.com/llvm/llvm-project/commit/d0a32b0273b9e5d881417cc668e944e35e55c845.diff

LOG: [doc][LoongArch] Add missed release note about `ual` feature addition

I meant to fold this into 47601815ec3a4f31c797c75748af08acfabc46dc
but failed to do so.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D152671

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
llvm/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 13c587228bb1e..da2e7ac47553e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -682,6 +682,8 @@ LoongArch Support
 
 - Patchable function entry (``-fpatchable-function-entry``) is now supported
   on LoongArch.
+- Unaligned memory accesses can be toggled by ``-m[no-]unaligned-access`` or 
the
+  aliases ``-m[no-]strict-align``.
 
 RISC-V Support
 ^^

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 6efc991ff509e..3e070b2ebdfa1 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -173,6 +173,8 @@ Changes to the LoongArch Backend
 
 
 * The ``lp64s`` ABI is supported now and has been tested on Rust bare-matal 
target.
+* A target feature ``ual`` is introduced to allow unaligned memory accesses and
+  this feature is enabled by default for generic 64-bit processors.
 
 Changes to the MIPS Backend
 ---



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


[PATCH] D152671: [doc][LoongArch] Add missed release note about `ual` feature addition

2023-06-25 Thread Lu Weining via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd0a32b0273b9: [doc][LoongArch] Add missed release note about 
`ual` feature addition (authored by SixWeining).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152671

Files:
  clang/docs/ReleaseNotes.rst
  llvm/docs/ReleaseNotes.rst


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -173,6 +173,8 @@
 
 
 * The ``lp64s`` ABI is supported now and has been tested on Rust bare-matal 
target.
+* A target feature ``ual`` is introduced to allow unaligned memory accesses and
+  this feature is enabled by default for generic 64-bit processors.
 
 Changes to the MIPS Backend
 ---
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -682,6 +682,8 @@
 
 - Patchable function entry (``-fpatchable-function-entry``) is now supported
   on LoongArch.
+- Unaligned memory accesses can be toggled by ``-m[no-]unaligned-access`` or 
the
+  aliases ``-m[no-]strict-align``.
 
 RISC-V Support
 ^^


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -173,6 +173,8 @@
 
 
 * The ``lp64s`` ABI is supported now and has been tested on Rust bare-matal target.
+* A target feature ``ual`` is introduced to allow unaligned memory accesses and
+  this feature is enabled by default for generic 64-bit processors.
 
 Changes to the MIPS Backend
 ---
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -682,6 +682,8 @@
 
 - Patchable function entry (``-fpatchable-function-entry``) is now supported
   on LoongArch.
+- Unaligned memory accesses can be toggled by ``-m[no-]unaligned-access`` or the
+  aliases ``-m[no-]strict-align``.
 
 RISC-V Support
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-25 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen reopened this revision.
HaohaiWen added a comment.
This revision is now accepted and ready to land.

The path of this test you were running 
(/Users/thakis/src/llvm-project/clang/test/Driver/split-debug.c) started with 
/User which was interpreted as OPT_U option. Therefore split-debug.c haven't 
been treated as input file.
I'll add -- to tests to force clang-cl treat it as input file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

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


[PATCH] D153737: [clang] __is_trivially_equality_comparable should return false for arrays

2023-06-25 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik created this revision.
Herald added a project: All.
philnik requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When comparing two arrays, their pointers are compared instead of their 
elements, which menas that they are not trivially equality comparable


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153737

Files:
  clang/lib/AST/Type.cpp
  clang/test/SemaCXX/type-traits.cpp


Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -3110,7 +3110,7 @@
 static_assert(!__is_trivially_equality_comparable(void), "");
 static_assert(__is_trivially_equality_comparable(int), "");
 static_assert(!__is_trivially_equality_comparable(int[]), "");
-static_assert(__is_trivially_equality_comparable(int[3]), "");
+static_assert(!__is_trivially_equality_comparable(int[3]), "");
 static_assert(!__is_trivially_equality_comparable(float), "");
 static_assert(!__is_trivially_equality_comparable(double), "");
 static_assert(!__is_trivially_equality_comparable(long double), "");
@@ -3134,6 +3134,13 @@
 };
 static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparable), 
"");
 
+struct TriviallyEqualityComparableContainsArray {
+  int a[4];
+
+  bool operator==(const TriviallyEqualityComparableContainsArray&) const = 
default;
+};
+static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparableContainsArray));
+
 struct TriviallyEqualityComparableNonTriviallyCopyable {
   TriviallyEqualityComparableNonTriviallyCopyable(const 
TriviallyEqualityComparableNonTriviallyCopyable&);
   ~TriviallyEqualityComparableNonTriviallyCopyable();
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2684,7 +2684,7 @@
 const ASTContext &Context) const {
   QualType CanonicalType = getCanonicalType();
   if (CanonicalType->isIncompleteType() || CanonicalType->isDependentType() ||
-  CanonicalType->isEnumeralType())
+  CanonicalType->isEnumeralType() || CanonicalType->isArrayType())
 return false;
 
   if (const auto *RD = CanonicalType->getAsCXXRecordDecl()) {


Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -3110,7 +3110,7 @@
 static_assert(!__is_trivially_equality_comparable(void), "");
 static_assert(__is_trivially_equality_comparable(int), "");
 static_assert(!__is_trivially_equality_comparable(int[]), "");
-static_assert(__is_trivially_equality_comparable(int[3]), "");
+static_assert(!__is_trivially_equality_comparable(int[3]), "");
 static_assert(!__is_trivially_equality_comparable(float), "");
 static_assert(!__is_trivially_equality_comparable(double), "");
 static_assert(!__is_trivially_equality_comparable(long double), "");
@@ -3134,6 +3134,13 @@
 };
 static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparable), "");
 
+struct TriviallyEqualityComparableContainsArray {
+  int a[4];
+
+  bool operator==(const TriviallyEqualityComparableContainsArray&) const = default;
+};
+static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparableContainsArray));
+
 struct TriviallyEqualityComparableNonTriviallyCopyable {
   TriviallyEqualityComparableNonTriviallyCopyable(const TriviallyEqualityComparableNonTriviallyCopyable&);
   ~TriviallyEqualityComparableNonTriviallyCopyable();
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2684,7 +2684,7 @@
 const ASTContext &Context) const {
   QualType CanonicalType = getCanonicalType();
   if (CanonicalType->isIncompleteType() || CanonicalType->isDependentType() ||
-  CanonicalType->isEnumeralType())
+  CanonicalType->isEnumeralType() || CanonicalType->isArrayType())
 return false;
 
   if (const auto *RD = CanonicalType->getAsCXXRecordDecl()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-25 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen updated this revision to Diff 534413.
HaohaiWen edited the summary of this revision.
HaohaiWen added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/split-debug.c
  llvm/include/llvm/MC/MCWinCOFFObjectWriter.h
  llvm/lib/MC/MCAsmBackend.cpp
  llvm/lib/MC/WinCOFFObjectWriter.cpp
  llvm/test/DebugInfo/COFF/dwarf-headers.ll
  llvm/test/DebugInfo/COFF/fission-cu.ll
  llvm/test/DebugInfo/COFF/fission-sections.ll

Index: llvm/test/DebugInfo/COFF/fission-sections.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-sections.ll
@@ -0,0 +1,42 @@
+; RUN: llc -split-dwarf-file=baz.dwo -split-dwarf-output=%t.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t.dwo | FileCheck --check-prefix=DWO %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+; But it checks that the output objects have the expected sections
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+!6 = !{!0}
+!7 = !{i32 1, !"Debug Info Version", i32 3}
+
+; CHECK-LABEL: Sections:
+
+; OBJ: Idx Name
+; OBJ-NEXT:  0 .text
+; OBJ-NEXT:  1 .data
+; OBJ-NEXT:  2 .bss
+; OBJ-NEXT:  3 .debug_abbrev
+; OBJ-NEXT:  4 .debug_info
+; OBJ-NEXT:  5 .debug_str
+; OBJ-NEXT:  6 .debug_addr
+; OBJ-NEXT:  7 .debug_pubnames
+; OBJ-NEXT:  8 .debug_pubtypes
+; OBJ-NEXT:  9 .debug_line
+
+; DWO:  Idx Name
+; DWO-NEXT:   0 .debug_str.dwo
+; DWO-NEXT:   1 .debug_str_offsets.dwo
+; DWO-NEXT:   2 .debug_info.dwo
+; DWO-NEXT:   3 .debug_abbrev.dwo
Index: llvm/test/DebugInfo/COFF/fission-cu.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-cu.ll
@@ -0,0 +1,120 @@
+; RUN: llc -split-dwarf-file=baz.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-dwarfdump -v -all %t | FileCheck %s
+; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=HDR %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+; Check that the skeleton compile unit contains the proper attributes:
+; This DIE has the following attributes: DW_AT_comp_dir, DW_AT_stmt_list,
+; DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_dwo_name, DW_AT_dwo_id,
+; DW_AT_ranges_base, DW_AT_addr_base.
+
+; CHECK: .debug_abbrev contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_no
+; CHECK: DW_AT_stmt_list DW_FORM_sec_offset
+; CHECK: DW_AT_comp_dir  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_idDW_FORM_data8
+
+; Check that we're using the right forms.
+; CHECK: .debug_abbrev.dwo contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_yes
+; CHECK: DW_AT_producer  DW_FORM_GNU_str_index
+; CHECK: DW_AT_language  DW_FORM_data2
+; CHECK: DW_AT_name  DW_FORM_GNU_str_index
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_GNU_str_index
+; CHECK-NOT: DW_AT_low_pc
+; CHECK-NOT: DW_AT_stmt_list
+; CHECK-NOT: DW_AT_comp_dir
+; CHECK: DW_AT_GNU_dwo_idDW_FORM_data8

[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-25 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen updated this revision to Diff 534417.
HaohaiWen added a comment.

Add -- to clang_cl input file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/split-debug.c
  llvm/include/llvm/MC/MCWinCOFFObjectWriter.h
  llvm/lib/MC/MCAsmBackend.cpp
  llvm/lib/MC/WinCOFFObjectWriter.cpp
  llvm/test/DebugInfo/COFF/dwarf-headers.ll
  llvm/test/DebugInfo/COFF/fission-cu.ll
  llvm/test/DebugInfo/COFF/fission-sections.ll

Index: llvm/test/DebugInfo/COFF/fission-sections.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-sections.ll
@@ -0,0 +1,42 @@
+; RUN: llc -split-dwarf-file=baz.dwo -split-dwarf-output=%t.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t.dwo | FileCheck --check-prefix=DWO %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+; But it checks that the output objects have the expected sections
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+!6 = !{!0}
+!7 = !{i32 1, !"Debug Info Version", i32 3}
+
+; CHECK-LABEL: Sections:
+
+; OBJ: Idx Name
+; OBJ-NEXT:  0 .text
+; OBJ-NEXT:  1 .data
+; OBJ-NEXT:  2 .bss
+; OBJ-NEXT:  3 .debug_abbrev
+; OBJ-NEXT:  4 .debug_info
+; OBJ-NEXT:  5 .debug_str
+; OBJ-NEXT:  6 .debug_addr
+; OBJ-NEXT:  7 .debug_pubnames
+; OBJ-NEXT:  8 .debug_pubtypes
+; OBJ-NEXT:  9 .debug_line
+
+; DWO:  Idx Name
+; DWO-NEXT:   0 .debug_str.dwo
+; DWO-NEXT:   1 .debug_str_offsets.dwo
+; DWO-NEXT:   2 .debug_info.dwo
+; DWO-NEXT:   3 .debug_abbrev.dwo
Index: llvm/test/DebugInfo/COFF/fission-cu.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-cu.ll
@@ -0,0 +1,120 @@
+; RUN: llc -split-dwarf-file=baz.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-dwarfdump -v -all %t | FileCheck %s
+; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=HDR %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+; Check that the skeleton compile unit contains the proper attributes:
+; This DIE has the following attributes: DW_AT_comp_dir, DW_AT_stmt_list,
+; DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_dwo_name, DW_AT_dwo_id,
+; DW_AT_ranges_base, DW_AT_addr_base.
+
+; CHECK: .debug_abbrev contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_no
+; CHECK: DW_AT_stmt_list DW_FORM_sec_offset
+; CHECK: DW_AT_comp_dir  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_idDW_FORM_data8
+
+; Check that we're using the right forms.
+; CHECK: .debug_abbrev.dwo contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_yes
+; CHECK: DW_AT_producer  DW_FORM_GNU_str_index
+; CHECK: DW_AT_language  DW_FORM_data2
+; CHECK: DW_AT_name  DW_FORM_GNU_str_index
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_GNU_str_index
+; CHECK-NOT: DW_AT_low_pc
+; CHECK-NOT: DW_AT_stmt_list
+; CHECK-NOT: DW_AT_comp_dir
+; CHECK: DW_AT_GNU_dwo_idDW_FORM_data8
+
+; CHECK: [2] DW_TAG_

[PATCH] D153707: [Clang][LoongArch] Consume and check -mabi and -mfpu even if -m*-float is present

2023-06-25 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:732
+def warn_drv_loongarch_conflicting_mabi : Warning<
+  "ignoring -mabi value '%0' as it conflicts with that implied by -m*-float 
(%1)">,
+  InGroup;

You can make `-mabi`/`-mfpu` an argument as well so that we can create just one 
`def`.
It would be good to expand `-m*-float`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153707

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


[PATCH] D129635: [OpenMP] Update the default version of OpenMP to 5.1

2023-06-25 Thread Animesh Kumar via Phabricator via cfe-commits
animeshk-amd added a comment.

In D129635#4442580 , @h-vetinari 
wrote:

> In D129635#4440613 , @animeshk-amd 
> wrote:
>
>> In the multi-company community meeting, the agreement was to move to the 5.1 
>> version assuming that these features are supported.
>
> We shouldn't need to assume - either the features are supported or not. I 
> thought the status page would be the right place for this information, but 
> perhaps it is out of date? Whoever the openmp stakeholders are here should 
> ensure this information is correct and up-to-date!
>
> I mean, I'm sure the participants in that meeting know the situation much 
> better than I do, but from what's visible from the outside, it looks unusual 
> to default to something that's not yet fully implemented (for all the usual 
> reasons: assuming there are mistakes found in the not-yet-complete 
> implementation of 5.1, you'll then have to break your users to fix it, 
> whereas until this PR, it was an explicit choice of the consumer to use the 
> not-yet-fully-supported 5.1; it's also unusual in the way that a user will 
> get an error for using features that aren't implemented yet, despite being 
> able to see that the default is 5.1)

I understand your concerns. However, I would like to point out that the various 
stakeholders involved in this community meeting are well aware of the default 
version update and its consequences as it was discussed well throughout an 
year. Regarding status page, I agree that the individual contributors for 
respective features should be responsible for updating the page.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129635

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


[clang] 612b7e1 - [RISCV] Change the type of argument to clz and ctz from ZiZi/WiWi to iUZi/iUWi

2023-06-25 Thread Jim Lin via cfe-commits

Author: Jim Lin
Date: 2023-06-26T13:15:37+08:00
New Revision: 612b7e10a9afa797d41e134bc62a8ef87a014caf

URL: 
https://github.com/llvm/llvm-project/commit/612b7e10a9afa797d41e134bc62a8ef87a014caf
DIFF: 
https://github.com/llvm/llvm-project/commit/612b7e10a9afa797d41e134bc62a8ef87a014caf.diff

LOG: [RISCV] Change the type of argument to clz and ctz from ZiZi/WiWi to 
iUZi/iUWi

Input argument of clz and ctz should be unsigned type and return value
should be integer like `builtin_clz` and `builtin_ctz` defined in 
clang/include/clang/Basic/Builtins.def.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D153235

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsRISCV.def
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsRISCV.def 
b/clang/include/clang/Basic/BuiltinsRISCV.def
index a1a32f0a3e4ef..7f84be42faf40 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.def
+++ b/clang/include/clang/Basic/BuiltinsRISCV.def
@@ -18,10 +18,10 @@
 // Zbb extension
 TARGET_BUILTIN(__builtin_riscv_orc_b_32, "ZiZi", "nc", "zbb")
 TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", "zbb,64bit")
-TARGET_BUILTIN(__builtin_riscv_clz_32, "ZiZi", "nc", "zbb|xtheadbb")
-TARGET_BUILTIN(__builtin_riscv_clz_64, "WiWi", "nc", "zbb|xtheadbb,64bit")
-TARGET_BUILTIN(__builtin_riscv_ctz_32, "ZiZi", "nc", "zbb")
-TARGET_BUILTIN(__builtin_riscv_ctz_64, "WiWi", "nc", "zbb,64bit")
+TARGET_BUILTIN(__builtin_riscv_clz_32, "iUZi", "nc", "zbb|xtheadbb")
+TARGET_BUILTIN(__builtin_riscv_clz_64, "iUWi", "nc", "zbb|xtheadbb,64bit")
+TARGET_BUILTIN(__builtin_riscv_ctz_32, "iUZi", "nc", "zbb")
+TARGET_BUILTIN(__builtin_riscv_ctz_64, "iUWi", "nc", "zbb,64bit")
 
 // Zbc or Zbkc extension
 TARGET_BUILTIN(__builtin_riscv_clmul, "LiLiLi", "nc", "zbc|zbkc")

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
index 329f9ec52a0ce..4129457fcd073 100644
--- a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
@@ -22,7 +22,7 @@ int orc_b_32(int a) {
 // RV32ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.ctlz.i32(i32 [[TMP0]], i1 
false)
 // RV32ZBB-NEXT:ret i32 [[TMP1]]
 //
-int clz_32(int a) {
+int clz_32(unsigned int a) {
   return __builtin_riscv_clz_32(a);
 }
 
@@ -34,6 +34,6 @@ int clz_32(int a) {
 // RV32ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.cttz.i32(i32 [[TMP0]], i1 
false)
 // RV32ZBB-NEXT:ret i32 [[TMP1]]
 //
-int ctz_32(int a) {
+int ctz_32(unsigned int a) {
   return __builtin_riscv_ctz_32(a);
 }
\ No newline at end of file

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
index 0133cb1ec202d..baf7de1e0b9f1 100644
--- a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
@@ -34,19 +34,22 @@ long orc_b_64(long a) {
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.ctlz.i32(i32 [[TMP0]], i1 
false)
 // RV64ZBB-NEXT:ret i32 [[TMP1]]
 //
-int clz_32(int a) {
+int clz_32(unsigned int a) {
   return __builtin_riscv_clz_32(a);
 }
 
 // RV64ZBB-LABEL: @clz_64(
 // RV64ZBB-NEXT:  entry:
+// RV64ZBB-NEXT:[[RETVAL:%.*]] = alloca i32, align 4
 // RV64ZBB-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8
 // RV64ZBB-NEXT:store i64 [[A:%.*]], ptr [[A_ADDR]], align 8
 // RV64ZBB-NEXT:[[TMP0:%.*]] = load i64, ptr [[A_ADDR]], align 8
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i64 @llvm.ctlz.i64(i64 [[TMP0]], i1 
false)
-// RV64ZBB-NEXT:ret i64 [[TMP1]]
+// RV64ZBB-NEXT:store i64 [[TMP1]], ptr [[RETVAL]], align 4
+// RV64ZBB-NEXT:[[TMP2:%.*]] = load i32, ptr [[RETVAL]], align 4
+// RV64ZBB-NEXT:ret i32 [[TMP2]]
 //
-long clz_64(long a) {
+int clz_64(unsigned long a) {
   return __builtin_riscv_clz_64(a);
 }
 
@@ -58,18 +61,21 @@ long clz_64(long a) {
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.cttz.i32(i32 [[TMP0]], i1 
false)
 // RV64ZBB-NEXT:ret i32 [[TMP1]]
 //
-int ctz_32(int a) {
+int ctz_32(unsigned int a) {
   return __builtin_riscv_ctz_32(a);
 }
 
 // RV64ZBB-LABEL: @ctz_64(
 // RV64ZBB-NEXT:  entry:
+// RV64ZBB-NEXT:[[RETVAL:%.*]] = alloca i32, align 4
 // RV64ZBB-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8
 // RV64ZBB-NEXT:store i64 [[A:%.*]], ptr [[A_ADDR]], align 8
 // RV64ZBB-NEXT:[[TMP0:%.*]] = load i64, ptr [[A_ADDR]], align 8
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i64 @llvm.cttz.i64(i64 [[TMP0]], i1 
false)
-// RV64ZBB-NEXT:ret i64 [[TMP1]]
+// RV64ZBB-NEXT:store i64 [[TMP1]], ptr [[RETVAL]], align 4
+// RV64ZBB-NEXT:[[TMP2:%.*]] = load i32, ptr [[RETVAL]], align 4
+// RV64ZBB-NEXT:ret i32 [[TMP2]]
 //
-long ctz_64(long a) {
+int ctz_64(unsigned long a) {

[PATCH] D153235: [RISCV] Change the type of argument to clz and ctz from ZiZi/WiWi to iUZi/iUWi

2023-06-25 Thread Jim Lin via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG612b7e10a9af: [RISCV] Change the type of argument to clz and 
ctz from ZiZi/WiWi to iUZi/iUWi (authored by Jim).

Changed prior to commit:
  https://reviews.llvm.org/D153235?vs=532790&id=534425#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153235

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c


Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
@@ -34,19 +34,22 @@
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.ctlz.i32(i32 [[TMP0]], i1 
false)
 // RV64ZBB-NEXT:ret i32 [[TMP1]]
 //
-int clz_32(int a) {
+int clz_32(unsigned int a) {
   return __builtin_riscv_clz_32(a);
 }
 
 // RV64ZBB-LABEL: @clz_64(
 // RV64ZBB-NEXT:  entry:
+// RV64ZBB-NEXT:[[RETVAL:%.*]] = alloca i32, align 4
 // RV64ZBB-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8
 // RV64ZBB-NEXT:store i64 [[A:%.*]], ptr [[A_ADDR]], align 8
 // RV64ZBB-NEXT:[[TMP0:%.*]] = load i64, ptr [[A_ADDR]], align 8
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i64 @llvm.ctlz.i64(i64 [[TMP0]], i1 
false)
-// RV64ZBB-NEXT:ret i64 [[TMP1]]
+// RV64ZBB-NEXT:store i64 [[TMP1]], ptr [[RETVAL]], align 4
+// RV64ZBB-NEXT:[[TMP2:%.*]] = load i32, ptr [[RETVAL]], align 4
+// RV64ZBB-NEXT:ret i32 [[TMP2]]
 //
-long clz_64(long a) {
+int clz_64(unsigned long a) {
   return __builtin_riscv_clz_64(a);
 }
 
@@ -58,18 +61,21 @@
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.cttz.i32(i32 [[TMP0]], i1 
false)
 // RV64ZBB-NEXT:ret i32 [[TMP1]]
 //
-int ctz_32(int a) {
+int ctz_32(unsigned int a) {
   return __builtin_riscv_ctz_32(a);
 }
 
 // RV64ZBB-LABEL: @ctz_64(
 // RV64ZBB-NEXT:  entry:
+// RV64ZBB-NEXT:[[RETVAL:%.*]] = alloca i32, align 4
 // RV64ZBB-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8
 // RV64ZBB-NEXT:store i64 [[A:%.*]], ptr [[A_ADDR]], align 8
 // RV64ZBB-NEXT:[[TMP0:%.*]] = load i64, ptr [[A_ADDR]], align 8
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i64 @llvm.cttz.i64(i64 [[TMP0]], i1 
false)
-// RV64ZBB-NEXT:ret i64 [[TMP1]]
+// RV64ZBB-NEXT:store i64 [[TMP1]], ptr [[RETVAL]], align 4
+// RV64ZBB-NEXT:[[TMP2:%.*]] = load i32, ptr [[RETVAL]], align 4
+// RV64ZBB-NEXT:ret i32 [[TMP2]]
 //
-long ctz_64(long a) {
+int ctz_64(unsigned long a) {
   return __builtin_riscv_ctz_64(a);
 }
\ No newline at end of file
Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
@@ -22,7 +22,7 @@
 // RV32ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.ctlz.i32(i32 [[TMP0]], i1 
false)
 // RV32ZBB-NEXT:ret i32 [[TMP1]]
 //
-int clz_32(int a) {
+int clz_32(unsigned int a) {
   return __builtin_riscv_clz_32(a);
 }
 
@@ -34,6 +34,6 @@
 // RV32ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.cttz.i32(i32 [[TMP0]], i1 
false)
 // RV32ZBB-NEXT:ret i32 [[TMP1]]
 //
-int ctz_32(int a) {
+int ctz_32(unsigned int a) {
   return __builtin_riscv_ctz_32(a);
 }
\ No newline at end of file
Index: clang/include/clang/Basic/BuiltinsRISCV.def
===
--- clang/include/clang/Basic/BuiltinsRISCV.def
+++ clang/include/clang/Basic/BuiltinsRISCV.def
@@ -18,10 +18,10 @@
 // Zbb extension
 TARGET_BUILTIN(__builtin_riscv_orc_b_32, "ZiZi", "nc", "zbb")
 TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", "zbb,64bit")
-TARGET_BUILTIN(__builtin_riscv_clz_32, "ZiZi", "nc", "zbb|xtheadbb")
-TARGET_BUILTIN(__builtin_riscv_clz_64, "WiWi", "nc", "zbb|xtheadbb,64bit")
-TARGET_BUILTIN(__builtin_riscv_ctz_32, "ZiZi", "nc", "zbb")
-TARGET_BUILTIN(__builtin_riscv_ctz_64, "WiWi", "nc", "zbb,64bit")
+TARGET_BUILTIN(__builtin_riscv_clz_32, "iUZi", "nc", "zbb|xtheadbb")
+TARGET_BUILTIN(__builtin_riscv_clz_64, "iUWi", "nc", "zbb|xtheadbb,64bit")
+TARGET_BUILTIN(__builtin_riscv_ctz_32, "iUZi", "nc", "zbb")
+TARGET_BUILTIN(__builtin_riscv_ctz_64, "iUWi", "nc", "zbb,64bit")
 
 // Zbc or Zbkc extension
 TARGET_BUILTIN(__builtin_riscv_clmul, "LiLiLi", "nc", "zbc|zbkc")


Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
@@ -34,19 +34,22 @@
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.ctlz.i32(i32 [[TMP0]], i1 false)
 // RV64ZBB-NEXT:ret i32 [[TMP1]]
 //
-int clz_32(int a) {

[PATCH] D153738: Add LibClang guide

2023-06-25 Thread Manuel via Phabricator via cfe-commits
manuel5975p created this revision.
manuel5975p added a reviewer: aaron.ballman.
manuel5975p added projects: clang, clang-c.
Herald added a project: All.
manuel5975p requested review of this revision.
Herald added a subscriber: cfe-commits.

Add a libclang .rst file with some code examples, going over the most important 
types and functions of libclang.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153738

Files:
  clang/docs/LibClang.rst

Index: clang/docs/LibClang.rst
===
--- /dev/null
+++ clang/docs/LibClang.rst
@@ -0,0 +1,344 @@
+.. role:: raw-html(raw)
+:format: html
+
+Libclang tutorial
+
+The C Interface to Clang provides a relatively small API that exposes facilities for parsing source code into an abstract syntax tree (AST), loading already-parsed ASTs, traversing the AST, associating physical source locations with elements within the AST, and other facilities that support Clang-based development tools.
+This C interface to Clang will never provide all of the information representation stored in Clang's C++ AST, nor should it: the intent is to maintain an API that is relatively stable from one release to the next, providing only the basic functionality needed to support development tools.
+The entire C interface of libclang is available in the file `Index.h`_
+
+Essential types overview
+-
+
+All types of libclang are prefixed with ``CX``
+
+CXIndex
+~~~
+An Index that consists of a set of translation units that would typically be linked together into an executable or library.
+
+CXTranslationUnit
+~
+A single translation unit, which resides in an index.
+
+CXCursor
+~
+A cursor representing a pointer to some element in the abstract syntax tree of a translation unit.
+
+
+Code example
+
+
+.. code-block:: cpp
+  
+  // file.hpp
+  struct foo{
+int bar;
+int* bar_pointer;
+  };
+.. code-block:: cpp
+  
+  #include 
+  #include 
+
+  int main(){
+CXIndex index = clang_createIndex(0, 0); //Create index
+CXTranslationUnit unit = clang_parseTranslationUnit(
+  index,
+  "file.hpp", nullptr, 0,
+  nullptr, 0,
+  CXTranslationUnit_None); //Parse "file.hpp"
+
+
+if (unit == nullptr){
+  std::cerr << "Unable to parse translation unit. Quitting.\n";
+  return 0;
+}
+CXCursor cursor = clang_getTranslationUnitCursor(unit); //Obtain a cursor at the root of the translation unit
+  }
+
+Visiting elements of an AST
+~~~
+The elements of an AST can be recursively visited with pre-order traversal with ``clang_visitChildren``.
+
+.. code-block:: cpp
+
+  clang_visitChildren(
+cursor, //Root cursor
+[](CXCursor current_cursor, CXCursor parent, CXClientData client_data){
+
+  CXString current_display_name = clang_getCursorDisplayName(current_cursor); 
+  //Allocate a CXString representing the name of the current cursor
+  
+  std::cout << "Visiting element " << clang_getCString(current_display_name) << "\n";
+  //Print the char* value of current_display_name
+
+  clang_disposeString(current_display_name);
+  //Since clang_getCursorDisplayName allocates a new CXString, it must be freed. This applies
+  //to all functions returning a CXString
+
+  return CXChildVisit_Recurse;
+
+
+}, //CXCursorVisitor: a function pointer
+nullptr //client_data
+);
+
+The return value of ``CXCursorVisitor``, the callable argument of ``clang_visitChildren``, can return of of the three:
+
+#. ``CXChildVisit_Break``: Terminates the cursor traversal
+
+#. ``CXChildVisit_Continue``: Continues the cursor traversal with the next sibling of the cursor just visited, without visiting its children.
+
+#. ``CXChildVisit_Recurse``: Recursively traverse the children of this cursor, using the same visitor and client data
+
+The expected output of that program is
+
+.. code-block:: 
+
+  Visiting element foo
+  Visiting element bar
+  Visiting element bar_pointer
+
+
+Extracting information from a Cursor
+
+.. The following functions take a ``CXCursor`` as an argument and return associated information.
+
+
+
+Extracting the Cursor kind
+""
+
+``CXCursorKind clang_getCursorKind(CXCursor)`` Describes the kind of entity that a cursor refers to. Example values:
+  
+- ``CXCursor_StructDecl``: A C or C++ struct.
+- ``CXCursor_FieldDecl``: A field in a struct, union, or C++ class.
+- ``CXCursor_CallExpr``: An expression that calls a function
+
+
+Extracting the Cursor type
+""
+``CXType clang_getCursorType(CXCursor)``: Retrieve the type of a CXCursor (if any).
+
+``CXType`` is a struct with two members:
+
+.. code-block:: cpp
+
+  typedef struct {
+enum CXTypeKind kind;
+void *data[2];
+  } CXType;
+
+Example values for ``CXTypeKind kind``
+
+- ``CXType_I

[PATCH] D153707: [Clang][LoongArch] Consume and check -mabi and -mfpu even if -m*-float is present

2023-06-25 Thread WÁNG Xuěruì via Phabricator via cfe-commits
xen0n updated this revision to Diff 534427.
xen0n marked an inline comment as done.
xen0n added a comment.

Unify the diagnostic messages and show the actual `-m*-float` option being 
passed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153707

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
  clang/test/Driver/loongarch-mdouble-float.c
  clang/test/Driver/loongarch-msingle-float.c
  clang/test/Driver/loongarch-msoft-float.c

Index: clang/test/Driver/loongarch-msoft-float.c
===
--- clang/test/Driver/loongarch-msoft-float.c
+++ clang/test/Driver/loongarch-msoft-float.c
@@ -1,12 +1,15 @@
 // RUN: %clang --target=loongarch64 -msoft-float -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefix=CC1
+// RUN: %clang --target=loongarch64 -msoft-float -mfpu=0 -mabi=lp64s -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefixes=CC1,NOWARN
 // RUN: %clang --target=loongarch64 -msoft-float -mfpu=64 -mabi=lp64d -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefixes=CC1,WARN
 // RUN: %clang --target=loongarch64 -msoft-float -S -emit-llvm %s -o - | \
 // RUN:   FileCheck %s --check-prefix=IR
 
-// WARN: warning: argument unused during compilation: '-mfpu=64'
-// WARN: warning: argument unused during compilation: '-mabi=lp64d'
+// NOWARN-NOT: warning:
+// WARN: warning: ignoring '-mabi=' value 'lp64d' as it conflicts with that implied by '-msoft-float' (lp64s)
+// WARN: warning: ignoring '-mfpu=' value '64' as it conflicts with that implied by '-msoft-float' (0)
 
 // CC1: "-target-feature" "-f"{{.*}} "-target-feature" "-d"
 // CC1: "-target-abi" "lp64s"
Index: clang/test/Driver/loongarch-msingle-float.c
===
--- clang/test/Driver/loongarch-msingle-float.c
+++ clang/test/Driver/loongarch-msingle-float.c
@@ -1,12 +1,15 @@
 // RUN: %clang --target=loongarch64 -msingle-float -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefix=CC1
+// RUN: %clang --target=loongarch64 -msingle-float -mfpu=32 -mabi=lp64f -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefixes=CC1,NOWARN
 // RUN: %clang --target=loongarch64 -msingle-float -mfpu=0 -mabi=lp64s -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefixes=CC1,WARN
 // RUN: %clang --target=loongarch64 -msingle-float -S -emit-llvm %s -o - | \
 // RUN:   FileCheck %s --check-prefix=IR
 
-// WARN: warning: argument unused during compilation: '-mfpu=0'
-// WARN: warning: argument unused during compilation: '-mabi=lp64s'
+// NOWARN-NOT: warning:
+// WARN: warning: ignoring '-mabi=' value 'lp64s' as it conflicts with that implied by '-msingle-float' (lp64f)
+// WARN: warning: ignoring '-mfpu=' value '0' as it conflicts with that implied by '-msingle-float' (32)
 
 // CC1: "-target-feature" "+f"{{.*}} "-target-feature" "-d"
 // CC1: "-target-abi" "lp64f"
Index: clang/test/Driver/loongarch-mdouble-float.c
===
--- clang/test/Driver/loongarch-mdouble-float.c
+++ clang/test/Driver/loongarch-mdouble-float.c
@@ -1,12 +1,15 @@
 // RUN: %clang --target=loongarch64 -mdouble-float -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefix=CC1
+// RUN: %clang --target=loongarch64 -mdouble-float -mfpu=64 -mabi=lp64d -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefixes=CC1,NOWARN
 // RUN: %clang --target=loongarch64 -mdouble-float -mfpu=0 -mabi=lp64s -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefixes=CC1,WARN
 // RUN: %clang --target=loongarch64 -mdouble-float -S -emit-llvm %s -o - | \
 // RUN:   FileCheck %s --check-prefix=IR
 
-// WARN: warning: argument unused during compilation: '-mfpu=0'
-// WARN: warning: argument unused during compilation: '-mabi=lp64s'
+// NOWARN-NOT: warning:
+// WARN: warning: ignoring '-mabi=' value 'lp64s' as it conflicts with that implied by '-mdouble-float' (lp64d)
+// WARN: warning: ignoring '-mfpu=' value '0' as it conflicts with that implied by '-mdouble-float' (64)
 
 // CC1: "-target-feature" "+f"{{.*}} "-target-feature" "+d"
 // CC1: "-target-abi" "lp64d"
Index: clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
===
--- clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
+++ clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
@@ -26,32 +26,80 @@
  "Unexpected triple");
   bool IsLA32 = Triple.getArch() == llvm::Triple::loongarch32;
 
+  // Record -mabi value for later use.
+  std::optional MABIOption;
+  StringRef MABIValue;
+  if (const Arg *A = Args.getLastArg(options::OPT_mabi_EQ)) {
+MABIOption = A->getOption();
+MABIValue = A->getValue();
+  }
+
+  // Parse -mfpu value for later use.
+  std::optional MFPUOption;
+  int FPU 

[PATCH] D151730: [RISCV] Support target attribute for function

2023-06-25 Thread Piyou Chen via Phabricator via cfe-commits
BeMg updated this revision to Diff 534428.
BeMg added a comment.

1. Attrstring -> AttrString
2. using StringRef instead of string
3. Append unsupported target feature Let follow-up procedure raise diagnostic 
code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151730

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/test/CodeGen/RISCV/riscv-func-attr-target.c
  llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
  llvm/test/CodeGen/RISCV/riscv-func-attr-target.ll

Index: llvm/test/CodeGen/RISCV/riscv-func-attr-target.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/riscv-func-attr-target.ll
@@ -0,0 +1,81 @@
+; RUN: llc -mtriple=riscv64 -mattr=+a,+d,+f,+m -verify-machineinstrs < %s | FileCheck %s
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +c, +v, +zifencei, +zve32f, +zve32x, +zve64d, +zve64f, +zve64x, +zvl128b, +zvl32b, +zvl64b
+define void @test1() #0 {
+; CHECK-LABEL: test1
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +c, +zifencei
+define void @test2() #1 {
+; CHECK-LABEL: test2
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +c, +zifencei
+define void @test3() #1 {
+; CHECK-LABEL: test3
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +v, +zifencei, +zve32f, +zve32x, +zve64d, +zve64f, +zve64x, +zvl128b, +zvl32b, +zvl64b
+define void @test4() #2 {
+; CHECK-LABEL: test4
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +experimental-zihintntl, +zifencei
+define void @test5() #3 {
+; CHECK-LABEL: test5
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +zifencei
+define void @test7() #4 {
+; CHECK-LABEL: test7
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +c, +zifencei
+define void @test9() #6 {
+; CHECK-LABEL: test9
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +c, +v, +zifencei, +zve32f, +zve32x, +zve64d, +zve64f, +zve64x, +zvl128b, +zvl32b, +zvl64b
+define void @test10() #7 {
+; CHECK-LABEL: test10
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic-rv64" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-e,-experimental-smaia,-experimental-ssaia,-experimental-zca,-experimental-zcb,-experimental-zcd,-experimental-zcf,-experimental-zcmp,-experimental-zcmt,-experimental-zfa,-experimental-zfbfmin,-experimental-zicond,-experimental-zihintntl,-experimental-ztso,-experimental-zvbb,-experimental-zvbc,-experimental-zvfbfmin,-experimental-zvfbfwma,-experimental-zvfh,-experimental-zvkg,-experimental-zvkn,-experimental-zvkned,-experimental-zvkng,-experimental-zvknha,-experimental-zvknhb,-experimental-zvks,-experimental-zvksed,-experimental-zvksg,-experimental-zvksh,-experimental-zvkt,-h,-save-restore,-svinval,-svnapot,-svpbmt,-xsfvcp,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zdinx,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zicbom,-zicbop,-zicboz,-zicntr,-zihintpause,-zihpm,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-zmmul,-zvl1024b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b" }
+attributes #1 = { noinline nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic-rv64" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,+zicsr,+zifencei,-e,-experimental-smaia,-experimental-ssaia,-experimental-zca,-experimental-zcb,-experimental-zcd,-experimental-zcf,-experimental-zcmp,-experimental-zcmt,-experimental-zfa,-experimental-zfbfmin,-experimental-zicond,-experimental-zihintntl,-experimental-ztso,-experimental-zvbb,-experimental-zvbc,-experimental-zvfbfmin,-experimental-zvfbfwma,-experimental-zvfh,-experimental-zvkg,-experimental-zvkn,-experimental-zvkned,-experimental-zvkng,-experimental-zvknha,-experimental-zvknhb,-experimental-zvks,-experimental-zvksed,-experimental-zvksg,-experimental-zvksh,-experimental-zvkt,-h,-save-restore,-svinval,-svnapot,-svpbmt,-v,-xsfvcp,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zdinx,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zicbom,-zicbop,-zicboz,-zicntr,-zihi

[clang] f67dfb3 - [RISCV] Use unsigned types for orc_b builtins.

2023-06-25 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2023-06-25T22:54:07-07:00
New Revision: f67dfb3cdb4b980103e262fb4c575e6310032dd4

URL: 
https://github.com/llvm/llvm-project/commit/f67dfb3cdb4b980103e262fb4c575e6310032dd4
DIFF: 
https://github.com/llvm/llvm-project/commit/f67dfb3cdb4b980103e262fb4c575e6310032dd4.diff

LOG: [RISCV] Use unsigned types for orc_b builtins.

Inspired by D153235, I think bit manipulation makes more
sense on unsigned types.

Reviewed By: Jim

Differential Revision: https://reviews.llvm.org/D153403

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsRISCV.def
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsRISCV.def 
b/clang/include/clang/Basic/BuiltinsRISCV.def
index 7f84be42faf40..baae5e82bc59f 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.def
+++ b/clang/include/clang/Basic/BuiltinsRISCV.def
@@ -16,8 +16,8 @@
 #endif
 
 // Zbb extension
-TARGET_BUILTIN(__builtin_riscv_orc_b_32, "ZiZi", "nc", "zbb")
-TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", "zbb,64bit")
+TARGET_BUILTIN(__builtin_riscv_orc_b_32, "UZiUZi", "nc", "zbb")
+TARGET_BUILTIN(__builtin_riscv_orc_b_64, "UWiUWi", "nc", "zbb,64bit")
 TARGET_BUILTIN(__builtin_riscv_clz_32, "iUZi", "nc", "zbb|xtheadbb")
 TARGET_BUILTIN(__builtin_riscv_clz_64, "iUWi", "nc", "zbb|xtheadbb,64bit")
 TARGET_BUILTIN(__builtin_riscv_ctz_32, "iUZi", "nc", "zbb")

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c
index cb90a26c3b0cd..ecf090a128aac 100644
--- a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c
@@ -1,6 +1,6 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // RUN: %clang_cc1 -triple riscv32 -target-feature +zbb -verify %s -o -
 
-int orc_b_64(int a) {
+unsigned int orc_b_64(unsigned int a) {
   return __builtin_riscv_orc_b_64(a); // expected-error {{builtin requires: 
'RV64'}}
 }

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
index 4129457fcd073..b4610be2714e7 100644
--- a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
@@ -10,7 +10,7 @@
 // RV32ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.riscv.orc.b.i32(i32 [[TMP0]])
 // RV32ZBB-NEXT:ret i32 [[TMP1]]
 //
-int orc_b_32(int a) {
+unsigned int orc_b_32(unsigned int a) {
   return __builtin_riscv_orc_b_32(a);
 }
 
@@ -36,4 +36,4 @@ int clz_32(unsigned int a) {
 //
 int ctz_32(unsigned int a) {
   return __builtin_riscv_ctz_32(a);
-}
\ No newline at end of file
+}

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
index baf7de1e0b9f1..62c5996241495 100644
--- a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
@@ -10,7 +10,7 @@
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.riscv.orc.b.i32(i32 [[TMP0]])
 // RV64ZBB-NEXT:ret i32 [[TMP1]]
 //
-int orc_b_32(int a) {
+unsigned int orc_b_32(unsigned int a) {
   return __builtin_riscv_orc_b_32(a);
 }
 
@@ -22,7 +22,7 @@ int orc_b_32(int a) {
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.orc.b.i64(i64 [[TMP0]])
 // RV64ZBB-NEXT:ret i64 [[TMP1]]
 //
-long orc_b_64(long a) {
+unsigned long orc_b_64(unsigned long a) {
   return __builtin_riscv_orc_b_64(a);
 }
 
@@ -78,4 +78,4 @@ int ctz_32(unsigned int a) {
 //
 int ctz_64(unsigned long a) {
   return __builtin_riscv_ctz_64(a);
-}
\ No newline at end of file
+}



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


[PATCH] D153403: [RISCV] Use unsigned types for orc_b builtins.

2023-06-25 Thread Craig Topper via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf67dfb3cdb4b: [RISCV] Use unsigned types for orc_b builtins. 
(authored by craig.topper).

Changed prior to commit:
  https://reviews.llvm.org/D153403?vs=533169&id=534429#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153403

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c


Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
@@ -10,7 +10,7 @@
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.riscv.orc.b.i32(i32 [[TMP0]])
 // RV64ZBB-NEXT:ret i32 [[TMP1]]
 //
-int orc_b_32(int a) {
+unsigned int orc_b_32(unsigned int a) {
   return __builtin_riscv_orc_b_32(a);
 }
 
@@ -22,7 +22,7 @@
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.orc.b.i64(i64 [[TMP0]])
 // RV64ZBB-NEXT:ret i64 [[TMP1]]
 //
-long orc_b_64(long a) {
+unsigned long orc_b_64(unsigned long a) {
   return __builtin_riscv_orc_b_64(a);
 }
 
@@ -78,4 +78,4 @@
 //
 int ctz_64(unsigned long a) {
   return __builtin_riscv_ctz_64(a);
-}
\ No newline at end of file
+}
Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
@@ -10,7 +10,7 @@
 // RV32ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.riscv.orc.b.i32(i32 [[TMP0]])
 // RV32ZBB-NEXT:ret i32 [[TMP1]]
 //
-int orc_b_32(int a) {
+unsigned int orc_b_32(unsigned int a) {
   return __builtin_riscv_orc_b_32(a);
 }
 
@@ -36,4 +36,4 @@
 //
 int ctz_32(unsigned int a) {
   return __builtin_riscv_ctz_32(a);
-}
\ No newline at end of file
+}
Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c
@@ -1,6 +1,6 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // RUN: %clang_cc1 -triple riscv32 -target-feature +zbb -verify %s -o -
 
-int orc_b_64(int a) {
+unsigned int orc_b_64(unsigned int a) {
   return __builtin_riscv_orc_b_64(a); // expected-error {{builtin requires: 
'RV64'}}
 }
Index: clang/include/clang/Basic/BuiltinsRISCV.def
===
--- clang/include/clang/Basic/BuiltinsRISCV.def
+++ clang/include/clang/Basic/BuiltinsRISCV.def
@@ -16,8 +16,8 @@
 #endif
 
 // Zbb extension
-TARGET_BUILTIN(__builtin_riscv_orc_b_32, "ZiZi", "nc", "zbb")
-TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", "zbb,64bit")
+TARGET_BUILTIN(__builtin_riscv_orc_b_32, "UZiUZi", "nc", "zbb")
+TARGET_BUILTIN(__builtin_riscv_orc_b_64, "UWiUWi", "nc", "zbb,64bit")
 TARGET_BUILTIN(__builtin_riscv_clz_32, "iUZi", "nc", "zbb|xtheadbb")
 TARGET_BUILTIN(__builtin_riscv_clz_64, "iUWi", "nc", "zbb|xtheadbb,64bit")
 TARGET_BUILTIN(__builtin_riscv_ctz_32, "iUZi", "nc", "zbb")


Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
@@ -10,7 +10,7 @@
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.riscv.orc.b.i32(i32 [[TMP0]])
 // RV64ZBB-NEXT:ret i32 [[TMP1]]
 //
-int orc_b_32(int a) {
+unsigned int orc_b_32(unsigned int a) {
   return __builtin_riscv_orc_b_32(a);
 }
 
@@ -22,7 +22,7 @@
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.orc.b.i64(i64 [[TMP0]])
 // RV64ZBB-NEXT:ret i64 [[TMP1]]
 //
-long orc_b_64(long a) {
+unsigned long orc_b_64(unsigned long a) {
   return __builtin_riscv_orc_b_64(a);
 }
 
@@ -78,4 +78,4 @@
 //
 int ctz_64(unsigned long a) {
   return __builtin_riscv_ctz_64(a);
-}
\ No newline at end of file
+}
Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
@@ -10,7 +10,7 @@
 // RV32ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.riscv.orc.b.i32(i32 [[TMP0]])
 // RV32ZBB-NEXT:ret i32 [[TMP1]]
 //
-int orc_b_32(int a) {
+unsigned int orc_b_32(unsigned int a) {
   return __builtin_riscv_orc_b_32(a);
 }
 
@@ -36,4 +36,4 @@
 //
 int ctz_32(unsigned int a) {
   return __builtin_riscv_ctz_32(a);
-}
\ No newline at end of file
+}
Inde

[PATCH] D153707: [Clang][LoongArch] Consume and check -mabi and -mfpu even if -m*-float is present

2023-06-25 Thread WÁNG Xuěruì via Phabricator via cfe-commits
xen0n updated this revision to Diff 534430.
xen0n added a comment.

Refactor more to be able to show the exact `-mabi` and `-mfpu` argument given.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153707

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
  clang/test/Driver/loongarch-mdouble-float.c
  clang/test/Driver/loongarch-msingle-float.c
  clang/test/Driver/loongarch-msoft-float.c

Index: clang/test/Driver/loongarch-msoft-float.c
===
--- clang/test/Driver/loongarch-msoft-float.c
+++ clang/test/Driver/loongarch-msoft-float.c
@@ -1,12 +1,15 @@
 // RUN: %clang --target=loongarch64 -msoft-float -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefix=CC1
+// RUN: %clang --target=loongarch64 -msoft-float -mfpu=0 -mabi=lp64s -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefixes=CC1,NOWARN
 // RUN: %clang --target=loongarch64 -msoft-float -mfpu=64 -mabi=lp64d -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefixes=CC1,WARN
 // RUN: %clang --target=loongarch64 -msoft-float -S -emit-llvm %s -o - | \
 // RUN:   FileCheck %s --check-prefix=IR
 
-// WARN: warning: argument unused during compilation: '-mfpu=64'
-// WARN: warning: argument unused during compilation: '-mabi=lp64d'
+// NOWARN-NOT: warning:
+// WARN: warning: ignoring '-mabi=lp64d' as it conflicts with that implied by '-msoft-float' (lp64s)
+// WARN: warning: ignoring '-mfpu=64' as it conflicts with that implied by '-msoft-float' (0)
 
 // CC1: "-target-feature" "-f"{{.*}} "-target-feature" "-d"
 // CC1: "-target-abi" "lp64s"
Index: clang/test/Driver/loongarch-msingle-float.c
===
--- clang/test/Driver/loongarch-msingle-float.c
+++ clang/test/Driver/loongarch-msingle-float.c
@@ -1,12 +1,15 @@
 // RUN: %clang --target=loongarch64 -msingle-float -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefix=CC1
-// RUN: %clang --target=loongarch64 -msingle-float -mfpu=0 -mabi=lp64s -fsyntax-only %s -### 2>&1 | \
+// RUN: %clang --target=loongarch64 -msingle-float -mfpu=32 -mabi=lp64f -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefixes=CC1,NOWARN
+// RUN: %clang --target=loongarch64 -msingle-float -mfpu=64 -mabi=lp64s -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefixes=CC1,WARN
 // RUN: %clang --target=loongarch64 -msingle-float -S -emit-llvm %s -o - | \
 // RUN:   FileCheck %s --check-prefix=IR
 
-// WARN: warning: argument unused during compilation: '-mfpu=0'
-// WARN: warning: argument unused during compilation: '-mabi=lp64s'
+// NOWARN-NOT: warning:
+// WARN: warning: ignoring '-mabi=lp64s' as it conflicts with that implied by '-msingle-float' (lp64f)
+// WARN: warning: ignoring '-mfpu=64' as it conflicts with that implied by '-msingle-float' (32)
 
 // CC1: "-target-feature" "+f"{{.*}} "-target-feature" "-d"
 // CC1: "-target-abi" "lp64f"
Index: clang/test/Driver/loongarch-mdouble-float.c
===
--- clang/test/Driver/loongarch-mdouble-float.c
+++ clang/test/Driver/loongarch-mdouble-float.c
@@ -1,12 +1,18 @@
 // RUN: %clang --target=loongarch64 -mdouble-float -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck %s --check-prefix=CC1
+// RUN: %clang --target=loongarch64 -mdouble-float -mfpu=64 -mabi=lp64d -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefixes=CC1,NOWARN
 // RUN: %clang --target=loongarch64 -mdouble-float -mfpu=0 -mabi=lp64s -fsyntax-only %s -### 2>&1 | \
-// RUN:   FileCheck %s --check-prefixes=CC1,WARN
+// RUN:   FileCheck %s --check-prefixes=CC1,WARN,WARN-FPU0
+// RUN: %clang --target=loongarch64 -mdouble-float -mfpu=none -mabi=lp64s -fsyntax-only %s -### 2>&1 | \
+// RUN:   FileCheck %s --check-prefixes=CC1,WARN,WARN-FPUNONE
 // RUN: %clang --target=loongarch64 -mdouble-float -S -emit-llvm %s -o - | \
 // RUN:   FileCheck %s --check-prefix=IR
 
-// WARN: warning: argument unused during compilation: '-mfpu=0'
-// WARN: warning: argument unused during compilation: '-mabi=lp64s'
+// NOWARN-NOT: warning:
+// WARN: warning: ignoring '-mabi=lp64s' as it conflicts with that implied by '-mdouble-float' (lp64d)
+// WARN-FPU0: warning: ignoring '-mfpu=0' as it conflicts with that implied by '-mdouble-float' (64)
+// WARN-FPUNONE: warning: ignoring '-mfpu=none' as it conflicts with that implied by '-mdouble-float' (64)
 
 // CC1: "-target-feature" "+f"{{.*}} "-target-feature" "+d"
 // CC1: "-target-abi" "lp64d"
Index: clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
===
--- clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
+++ clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
@@ -26,32 +26,75 @@
  "Unexpected triple");
   bool IsLA32 = Triple.ge

[clang] 21765af - [C++] [Coroutines] Assume the allocation doesn't return nullptr

2023-06-25 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-06-26T14:37:25+08:00
New Revision: 21765af763f163e6c87f63d3c1dbc32b06119f60

URL: 
https://github.com/llvm/llvm-project/commit/21765af763f163e6c87f63d3c1dbc32b06119f60
DIFF: 
https://github.com/llvm/llvm-project/commit/21765af763f163e6c87f63d3c1dbc32b06119f60.diff

LOG: [C++] [Coroutines] Assume the allocation doesn't return nullptr

In case of 'get_return_object_on_allocation_failure' get declared, the
compiler is required to call 'operator new(size_t, nothrow_t)' and the
handle the failure case by calling
'get_return_object_on_allocation_failure()'. But the failure case should
be rare and we can assume the allocation is successful and pass the
information to the optimizer.

Added: 


Modified: 
clang/lib/CodeGen/CGCoroutine.cpp
clang/test/CodeGenCoroutines/coro-alloc.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCoroutine.cpp 
b/clang/lib/CodeGen/CGCoroutine.cpp
index da3da5e600104..8437cda79beb2 100644
--- a/clang/lib/CodeGen/CGCoroutine.cpp
+++ b/clang/lib/CodeGen/CGCoroutine.cpp
@@ -630,6 +630,8 @@ void CodeGenFunction::EmitCoroutineBody(const 
CoroutineBodyStmt &S) {
 // See if allocation was successful.
 auto *NullPtr = llvm::ConstantPointerNull::get(Int8PtrTy);
 auto *Cond = Builder.CreateICmpNE(AllocateCall, NullPtr);
+// Expect the allocation to be successful.
+emitCondLikelihoodViaExpectIntrinsic(Cond, Stmt::LH_Likely);
 Builder.CreateCondBr(Cond, InitBB, RetOnFailureBB);
 
 // If not, return OnAllocFailure object.

diff  --git a/clang/test/CodeGenCoroutines/coro-alloc.cpp 
b/clang/test/CodeGenCoroutines/coro-alloc.cpp
index 05b3d56483d0e..d026a0d7df227 100644
--- a/clang/test/CodeGenCoroutines/coro-alloc.cpp
+++ b/clang/test/CodeGenCoroutines/coro-alloc.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 \
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -O2 \
 // RUN:-Wno-coroutine-missing-unhandled-exception -emit-llvm %s -o - 
-disable-llvm-passes \
 // RUN:   | FileCheck %s
 
@@ -228,6 +228,7 @@ extern "C" int f4(promise_on_alloc_failure_tag) {
   // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
   // CHECK: %[[MEM:.+]] = call noalias noundef ptr @_ZnwmRKSt9nothrow_t(i64 
noundef %[[SIZE]], ptr noundef nonnull align 1 dereferenceable(1) 
@_ZStL7nothrow)
   // CHECK: %[[OK:.+]] = icmp ne ptr %[[MEM]], null
+  // CHECK: call i1 @llvm.expect.i1(i1 %[[OK]], i1 true)
   // CHECK: br i1 %[[OK]], label %[[OKBB:.+]], label %[[ERRBB:.+]]
 
   // CHECK: [[ERRBB]]:



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