[clang-tools-extra] [clang-doc] modify basic-project test (PR #97684)
llvmbot wrote: @llvm/pr-subscribers-clang-tools-extra Author: None (PeterChou1) Changes This patch modifies the basic-project in clang-doc. Currently we're matching the entire html output. This patch modifies it so that we only match the parts relevant to the documentation logic instead just matching the boilerplate code. This patch also adds the markdown output to the basic-project test --- Patch is 25.30 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/97684.diff 1 Files Affected: - (modified) clang-tools-extra/test/clang-doc/basic-project.test (+243-300) ``diff diff --git a/clang-tools-extra/test/clang-doc/basic-project.test b/clang-tools-extra/test/clang-doc/basic-project.test index bab5f8e1761bc..2e708aa97bdef 100644 --- a/clang-tools-extra/test/clang-doc/basic-project.test +++ b/clang-tools-extra/test/clang-doc/basic-project.test @@ -54,306 +54,249 @@ // JSON-INDEX-NEXT: }; // JSON-INDEX-NEXT: } -// HTML-SHAPE: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: class Shape -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: class Shape -// HTML-SHAPE-NEXT: Defined at line 8 of file {{.*}}Shape.h -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: Provides a common interface for different types of shapes. -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: Functions -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: ~Shape -// HTML-SHAPE-NEXT: public void ~Shape() -// HTML-SHAPE-NEXT: Defined at line 13 of file {{.*}}Shape.h -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: area -// HTML-SHAPE-NEXT: public double area() -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: perimeter -// HTML-SHAPE-NEXT: public double perimeter() -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: Functions -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: ~Shape -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: area -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: perimeter -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: +// HTML-SHAPE: class Shape +// HTML-SHAPE: Defined at line 8 of file {{.*}}Shape.h +// HTML-SHAPE: +// HTML-SHAPE: +// HTML-SHAPE: Provides a common interface for different types of shapes. +// HTML-SHAPE: +// HTML-SHAPE: +// HTML-SHAPE: Functions +// HTML-SHAPE: +// HTML-SHAPE: ~Shape +// HTML-SHAPE: public void ~Shape() +// HTML-SHAPE: Defined at line 13 of file {{.*}}Shape.h +// HTML-SHAPE: +// HTML-SHAPE: +// HTML-SHAPE: +// HTML-SHAPE: area +// HTML-SHAPE: public double area() +// HTML-SHAPE: +// HTML-SHAPE: +// HTML-SHAPE: +// HTML-SHAPE: perimeter +// HTML-SHAPE: public double perimeter() +// HTML-SHAPE: +// HTML-SHAPE: +// HTML-SHAPE: +// HTML-SHAPE: -// HTML-CALC: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: class Calculator -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: class Calculator -// HTML-CALC-NEXT: Defined at line 8 of file {{.*}}Calculator.h -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: Provides basic arithmetic operations. -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: Functions -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: add -// HTML-CALC-NEXT: public int add(int a, int b) -// HTML-CALC-NEXT: Defined at line 3 of file {{.*}}Calculator.cpp -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: subtract -// HTML-CALC-NEXT: public int subtract(int a, int b) -// HTML-CALC-NEXT: Defined at line 7 of file {{.*}}Calculator.cpp -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: multiply -// HTML-CALC-NEXT: public int multiply(int a, int b) -// HTML-CALC-NEXT: Defined at line
[clang-tools-extra] [clang-doc] modify basic-project test (PR #97684)
https://github.com/PeterChou1 created https://github.com/llvm/llvm-project/pull/97684 This patch modifies the basic-project in clang-doc. Currently we're matching the entire html output. This patch modifies it so that we only match the parts relevant to the documentation logic instead just matching the boilerplate code. This patch also adds the markdown output to the basic-project test >From 778f43dd6505c41d4175c1fe717b8cf79d7a43fc Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Thu, 4 Jul 2024 02:52:11 -0400 Subject: [PATCH] [clang-doc] modify basic-project test --- .../test/clang-doc/basic-project.test | 543 -- 1 file changed, 243 insertions(+), 300 deletions(-) diff --git a/clang-tools-extra/test/clang-doc/basic-project.test b/clang-tools-extra/test/clang-doc/basic-project.test index bab5f8e1761bc..2e708aa97bdef 100644 --- a/clang-tools-extra/test/clang-doc/basic-project.test +++ b/clang-tools-extra/test/clang-doc/basic-project.test @@ -54,306 +54,249 @@ // JSON-INDEX-NEXT: }; // JSON-INDEX-NEXT: } -// HTML-SHAPE: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: class Shape -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: class Shape -// HTML-SHAPE-NEXT: Defined at line 8 of file {{.*}}Shape.h -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: Provides a common interface for different types of shapes. -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: Functions -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: ~Shape -// HTML-SHAPE-NEXT: public void ~Shape() -// HTML-SHAPE-NEXT: Defined at line 13 of file {{.*}}Shape.h -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: area -// HTML-SHAPE-NEXT: public double area() -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: perimeter -// HTML-SHAPE-NEXT: public double perimeter() -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: Functions -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: ~Shape -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: area -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: perimeter -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: -// HTML-SHAPE-NEXT: +// HTML-SHAPE: class Shape +// HTML-SHAPE: Defined at line 8 of file {{.*}}Shape.h +// HTML-SHAPE: +// HTML-SHAPE: +// HTML-SHAPE: Provides a common interface for different types of shapes. +// HTML-SHAPE: +// HTML-SHAPE: +// HTML-SHAPE: Functions +// HTML-SHAPE: +// HTML-SHAPE: ~Shape +// HTML-SHAPE: public void ~Shape() +// HTML-SHAPE: Defined at line 13 of file {{.*}}Shape.h +// HTML-SHAPE: +// HTML-SHAPE: +// HTML-SHAPE: +// HTML-SHAPE: area +// HTML-SHAPE: public double area() +// HTML-SHAPE: +// HTML-SHAPE: +// HTML-SHAPE: +// HTML-SHAPE: perimeter +// HTML-SHAPE: public double perimeter() +// HTML-SHAPE: +// HTML-SHAPE: +// HTML-SHAPE: +// HTML-SHAPE: -// HTML-CALC: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: class Calculator -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: class Calculator -// HTML-CALC-NEXT: Defined at line 8 of file {{.*}}Calculator.h -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: Provides basic arithmetic operations. -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: Functions -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: add -// HTML-CALC-NEXT: public int add(int a, int b) -// HTML-CALC-NEXT: Defined at line 3 of file {{.*}}Calculator.cpp -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: subtract -// HTML-CALC-NEXT: public int subtract(int a, int b) -// HTML-CALC-NEXT: Defined at line 7 of file {{.*}}Calculator.cpp -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: -// HTML-CALC-NEXT: multiply -// HTML-CALC-NEXT: public in
[clang] 2dda8a2 - Revert "[clang][Interp] Fix init chain in local initializers"
Author: Timm Bäder Date: 2024-07-04T08:50:14+02:00 New Revision: 2dda8a2650927e4b0fbb459507684455e196d9a9 URL: https://github.com/llvm/llvm-project/commit/2dda8a2650927e4b0fbb459507684455e196d9a9 DIFF: https://github.com/llvm/llvm-project/commit/2dda8a2650927e4b0fbb459507684455e196d9a9.diff LOG: Revert "[clang][Interp] Fix init chain in local initializers" This reverts commit 86187ed2998e43be62176c2c4a7b204cc52f6ce6. Seems like this breaks buildbots: https://lab.llvm.org/buildbot/#/builders/56/builds/1638 Added: Modified: clang/lib/AST/Interp/Compiler.cpp clang/test/AST/Interp/records.cpp Removed: diff --git a/clang/lib/AST/Interp/Compiler.cpp b/clang/lib/AST/Interp/Compiler.cpp index 2af4c38c5ac3d..775cabf7f8c59 100644 --- a/clang/lib/AST/Interp/Compiler.cpp +++ b/clang/lib/AST/Interp/Compiler.cpp @@ -3577,7 +3577,6 @@ VarCreationState Compiler::visitVarDecl(const VarDecl *VD, bool Topleve return !Init || (checkDecl() && initGlobal(*GlobalIndex)); } else { VariableScope LocalScope(this, VD); -InitLinkScope ILS(this, InitLink::Decl(VD)); if (VarT) { unsigned Offset = this->allocateLocalPrimitive( @@ -3912,8 +3911,7 @@ bool Compiler::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *E) { SourceLocScope SLS(this, E); bool Old = InitStackActive; - InitStackActive = - !(E->getUsedContext()->getDeclKind() == Decl::CXXConstructor); + InitStackActive = !isa(E->getUsedContext()); bool Result = this->delegate(E->getExpr()); InitStackActive = Old; return Result; diff --git a/clang/test/AST/Interp/records.cpp b/clang/test/AST/Interp/records.cpp index 1554e54275598..9f341f5bc6d1d 100644 --- a/clang/test/AST/Interp/records.cpp +++ b/clang/test/AST/Interp/records.cpp @@ -1482,15 +1482,3 @@ namespace FloatAPValue { ClassTemplateArgRefTemplate ClassTemplateArgRefObj; } #endif - -namespace LocalWithThisPtrInit { - struct S { -int i; -int *p = &i; - }; - constexpr int foo() { -S s{2}; -return *s.p; - } - static_assert(foo() == 2, ""); -} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 86187ed - [clang][Interp] Fix init chain in local initializers
Author: Timm Bäder Date: 2024-07-04T08:41:09+02:00 New Revision: 86187ed2998e43be62176c2c4a7b204cc52f6ce6 URL: https://github.com/llvm/llvm-project/commit/86187ed2998e43be62176c2c4a7b204cc52f6ce6 DIFF: https://github.com/llvm/llvm-project/commit/86187ed2998e43be62176c2c4a7b204cc52f6ce6.diff LOG: [clang][Interp] Fix init chain in local initializers Added: Modified: clang/lib/AST/Interp/Compiler.cpp clang/test/AST/Interp/records.cpp Removed: diff --git a/clang/lib/AST/Interp/Compiler.cpp b/clang/lib/AST/Interp/Compiler.cpp index 775cabf7f8c59..2af4c38c5ac3d 100644 --- a/clang/lib/AST/Interp/Compiler.cpp +++ b/clang/lib/AST/Interp/Compiler.cpp @@ -3577,6 +3577,7 @@ VarCreationState Compiler::visitVarDecl(const VarDecl *VD, bool Topleve return !Init || (checkDecl() && initGlobal(*GlobalIndex)); } else { VariableScope LocalScope(this, VD); +InitLinkScope ILS(this, InitLink::Decl(VD)); if (VarT) { unsigned Offset = this->allocateLocalPrimitive( @@ -3911,7 +3912,8 @@ bool Compiler::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *E) { SourceLocScope SLS(this, E); bool Old = InitStackActive; - InitStackActive = !isa(E->getUsedContext()); + InitStackActive = + !(E->getUsedContext()->getDeclKind() == Decl::CXXConstructor); bool Result = this->delegate(E->getExpr()); InitStackActive = Old; return Result; diff --git a/clang/test/AST/Interp/records.cpp b/clang/test/AST/Interp/records.cpp index 9f341f5bc6d1d..1554e54275598 100644 --- a/clang/test/AST/Interp/records.cpp +++ b/clang/test/AST/Interp/records.cpp @@ -1482,3 +1482,15 @@ namespace FloatAPValue { ClassTemplateArgRefTemplate ClassTemplateArgRefObj; } #endif + +namespace LocalWithThisPtrInit { + struct S { +int i; +int *p = &i; + }; + constexpr int foo() { +S s{2}; +return *s.p; + } + static_assert(foo() == 2, ""); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Interp] Implement dynamic memory allocation handling (PR #70306)
Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/70306 >From a2213c595637d63b48658d2532e00b08fd05427f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Thu, 4 Jul 2024 07:26:27 +0200 Subject: [PATCH 1/2] [clang][Interp] Fix init chain in local initializers --- clang/lib/AST/Interp/Compiler.cpp | 4 +++- clang/test/AST/Interp/records.cpp | 12 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/clang/lib/AST/Interp/Compiler.cpp b/clang/lib/AST/Interp/Compiler.cpp index 775cabf7f8c59..2af4c38c5ac3d 100644 --- a/clang/lib/AST/Interp/Compiler.cpp +++ b/clang/lib/AST/Interp/Compiler.cpp @@ -3577,6 +3577,7 @@ VarCreationState Compiler::visitVarDecl(const VarDecl *VD, bool Topleve return !Init || (checkDecl() && initGlobal(*GlobalIndex)); } else { VariableScope LocalScope(this, VD); +InitLinkScope ILS(this, InitLink::Decl(VD)); if (VarT) { unsigned Offset = this->allocateLocalPrimitive( @@ -3911,7 +3912,8 @@ bool Compiler::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *E) { SourceLocScope SLS(this, E); bool Old = InitStackActive; - InitStackActive = !isa(E->getUsedContext()); + InitStackActive = + !(E->getUsedContext()->getDeclKind() == Decl::CXXConstructor); bool Result = this->delegate(E->getExpr()); InitStackActive = Old; return Result; diff --git a/clang/test/AST/Interp/records.cpp b/clang/test/AST/Interp/records.cpp index 9f341f5bc6d1d..1554e54275598 100644 --- a/clang/test/AST/Interp/records.cpp +++ b/clang/test/AST/Interp/records.cpp @@ -1482,3 +1482,15 @@ namespace FloatAPValue { ClassTemplateArgRefTemplate ClassTemplateArgRefObj; } #endif + +namespace LocalWithThisPtrInit { + struct S { +int i; +int *p = &i; + }; + constexpr int foo() { +S s{2}; +return *s.p; + } + static_assert(foo() == 2, ""); +} >From 43f20bfd68556d7ba246f90599345077488c6a92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Wed, 25 Oct 2023 08:33:30 +0200 Subject: [PATCH 2/2] [clang][Interp] Implement dynamic memory allocation handling --- clang/lib/AST/CMakeLists.txt | 1 + clang/lib/AST/Interp/Compiler.cpp | 103 + clang/lib/AST/Interp/Compiler.h| 2 + clang/lib/AST/Interp/DynamicAllocator.cpp | 118 + clang/lib/AST/Interp/DynamicAllocator.h| 96 clang/lib/AST/Interp/EvalEmitter.cpp | 23 + clang/lib/AST/Interp/EvaluationResult.cpp | 72 +++ clang/lib/AST/Interp/EvaluationResult.h| 6 + clang/lib/AST/Interp/Interp.cpp| 52 +++ clang/lib/AST/Interp/Interp.h | 151 +++ clang/lib/AST/Interp/InterpBlock.h | 11 +- clang/lib/AST/Interp/InterpState.cpp | 17 +- clang/lib/AST/Interp/InterpState.h | 11 + clang/lib/AST/Interp/Opcodes.td| 24 +- clang/lib/AST/Interp/Pointer.h | 1 + clang/test/AST/Interp/new-delete.cpp | 488 + clang/test/Rewriter/rewrite-modern-catch.m | 2 +- clang/test/SemaCXX/delete.cpp | 2 +- clang/test/SemaCXX/new-delete.cpp | 22 +- 19 files changed, 1193 insertions(+), 9 deletions(-) create mode 100644 clang/lib/AST/Interp/DynamicAllocator.cpp create mode 100644 clang/lib/AST/Interp/DynamicAllocator.h create mode 100644 clang/test/AST/Interp/new-delete.cpp diff --git a/clang/lib/AST/CMakeLists.txt b/clang/lib/AST/CMakeLists.txt index ceaad8d3c5a86..70aecb781c2ff 100644 --- a/clang/lib/AST/CMakeLists.txt +++ b/clang/lib/AST/CMakeLists.txt @@ -75,6 +75,7 @@ add_clang_library(clangAST Interp/InterpBuiltin.cpp Interp/Floating.cpp Interp/EvaluationResult.cpp + Interp/DynamicAllocator.cpp Interp/Interp.cpp Interp/InterpBlock.cpp Interp/InterpFrame.cpp diff --git a/clang/lib/AST/Interp/Compiler.cpp b/clang/lib/AST/Interp/Compiler.cpp index 2af4c38c5ac3d..7ffec61e01d1d 100644 --- a/clang/lib/AST/Interp/Compiler.cpp +++ b/clang/lib/AST/Interp/Compiler.cpp @@ -2756,6 +2756,109 @@ bool Compiler::VisitCXXInheritedCtorInitExpr( return this->emitCall(F, 0, E); } +template +bool Compiler::VisitCXXNewExpr(const CXXNewExpr *E) { + assert(classifyPrim(E->getType()) == PT_Ptr); + const Expr *Init = E->getInitializer(); + QualType ElementType = E->getAllocatedType(); + std::optional ElemT = classify(ElementType); + unsigned PlacementArgs = E->getNumPlacementArgs(); + bool IsNoThrow = false; + + // FIXME: Better diagnostic. diag::note_constexpr_new_placement + if (PlacementArgs != 0) { +// The only new-placement list we support is of the form (std::nothrow). +// +// FIXME: There is no restriction on this, but it's not clear that any +// other form makes any sense. We get here for cases such as: +// +// new (std::align_val_t{N}) X(int) +// +// (which should presumably be valid only if N is a multiple of +// alignof(int), and
[clang-tools-extra] [clang-doc] add nested namespace test case (PR #97681)
https://github.com/PeterChou1 updated https://github.com/llvm/llvm-project/pull/97681 >From f9d5cc074e4b65a92703bd09e62696a29fed1237 Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Thu, 4 Jul 2024 01:31:13 -0400 Subject: [PATCH 1/2] [clang-doc] add nested naemspace --- .../test/clang-doc/namespace.cpp | 340 ++ 1 file changed, 340 insertions(+) create mode 100644 clang-tools-extra/test/clang-doc/namespace.cpp diff --git a/clang-tools-extra/test/clang-doc/namespace.cpp b/clang-tools-extra/test/clang-doc/namespace.cpp new file mode 100644 index 0..6fb91c9aa3c51 --- /dev/null +++ b/clang-tools-extra/test/clang-doc/namespace.cpp @@ -0,0 +1,340 @@ +// RUN: clang-doc --format=html --output=%t/docs --executor=standalone %s +// RUN: clang-doc --format=md --output=%t/docs --executor=standalone %s +// RUN: FileCheck %s -input-file=%t/docs/index_json.js -check-prefix=JSON-INDEX +// RUN: FileCheck %s -input-file=%t/docs/@nonymous_namespace/AnonClass.html -check-prefix=HTML-ANON-CLASS +// RUN: FileCheck %s -input-file=%t/docs/@nonymous_namespace/index.html -check-prefix=HTML-ANON-INDEX +// RUN: FileCheck %s -input-file=%t/docs/AnotherNamespace/ClassInAnotherNamespace.html -check-prefix=HTML-ANOTHER-CLASS +// RUN: FileCheck %s -input-file=%t/docs/AnotherNamespace/index.html -check-prefix=HTML-ANOTHER-INDEX +// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.html -check-prefix=HTML-GLOBAL-INDEX +// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/NestedNamespace/ClassInNestedNamespace.html -check-prefix=HTML-NESTED-CLASS +// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/NestedNamespace/index.html -check-prefix=HTML-NESTED-INDEX +// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/index.html -check-prefix=HTML-PRIMARY-INDEX +// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/ClassInPrimaryNamespace.html -check-prefix=HTML-PRIMARY-CLASS +// RUN: FileCheck %s -input-file=%t/docs/@nonymous_namespace/AnonClass.md -check-prefix=MD-ANON-CLASS +// RUN: FileCheck %s -input-file=%t/docs/@nonymous_namespace/index.md -check-prefix=MD-ANON-INDEX +// RUN: FileCheck %s -input-file=%t/docs/AnotherNamespace/ClassInAnotherNamespace.md -check-prefix=MD-ANOTHER-CLASS +// RUN: FileCheck %s -input-file=%t/docs/AnotherNamespace/index.md -check-prefix=MD-ANOTHER-INDEX +// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.md -check-prefix=MD-GLOBAL-INDEX +// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/NestedNamespace/ClassInNestedNamespace.md -check-prefix=MD-NESTED-CLASS +// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/NestedNamespace/index.md -check-prefix=MD-NESTED-INDEX +// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/index.md -check-prefix=MD-PRIMARY-INDEX +// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/ClassInPrimaryNamespace.md -check-prefix=MD-PRIMARY-CLASS +// RUN: FileCheck %s -input-file=%t/docs/all_files.md -check-prefix=MD-ALL-FILES +// RUN: FileCheck %s -input-file=%t/docs/index.md -check-prefix=MD-INDEX + +// Anonymous Namespace +namespace +{ +void anonFunction() {} +class AnonClass {}; +} + +// Primary Namespace +namespace PrimaryNamespace { +// Function in PrimaryNamespace +void functionInPrimaryNamespace() {} + +// Class in PrimaryNamespace +class ClassInPrimaryNamespace {}; + +// Nested namespace +namespace NestedNamespace { +// Function in NestedNamespace +void functionInNestedNamespace() {} +// Class in NestedNamespace +class ClassInNestedNamespace {}; +} +} + +// AnotherNamespace +namespace AnotherNamespace { +// Function in AnotherNamespace +void functionInAnotherNamespace() {} +// Class in AnotherNamespace +class ClassInAnotherNamespace {}; +} + +// JSON-INDEX: async function LoadIndex() { +// JSON-INDEX-NEXT: return{ +// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}", +// JSON-INDEX-NEXT: "Name": "", +// JSON-INDEX-NEXT: "RefType": "default", +// JSON-INDEX-NEXT: "Path": "", +// JSON-INDEX-NEXT: "Children": [ +// JSON-INDEX-NEXT: { +// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}", +// JSON-INDEX-NEXT: "Name": "@nonymous_namespace", +// JSON-INDEX-NEXT: "RefType": "namespace", +// JSON-INDEX-NEXT: "Path": "@nonymous_namespace", +// JSON-INDEX-NEXT: "Children": [ +// JSON-INDEX-NEXT: { +// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}", +// JSON-INDEX-NEXT: "Name": "AnonClass", +// JSON-INDEX-NEXT: "RefType": "record", +// JSON-INDEX-NEXT: "Path": "@nonymous_namespace", +// JSON-INDEX-NEXT: "Children": [] +// JSON-INDEX-NEXT: } +// JSON-INDEX-NEXT: ] +// JSON-INDEX-NEXT: }, +// JSON-INDEX-NEXT: { +// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}", +// JSON-INDEX-NEXT: "Name": "AnotherNamespace", +// JSON-INDEX-NEXT: "RefType": "namespace", +
[clang] [clang][CodeGen] Zero init unspecified fields in initializers in C (#97459) (PR #97121)
https://github.com/yabinc updated https://github.com/llvm/llvm-project/pull/97121 >From fe8740927f9d6d83d5eef44516bcb5d042b9960e Mon Sep 17 00:00:00 2001 From: Yabin Cui Date: Thu, 27 Jun 2024 17:11:52 -0700 Subject: [PATCH] [clang][CodeGen] Zero init unspecified fields in initializers in C (#97459) When an initializer is provided to a variable, the Linux kernel relied on the compiler to zero-initialize unspecified fields, as clarified in https://www.spinics.net/lists/netdev/msg1007244.html. But clang doesn't guarantee this: 1. For a union type, if an empty initializer is given, clang only initializes bytes for the first field, left bytes for other (larger) fields are marked as undef. Accessing those undef bytes can lead to undefined behaviors. 2. For a union type, if an initializer explicitly sets a field, left bytes for other (larger) fields are marked as undef. 3. When an initializer is given, clang doesn't zero initialize padding. So this patch makes the following change: In C, when an initializer is provided for a variable, zero-initialize undef and padding fields in the initializer. As suggested in https://github.com/llvm/llvm-project/issues/78034#issuecomment-2183437928, the change isn't required by C23, but it's standards conforming to do so. --- clang/lib/CodeGen/CGDecl.cpp | 63 -- clang/lib/CodeGen/CodeGenModule.cpp | 6 + clang/lib/CodeGen/CodeGenModule.h | 2 + ...07-22-bitfield-init-after-zero-len-array.c | 2 +- clang/test/CodeGen/2008-08-07-AlignPadding1.c | 4 +- clang/test/CodeGen/64bit-swiftcall.c | 12 +- clang/test/CodeGen/arm-swiftcall.c| 4 +- clang/test/CodeGen/const-init.c | 4 +- clang/test/CodeGen/designated-initializers.c | 12 +- clang/test/CodeGen/flexible-array-init.c | 24 +- clang/test/CodeGen/global-init.c | 2 +- clang/test/CodeGen/init.c | 19 -- .../linux-kernel-struct-union-initializer.c | 212 ++ clang/test/CodeGen/mingw-long-double.c| 9 +- clang/test/CodeGen/mms-bitfields.c| 4 +- clang/test/CodeGen/union-init2.c | 4 +- clang/test/CodeGen/windows-swiftcall.c| 12 +- .../CodeGenObjC/designated-initializers.m | 2 +- 18 files changed, 307 insertions(+), 90 deletions(-) create mode 100644 clang/test/CodeGen/linux-kernel-struct-union-initializer.c diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 90aa4c0745a8a..960add12f323b 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -334,6 +334,13 @@ llvm::Constant *CodeGenModule::getOrCreateStaticVarDecl( return Addr; } +enum class IsPattern { No, Yes }; + +static llvm::Constant *replaceUndef(CodeGenModule &CGM, IsPattern isPattern, +llvm::Constant *constant); +static llvm::Constant *constWithPadding(CodeGenModule &CGM, IsPattern isPattern, +llvm::Constant *constant); + /// AddInitializerToStaticVarDecl - Add the initializer for 'D' to the /// global variable that has already been created for it. If the initializer /// has a different type than GV does, this may free GV and return a different @@ -360,6 +367,13 @@ CodeGenFunction::AddInitializerToStaticVarDecl(const VarDecl &D, } return GV; } + if (getLangOpts().C99) { +// In C, static initialization guarantees that padding is initialized to +// zero bits. And the Linux kernel relies on clang to zero-initialize +// unspecified fields. +Init = constWithPadding(CGM, IsPattern::No, +replaceUndef(CGM, IsPattern::No, Init)); + } #ifndef NDEBUG CharUnits VarSize = CGM.getContext().getTypeSizeInChars(D.getType()) + @@ -1037,8 +1051,6 @@ static bool shouldSplitConstantStore(CodeGenModule &CGM, return false; } -enum class IsPattern { No, Yes }; - /// Generate a constant filled with either a pattern or zeroes. static llvm::Constant *patternOrZeroFor(CodeGenModule &CGM, IsPattern isPattern, llvm::Type *Ty) { @@ -1048,9 +1060,6 @@ static llvm::Constant *patternOrZeroFor(CodeGenModule &CGM, IsPattern isPattern, return llvm::Constant::getNullValue(Ty); } -static llvm::Constant *constWithPadding(CodeGenModule &CGM, IsPattern isPattern, -llvm::Constant *constant); - /// Helper function for constWithPadding() to deal with padding in structures. static llvm::Constant *constStructWithPadding(CodeGenModule &CGM, IsPattern isPattern, @@ -1108,6 +1117,9 @@ static llvm::Constant *constWithPadding(CodeGenModule &CGM, IsPattern isPattern, if (ZeroInitializer) { OpValue = llvm::Constant::getNullValue(ElemTy); PaddedOp = constWithPadding(CGM, isPattern, OpValue); + // Avoid iterating large a
[clang] Enable frame pointer for non-leaf functions on Android (PR #97614)
https://github.com/yabinc updated https://github.com/llvm/llvm-project/pull/97614 >From 3a705f4ce3e35a7a04b1d7002f36d77a617ba2e0 Mon Sep 17 00:00:00 2001 From: Yabin Cui Date: Wed, 3 Jul 2024 11:03:35 -0700 Subject: [PATCH] Enable frame pointer for non-leaf functions on Android On Android, we always want frame pointers to make debugging in the field easier. Since frame pointers are already enabled for AArch64, ARM and RISCV64, effectively this change further enables frame pointers for X86 and X86_64. --- clang/lib/Driver/ToolChains/CommonArgs.cpp | 17 +++-- clang/test/Driver/frame-pointer.c | 15 +++ 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index c56a0c2c46c47..ab1590104b790 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -78,19 +78,8 @@ static bool useFramePointerForTargetByDefault(const llvm::opt::ArgList &Args, !Args.hasArg(clang::driver::options::OPT_mfentry)) return true; - if (Triple.isAndroid()) { -switch (Triple.getArch()) { -case llvm::Triple::aarch64: -case llvm::Triple::arm: -case llvm::Triple::armeb: -case llvm::Triple::thumb: -case llvm::Triple::thumbeb: -case llvm::Triple::riscv64: - return true; -default: - break; -} - } + if (Triple.isAndroid()) +return true; switch (Triple.getArch()) { case llvm::Triple::xcore: @@ -166,7 +155,7 @@ static bool useFramePointerForTargetByDefault(const llvm::opt::ArgList &Args, static bool useLeafFramePointerForTargetByDefault(const llvm::Triple &Triple) { if (Triple.isAArch64() || Triple.isPS() || Triple.isVE() || - (Triple.isAndroid() && Triple.isRISCV64())) + (Triple.isAndroid() && !Triple.isARM())) return false; return true; diff --git a/clang/test/Driver/frame-pointer.c b/clang/test/Driver/frame-pointer.c index 2b4287bf447ca..2015fa520c2a2 100644 --- a/clang/test/Driver/frame-pointer.c +++ b/clang/test/Driver/frame-pointer.c @@ -4,6 +4,9 @@ // RUN: %clang --target=i386-pc-linux -### -S -O3 %s 2>&1 | FileCheck -check-prefix=CHECK3-32 %s // RUN: %clang --target=i386-pc-linux -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECKs-32 %s +// RUN: %clang --target=i386-linux-android -### -S -O0 %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID %s +// RUN: %clang --target=i386-linux-android -### -S -O1 %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID %s +// RUN: %clang --target=i386-linux-android -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID %s // RUN: %clang --target=x86_64-pc-linux -### -S -O0 %s 2>&1 | FileCheck -check-prefix=CHECK0-64 %s // RUN: %clang --target=x86_64-pc-linux -### -S -O1 %s 2>&1 | FileCheck -check-prefix=CHECK1-64 %s @@ -12,6 +15,10 @@ // RUN: %clang --target=x86_64-pc-linux -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECKs-64 %s // RUN: %clang --target=x86_64-pc-win32-macho -### -S -O3 %s 2>&1 | FileCheck -check-prefix=CHECK-MACHO-64 %s +// RUN: %clang --target=x86_64-linux-android -### -S -O0 %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID %s +// RUN: %clang --target=x86_64-linux-android -### -S -O1 %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID %s +// RUN: %clang --target=x86_64-linux-android -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID %s + // Trust the above to get the optimizations right, and just test other targets // that want this by default. // RUN: %clang --target=s390x-pc-linux -### -S -O0 %s 2>&1 | FileCheck -check-prefix=CHECK0-64 %s @@ -57,9 +64,9 @@ // RUN: %clang --target=riscv64-unknown-linux-gnu -### -S -O3 %s 2>&1 | FileCheck -check-prefix=CHECK3-64 %s // RUN: %clang --target=riscv64-unknown-linux-gnu -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECKs-64 %s -// RUN: %clang --target=riscv64-linux-android -### -S -O0 %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID-64 %s -// RUN: %clang --target=riscv64-linux-android -### -S -O1 %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID-64 %s -// RUN: %clang --target=riscv64-linux-android -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID-64 %s +// RUN: %clang --target=riscv64-linux-android -### -S -O0 %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID %s +// RUN: %clang --target=riscv64-linux-android -### -S -O1 %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID %s +// RUN: %clang --target=riscv64-linux-android -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID %s // RUN: %clang --target=loongarch32 -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s // RUN: %clang --target=loongarch32 -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s @@ -86,4 +93,4 @@ // CHECKs-64-NOT: -mframe-pointer=all // CHECK-MACHO-64: -mframe-pointer=all -// CHECK-ANDROID-64: -mframe-pointer=non-leaf +// CHECK-ANDROID: -mframe-pointer=non-leaf __
[clang-tools-extra] [clang-doc] add enum test (PR #97679)
https://github.com/PeterChou1 updated https://github.com/llvm/llvm-project/pull/97679 >From b5e0335199541225a1b0eb5eaf661cd4df55dbd7 Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Thu, 4 Jul 2024 01:14:11 -0400 Subject: [PATCH 1/3] [clang-doc] add enum test --- clang-tools-extra/test/clang-doc/enum.cpp | 38 +++ 1 file changed, 38 insertions(+) create mode 100644 clang-tools-extra/test/clang-doc/enum.cpp diff --git a/clang-tools-extra/test/clang-doc/enum.cpp b/clang-tools-extra/test/clang-doc/enum.cpp new file mode 100644 index 0..2f25eaf4e44e2 --- /dev/null +++ b/clang-tools-extra/test/clang-doc/enum.cpp @@ -0,0 +1,38 @@ +// RUN: clang-doc --format=html --doxygen --output=%t/docs --executor=standalone %s +// RUN: clang-doc --format=md --doxygen --output=%t/docs --executor=standalone %s +// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.html -check-prefix=HTML-INDEX +// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.md -check-prefix=MD-INDEX + +/** + * @brief For specifying RGB colors + */ +enum Color { + Red, // Red enums + Green, // Green enums + Blue // Blue enums +}; + +// HTML-INDEX: Global Namespace +// HTML-INDEX: Enums +// HTML-INDEX: +// HTML-INDEX: enum Color +// HTML-INDEX: +// HTML-INDEX: Red +// HTML-INDEX: Green +// HTML-INDEX: Blue +// HTML-INDEX: +// HTML-INDEX: Defined at line 11 of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp +// HTML-INDEX: +// HTML-INDEX: +// HTML-INDEX: +// HTML-INDEX: + +// MD-INDEX: # Global Namespace +// MD-INDEX: ## Enums +// MD-INDEX: | enum Color | +// MD-INDEX: -- +// MD-INDEX: | Red | +// MD-INDEX: | Green | +// MD-INDEX: | Blue | +// MD-INDEX: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#11* +// MD-INDEX: **brief** For specifying RGB colors \ No newline at end of file >From c10f9d42c26e6d26833a35824216529ab25e7fe8 Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Thu, 4 Jul 2024 01:53:19 -0400 Subject: [PATCH 2/3] [clang-doc] update defined at line --- clang-tools-extra/test/clang-doc/enum.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang-tools-extra/test/clang-doc/enum.cpp b/clang-tools-extra/test/clang-doc/enum.cpp index 2f25eaf4e44e2..1e7dd6e4c5b0c 100644 --- a/clang-tools-extra/test/clang-doc/enum.cpp +++ b/clang-tools-extra/test/clang-doc/enum.cpp @@ -21,7 +21,7 @@ enum Color { // HTML-INDEX: Green // HTML-INDEX: Blue // HTML-INDEX: -// HTML-INDEX: Defined at line 11 of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp +// HTML-INDEX: Defined at line 9 of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp // HTML-INDEX: // HTML-INDEX: // HTML-INDEX: >From 8709091091b0ca889ca7911e06b7a4dae61a3581 Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Thu, 4 Jul 2024 02:06:08 -0400 Subject: [PATCH 3/3] [clang-doc] fix lines --- clang-tools-extra/test/clang-doc/enum.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang-tools-extra/test/clang-doc/enum.cpp b/clang-tools-extra/test/clang-doc/enum.cpp index 1e7dd6e4c5b0c..5a1452788a55f 100644 --- a/clang-tools-extra/test/clang-doc/enum.cpp +++ b/clang-tools-extra/test/clang-doc/enum.cpp @@ -34,5 +34,5 @@ enum Color { // MD-INDEX: | Red | // MD-INDEX: | Green | // MD-INDEX: | Blue | -// MD-INDEX: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#11* +// MD-INDEX: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#9* // MD-INDEX: **brief** For specifying RGB colors \ 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
[clang-tools-extra] [clang-doc] Add another test project to clang-doc (PR #97518)
https://github.com/PeterChou1 edited https://github.com/llvm/llvm-project/pull/97518 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] Add another test project to clang-doc (PR #97518)
PeterChou1 wrote: I've split this pr into 3 including this PR - https://github.com/llvm/llvm-project/pull/97681 - https://github.com/llvm/llvm-project/pull/97679 https://github.com/llvm/llvm-project/pull/97518 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] add nested namespace test case (PR #97681)
llvmbot wrote: @llvm/pr-subscribers-clang-tools-extra Author: None (PeterChou1) Changes This patch adds a test to clang-doc which test the nested namespace generation of clang-doc --- Full diff: https://github.com/llvm/llvm-project/pull/97681.diff 1 Files Affected: - (added) clang-tools-extra/test/clang-doc/namespace.cpp (+340) ``diff diff --git a/clang-tools-extra/test/clang-doc/namespace.cpp b/clang-tools-extra/test/clang-doc/namespace.cpp new file mode 100644 index 0..6fb91c9aa3c51 --- /dev/null +++ b/clang-tools-extra/test/clang-doc/namespace.cpp @@ -0,0 +1,340 @@ +// RUN: clang-doc --format=html --output=%t/docs --executor=standalone %s +// RUN: clang-doc --format=md --output=%t/docs --executor=standalone %s +// RUN: FileCheck %s -input-file=%t/docs/index_json.js -check-prefix=JSON-INDEX +// RUN: FileCheck %s -input-file=%t/docs/@nonymous_namespace/AnonClass.html -check-prefix=HTML-ANON-CLASS +// RUN: FileCheck %s -input-file=%t/docs/@nonymous_namespace/index.html -check-prefix=HTML-ANON-INDEX +// RUN: FileCheck %s -input-file=%t/docs/AnotherNamespace/ClassInAnotherNamespace.html -check-prefix=HTML-ANOTHER-CLASS +// RUN: FileCheck %s -input-file=%t/docs/AnotherNamespace/index.html -check-prefix=HTML-ANOTHER-INDEX +// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.html -check-prefix=HTML-GLOBAL-INDEX +// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/NestedNamespace/ClassInNestedNamespace.html -check-prefix=HTML-NESTED-CLASS +// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/NestedNamespace/index.html -check-prefix=HTML-NESTED-INDEX +// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/index.html -check-prefix=HTML-PRIMARY-INDEX +// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/ClassInPrimaryNamespace.html -check-prefix=HTML-PRIMARY-CLASS +// RUN: FileCheck %s -input-file=%t/docs/@nonymous_namespace/AnonClass.md -check-prefix=MD-ANON-CLASS +// RUN: FileCheck %s -input-file=%t/docs/@nonymous_namespace/index.md -check-prefix=MD-ANON-INDEX +// RUN: FileCheck %s -input-file=%t/docs/AnotherNamespace/ClassInAnotherNamespace.md -check-prefix=MD-ANOTHER-CLASS +// RUN: FileCheck %s -input-file=%t/docs/AnotherNamespace/index.md -check-prefix=MD-ANOTHER-INDEX +// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.md -check-prefix=MD-GLOBAL-INDEX +// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/NestedNamespace/ClassInNestedNamespace.md -check-prefix=MD-NESTED-CLASS +// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/NestedNamespace/index.md -check-prefix=MD-NESTED-INDEX +// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/index.md -check-prefix=MD-PRIMARY-INDEX +// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/ClassInPrimaryNamespace.md -check-prefix=MD-PRIMARY-CLASS +// RUN: FileCheck %s -input-file=%t/docs/all_files.md -check-prefix=MD-ALL-FILES +// RUN: FileCheck %s -input-file=%t/docs/index.md -check-prefix=MD-INDEX + +// Anonymous Namespace +namespace +{ +void anonFunction() {} +class AnonClass {}; +} + +// Primary Namespace +namespace PrimaryNamespace { +// Function in PrimaryNamespace +void functionInPrimaryNamespace() {} + +// Class in PrimaryNamespace +class ClassInPrimaryNamespace {}; + +// Nested namespace +namespace NestedNamespace { +// Function in NestedNamespace +void functionInNestedNamespace() {} +// Class in NestedNamespace +class ClassInNestedNamespace {}; +} +} + +// AnotherNamespace +namespace AnotherNamespace { +// Function in AnotherNamespace +void functionInAnotherNamespace() {} +// Class in AnotherNamespace +class ClassInAnotherNamespace {}; +} + +// JSON-INDEX: async function LoadIndex() { +// JSON-INDEX-NEXT: return{ +// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}", +// JSON-INDEX-NEXT: "Name": "", +// JSON-INDEX-NEXT: "RefType": "default", +// JSON-INDEX-NEXT: "Path": "", +// JSON-INDEX-NEXT: "Children": [ +// JSON-INDEX-NEXT: { +// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}", +// JSON-INDEX-NEXT: "Name": "@nonymous_namespace", +// JSON-INDEX-NEXT: "RefType": "namespace", +// JSON-INDEX-NEXT: "Path": "@nonymous_namespace", +// JSON-INDEX-NEXT: "Children": [ +// JSON-INDEX-NEXT: { +// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}", +// JSON-INDEX-NEXT: "Name": "AnonClass", +// JSON-INDEX-NEXT: "RefType": "record", +// JSON-INDEX-NEXT: "Path": "@nonymous_namespace", +// JSON-INDEX-NEXT: "Children": [] +// JSON-INDEX-NEXT: } +// JSON-INDEX-NEXT: ] +// JSON-INDEX-NEXT: }, +// JSON-INDEX-NEXT: { +// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}", +// JSON-INDEX-NEXT: "Name": "AnotherNamespace", +// JSON-INDEX-NEXT: "RefType": "namespace", +// JSON-INDEX-NEXT: "Path": "AnotherNamespace", +// JSON-INDEX-NEXT: "Childr
[clang-tools-extra] [clang-doc] add nested namespace test case (PR #97681)
https://github.com/PeterChou1 created https://github.com/llvm/llvm-project/pull/97681 This patch adds a test to clang-doc which test the nested namespace generation of clang-doc >From f9d5cc074e4b65a92703bd09e62696a29fed1237 Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Thu, 4 Jul 2024 01:31:13 -0400 Subject: [PATCH] [clang-doc] add nested naemspace --- .../test/clang-doc/namespace.cpp | 340 ++ 1 file changed, 340 insertions(+) create mode 100644 clang-tools-extra/test/clang-doc/namespace.cpp diff --git a/clang-tools-extra/test/clang-doc/namespace.cpp b/clang-tools-extra/test/clang-doc/namespace.cpp new file mode 100644 index 0..6fb91c9aa3c51 --- /dev/null +++ b/clang-tools-extra/test/clang-doc/namespace.cpp @@ -0,0 +1,340 @@ +// RUN: clang-doc --format=html --output=%t/docs --executor=standalone %s +// RUN: clang-doc --format=md --output=%t/docs --executor=standalone %s +// RUN: FileCheck %s -input-file=%t/docs/index_json.js -check-prefix=JSON-INDEX +// RUN: FileCheck %s -input-file=%t/docs/@nonymous_namespace/AnonClass.html -check-prefix=HTML-ANON-CLASS +// RUN: FileCheck %s -input-file=%t/docs/@nonymous_namespace/index.html -check-prefix=HTML-ANON-INDEX +// RUN: FileCheck %s -input-file=%t/docs/AnotherNamespace/ClassInAnotherNamespace.html -check-prefix=HTML-ANOTHER-CLASS +// RUN: FileCheck %s -input-file=%t/docs/AnotherNamespace/index.html -check-prefix=HTML-ANOTHER-INDEX +// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.html -check-prefix=HTML-GLOBAL-INDEX +// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/NestedNamespace/ClassInNestedNamespace.html -check-prefix=HTML-NESTED-CLASS +// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/NestedNamespace/index.html -check-prefix=HTML-NESTED-INDEX +// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/index.html -check-prefix=HTML-PRIMARY-INDEX +// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/ClassInPrimaryNamespace.html -check-prefix=HTML-PRIMARY-CLASS +// RUN: FileCheck %s -input-file=%t/docs/@nonymous_namespace/AnonClass.md -check-prefix=MD-ANON-CLASS +// RUN: FileCheck %s -input-file=%t/docs/@nonymous_namespace/index.md -check-prefix=MD-ANON-INDEX +// RUN: FileCheck %s -input-file=%t/docs/AnotherNamespace/ClassInAnotherNamespace.md -check-prefix=MD-ANOTHER-CLASS +// RUN: FileCheck %s -input-file=%t/docs/AnotherNamespace/index.md -check-prefix=MD-ANOTHER-INDEX +// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.md -check-prefix=MD-GLOBAL-INDEX +// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/NestedNamespace/ClassInNestedNamespace.md -check-prefix=MD-NESTED-CLASS +// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/NestedNamespace/index.md -check-prefix=MD-NESTED-INDEX +// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/index.md -check-prefix=MD-PRIMARY-INDEX +// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/ClassInPrimaryNamespace.md -check-prefix=MD-PRIMARY-CLASS +// RUN: FileCheck %s -input-file=%t/docs/all_files.md -check-prefix=MD-ALL-FILES +// RUN: FileCheck %s -input-file=%t/docs/index.md -check-prefix=MD-INDEX + +// Anonymous Namespace +namespace +{ +void anonFunction() {} +class AnonClass {}; +} + +// Primary Namespace +namespace PrimaryNamespace { +// Function in PrimaryNamespace +void functionInPrimaryNamespace() {} + +// Class in PrimaryNamespace +class ClassInPrimaryNamespace {}; + +// Nested namespace +namespace NestedNamespace { +// Function in NestedNamespace +void functionInNestedNamespace() {} +// Class in NestedNamespace +class ClassInNestedNamespace {}; +} +} + +// AnotherNamespace +namespace AnotherNamespace { +// Function in AnotherNamespace +void functionInAnotherNamespace() {} +// Class in AnotherNamespace +class ClassInAnotherNamespace {}; +} + +// JSON-INDEX: async function LoadIndex() { +// JSON-INDEX-NEXT: return{ +// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}", +// JSON-INDEX-NEXT: "Name": "", +// JSON-INDEX-NEXT: "RefType": "default", +// JSON-INDEX-NEXT: "Path": "", +// JSON-INDEX-NEXT: "Children": [ +// JSON-INDEX-NEXT: { +// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}", +// JSON-INDEX-NEXT: "Name": "@nonymous_namespace", +// JSON-INDEX-NEXT: "RefType": "namespace", +// JSON-INDEX-NEXT: "Path": "@nonymous_namespace", +// JSON-INDEX-NEXT: "Children": [ +// JSON-INDEX-NEXT: { +// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}", +// JSON-INDEX-NEXT: "Name": "AnonClass", +// JSON-INDEX-NEXT: "RefType": "record", +// JSON-INDEX-NEXT: "Path": "@nonymous_namespace", +// JSON-INDEX-NEXT: "Children": [] +// JSON-INDEX-NEXT: } +// JSON-INDEX-NEXT: ] +// JSON-INDEX-NEXT: }, +// JSON-INDEX-NEXT: { +// JSON-INDEX-NEXT: "USR": "{{([0-9A-F]{40})}}", +// JSON-INDEX-NE
[clang-tools-extra] [clang-doc] add enum test (PR #97679)
https://github.com/PeterChou1 updated https://github.com/llvm/llvm-project/pull/97679 >From b5e0335199541225a1b0eb5eaf661cd4df55dbd7 Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Thu, 4 Jul 2024 01:14:11 -0400 Subject: [PATCH 1/2] [clang-doc] add enum test --- clang-tools-extra/test/clang-doc/enum.cpp | 38 +++ 1 file changed, 38 insertions(+) create mode 100644 clang-tools-extra/test/clang-doc/enum.cpp diff --git a/clang-tools-extra/test/clang-doc/enum.cpp b/clang-tools-extra/test/clang-doc/enum.cpp new file mode 100644 index 0..2f25eaf4e44e2 --- /dev/null +++ b/clang-tools-extra/test/clang-doc/enum.cpp @@ -0,0 +1,38 @@ +// RUN: clang-doc --format=html --doxygen --output=%t/docs --executor=standalone %s +// RUN: clang-doc --format=md --doxygen --output=%t/docs --executor=standalone %s +// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.html -check-prefix=HTML-INDEX +// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.md -check-prefix=MD-INDEX + +/** + * @brief For specifying RGB colors + */ +enum Color { + Red, // Red enums + Green, // Green enums + Blue // Blue enums +}; + +// HTML-INDEX: Global Namespace +// HTML-INDEX: Enums +// HTML-INDEX: +// HTML-INDEX: enum Color +// HTML-INDEX: +// HTML-INDEX: Red +// HTML-INDEX: Green +// HTML-INDEX: Blue +// HTML-INDEX: +// HTML-INDEX: Defined at line 11 of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp +// HTML-INDEX: +// HTML-INDEX: +// HTML-INDEX: +// HTML-INDEX: + +// MD-INDEX: # Global Namespace +// MD-INDEX: ## Enums +// MD-INDEX: | enum Color | +// MD-INDEX: -- +// MD-INDEX: | Red | +// MD-INDEX: | Green | +// MD-INDEX: | Blue | +// MD-INDEX: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#11* +// MD-INDEX: **brief** For specifying RGB colors \ No newline at end of file >From c10f9d42c26e6d26833a35824216529ab25e7fe8 Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Thu, 4 Jul 2024 01:53:19 -0400 Subject: [PATCH 2/2] [clang-doc] update defined at line --- clang-tools-extra/test/clang-doc/enum.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang-tools-extra/test/clang-doc/enum.cpp b/clang-tools-extra/test/clang-doc/enum.cpp index 2f25eaf4e44e2..1e7dd6e4c5b0c 100644 --- a/clang-tools-extra/test/clang-doc/enum.cpp +++ b/clang-tools-extra/test/clang-doc/enum.cpp @@ -21,7 +21,7 @@ enum Color { // HTML-INDEX: Green // HTML-INDEX: Blue // HTML-INDEX: -// HTML-INDEX: Defined at line 11 of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp +// HTML-INDEX: Defined at line 9 of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp // HTML-INDEX: // HTML-INDEX: // HTML-INDEX: ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] add enum test (PR #97679)
llvmbot wrote: @llvm/pr-subscribers-clang-tools-extra Author: None (PeterChou1) Changes This patch adds a test which test the enum generation for clang-doc. --- Full diff: https://github.com/llvm/llvm-project/pull/97679.diff 1 Files Affected: - (added) clang-tools-extra/test/clang-doc/enum.cpp (+38) ``diff diff --git a/clang-tools-extra/test/clang-doc/enum.cpp b/clang-tools-extra/test/clang-doc/enum.cpp new file mode 100644 index 0..2f25eaf4e44e2 --- /dev/null +++ b/clang-tools-extra/test/clang-doc/enum.cpp @@ -0,0 +1,38 @@ +// RUN: clang-doc --format=html --doxygen --output=%t/docs --executor=standalone %s +// RUN: clang-doc --format=md --doxygen --output=%t/docs --executor=standalone %s +// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.html -check-prefix=HTML-INDEX +// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.md -check-prefix=MD-INDEX + +/** + * @brief For specifying RGB colors + */ +enum Color { + Red, // Red enums + Green, // Green enums + Blue // Blue enums +}; + +// HTML-INDEX: Global Namespace +// HTML-INDEX: Enums +// HTML-INDEX: +// HTML-INDEX: enum Color +// HTML-INDEX: +// HTML-INDEX: Red +// HTML-INDEX: Green +// HTML-INDEX: Blue +// HTML-INDEX: +// HTML-INDEX: Defined at line 11 of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp +// HTML-INDEX: +// HTML-INDEX: +// HTML-INDEX: +// HTML-INDEX: + +// MD-INDEX: # Global Namespace +// MD-INDEX: ## Enums +// MD-INDEX: | enum Color | +// MD-INDEX: -- +// MD-INDEX: | Red | +// MD-INDEX: | Green | +// MD-INDEX: | Blue | +// MD-INDEX: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#11* +// MD-INDEX: **brief** For specifying RGB colors \ No newline at end of file `` https://github.com/llvm/llvm-project/pull/97679 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] add enum test (PR #97679)
https://github.com/PeterChou1 created https://github.com/llvm/llvm-project/pull/97679 This patch adds a test which test the enum generation for clang-doc. >From b5e0335199541225a1b0eb5eaf661cd4df55dbd7 Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Thu, 4 Jul 2024 01:14:11 -0400 Subject: [PATCH] [clang-doc] add enum test --- clang-tools-extra/test/clang-doc/enum.cpp | 38 +++ 1 file changed, 38 insertions(+) create mode 100644 clang-tools-extra/test/clang-doc/enum.cpp diff --git a/clang-tools-extra/test/clang-doc/enum.cpp b/clang-tools-extra/test/clang-doc/enum.cpp new file mode 100644 index 0..2f25eaf4e44e2 --- /dev/null +++ b/clang-tools-extra/test/clang-doc/enum.cpp @@ -0,0 +1,38 @@ +// RUN: clang-doc --format=html --doxygen --output=%t/docs --executor=standalone %s +// RUN: clang-doc --format=md --doxygen --output=%t/docs --executor=standalone %s +// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.html -check-prefix=HTML-INDEX +// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.md -check-prefix=MD-INDEX + +/** + * @brief For specifying RGB colors + */ +enum Color { + Red, // Red enums + Green, // Green enums + Blue // Blue enums +}; + +// HTML-INDEX: Global Namespace +// HTML-INDEX: Enums +// HTML-INDEX: +// HTML-INDEX: enum Color +// HTML-INDEX: +// HTML-INDEX: Red +// HTML-INDEX: Green +// HTML-INDEX: Blue +// HTML-INDEX: +// HTML-INDEX: Defined at line 11 of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp +// HTML-INDEX: +// HTML-INDEX: +// HTML-INDEX: +// HTML-INDEX: + +// MD-INDEX: # Global Namespace +// MD-INDEX: ## Enums +// MD-INDEX: | enum Color | +// MD-INDEX: -- +// MD-INDEX: | Red | +// MD-INDEX: | Green | +// MD-INDEX: | Blue | +// MD-INDEX: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#11* +// MD-INDEX: **brief** For specifying RGB colors \ 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
[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)
@@ -3183,8 +3193,31 @@ bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) { DiagID = diag::ext_no_newline_eof; } -Diag(BufferEnd, DiagID) - << FixItHint::CreateInsertion(EndLoc, "\n"); +if (LastNewline.empty()) { + Diag(BufferEnd, DiagID) << FixItHint::CreateInsertion(EndLoc, "\n"); +} else { + // While the file physically ends in a newline, the previous + // line might have ended in a splice, so it would be deleted + const char *LastSpliceLocation = LastNewline.data(); + while (LastSpliceLocation != BufferStart && + isHorizontalWhitespace(*--LastSpliceLocation)) +; Sirraide wrote: This might just be me, but I personally typically prefer not to have `*--...` or `*...--` in the condition of a loop because it always gives me a massive headache when I think about what state everything is supposed to be in when the loop terminates. I *think* this might be correct, but I’m not 100% sure. https://github.com/llvm/llvm-project/pull/97585 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)
https://github.com/Sirraide commented: The approach overall seems fine, but a few more tests would be nice. https://github.com/llvm/llvm-project/pull/97585 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)
@@ -3183,8 +3193,31 @@ bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) { DiagID = diag::ext_no_newline_eof; } -Diag(BufferEnd, DiagID) - << FixItHint::CreateInsertion(EndLoc, "\n"); +if (LastNewline.empty()) { + Diag(BufferEnd, DiagID) << FixItHint::CreateInsertion(EndLoc, "\n"); +} else { + // While the file physically ends in a newline, the previous + // line might have ended in a splice, so it would be deleted + const char *LastSpliceLocation = LastNewline.data(); + while (LastSpliceLocation != BufferStart && + isHorizontalWhitespace(*--LastSpliceLocation)) +; + + bool LastIsSplice = *LastSpliceLocation == '\\'; + if (*LastSpliceLocation == '/' && LangOpts.Trigraphs) +// Check for "??/" trigraph for "\" +LastIsSplice = +LastSpliceLocation != BufferStart && *--LastSpliceLocation == '?' && +LastSpliceLocation != BufferStart && *--LastSpliceLocation == '?'; Sirraide wrote: There don’t seem to be any tests for this either (and just for the record, the `*--` here is fine imo). https://github.com/llvm/llvm-project/pull/97585 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)
@@ -3183,8 +3193,31 @@ bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) { DiagID = diag::ext_no_newline_eof; } -Diag(BufferEnd, DiagID) - << FixItHint::CreateInsertion(EndLoc, "\n"); +if (LastNewline.empty()) { + Diag(BufferEnd, DiagID) << FixItHint::CreateInsertion(EndLoc, "\n"); +} else { + // While the file physically ends in a newline, the previous + // line might have ended in a splice, so it would be deleted + const char *LastSpliceLocation = LastNewline.data(); + while (LastSpliceLocation != BufferStart && + isHorizontalWhitespace(*--LastSpliceLocation)) +; Sirraide wrote: On that note, we appear to be missing tests for when there is horizontal whitespace after a splice. https://github.com/llvm/llvm-project/pull/97585 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Warn on backslash-newline-EOF (PR #97585)
https://github.com/Sirraide edited https://github.com/llvm/llvm-project/pull/97585 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [X86][CodeGen] security check cookie execute only when needed (PR #95904)
@@ -0,0 +1,247 @@ +//=== X86FixupBufferSecurityCheck.cpp Fix Buffer Security Check Call---===// mahesh-attarde wrote: done https://github.com/llvm/llvm-project/pull/95904 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Allow raw string literals in C as an extension (PR #88265)
Sirraide wrote: Alright, I just enabled raw string literals in the dependency scanner by default; barring any further complications, I’ll merge this once CI is done. https://github.com/llvm/llvm-project/pull/88265 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Allow raw string literals in C as an extension (PR #88265)
https://github.com/Sirraide updated https://github.com/llvm/llvm-project/pull/88265 >From 40e533e6f58acbe832b3fa4e14ca9fd600cf77cf Mon Sep 17 00:00:00 2001 From: Sirraide Date: Wed, 10 Apr 2024 14:36:23 +0200 Subject: [PATCH 1/7] [Clang] Allow raw string literals in C as an extension --- clang/docs/ReleaseNotes.rst | 3 +++ clang/include/clang/Basic/LangOptions.def | 2 ++ clang/include/clang/Basic/LangStandard.h | 6 ++ clang/include/clang/Driver/Options.td | 6 ++ clang/lib/Basic/LangOptions.cpp | 1 + clang/lib/Driver/ToolChains/Clang.cpp | 2 ++ clang/lib/Format/Format.cpp | 1 + clang/lib/Lex/Lexer.cpp | 10 +- clang/test/Lexer/raw-string-ext.c | 18 ++ 9 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 clang/test/Lexer/raw-string-ext.c diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index f96cebbde3d82..20d14130fb62b 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -43,6 +43,9 @@ code bases. C/C++ Language Potentially Breaking Changes --- +- Clang now supports raw string literals in ``-std=gnuXY`` mode as an extension in + C. This behaviour can also be overridden using ``-f[no-]raw-string-literals``. + C++ Specific Potentially Breaking Changes - - Clang now diagnoses function/variable templates that shadow their own template parameters, e.g. ``template void T();``. diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 8ef6700ecdc78..96bd339bb1851 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -454,6 +454,8 @@ LANGOPT(MatrixTypes, 1, 0, "Enable or disable the builtin matrix type") LANGOPT(CXXAssumptions, 1, 1, "Enable or disable codegen and compile-time checks for C++23's [[assume]] attribute") +LANGOPT(RawStringLiterals, 1, 0, "Enable or disable raw string literals") + ENUM_LANGOPT(StrictFlexArraysLevel, StrictFlexArraysLevelKind, 2, StrictFlexArraysLevelKind::Default, "Rely on strict definition of flexible arrays") diff --git a/clang/include/clang/Basic/LangStandard.h b/clang/include/clang/Basic/LangStandard.h index 8e25afc833661..0a308b93ada74 100644 --- a/clang/include/clang/Basic/LangStandard.h +++ b/clang/include/clang/Basic/LangStandard.h @@ -130,6 +130,12 @@ struct LangStandard { /// hasDigraphs - Language supports digraphs. bool hasDigraphs() const { return Flags & Digraphs; } + /// hasRawStringLiterals - Language supports R"()" raw string literals. + bool hasRawStringLiterals() const { +// GCC supports raw string literals in C, but not in C++ before C++11. +return isCPlusPlus11() || (!isCPlusPlus() && isGNUMode()); + } + /// isGNUMode - Language includes GNU extensions. bool isGNUMode() const { return Flags & GNUMode; } diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index f745e573eb268..32e6c10e1251b 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4142,6 +4142,12 @@ def fenable_matrix : Flag<["-"], "fenable-matrix">, Group, HelpText<"Enable matrix data type and related builtin functions">, MarshallingInfoFlag>; +defm raw_string_literals : BoolFOption<"raw-string-literals", +LangOpts<"RawStringLiterals">, Default, +PosFlag, +NegFlag, +BothFlags<[], [ClangOption, CC1Option], " raw string literals">>; + def fzero_call_used_regs_EQ : Joined<["-"], "fzero-call-used-regs=">, Group, Visibility<[ClangOption, CC1Option]>, diff --git a/clang/lib/Basic/LangOptions.cpp b/clang/lib/Basic/LangOptions.cpp index a0adfbf61840e..c34f0ed5ed717 100644 --- a/clang/lib/Basic/LangOptions.cpp +++ b/clang/lib/Basic/LangOptions.cpp @@ -124,6 +124,7 @@ void LangOptions::setLangDefaults(LangOptions &Opts, Language Lang, Opts.HexFloats = Std.hasHexFloats(); Opts.WChar = Std.isCPlusPlus(); Opts.Digraphs = Std.hasDigraphs(); + Opts.RawStringLiterals = Std.hasRawStringLiterals(); Opts.HLSL = Lang == Language::HLSL; if (Opts.HLSL && Opts.IncludeDefaultHeader) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 766a9b91e3c0a..c99bfe4efc413 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -6536,6 +6536,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, Args.AddLastArg(CmdArgs, options::OPT_fheinous_gnu_extensions); Args.AddLastArg(CmdArgs, options::OPT_fdigraphs, options::OPT_fno_digraphs); Args.AddLastArg(CmdArgs, options::OPT_fzero_call_used_regs_EQ); + Args.AddLastArg(CmdArgs, options::OPT_fraw_string_literals, + options::OPT_fno_raw_string_literals); if (Args.hasFlag(options::OPT_f
[clang] [Clang] Disallow explicit object parameters in more contexts (PR #89078)
Sirraide wrote: ping https://github.com/llvm/llvm-project/pull/89078 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema] Fix crash in Sema::FindInstantiatedDecl (PR #96509)
@@ -6300,7 +6300,7 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, getTrivialTemplateArgumentLoc(UnpackedArg, QualType(), Loc)); } QualType T = CheckTemplateIdType(TemplateName(TD), Loc, Args); - if (T.isNull()) + if (T.isNull() || T->containsErrors()) Sirraide wrote: Is there a reason this check isn’t done in `CheckTemplateIdType()` instead? Because there are a few other places where this exact pattern appears; is there a difference between this and other uses of `CheckTemplateIdType()` that makes it so it only makes sense to check for errors here (and if so, then that would probably deserve a comment explaining that)? https://github.com/llvm/llvm-project/pull/96509 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][OpenMP] This is addition fix for #92210. (PR #94802)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `sanitizer-x86_64-linux` running on `sanitizer-buildbot1` while building `clang,offload` at step 2 "annotate". Full details are available at: https://lab.llvm.org/buildbot/#/builders/66/builds/995 Here is the relevant piece of the build log for the reference: ``` Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure) ... llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_symbolizer/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir']. llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_symbolizer/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-Wthread-safety', '-Wthread-safety-reference', '-Wthread-safety-beta', '-print-runtime-dir']. llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_symbolizer/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir']. llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_symbolizer/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir']. llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_symbolizer/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir']. llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_symbolizer/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir']. llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds. -- Testing: 9980 tests, 80 workers -- Testing: 0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. TIMEOUT: SanitizerCommon-hwasan-x86_64-Linux :: Posix/fork_threaded.c (9980 of 9980) TEST 'SanitizerCommon-hwasan-x86_64-Linux :: Posix/fork_threaded.c' FAILED Exit Code: 137 Timeout: Reached timeout of 900 seconds Command Output (stderr): -- RUN: at line 1: /b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -fsanitize-hwaddress-experimental-aliasing -m64 -funwind-tables -I/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test -ldl -O0 /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c -o /b/sanitizer-x86_64-linux/build/build_symbolizer/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp && env HWASAN_OPTIONS=die_after_fork=0 /b/sanitizer-x86_64-linux/build/build_symbolizer/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp + /b/sanitizer-x86_64-linux/build/build_symbolizer/./bin/clang -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -fsanitize-hwaddress-experimental-aliasing -m64 -funwind-tables -I/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test -ldl -O0 /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c -o /b/sanitizer-x86_64-linux/build/build_symbolizer/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp + env HWASAN_OPTIONS=die_after_fork=0 /b/sanitizer-x86_64-linux/build/build_sy
[clang-tools-extra] [llvm] [clang-doc] fix bug introduced by asset test (PR #97540)
https://github.com/PeterChou1 updated https://github.com/llvm/llvm-project/pull/97540 >From b8dd4f6f2005d2e08ae13023905d0f36edd6348b Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Wed, 3 Jul 2024 04:42:33 -0400 Subject: [PATCH 1/9] [clang-doc] fix path bug introduced by asset test --- clang-tools-extra/clang-doc/tool/CMakeLists.txt | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt index e93a5728d6b6b..3fd41f187a617 100644 --- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt @@ -25,7 +25,11 @@ set(assets ) set(asset_dir "${CMAKE_CURRENT_SOURCE_DIR}/../assets") -set(resource_dir "${CMAKE_BINARY_DIR}/share/clang-doc") +if(MSVC) + set(resource_dir "${CMAKE_BINARY_DIR}/$/share/clang-doc") +else() + set(resource_dir "${CMAKE_BINARY_DIR}/share/clang-doc") +endif() set(out_files) function(copy_files_to_dst src_dir dst_dir file) @@ -52,4 +56,4 @@ add_custom_target(copy-clang-doc-assets COMMENT "Copying Clang-Doc Assets" ) set_target_properties(copy-clang-doc-assets PROPERTIES FOLDER "Clang-Doc/Assets") -add_dependencies(clang-doc copy-clang-doc-assets) +add_dependencies(clang-doc copy-clang-doc-assets) \ No newline at end of file >From cf993cfeeab18be6aa434e159fb625456183d4da Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Wed, 3 Jul 2024 13:49:26 -0400 Subject: [PATCH 2/9] [clang-doc] modify cmake file to fix asset install path --- clang-tools-extra/clang-doc/tool/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt index 3fd41f187a617..ddaf8cd4cdbd6 100644 --- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt @@ -25,7 +25,7 @@ set(assets ) set(asset_dir "${CMAKE_CURRENT_SOURCE_DIR}/../assets") -if(MSVC) +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") set(resource_dir "${CMAKE_BINARY_DIR}/$/share/clang-doc") else() set(resource_dir "${CMAKE_BINARY_DIR}/share/clang-doc") >From e389b78848127be9753797d355d196c03e3974fd Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Wed, 3 Jul 2024 14:14:56 -0400 Subject: [PATCH 3/9] [clang-doc] fix nit --- clang-tools-extra/clang-doc/tool/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt index ddaf8cd4cdbd6..aaf3c3b8734c8 100644 --- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt @@ -56,4 +56,4 @@ add_custom_target(copy-clang-doc-assets COMMENT "Copying Clang-Doc Assets" ) set_target_properties(copy-clang-doc-assets PROPERTIES FOLDER "Clang-Doc/Assets") -add_dependencies(clang-doc copy-clang-doc-assets) \ No newline at end of file +add_dependencies(clang-doc copy-clang-doc-assets) >From 4733341a26ef3b6faa1a00d2e53b0033de440eb7 Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Wed, 3 Jul 2024 16:04:37 -0400 Subject: [PATCH 4/9] [llvm] modify cmake list to add shared directory --- clang-tools-extra/clang-doc/tool/CMakeLists.txt | 7 +-- llvm/CMakeLists.txt | 6 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt index aaf3c3b8734c8..c908cac9ce2a5 100644 --- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt @@ -25,11 +25,6 @@ set(assets ) set(asset_dir "${CMAKE_CURRENT_SOURCE_DIR}/../assets") -if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") - set(resource_dir "${CMAKE_BINARY_DIR}/$/share/clang-doc") -else() - set(resource_dir "${CMAKE_BINARY_DIR}/share/clang-doc") -endif() set(out_files) function(copy_files_to_dst src_dir dst_dir file) @@ -48,7 +43,7 @@ foreach(f ${assets}) install(FILES ${asset_dir}/${f} DESTINATION "${CMAKE_INSTALL_DATADIR}/clang-doc" COMPONENT clang-doc) - copy_files_to_dst(${asset_dir} ${resource_dir} ${f}) + copy_files_to_dst(${asset_dir} ${LLVM_SHARE_DIR} ${f}) endforeach(f) add_custom_target(copy-clang-doc-assets diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 91a2b6181ce0a..0c02498aa6fce 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -452,6 +452,12 @@ if(WIN32 OR CYGWIN) else() set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) endif() +# set shared directory +if(CMAKE_GENERATOR MATCHES "Visual Studio") + set(LLVM_SHARE_DIR "${CMAKE_BINARY_DIR}/$/share") +else() + set(LLVM_SHARE_DIR "${CMAKE_BINARY_DIR}/share") +endif() # Each of them corresponds to llvm-config's. set(LLVM_TOOLS_BINARY_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) # --bindir >From 3433bfecffe25077fc1749be6c30512e2e47eadb Mon Sep 17 00:00
[clang-tools-extra] [llvm] [clang-doc] fix bug introduced by asset test (PR #97540)
https://github.com/PeterChou1 updated https://github.com/llvm/llvm-project/pull/97540 >From b8dd4f6f2005d2e08ae13023905d0f36edd6348b Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Wed, 3 Jul 2024 04:42:33 -0400 Subject: [PATCH 1/8] [clang-doc] fix path bug introduced by asset test --- clang-tools-extra/clang-doc/tool/CMakeLists.txt | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt index e93a5728d6b6b..3fd41f187a617 100644 --- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt @@ -25,7 +25,11 @@ set(assets ) set(asset_dir "${CMAKE_CURRENT_SOURCE_DIR}/../assets") -set(resource_dir "${CMAKE_BINARY_DIR}/share/clang-doc") +if(MSVC) + set(resource_dir "${CMAKE_BINARY_DIR}/$/share/clang-doc") +else() + set(resource_dir "${CMAKE_BINARY_DIR}/share/clang-doc") +endif() set(out_files) function(copy_files_to_dst src_dir dst_dir file) @@ -52,4 +56,4 @@ add_custom_target(copy-clang-doc-assets COMMENT "Copying Clang-Doc Assets" ) set_target_properties(copy-clang-doc-assets PROPERTIES FOLDER "Clang-Doc/Assets") -add_dependencies(clang-doc copy-clang-doc-assets) +add_dependencies(clang-doc copy-clang-doc-assets) \ No newline at end of file >From cf993cfeeab18be6aa434e159fb625456183d4da Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Wed, 3 Jul 2024 13:49:26 -0400 Subject: [PATCH 2/8] [clang-doc] modify cmake file to fix asset install path --- clang-tools-extra/clang-doc/tool/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt index 3fd41f187a617..ddaf8cd4cdbd6 100644 --- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt @@ -25,7 +25,7 @@ set(assets ) set(asset_dir "${CMAKE_CURRENT_SOURCE_DIR}/../assets") -if(MSVC) +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") set(resource_dir "${CMAKE_BINARY_DIR}/$/share/clang-doc") else() set(resource_dir "${CMAKE_BINARY_DIR}/share/clang-doc") >From e389b78848127be9753797d355d196c03e3974fd Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Wed, 3 Jul 2024 14:14:56 -0400 Subject: [PATCH 3/8] [clang-doc] fix nit --- clang-tools-extra/clang-doc/tool/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt index ddaf8cd4cdbd6..aaf3c3b8734c8 100644 --- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt @@ -56,4 +56,4 @@ add_custom_target(copy-clang-doc-assets COMMENT "Copying Clang-Doc Assets" ) set_target_properties(copy-clang-doc-assets PROPERTIES FOLDER "Clang-Doc/Assets") -add_dependencies(clang-doc copy-clang-doc-assets) \ No newline at end of file +add_dependencies(clang-doc copy-clang-doc-assets) >From 4733341a26ef3b6faa1a00d2e53b0033de440eb7 Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Wed, 3 Jul 2024 16:04:37 -0400 Subject: [PATCH 4/8] [llvm] modify cmake list to add shared directory --- clang-tools-extra/clang-doc/tool/CMakeLists.txt | 7 +-- llvm/CMakeLists.txt | 6 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt index aaf3c3b8734c8..c908cac9ce2a5 100644 --- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt @@ -25,11 +25,6 @@ set(assets ) set(asset_dir "${CMAKE_CURRENT_SOURCE_DIR}/../assets") -if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") - set(resource_dir "${CMAKE_BINARY_DIR}/$/share/clang-doc") -else() - set(resource_dir "${CMAKE_BINARY_DIR}/share/clang-doc") -endif() set(out_files) function(copy_files_to_dst src_dir dst_dir file) @@ -48,7 +43,7 @@ foreach(f ${assets}) install(FILES ${asset_dir}/${f} DESTINATION "${CMAKE_INSTALL_DATADIR}/clang-doc" COMPONENT clang-doc) - copy_files_to_dst(${asset_dir} ${resource_dir} ${f}) + copy_files_to_dst(${asset_dir} ${LLVM_SHARE_DIR} ${f}) endforeach(f) add_custom_target(copy-clang-doc-assets diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 91a2b6181ce0a..0c02498aa6fce 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -452,6 +452,12 @@ if(WIN32 OR CYGWIN) else() set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) endif() +# set shared directory +if(CMAKE_GENERATOR MATCHES "Visual Studio") + set(LLVM_SHARE_DIR "${CMAKE_BINARY_DIR}/$/share") +else() + set(LLVM_SHARE_DIR "${CMAKE_BINARY_DIR}/share") +endif() # Each of them corresponds to llvm-config's. set(LLVM_TOOLS_BINARY_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) # --bindir >From 3433bfecffe25077fc1749be6c30512e2e47eadb Mon Sep 17 00:00
[clang] [llvm] [Clang][OpenMP] This is addition fix for #92210. (PR #94802)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `sanitizer-ppc64le-linux` running on `ppc64le-sanitizer` while building `clang,offload` at step 2 "annotate". Full details are available at: https://lab.llvm.org/buildbot/#/builders/72/builds/780 Here is the relevant piece of the build log for the reference: ``` Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure) ... PASS: SanitizerCommon-tsan-powerpc64le-Linux :: Linux/signal_trap_handler.cpp (924 of 2450) PASS: ThreadSanitizer-Unit :: unit/./TsanUnitTest-powerpc64le-Test/4/33 (925 of 2450) PASS: MemorySanitizer-Unit :: ./Msan-powerpc64le-Test/277/281 (926 of 2450) PASS: MemorySanitizer-Unit :: ./Msan-powerpc64le-with-call-Test/6/281 (927 of 2450) PASS: ThreadSanitizer-powerpc64le :: exceptions.cpp (928 of 2450) PASS: Profile-powerpc64le :: ContinuousSyncMode/runtime-counter-relocation.c (929 of 2450) PASS: SanitizerCommon-lsan-powerpc64le-Linux :: Posix/bsearch.cpp (930 of 2450) PASS: SanitizerCommon-lsan-powerpc64le-Linux :: allocator_returns_null.cpp (931 of 2450) PASS: MemorySanitizer-Unit :: ./Msan-powerpc64le-with-call-Test/189/281 (932 of 2450) PASS: MemorySanitizer-POWERPC64LE :: Linux/swapcontext_annotation_reset.cpp (933 of 2450) FAIL: ThreadSanitizer-powerpc64le :: signal_block.cpp (934 of 2450) TEST 'ThreadSanitizer-powerpc64le :: signal_block.cpp' FAILED Exit Code: 1 Command Output (stderr): -- RUN: at line 1: /home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_debug/./bin/clang -fsanitize=thread -Wall -m64 -fno-function-sections -gline-tables-only -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/../ -O1 /home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/signal_block.cpp -o /home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_debug/runtimes/runtimes-bins/compiler-rt/test/tsan/POWERPC64LEConfig/Output/signal_block.cpp.tmp && /home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_debug/runtimes/runtimes-bins/compiler-rt/test/tsan/POWERPC64LEConfig/Output/signal_block.cpp.tmp 2>&1 | FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/signal_block.cpp + /home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_debug/./bin/clang -fsanitize=thread -Wall -m64 -fno-function-sections -gline-tables-only -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/../ -O1 /home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/signal_block.cpp -o /home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_debug/runtimes/runtimes-bins/compiler-rt/test/tsan/POWERPC64LEConfig/Output/signal_block.cpp.tmp + /home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_debug/runtimes/runtimes-bins/compiler-rt/test/tsan/POWERPC64LEConfig/Output/signal_block.cpp.tmp + FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/signal_block.cpp /home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/signal_block.cpp:59:15: error: CHECK-NOT: excluded string found in input // CHECK-NOT: WARNING: ThreadSanitizer: ^ :2:1: note: found here WARNING: ThreadSanitizer: signal handler spoils errno (pid=3370566) ^ Input file: Check file: /home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/signal_block.cpp -dump-input=help explains the following input dump. Input was: << 1: == 2: WARNING: ThreadSanitizer: signal handler spoils errno (pid=3370566) not:59 ! error: no match expected 3: Signal 10 handler invoked at: 4: #0 handler(int) /home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/signal_block.cpp:13 (signal_block.cpp.tmp+0xfea60) 5: #1 thread(void*) /home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/compiler-rt/test/tsan/signal_block.cpp:25:5 (signal_block.cpp.tmp+0xfebb0) 6: 7: SUMMARY: ThreadSanitizer: signal handler spoils errno /home/buildbots/llvm-externa
[clang] [llvm] [Clang][OpenMP] This is addition fix for #92210. (PR #94802)
https://github.com/jyu2-git closed https://github.com/llvm/llvm-project/pull/94802 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][PAC] Sign block addresses used in indirectbr. (PR #97647)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Ahmed Bougacha (ahmedbougacha) Changes Enabled in clang using: -fptrauth-indirect-gotos and at the IR level using function attribute: "ptrauth-indirect-gotos" Signing uses IA and a per-function integer discriminator. The discriminator isn't ABI-visible, and is currently: ptrauth_string_discriminator("blockaddress") A sufficiently sophisticated frontend could benefit from per-indirectbr discrimination, which would need additional machinery, such as allowing "ptrauth" bundles on indirectbr. For our purposes, the simple scheme above is sufficient. --- Patch is 28.91 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/97647.diff 20 Files Affected: - (modified) clang/include/clang/Basic/Features.def (+1) - (modified) clang/include/clang/Basic/LangOptions.def (+1) - (modified) clang/include/clang/Basic/PointerAuthOptions.h (+3) - (modified) clang/include/clang/Driver/Options.td (+2) - (modified) clang/lib/CodeGen/CodeGenFunction.cpp (+2) - (modified) clang/lib/Driver/ToolChains/Clang.cpp (+3) - (modified) clang/lib/Frontend/CompilerInvocation.cpp (+5-1) - (modified) clang/test/CodeGen/ptrauth-function-attributes.c (+5) - (modified) llvm/docs/PointerAuth.md (+24) - (modified) llvm/include/llvm/CodeGen/AsmPrinter.h (+3) - (modified) llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (+5-1) - (modified) llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp (+30-5) - (modified) llvm/lib/Target/AArch64/AArch64FastISel.cpp (+4) - (modified) llvm/lib/Target/AArch64/AArch64ISelLowering.cpp (+49-4) - (modified) llvm/lib/Target/AArch64/AArch64ISelLowering.h (+1) - (modified) llvm/lib/Target/AArch64/AArch64InstrInfo.td (+18) - (modified) llvm/lib/Target/AArch64/AArch64Subtarget.cpp (+11) - (modified) llvm/lib/Target/AArch64/AArch64Subtarget.h (+9) - (modified) llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp (+26) - (added) llvm/test/CodeGen/AArch64/ptrauth-indirectbr.ll (+106) ``diff diff --git a/clang/include/clang/Basic/Features.def b/clang/include/clang/Basic/Features.def index 53f410d3cb4bd..cf800afe08557 100644 --- a/clang/include/clang/Basic/Features.def +++ b/clang/include/clang/Basic/Features.def @@ -108,6 +108,7 @@ FEATURE(ptrauth_calls, LangOpts.PointerAuthCalls) FEATURE(ptrauth_returns, LangOpts.PointerAuthReturns) FEATURE(ptrauth_vtable_pointer_address_discrimination, LangOpts.PointerAuthVTPtrAddressDiscrimination) FEATURE(ptrauth_vtable_pointer_type_discrimination, LangOpts.PointerAuthVTPtrTypeDiscrimination) +FEATURE(ptrauth_indirect_gotos, LangOpts.PointerAuthIndirectGotos) FEATURE(ptrauth_member_function_pointer_type_discrimination, LangOpts.PointerAuthCalls) FEATURE(ptrauth_init_fini, LangOpts.PointerAuthInitFini) EXTENSION(swiftcc, diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 491759e2fcdbb..bdf77a5b35208 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -165,6 +165,7 @@ LANGOPT(ExperimentalLibrary, 1, 0, "enable unstable and experimental library fea LANGOPT(PointerAuthIntrinsics, 1, 0, "pointer authentication intrinsics") LANGOPT(PointerAuthCalls , 1, 0, "function pointer authentication") LANGOPT(PointerAuthReturns, 1, 0, "return pointer authentication") +LANGOPT(PointerAuthIndirectGotos, 1, 0, "indirect gotos pointer authentication") LANGOPT(PointerAuthAuthTraps, 1, 0, "pointer authentication failure traps") LANGOPT(PointerAuthVTPtrAddressDiscrimination, 1, 0, "incorporate address discrimination in authenticated vtable pointers") LANGOPT(PointerAuthVTPtrTypeDiscrimination, 1, 0, "incorporate type discrimination in authenticated vtable pointers") diff --git a/clang/include/clang/Basic/PointerAuthOptions.h b/clang/include/clang/Basic/PointerAuthOptions.h index 197d63642ca6d..2711639dbe299 100644 --- a/clang/include/clang/Basic/PointerAuthOptions.h +++ b/clang/include/clang/Basic/PointerAuthOptions.h @@ -154,6 +154,9 @@ class PointerAuthSchema { }; struct PointerAuthOptions { + /// Do indirect goto label addresses need to be authenticated? + bool IndirectGotos = false; + /// The ABI for C function pointers. PointerAuthSchema FunctionPointers; diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 58ca6f2bea9e4..791b7261ddbda 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4228,6 +4228,8 @@ defm ptrauth_vtable_pointer_address_discrimination : defm ptrauth_vtable_pointer_type_discrimination : OptInCC1FFlag<"ptrauth-vtable-pointer-type-discrimination", "Enable type discrimination of vtable pointers">; defm ptrauth_init_fini : OptInCC1FFlag<"ptrauth-init-fini", "Enable signing of function pointers in init/fini arrays">; +defm ptrauth_indirect_gotos : OptInCC1FFlag<"ptrauth-indirect-gotos", + "En
[clang] [llvm] [AArch64][PAC] Sign block addresses used in indirectbr. (PR #97647)
https://github.com/ahmedbougacha ready_for_review https://github.com/llvm/llvm-project/pull/97647 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Compiler messages on HIP SDK for Windows (PR #97668)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 845dee36ba4161df153ba05009cea615e20eda5a eb83f777e5e15f2602b34b0ba48d1cf5ac803d16 -- clang/lib/Driver/ToolChains/AMDGPU.cpp clang/lib/Driver/ToolChains/ROCm.h `` View the diff from clang-format here. ``diff diff --git a/clang/lib/Driver/ToolChains/ROCm.h b/clang/lib/Driver/ToolChains/ROCm.h index e2492b1630..242e84a32e 100644 --- a/clang/lib/Driver/ToolChains/ROCm.h +++ b/clang/lib/Driver/ToolChains/ROCm.h @@ -196,7 +196,7 @@ public: bool hasHIPStdParLibrary() const { return HasHIPStdParLibrary; } /// Check whether the target triple is for Windows. - bool isWindows() const { return hostTriple.isOSWindows();} + bool isWindows() const { return hostTriple.isOSWindows(); } /// Print information about the detected ROCm installation. void print(raw_ostream &OS) const; `` https://github.com/llvm/llvm-project/pull/97668 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Compiler messages on HIP SDK for Windows (PR #97668)
llvmbot wrote: @llvm/pr-subscribers-backend-amdgpu Author: David Salinas (david-salinas) Changes When target triple indicates we are on Windows, do not add linux paths to search path in ROCm Installation Detection. Change-Id: I18effb8c20252de3d84ea37ef562124695c5a570 --- Full diff: https://github.com/llvm/llvm-project/pull/97668.diff 2 Files Affected: - (modified) clang/lib/Driver/ToolChains/AMDGPU.cpp (+10-8) - (modified) clang/lib/Driver/ToolChains/ROCm.h (+5) ``diff diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 453daed7cc7d5..e05b9202599c7 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -306,14 +306,16 @@ RocmInstallationDetector::getInstallationPathCandidates() { LatestVer = Ver; } } - if (!LatestROCm.empty()) -ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, -/*StrictChecking=*/true); + if (!isWindows()) { +if (!LatestROCm.empty()) + ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, + /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", - /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", - /*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", +/*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", +/*StrictChecking=*/true); + } DoPrintROCmSearchDirs(); return ROCmSearchDirs; @@ -322,7 +324,7 @@ RocmInstallationDetector::getInstallationPathCandidates() { RocmInstallationDetector::RocmInstallationDetector( const Driver &D, const llvm::Triple &HostTriple, const llvm::opt::ArgList &Args, bool DetectHIPRuntime, bool DetectDeviceLib) -: D(D) { +: D(D), hostTriple(HostTriple) { Verbose = Args.hasArg(options::OPT_v); RocmPathArg = Args.getLastArgValue(clang::driver::options::OPT_rocm_path_EQ); PrintROCmSearchDirs = diff --git a/clang/lib/Driver/ToolChains/ROCm.h b/clang/lib/Driver/ToolChains/ROCm.h index dceb0ab036693..e2492b1630238 100644 --- a/clang/lib/Driver/ToolChains/ROCm.h +++ b/clang/lib/Driver/ToolChains/ROCm.h @@ -111,6 +111,8 @@ class RocmInstallationDetector { // Wheter -nogpulib is specified. bool NoBuiltinLibs = false; + llvm::Triple hostTriple; + // Paths SmallString<0> InstallPath; SmallString<0> BinPath; @@ -193,6 +195,9 @@ class RocmInstallationDetector { /// Check whether we detected a valid HIP STDPAR Acceleration library. bool hasHIPStdParLibrary() const { return HasHIPStdParLibrary; } + /// Check whether the target triple is for Windows. + bool isWindows() const { return hostTriple.isOSWindows();} + /// Print information about the detected ROCm installation. void print(raw_ostream &OS) const; `` https://github.com/llvm/llvm-project/pull/97668 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Compiler messages on HIP SDK for Windows (PR #97668)
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using `@` followed by their GitHub username. If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the [LLVM GitHub User Guide](https://llvm.org/docs/GitHub.html). You can also ask questions in a comment on this PR, on the [LLVM Discord](https://discord.com/invite/xS7Z362) or on the [forums](https://discourse.llvm.org/). https://github.com/llvm/llvm-project/pull/97668 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Compiler messages on HIP SDK for Windows (PR #97668)
https://github.com/david-salinas created https://github.com/llvm/llvm-project/pull/97668 When target triple indicates we are on Windows, do not add linux paths to search path in ROCm Installation Detection. Change-Id: I18effb8c20252de3d84ea37ef562124695c5a570 >From eb83f777e5e15f2602b34b0ba48d1cf5ac803d16 Mon Sep 17 00:00:00 2001 From: David Salinas Date: Thu, 4 Jul 2024 03:32:13 + Subject: [PATCH] Compiler messages on HIP SDK for Windows When target triple indicates we are on Windows, do not add linux paths to search path in ROCm Installation Detection. Change-Id: I18effb8c20252de3d84ea37ef562124695c5a570 --- clang/lib/Driver/ToolChains/AMDGPU.cpp | 18 ++ clang/lib/Driver/ToolChains/ROCm.h | 5 + 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 453daed7cc7d5..e05b9202599c7 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -306,14 +306,16 @@ RocmInstallationDetector::getInstallationPathCandidates() { LatestVer = Ver; } } - if (!LatestROCm.empty()) -ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, -/*StrictChecking=*/true); + if (!isWindows()) { +if (!LatestROCm.empty()) + ROCmSearchDirs.emplace_back(D.SysRoot + "/opt/" + LatestROCm, + /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", - /*StrictChecking=*/true); - ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", - /*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr/local", +/*StrictChecking=*/true); +ROCmSearchDirs.emplace_back(D.SysRoot + "/usr", +/*StrictChecking=*/true); + } DoPrintROCmSearchDirs(); return ROCmSearchDirs; @@ -322,7 +324,7 @@ RocmInstallationDetector::getInstallationPathCandidates() { RocmInstallationDetector::RocmInstallationDetector( const Driver &D, const llvm::Triple &HostTriple, const llvm::opt::ArgList &Args, bool DetectHIPRuntime, bool DetectDeviceLib) -: D(D) { +: D(D), hostTriple(HostTriple) { Verbose = Args.hasArg(options::OPT_v); RocmPathArg = Args.getLastArgValue(clang::driver::options::OPT_rocm_path_EQ); PrintROCmSearchDirs = diff --git a/clang/lib/Driver/ToolChains/ROCm.h b/clang/lib/Driver/ToolChains/ROCm.h index dceb0ab036693..e2492b1630238 100644 --- a/clang/lib/Driver/ToolChains/ROCm.h +++ b/clang/lib/Driver/ToolChains/ROCm.h @@ -111,6 +111,8 @@ class RocmInstallationDetector { // Wheter -nogpulib is specified. bool NoBuiltinLibs = false; + llvm::Triple hostTriple; + // Paths SmallString<0> InstallPath; SmallString<0> BinPath; @@ -193,6 +195,9 @@ class RocmInstallationDetector { /// Check whether we detected a valid HIP STDPAR Acceleration library. bool hasHIPStdParLibrary() const { return HasHIPStdParLibrary; } + /// Check whether the target triple is for Windows. + bool isWindows() const { return hostTriple.isOSWindows();} + /// Print information about the detected ROCm installation. void print(raw_ostream &OS) const; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][PAC] Sign block addresses used in indirectbr. (PR #97647)
ahmedbougacha wrote: > Please make sure you have a testcase for computing the difference between two > blockaddresses (void g(int*); int f() { static int x = &&A-&&B; > A:g(&x);B:return x; }). Not sure how you should handle that case. Oh yeah, we can't handle that at all, I don't think! The best we can do is probably to declare it disallowed and try to diagnose it in the frontend as best we can.. I don't think we ever looked into that, I'll give it a try https://github.com/llvm/llvm-project/pull/97647 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Support --sysroot= for ${arch}-windows-msvc targets (PR #96417)
https://github.com/trcrsired updated https://github.com/llvm/llvm-project/pull/96417 >From 74163b6245730b8e709a2a15ac1ee03255815a25 Mon Sep 17 00:00:00 2001 From: trcrsired Date: Sun, 23 Jun 2024 00:07:19 -0400 Subject: [PATCH] Support --sysroot= for ${arch}-windows-msvc targets I think it is possible to use the same rule for msvc targets with --target= and --sysroot= See Repository: https://github.com/trcrsired/windows-msvc-sysroot Add sysroot support for msvc MSVC.cpp needs getDriver before using D add stl in parser for -stdlib= Add Vcruntime to runtime list and unwind list MSVC add default runtime lib type and default unwind lib type add a msvc sysroot test use %S instead of /foo Fix test for msvc-sysroot Also add a pesudo implementation for WebAssembly and maybe Microsoft STL could be ported to more targets in the future Fix the toggle of wasm that prevents -stdlib=stl passed into Avoid clang-formatting in MSVC.cpp Add some comments to ToolChain avoid indent the if block Add back space before winsysroot line use instead of arch in the comment remove FIXME for libc++ since we have added the logic here Remove MSVC.h formatting Remove default cases in WebAssembly add back the empty line before the Sysroot line fix msvc-sysroot typo for libc++ loongarch Fix : missing in CST_Stl case --- clang/include/clang/Driver/ToolChain.h | 11 +- clang/lib/Driver/ToolChain.cpp | 10 ++ clang/lib/Driver/ToolChains/MSVC.cpp| 128 +++- clang/lib/Driver/ToolChains/MSVC.h | 15 +++ clang/lib/Driver/ToolChains/WebAssembly.cpp | 25 clang/lib/Driver/ToolChains/WebAssembly.h | 2 + clang/test/Driver/msvc-sysroot.cpp | 81 + clang/test/Driver/wasm-toolchain.cpp| 12 ++ 8 files changed, 279 insertions(+), 5 deletions(-) create mode 100644 clang/test/Driver/msvc-sysroot.cpp diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h index ece1384d5d3c02..a7483a89d9ff1d 100644 --- a/clang/include/clang/Driver/ToolChain.h +++ b/clang/include/clang/Driver/ToolChain.h @@ -94,19 +94,22 @@ class ToolChain { using path_list = SmallVector; enum CXXStdlibType { -CST_Libcxx, -CST_Libstdcxx +CST_Libcxx, // LLVM libc++ +CST_Libstdcxx, // GNU libstdc++ +CST_Stl, // MSVC STL }; enum RuntimeLibType { RLT_CompilerRT, -RLT_Libgcc +RLT_Libgcc, +RLT_Vcruntime }; enum UnwindLibType { UNW_None, UNW_CompilerRT, -UNW_Libgcc +UNW_Libgcc, +UNW_Vcruntime }; enum class UnwindTableLevel { diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 977e08390800d7..ed4a73c80c0b73 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -1097,6 +1097,8 @@ ToolChain::RuntimeLibType ToolChain::GetRuntimeLibType( runtimeLibType = ToolChain::RLT_CompilerRT; else if (LibName == "libgcc") runtimeLibType = ToolChain::RLT_Libgcc; + else if (LibName == "vcruntime") +runtimeLibType = ToolChain::RLT_Vcruntime; else if (LibName == "platform") runtimeLibType = GetDefaultRuntimeLibType(); else { @@ -1135,6 +1137,8 @@ ToolChain::UnwindLibType ToolChain::GetUnwindLibType( unwindLibType = ToolChain::UNW_CompilerRT; } else if (LibName == "libgcc") unwindLibType = ToolChain::UNW_Libgcc; + else if (LibName == "vcruntime") +unwindLibType = ToolChain::UNW_Vcruntime; else { if (A) getDriver().Diag(diag::err_drv_invalid_unwindlib_name) @@ -1158,6 +1162,8 @@ ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) const{ cxxStdlibType = ToolChain::CST_Libcxx; else if (LibName == "libstdc++") cxxStdlibType = ToolChain::CST_Libstdcxx; + else if (LibName == "stl") +cxxStdlibType = ToolChain::CST_Stl; else if (LibName == "platform") cxxStdlibType = GetDefaultCXXStdlibType(); else { @@ -1296,6 +1302,10 @@ void ToolChain::AddCXXStdlibLibArgs(const ArgList &Args, case ToolChain::CST_Libstdcxx: CmdArgs.push_back("-lstdc++"); break; + + case ToolChain::CST_Stl: +// MSVC STL does not need to add -l +break; } } diff --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp index ca266e3e1d1d3c..ad89003ed1c33c 100644 --- a/clang/lib/Driver/ToolChains/MSVC.cpp +++ b/clang/lib/Driver/ToolChains/MSVC.cpp @@ -90,6 +90,16 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-defaultlib:oldnames"); } + auto SysRoot = TC.getDriver().SysRoot; + if (!SysRoot.empty()) { +// If we have --sysroot, then we ignore all other setings +// libpath is $SYSROOT/lib and $SYSROOT/lib/${ARCH}-unknown-windows-msvc +const std::string MultiarchTriple = +TC.getMultiarchTriple(TC.getDriver(), TC.getTriple(), SysRoot); +std::string SysRootLib = "-libpath:" + SysRoot + "/lib"; +CmdA
[clang] [RISCV] Handle empty structs/unions passing in C++ (PR #97315)
https://github.com/svs-quic updated https://github.com/llvm/llvm-project/pull/97315 >From 3c744fe6111f0b6d24356a584f94c6d1cb273f7a Mon Sep 17 00:00:00 2001 From: Sudharsan Veeravalli Date: Mon, 1 Jul 2024 21:58:37 +0530 Subject: [PATCH 1/2] [RISCV] Handle empty structs/unions passing in C++ --- clang/lib/CodeGen/Targets/RISCV.cpp | 9 +++--- clang/test/CodeGen/RISCV/abi-empty-structs.c | 34 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/clang/lib/CodeGen/Targets/RISCV.cpp b/clang/lib/CodeGen/Targets/RISCV.cpp index a4c5ec315b8df..f2add9351c03c 100644 --- a/clang/lib/CodeGen/Targets/RISCV.cpp +++ b/clang/lib/CodeGen/Targets/RISCV.cpp @@ -361,12 +361,13 @@ ABIArgInfo RISCVABIInfo::classifyArgumentType(QualType Ty, bool IsFixed, CGCXXABI::RAA_DirectInMemory); } - // Ignore empty structs/unions. - if (isEmptyRecord(getContext(), Ty, true)) -return ABIArgInfo::getIgnore(); - uint64_t Size = getContext().getTypeSize(Ty); + // Ignore empty structs/unions whose size is zero. According to the calling + // convention empty structs/unions are required to be sized types in C++. + if (isEmptyRecord(getContext(), Ty, true) && Size == 0) +return ABIArgInfo::getIgnore(); + // Pass floating point values via FPRs if possible. if (IsFixed && Ty->isFloatingType() && !Ty->isComplexType() && FLen >= Size && ArgFPRsLeft) { diff --git a/clang/test/CodeGen/RISCV/abi-empty-structs.c b/clang/test/CodeGen/RISCV/abi-empty-structs.c index c48a2891627d4..877ed4962d4e8 100644 --- a/clang/test/CodeGen/RISCV/abi-empty-structs.c +++ b/clang/test/CodeGen/RISCV/abi-empty-structs.c @@ -167,6 +167,40 @@ struct s9 { // void test_s9(struct s9 a) {} +struct s10 { }; +// CHECK-C-LABEL: define dso_local void @test_s10 +// CHECK-C-SAME: () #[[ATTR0]] { +// CHECK-C: entry: +// +// CHECK32-CXX-LABEL: define dso_local i32 @_Z8test_s103s10 +// CHECK32-CXX-SAME: (i32 [[A_COERCE:%.*]]) #[[ATTR0]] { +// CHECK32-CXX: entry: +// +// CHECK64-CXX-LABEL: define dso_local i64 @_Z8test_s103s10 +// CHECK64-CXX-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] { +// CHECK64-CXX: entry: +// +struct s10 test_s10(struct s10 a) { + return a; +} + +struct s11 { int : 0; }; +// CHECK-C-LABEL: define dso_local void @test_s11 +// CHECK-C-SAME: () #[[ATTR0]] { +// CHECK-C: entry: +// +// CHECK32-CXX-LABEL: define dso_local i32 @_Z8test_s113s11 +// CHECK32-CXX-SAME: (i32 [[A_COERCE:%.*]]) #[[ATTR0]] { +// CHECK32-CXX: entry: +// +// CHECK64-CXX-LABEL: define dso_local i64 @_Z8test_s113s11 +// CHECK64-CXX-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] { +// CHECK64-CXX: entry: +// +struct s11 test_s11(struct s11 a) { + return a; +} + NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: // CHECK32-C: {{.*}} // CHECK64-C: {{.*}} >From 004881e8b3453532bd5253e36a7c75b125784eda Mon Sep 17 00:00:00 2001 From: Sudharsan Veeravalli Date: Thu, 4 Jul 2024 08:57:37 +0530 Subject: [PATCH 2/2] Add test case --- clang/test/CodeGen/RISCV/abi-empty-structs.c | 13 + 1 file changed, 13 insertions(+) diff --git a/clang/test/CodeGen/RISCV/abi-empty-structs.c b/clang/test/CodeGen/RISCV/abi-empty-structs.c index 877ed4962d4e8..fd119fbda046d 100644 --- a/clang/test/CodeGen/RISCV/abi-empty-structs.c +++ b/clang/test/CodeGen/RISCV/abi-empty-structs.c @@ -201,6 +201,19 @@ struct s11 test_s11(struct s11 a) { return a; } +struct s12 {int x[0];}; +// CHECK-C-LABEL: define dso_local void @test_s12 +// CHECK-C-SAME: () #[[ATTR0]] { +// CHECK-C: entry: +// +// CHECK-CXX-LABEL: define dso_local void @_Z8test_s123s12 +// CHECK-CXX-SAME: () #[[ATTR0]] { +// CHECK-CXX: entry: +// +struct s12 test_s12(struct s12 a) { + return a; +} + NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: // CHECK32-C: {{.*}} // CHECK64-C: {{.*}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [PowerPC] add TargetParser for PPC target (PR #97541)
@@ -0,0 +1,37 @@ +//=== PPCTargetParser - Parser for target features --*- 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 target parser to recognise hardware features +// for PPC CPUs. +// +//===--===// + +#ifndef LLVM_TARGETPARSER_PPCTARGETPARSER_H +#define LLVM_TARGETPARSER_PPCTARGETPARSER_H + +#include "llvm/ADT/StringRef.h" +#include "llvm/TargetParser/Triple.h" + +namespace llvm { +namespace PPC { +bool isValidCPU(StringRef CPU); +void fillValidCPUList(SmallVectorImpl &Values); +void fillValidTuneCPUList(SmallVectorImpl &Values); + +// Get default target CPU for PPC. +StringRef getPPCGenericTargetCPU(const Triple &T, StringRef CPUName = ""); +// Get default tune CPU for PPC. +StringRef getPPCGenericTuneCPU(const Triple &T, StringRef CPUName = ""); ecnelises wrote: We should rename this method (remove `Generic` or similar). Previous `getPPCGenericTargetCPU` does not have extra CPUName as parameter. What this function does now is not only returning a generic CPU for a platform. https://github.com/llvm/llvm-project/pull/97541 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] Add another test project to clang-doc (PR #97518)
https://github.com/PeterChou1 edited https://github.com/llvm/llvm-project/pull/97518 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] add more test to clang-doc (PR #97518)
https://github.com/PeterChou1 edited https://github.com/llvm/llvm-project/pull/97518 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
hekota wrote: > I see many places where extra cases have been added for the intangible types > but no corresponding tests. Is that ok? How did you know to update these > places? I looked at similar types in other languages, such as the `image*` types in [OpenCL](https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/OpenCLImageTypes.def) or `__externref_t` in [WebAssembly](https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/WebAssemblyReferenceTypes.def). I used the same implementation style and defaults as these types (except `__externref_t` is a typedef and not a language keyword). Some of the cases are tested when the two `builtin_hlsl_resource_t.hlsl` files are parsed and AST dumped, but it is not possible to test all case until we can actually use the type (llvm/llvm-project#84824). > I also don't see anywhere that actually successfully uses > `__builtin_hlsl_resource_t`. Am I missing it, or should I not expect to see > it? You are correct - the type cannot be directly declared in user code, so the tests only check for errors and that the type shows up properly in AST. It is possible to use this type internally in Clang or in implicit headers though, which are two ways how we could define `RWBuffer` and other builtin types that will internally use `__builtin_hlsl_resource_t` handle. That will come alive in (llvm/llvm-project#84824). https://github.com/llvm/llvm-project/pull/97362 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP] Correctly code-gen default atomic mem order (PR #97663)
llvmbot wrote: @llvm/pr-subscribers-clang-codegen @llvm/pr-subscribers-clang Author: Joseph Huber (jhuber6) Changes Summary: The parsing for this was implemented, but we never hooked up the default value to the result of this clause. This patch adds the support by making it default to the requires directive. --- Full diff: https://github.com/llvm/llvm-project/pull/97663.diff 2 Files Affected: - (modified) clang/lib/CodeGen/CGStmtOpenMP.cpp (+1-1) - (added) clang/test/OpenMP/requires_default_atomic_mem_order.cpp (+46) ``diff diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 76ff8f5b234da..4d05322951d0a 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -6555,7 +6555,7 @@ static void emitOMPAtomicExpr(CodeGenFunction &CGF, OpenMPClauseKind Kind, } void CodeGenFunction::EmitOMPAtomicDirective(const OMPAtomicDirective &S) { - llvm::AtomicOrdering AO = llvm::AtomicOrdering::Monotonic; + llvm::AtomicOrdering AO = CGM.getOpenMPRuntime().getDefaultMemoryOrdering(); // Fail Memory Clause Ordering. llvm::AtomicOrdering FailAO = llvm::AtomicOrdering::NotAtomic; bool MemOrderingSpecified = false; diff --git a/clang/test/OpenMP/requires_default_atomic_mem_order.cpp b/clang/test/OpenMP/requires_default_atomic_mem_order.cpp new file mode 100644 index 0..90d2db4eac20c --- /dev/null +++ b/clang/test/OpenMP/requires_default_atomic_mem_order.cpp @@ -0,0 +1,46 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -emit-llvm -fopenmp -triple=x86_64-unknown-linux-gnu \ +// RUN: -DORDERING=seq_cst -o - %s \ +// RUN: | FileCheck %s --check-prefix=SEQ_CST +// RUN: %clang_cc1 -emit-llvm -fopenmp -triple=x86_64-unknown-linux-gnu \ +// RUN: -DORDERING=acq_rel -o - %s \ +// RUN: | FileCheck %s --check-prefix=ACQ_REL +// RUN: %clang_cc1 -emit-llvm -fopenmp -triple=x86_64-unknown-linux-gnu \ +// RUN: -DORDERING=relaxed -o - %s \ +// RUN: | FileCheck %s --check-prefix=RELAXED + +#pragma omp requires atomic_default_mem_order(ORDERING) + +// SEQ_CST-LABEL: define dso_local void @_Z3fooPi( +// SEQ_CST-SAME: ptr noundef [[X:%.*]]) #[[ATTR0:[0-9]+]] { +// SEQ_CST-NEXT: [[ENTRY:.*:]] +// SEQ_CST-NEXT:[[X_ADDR:%.*]] = alloca ptr, align 8 +// SEQ_CST-NEXT:store ptr [[X]], ptr [[X_ADDR]], align 8 +// SEQ_CST-NEXT:[[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], align 8 +// SEQ_CST-NEXT:[[TMP1:%.*]] = atomicrmw add ptr [[TMP0]], i32 1 seq_cst, align 4 +// SEQ_CST-NEXT:call void @__kmpc_flush(ptr @[[GLOB1:[0-9]+]]) +// SEQ_CST-NEXT:ret void +// +// ACQ_REL-LABEL: define dso_local void @_Z3fooPi( +// ACQ_REL-SAME: ptr noundef [[X:%.*]]) #[[ATTR0:[0-9]+]] { +// ACQ_REL-NEXT: [[ENTRY:.*:]] +// ACQ_REL-NEXT:[[X_ADDR:%.*]] = alloca ptr, align 8 +// ACQ_REL-NEXT:store ptr [[X]], ptr [[X_ADDR]], align 8 +// ACQ_REL-NEXT:[[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], align 8 +// ACQ_REL-NEXT:[[TMP1:%.*]] = atomicrmw add ptr [[TMP0]], i32 1 release, align 4 +// ACQ_REL-NEXT:call void @__kmpc_flush(ptr @[[GLOB1:[0-9]+]]) +// ACQ_REL-NEXT:ret void +// +// RELAXED-LABEL: define dso_local void @_Z3fooPi( +// RELAXED-SAME: ptr noundef [[X:%.*]]) #[[ATTR0:[0-9]+]] { +// RELAXED-NEXT: [[ENTRY:.*:]] +// RELAXED-NEXT:[[X_ADDR:%.*]] = alloca ptr, align 8 +// RELAXED-NEXT:store ptr [[X]], ptr [[X_ADDR]], align 8 +// RELAXED-NEXT:[[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], align 8 +// RELAXED-NEXT:[[TMP1:%.*]] = atomicrmw add ptr [[TMP0]], i32 1 monotonic, align 4 +// RELAXED-NEXT:ret void +// +void foo(int *x) { + #pragma omp atomic update +*x = *x + 1; +} `` https://github.com/llvm/llvm-project/pull/97663 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP] Correctly code-gen default atomic mem order (PR #97663)
https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/97663 Summary: The parsing for this was implemented, but we never hooked up the default value to the result of this clause. This patch adds the support by making it default to the requires directive. >From fa3561bd4d42522f07ec901c15b411f06b844490 Mon Sep 17 00:00:00 2001 From: Joseph Huber Date: Wed, 3 Jul 2024 21:44:07 -0500 Subject: [PATCH] [OpenMP] Correctly code-gen default atomic mem order Summary: The parsing for this was implemented, but we never hooked up the default value to the result of this clause. This patch adds the support by making it default to the requires directive. --- clang/lib/CodeGen/CGStmtOpenMP.cpp| 2 +- .../requires_default_atomic_mem_order.cpp | 46 +++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 clang/test/OpenMP/requires_default_atomic_mem_order.cpp diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 76ff8f5b234da6..4d05322951d0a5 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -6555,7 +6555,7 @@ static void emitOMPAtomicExpr(CodeGenFunction &CGF, OpenMPClauseKind Kind, } void CodeGenFunction::EmitOMPAtomicDirective(const OMPAtomicDirective &S) { - llvm::AtomicOrdering AO = llvm::AtomicOrdering::Monotonic; + llvm::AtomicOrdering AO = CGM.getOpenMPRuntime().getDefaultMemoryOrdering(); // Fail Memory Clause Ordering. llvm::AtomicOrdering FailAO = llvm::AtomicOrdering::NotAtomic; bool MemOrderingSpecified = false; diff --git a/clang/test/OpenMP/requires_default_atomic_mem_order.cpp b/clang/test/OpenMP/requires_default_atomic_mem_order.cpp new file mode 100644 index 00..90d2db4eac20c4 --- /dev/null +++ b/clang/test/OpenMP/requires_default_atomic_mem_order.cpp @@ -0,0 +1,46 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// RUN: %clang_cc1 -emit-llvm -fopenmp -triple=x86_64-unknown-linux-gnu \ +// RUN: -DORDERING=seq_cst -o - %s \ +// RUN: | FileCheck %s --check-prefix=SEQ_CST +// RUN: %clang_cc1 -emit-llvm -fopenmp -triple=x86_64-unknown-linux-gnu \ +// RUN: -DORDERING=acq_rel -o - %s \ +// RUN: | FileCheck %s --check-prefix=ACQ_REL +// RUN: %clang_cc1 -emit-llvm -fopenmp -triple=x86_64-unknown-linux-gnu \ +// RUN: -DORDERING=relaxed -o - %s \ +// RUN: | FileCheck %s --check-prefix=RELAXED + +#pragma omp requires atomic_default_mem_order(ORDERING) + +// SEQ_CST-LABEL: define dso_local void @_Z3fooPi( +// SEQ_CST-SAME: ptr noundef [[X:%.*]]) #[[ATTR0:[0-9]+]] { +// SEQ_CST-NEXT: [[ENTRY:.*:]] +// SEQ_CST-NEXT:[[X_ADDR:%.*]] = alloca ptr, align 8 +// SEQ_CST-NEXT:store ptr [[X]], ptr [[X_ADDR]], align 8 +// SEQ_CST-NEXT:[[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], align 8 +// SEQ_CST-NEXT:[[TMP1:%.*]] = atomicrmw add ptr [[TMP0]], i32 1 seq_cst, align 4 +// SEQ_CST-NEXT:call void @__kmpc_flush(ptr @[[GLOB1:[0-9]+]]) +// SEQ_CST-NEXT:ret void +// +// ACQ_REL-LABEL: define dso_local void @_Z3fooPi( +// ACQ_REL-SAME: ptr noundef [[X:%.*]]) #[[ATTR0:[0-9]+]] { +// ACQ_REL-NEXT: [[ENTRY:.*:]] +// ACQ_REL-NEXT:[[X_ADDR:%.*]] = alloca ptr, align 8 +// ACQ_REL-NEXT:store ptr [[X]], ptr [[X_ADDR]], align 8 +// ACQ_REL-NEXT:[[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], align 8 +// ACQ_REL-NEXT:[[TMP1:%.*]] = atomicrmw add ptr [[TMP0]], i32 1 release, align 4 +// ACQ_REL-NEXT:call void @__kmpc_flush(ptr @[[GLOB1:[0-9]+]]) +// ACQ_REL-NEXT:ret void +// +// RELAXED-LABEL: define dso_local void @_Z3fooPi( +// RELAXED-SAME: ptr noundef [[X:%.*]]) #[[ATTR0:[0-9]+]] { +// RELAXED-NEXT: [[ENTRY:.*:]] +// RELAXED-NEXT:[[X_ADDR:%.*]] = alloca ptr, align 8 +// RELAXED-NEXT:store ptr [[X]], ptr [[X_ADDR]], align 8 +// RELAXED-NEXT:[[TMP0:%.*]] = load ptr, ptr [[X_ADDR]], align 8 +// RELAXED-NEXT:[[TMP1:%.*]] = atomicrmw add ptr [[TMP0]], i32 1 monotonic, align 4 +// RELAXED-NEXT:ret void +// +void foo(int *x) { + #pragma omp atomic update +*x = *x + 1; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
https://github.com/hekota edited https://github.com/llvm/llvm-project/pull/97362 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
@@ -115,6 +116,18 @@ GlobalVariable *replaceBuffer(CGHLSLRuntime::Buffer &Buf) { } // namespace +llvm::Type *CGHLSLRuntime::convertHLSLSpecificType(const Type *T) { + assert(T->isHLSLSpecificType() && "Not an HLSL specific type!"); + + // Check if the target has a specific translation for this type first. + if (llvm::Type *TargetTy = CGM.getTargetCodeGenInfo().getHLSLType(CGM, T)) +return TargetTy; + + // TODO: What do we actually want to do generically here? OpenCL uses a + // pointer in a particular address space. + llvm_unreachable("Generic handling of HLSL types is not implemented yet"); hekota wrote: I am not sure if we have any HLSL specific type that will not be handled by `getHLSLType`, so this might just become simple `llvm_unreachable` without the TODO: comment. @bogner? https://github.com/llvm/llvm-project/pull/97362 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Implement GCS ACLE intrinsics (PR #96903)
https://github.com/hstk30-hw approved this pull request. LGTM, don't known why the CI failed :> https://github.com/llvm/llvm-project/pull/96903 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Implement GCS ACLE intrinsics (PR #96903)
hstk30-hw wrote: LGTM, don't know why the CI failed :> https://github.com/llvm/llvm-project/pull/96903 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [HLSL] Implement intangible AST type (PR #97362)
@@ -2241,6 +2247,11 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const { Align = ALIGN; \ break; #include "clang/Basic/AMDGPUTypes.def" +#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id: +#include "clang/Basic/HLSLIntangibleTypes.def" + Width = 0; hekota wrote: The intangible type is currently implemented as size-less type, but that might change as the HLSL implementation evolves. Setting the width to 0 here matches what similar types from other languages have done, for example `__externref_t` in WebAssembly, which is also an opaque type whose value cannot be accessed or manipulated, only passed around. https://github.com/llvm/llvm-project/pull/97362 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [TBAA] Emit int TBAA metadata on FP math libcall expf (PR #96025)
https://github.com/vfdff edited https://github.com/llvm/llvm-project/pull/96025 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [clang-doc] fix bug introduced by asset test (PR #97540)
PeterChou1 wrote: I've added the install path using a platform agnostic variable LLVM_RUNTIME_OUTPUT_INTDIR which should fix build path problems https://github.com/llvm/llvm-project/pull/97540 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AMDGPU] Report error in clang if wave32 is requested where unsupported (PR #97633)
@@ -188,8 +188,12 @@ bool AMDGPUTargetInfo::initFeatureMap( // TODO: Should move this logic into TargetParser std::string ErrorMsg; - if (!insertWaveSizeFeature(CPU, getTriple(), Features, ErrorMsg)) { -Diags.Report(diag::err_invalid_feature_combination) << ErrorMsg; + bool IsCombinationError; + if (!insertWaveSizeFeature(CPU, getTriple(), Features, ErrorMsg, shiltian wrote: It's better to make it return a `std::optional<...>`. https://github.com/llvm/llvm-project/pull/97633 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Docs] Fix #40293 Add help text to coverage flag (PR #77705)
https://github.com/widberg closed https://github.com/llvm/llvm-project/pull/77705 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [TBAA] Emit int TBAA metadata on FP math libcall expf (PR #96025)
https://github.com/vfdff edited https://github.com/llvm/llvm-project/pull/96025 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [TBAA] Emit int TBAA metadata on FP math libcall expf (PR #96025)
https://github.com/vfdff edited https://github.com/llvm/llvm-project/pull/96025 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [TBAA] Emit int TBAA metadata on FP math libcall expf (PR #96025)
https://github.com/vfdff edited https://github.com/llvm/llvm-project/pull/96025 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [TBAA] Emit int TBAA metadata on FP math libcall expf (PR #96025)
https://github.com/vfdff edited https://github.com/llvm/llvm-project/pull/96025 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [TBAA] Emit int TBAA metadata on FP math libcalls (PR #96025)
@@ -707,7 +707,34 @@ static RValue emitLibraryCall(CodeGenFunction &CGF, const FunctionDecl *FD, const CallExpr *E, llvm::Constant *calleeValue) { CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, E); CGCallee callee = CGCallee::forDirect(calleeValue, GlobalDecl(FD)); - return CGF.EmitCall(E->getCallee()->getType(), callee, E, ReturnValueSlot()); + RValue Call = + CGF.EmitCall(E->getCallee()->getType(), callee, E, ReturnValueSlot()); + + // Check the supported intrinsic. + if (unsigned BuiltinID = FD->getBuiltinID()) { +auto IntrinsicID = [&]() -> unsigned { + switch (BuiltinID) { + case Builtin::BIexpf: + case Builtin::BI__builtin_expf: + case Builtin::BI__builtin_expf128: +return true; + } + // TODO: support more FP math libcalls vfdff wrote: Ok, thanks https://github.com/llvm/llvm-project/pull/96025 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [TBAA] Emit int TBAA metadata on FP math libcalls (PR #96025)
@@ -0,0 +1,43 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 +// The test may fail as time out on windows +// REQUIRES: system-linux + +// RUN: %clang -S -O3 -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK,NoNewStructPathTBAA +// RUN: %clang -S -O3 -Xclang -new-struct-path-tbaa -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefixes=CHECK,NewStructPathTBAA + vfdff wrote: * I add a head file in the test, and it could not find the head file with clang_cc1 * I'll try to relax the restriction, add that for windows because it run **timeout** with my first commit. https://github.com/llvm/llvm-project/pull/96025 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [llvm] [InstCombine] Canonicalize constant GEPs to i8 source element type (PR #68882)
karthik-man wrote: I am debugging a Triton issue (https://github.com/triton-lang/triton/issues/4060), where an {i32, i32, i32, i64} struct passed to _vprintf_ is printing the wrong value for the i64. The issue here seems to be that Triton creates a llvm:Module with a default DataLayout. In the default layout, i64 abi alignment is 4(DefaultAlignments in DataLayout.cpp). This causes the optimization in this PR to rewrite the GEP to the i64 as follows: `%8 = alloca { i32, i32, i32, i64 }, align 8` `%12 = getelementptr { i32, i32, i32, i64 }, ptr %8, i32 0, i32 3` to `%6 = alloca { i32, i32, i32, i64 }, align 8` `%9 = getelementptr inbounds i8, ptr %6, i64 12` But _vprintf_ expects the i64 to be at offset 16. Is it legal for InstCombine to assume that the DL attached to the Module is the right DL for the target? In other words, is it ok for InstCombine to do optimizations that are target-dependent? https://github.com/llvm/llvm-project/pull/68882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][deps] Don't treat ObjC method args as module directives (PR #97654)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Michael Spencer (Bigcheese) Changes `import:(type)name` is a method argument decl in ObjC, but the C++20 preprocessing rules say this is a preprocessing line. Because the dependency directive scanner is not language dependent, this patch extends the C++20 rule to exclude `module :` (which is never a valid module decl anyway), and `import :` that is not followed by an identifier. This is ok to do because in C++20 mode the compiler will later error on lines like this anyway, and the dependencies the scanner returns are still correct. --- Full diff: https://github.com/llvm/llvm-project/pull/97654.diff 2 Files Affected: - (modified) clang/lib/Lex/DependencyDirectivesScanner.cpp (+12-1) - (added) clang/test/ClangScanDeps/scanner-objc-compat.m (+28) ``diff diff --git a/clang/lib/Lex/DependencyDirectivesScanner.cpp b/clang/lib/Lex/DependencyDirectivesScanner.cpp index 0971daa1f3666..bd2a8d5115c81 100644 --- a/clang/lib/Lex/DependencyDirectivesScanner.cpp +++ b/clang/lib/Lex/DependencyDirectivesScanner.cpp @@ -660,7 +660,18 @@ bool Scanner::lexModule(const char *&First, const char *const End) { // an import. switch (*First) { - case ':': + case ':': { +// `module :` is never the start of a valid module declaration. +if (Id == "module") { + skipLine(First, End); + return false; +} +// `import:(type)name` is a valid ObjC method decl, so check one more token. +(void)lexToken(First, End); +if (!tryLexIdentifierOrSkipLine(First, End)) + return false; +break; + } case '<': case '"': break; diff --git a/clang/test/ClangScanDeps/scanner-objc-compat.m b/clang/test/ClangScanDeps/scanner-objc-compat.m new file mode 100644 index 0..302988f1f51d6 --- /dev/null +++ b/clang/test/ClangScanDeps/scanner-objc-compat.m @@ -0,0 +1,28 @@ +// RUN: rm -rf %t +// RUN: split-file %s %t +// RUN: clang-scan-deps -format experimental-full -- \ +// RUN: %clang -c %t/main.m -o %t/main.o -fmodules -I %t > %t/deps.db +// RUN: cat %t/deps.db | sed 's:\?:/:g' | FileCheck %s -DPREFIX=%/t + +// Verify that the scanner does not treat ObjC method decls with arguments named +// module or import as module/import decls. + +// CHECK: "module-name": "A" + +//--- A.h + +@interface SomeObjcClass + - (void)func:(int)otherData + module:(int)module + import:(int)import; +@end + +//--- module.modulemap + +module A { + header "A.h" +} + +//--- main.m + +#include "A.h" `` https://github.com/llvm/llvm-project/pull/97654 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][deps] Don't treat ObjC method args as module directives (PR #97654)
https://github.com/Bigcheese created https://github.com/llvm/llvm-project/pull/97654 `import:(type)name` is a method argument decl in ObjC, but the C++20 preprocessing rules say this is a preprocessing line. Because the dependency directive scanner is not language dependent, this patch extends the C++20 rule to exclude `module :` (which is never a valid module decl anyway), and `import :` that is not followed by an identifier. This is ok to do because in C++20 mode the compiler will later error on lines like this anyway, and the dependencies the scanner returns are still correct. >From dd1ab401f52710b7583e21dd5e5fa112902f8f7c Mon Sep 17 00:00:00 2001 From: Michael Spencer Date: Wed, 3 Jul 2024 16:39:41 -0700 Subject: [PATCH] [clang][deps] Don't treat ObjC method args as module directives `import:(type)name` is a method argument decl in ObjC, but the C++20 preprocessing rules say this is a preprocessing line. Because the dependency directive scanner is not language dependent, this patch extends the C++20 rule to exclude `module :` (which is never a valid module decl anyway), and `import :` that is not followed by an identifier. This is ok to do because in C++20 mode the compiler will later error on lines like this anyway, and the dependencies the scanner returns are still correct. --- clang/lib/Lex/DependencyDirectivesScanner.cpp | 13 - .../test/ClangScanDeps/scanner-objc-compat.m | 28 +++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 clang/test/ClangScanDeps/scanner-objc-compat.m diff --git a/clang/lib/Lex/DependencyDirectivesScanner.cpp b/clang/lib/Lex/DependencyDirectivesScanner.cpp index 0971daa1f3666..bd2a8d5115c81 100644 --- a/clang/lib/Lex/DependencyDirectivesScanner.cpp +++ b/clang/lib/Lex/DependencyDirectivesScanner.cpp @@ -660,7 +660,18 @@ bool Scanner::lexModule(const char *&First, const char *const End) { // an import. switch (*First) { - case ':': + case ':': { +// `module :` is never the start of a valid module declaration. +if (Id == "module") { + skipLine(First, End); + return false; +} +// `import:(type)name` is a valid ObjC method decl, so check one more token. +(void)lexToken(First, End); +if (!tryLexIdentifierOrSkipLine(First, End)) + return false; +break; + } case '<': case '"': break; diff --git a/clang/test/ClangScanDeps/scanner-objc-compat.m b/clang/test/ClangScanDeps/scanner-objc-compat.m new file mode 100644 index 0..302988f1f51d6 --- /dev/null +++ b/clang/test/ClangScanDeps/scanner-objc-compat.m @@ -0,0 +1,28 @@ +// RUN: rm -rf %t +// RUN: split-file %s %t +// RUN: clang-scan-deps -format experimental-full -- \ +// RUN: %clang -c %t/main.m -o %t/main.o -fmodules -I %t > %t/deps.db +// RUN: cat %t/deps.db | sed 's:\?:/:g' | FileCheck %s -DPREFIX=%/t + +// Verify that the scanner does not treat ObjC method decls with arguments named +// module or import as module/import decls. + +// CHECK: "module-name": "A" + +//--- A.h + +@interface SomeObjcClass + - (void)func:(int)otherData + module:(int)module + import:(int)import; +@end + +//--- module.modulemap + +module A { + header "A.h" +} + +//--- main.m + +#include "A.h" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ThreadSafety] Check trylock function success and return types (PR #95290)
@@ -1359,17 +1361,18 @@ void ThreadSafetyAnalyzer::getMutexIDs(CapExprSet &Mtxs, AttrType *Attr, const Expr *Exp, const NamedDecl *D, const CFGBlock *PredBlock, const CFGBlock *CurrBlock, - Expr *BrE, bool Neg) { - // Find out which branch has the lock - bool branch = false; - if (const auto *BLE = dyn_cast_or_null(BrE)) -branch = BLE->getValue(); - else if (const auto *ILE = dyn_cast_or_null(BrE)) -branch = ILE->getValue().getBoolValue(); aaronpuchert wrote: > My instinct is to explicitly disallow enumerator success expressions. [...] > To my knowledge, enumerators were never actually supported in success > expressions, so in some sense this will only break code that was already > broken. Agreed. > Is it normally expected to keep incorrect behavior around for compatibility? It depends. If the incorrect behavior is being relied upon, or the correction could produce hard-to-find issues like different behavior at runtime, then it could make sense to keep it. But here I find it unlikely that someone relies on this, as it does not properly work, and the additional error would at most make compilation fail and would be trivial to fix. > How are breaking changes such as this typically handled? I'd argue that the change isn't breaking anything, it's merely diagnosing a case that was already not appropriately handled. https://github.com/llvm/llvm-project/pull/95290 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][PAC] Sign block addresses used in indirectbr. (PR #97647)
efriedma-quic wrote: Please make sure you have a testcase for computing the difference between two blockaddresses (`void g(int*); int f() { static int x = &&A-&&B; A:g(&x);B:return x; }`). Not sure how you should handle that case. https://github.com/llvm/llvm-project/pull/97647 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] Fix Default Asset File locator for clang docs (PR #97505)
bob80905 wrote: Updated the description. In my tests, there are at least 5 copies of this file in the overall build output directory: ``` //Debug/share/clang-doc //Release/share/clang-doc //MinSizeRel/share/clang-doc //RelWithDebInfo/share/clang-doc //share/clang-doc ``` Yes, one per configuration, and one underneath the binary directory. I am unsure if we still need the copy in the binary directory, because I'm not sure which executable is run by default when running tests. https://github.com/llvm/llvm-project/pull/97505 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Correctly transform dependent operands of overloaded binary operator& (PR #97596)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `arc-builder` running on `arc-worker` while building `clang` at step 6 "test-build-unified-tree-check-all". Full details are available at: https://lab.llvm.org/buildbot/#/builders/3/builds/1033 Here is the relevant piece of the build log for the reference: ``` Step 6 (test-build-unified-tree-check-all) failure: 1200 seconds without output running [b'ninja', b'check-all'], attempting to kill ... OK 10.117 [33/18/25] Linking CXX executable unittests/DebugInfo/Symbolizer/DebugInfoSymbolizerTests 10.137 [32/18/26] Linking CXX executable unittests/DebugInfo/GSYM/DebugInfoGSYMTests 10.559 [31/18/27] Linking CXX executable unittests/DWARFLinkerParallel/DWARFLinkerParallelTests 10.795 [30/18/28] Linking CXX executable unittests/DebugInfo/PDB/DebugInfoPDBTests 10.864 [29/18/29] Linking CXX executable unittests/Debuginfod/DebuginfodTests 11.286 [28/18/30] Linking CXX executable unittests/ExecutionEngine/ExecutionEngineTests 11.293 [27/18/31] Linking CXX executable unittests/DebugInfo/LogicalView/DebugInfoLogicalViewTests 11.740 [26/18/32] Linking CXX executable unittests/ExecutionEngine/JITLink/JITLinkTests command timed out: 1200 seconds without output running [b'ninja', b'check-all'], attempting to kill process killed by signal 9 program finished with exit code -1 elapsedTime=1212.434721 ``` https://github.com/llvm/llvm-project/pull/97596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [MLIR] Add f8E4M3 IEEE 754 type (PR #97118)
apivovarov wrote: > Hey @apivovarov I just wanted to say my bad for not getting to this yet - I'm > buried at work but I haven't forgotten. If it's hipri I can find someone else > to review. Otherwise ~couple of days I think and I'll be clear to review. Hi Maksim, I think it has standard priority. APFloat PR is quiet for the last 4 days... https://github.com/llvm/llvm-project/pull/97179 . 4th of July week... https://github.com/llvm/llvm-project/pull/97118 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][PAC] Sign block addresses used in indirectbr. (PR #97647)
https://github.com/ahmedbougacha updated https://github.com/llvm/llvm-project/pull/97647 >From 519570896c82887a5dd878fcc16f884857d4fce3 Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Tue, 12 Mar 2024 14:40:17 -0700 Subject: [PATCH] [AArch64][PAC] Sign block addresses used in indirectbr. Enabled in clang using: -fptrauth-indirect-gotos and at the IR level using function attribute: "ptrauth-indirect-gotos" Signing uses IA and a per-function integer discriminator. The discriminator isn't ABI-visible, and is currently: ptrauth_string_discriminator(" blockaddress") A sufficiently sophisticated frontend could benefit from per-indirectbr discrimination, which would need additional machinery, such as allowing "ptrauth" bundles on indirectbr. For our purposes, the simple scheme above is sufficient. --- clang/include/clang/Basic/Features.def| 1 + clang/include/clang/Basic/LangOptions.def | 1 + .../include/clang/Basic/PointerAuthOptions.h | 3 + clang/include/clang/Driver/Options.td | 2 + clang/lib/CodeGen/CodeGenFunction.cpp | 2 + clang/lib/Driver/ToolChains/Clang.cpp | 3 + clang/lib/Frontend/CompilerInvocation.cpp | 6 +- .../CodeGen/ptrauth-function-attributes.c | 5 + llvm/docs/PointerAuth.md | 24 llvm/include/llvm/CodeGen/AsmPrinter.h| 3 + llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp| 6 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 35 +- llvm/lib/Target/AArch64/AArch64FastISel.cpp | 4 + .../Target/AArch64/AArch64ISelLowering.cpp| 53 - llvm/lib/Target/AArch64/AArch64ISelLowering.h | 1 + llvm/lib/Target/AArch64/AArch64InstrInfo.td | 18 +++ llvm/lib/Target/AArch64/AArch64Subtarget.cpp | 11 ++ llvm/lib/Target/AArch64/AArch64Subtarget.h| 9 ++ .../GISel/AArch64InstructionSelector.cpp | 26 + .../CodeGen/AArch64/ptrauth-indirectbr.ll | 106 ++ 20 files changed, 308 insertions(+), 11 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/ptrauth-indirectbr.ll diff --git a/clang/include/clang/Basic/Features.def b/clang/include/clang/Basic/Features.def index 53f410d3cb4bd..cf800afe08557 100644 --- a/clang/include/clang/Basic/Features.def +++ b/clang/include/clang/Basic/Features.def @@ -108,6 +108,7 @@ FEATURE(ptrauth_calls, LangOpts.PointerAuthCalls) FEATURE(ptrauth_returns, LangOpts.PointerAuthReturns) FEATURE(ptrauth_vtable_pointer_address_discrimination, LangOpts.PointerAuthVTPtrAddressDiscrimination) FEATURE(ptrauth_vtable_pointer_type_discrimination, LangOpts.PointerAuthVTPtrTypeDiscrimination) +FEATURE(ptrauth_indirect_gotos, LangOpts.PointerAuthIndirectGotos) FEATURE(ptrauth_member_function_pointer_type_discrimination, LangOpts.PointerAuthCalls) FEATURE(ptrauth_init_fini, LangOpts.PointerAuthInitFini) EXTENSION(swiftcc, diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 491759e2fcdbb..bdf77a5b35208 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -165,6 +165,7 @@ LANGOPT(ExperimentalLibrary, 1, 0, "enable unstable and experimental library fea LANGOPT(PointerAuthIntrinsics, 1, 0, "pointer authentication intrinsics") LANGOPT(PointerAuthCalls , 1, 0, "function pointer authentication") LANGOPT(PointerAuthReturns, 1, 0, "return pointer authentication") +LANGOPT(PointerAuthIndirectGotos, 1, 0, "indirect gotos pointer authentication") LANGOPT(PointerAuthAuthTraps, 1, 0, "pointer authentication failure traps") LANGOPT(PointerAuthVTPtrAddressDiscrimination, 1, 0, "incorporate address discrimination in authenticated vtable pointers") LANGOPT(PointerAuthVTPtrTypeDiscrimination, 1, 0, "incorporate type discrimination in authenticated vtable pointers") diff --git a/clang/include/clang/Basic/PointerAuthOptions.h b/clang/include/clang/Basic/PointerAuthOptions.h index 197d63642ca6d..2711639dbe299 100644 --- a/clang/include/clang/Basic/PointerAuthOptions.h +++ b/clang/include/clang/Basic/PointerAuthOptions.h @@ -154,6 +154,9 @@ class PointerAuthSchema { }; struct PointerAuthOptions { + /// Do indirect goto label addresses need to be authenticated? + bool IndirectGotos = false; + /// The ABI for C function pointers. PointerAuthSchema FunctionPointers; diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 58ca6f2bea9e4..791b7261ddbda 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4228,6 +4228,8 @@ defm ptrauth_vtable_pointer_address_discrimination : defm ptrauth_vtable_pointer_type_discrimination : OptInCC1FFlag<"ptrauth-vtable-pointer-type-discrimination", "Enable type discrimination of vtable pointers">; defm ptrauth_init_fini : OptInCC1FFlag<"ptrauth-init-fini", "Enable signing of function pointers in init/fini arrays">; +defm ptrauth_indirect_gotos : OptInCC1FFlag<"ptrauth-in
[clang-tools-extra] Fix Default Asset File locator for clang docs (PR #97505)
https://github.com/bob80905 edited https://github.com/llvm/llvm-project/pull/97505 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [clang-doc] fix bug introduced by asset test (PR #97540)
https://github.com/PeterChou1 updated https://github.com/llvm/llvm-project/pull/97540 >From b8dd4f6f2005d2e08ae13023905d0f36edd6348b Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Wed, 3 Jul 2024 04:42:33 -0400 Subject: [PATCH 1/7] [clang-doc] fix path bug introduced by asset test --- clang-tools-extra/clang-doc/tool/CMakeLists.txt | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt index e93a5728d6b6b..3fd41f187a617 100644 --- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt @@ -25,7 +25,11 @@ set(assets ) set(asset_dir "${CMAKE_CURRENT_SOURCE_DIR}/../assets") -set(resource_dir "${CMAKE_BINARY_DIR}/share/clang-doc") +if(MSVC) + set(resource_dir "${CMAKE_BINARY_DIR}/$/share/clang-doc") +else() + set(resource_dir "${CMAKE_BINARY_DIR}/share/clang-doc") +endif() set(out_files) function(copy_files_to_dst src_dir dst_dir file) @@ -52,4 +56,4 @@ add_custom_target(copy-clang-doc-assets COMMENT "Copying Clang-Doc Assets" ) set_target_properties(copy-clang-doc-assets PROPERTIES FOLDER "Clang-Doc/Assets") -add_dependencies(clang-doc copy-clang-doc-assets) +add_dependencies(clang-doc copy-clang-doc-assets) \ No newline at end of file >From cf993cfeeab18be6aa434e159fb625456183d4da Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Wed, 3 Jul 2024 13:49:26 -0400 Subject: [PATCH 2/7] [clang-doc] modify cmake file to fix asset install path --- clang-tools-extra/clang-doc/tool/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt index 3fd41f187a617..ddaf8cd4cdbd6 100644 --- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt @@ -25,7 +25,7 @@ set(assets ) set(asset_dir "${CMAKE_CURRENT_SOURCE_DIR}/../assets") -if(MSVC) +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") set(resource_dir "${CMAKE_BINARY_DIR}/$/share/clang-doc") else() set(resource_dir "${CMAKE_BINARY_DIR}/share/clang-doc") >From e389b78848127be9753797d355d196c03e3974fd Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Wed, 3 Jul 2024 14:14:56 -0400 Subject: [PATCH 3/7] [clang-doc] fix nit --- clang-tools-extra/clang-doc/tool/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt index ddaf8cd4cdbd6..aaf3c3b8734c8 100644 --- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt @@ -56,4 +56,4 @@ add_custom_target(copy-clang-doc-assets COMMENT "Copying Clang-Doc Assets" ) set_target_properties(copy-clang-doc-assets PROPERTIES FOLDER "Clang-Doc/Assets") -add_dependencies(clang-doc copy-clang-doc-assets) \ No newline at end of file +add_dependencies(clang-doc copy-clang-doc-assets) >From 4733341a26ef3b6faa1a00d2e53b0033de440eb7 Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Wed, 3 Jul 2024 16:04:37 -0400 Subject: [PATCH 4/7] [llvm] modify cmake list to add shared directory --- clang-tools-extra/clang-doc/tool/CMakeLists.txt | 7 +-- llvm/CMakeLists.txt | 6 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt index aaf3c3b8734c8..c908cac9ce2a5 100644 --- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt @@ -25,11 +25,6 @@ set(assets ) set(asset_dir "${CMAKE_CURRENT_SOURCE_DIR}/../assets") -if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") - set(resource_dir "${CMAKE_BINARY_DIR}/$/share/clang-doc") -else() - set(resource_dir "${CMAKE_BINARY_DIR}/share/clang-doc") -endif() set(out_files) function(copy_files_to_dst src_dir dst_dir file) @@ -48,7 +43,7 @@ foreach(f ${assets}) install(FILES ${asset_dir}/${f} DESTINATION "${CMAKE_INSTALL_DATADIR}/clang-doc" COMPONENT clang-doc) - copy_files_to_dst(${asset_dir} ${resource_dir} ${f}) + copy_files_to_dst(${asset_dir} ${LLVM_SHARE_DIR} ${f}) endforeach(f) add_custom_target(copy-clang-doc-assets diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 91a2b6181ce0a..0c02498aa6fce 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -452,6 +452,12 @@ if(WIN32 OR CYGWIN) else() set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) endif() +# set shared directory +if(CMAKE_GENERATOR MATCHES "Visual Studio") + set(LLVM_SHARE_DIR "${CMAKE_BINARY_DIR}/$/share") +else() + set(LLVM_SHARE_DIR "${CMAKE_BINARY_DIR}/share") +endif() # Each of them corresponds to llvm-config's. set(LLVM_TOOLS_BINARY_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) # --bindir >From 3433bfecffe25077fc1749be6c30512e2e47eadb Mon Sep 17 00:00
[clang-tools-extra] [llvm] [clang-doc] fix bug introduced by asset test (PR #97540)
https://github.com/PeterChou1 updated https://github.com/llvm/llvm-project/pull/97540 >From b8dd4f6f2005d2e08ae13023905d0f36edd6348b Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Wed, 3 Jul 2024 04:42:33 -0400 Subject: [PATCH 1/6] [clang-doc] fix path bug introduced by asset test --- clang-tools-extra/clang-doc/tool/CMakeLists.txt | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt index e93a5728d6b6b..3fd41f187a617 100644 --- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt @@ -25,7 +25,11 @@ set(assets ) set(asset_dir "${CMAKE_CURRENT_SOURCE_DIR}/../assets") -set(resource_dir "${CMAKE_BINARY_DIR}/share/clang-doc") +if(MSVC) + set(resource_dir "${CMAKE_BINARY_DIR}/$/share/clang-doc") +else() + set(resource_dir "${CMAKE_BINARY_DIR}/share/clang-doc") +endif() set(out_files) function(copy_files_to_dst src_dir dst_dir file) @@ -52,4 +56,4 @@ add_custom_target(copy-clang-doc-assets COMMENT "Copying Clang-Doc Assets" ) set_target_properties(copy-clang-doc-assets PROPERTIES FOLDER "Clang-Doc/Assets") -add_dependencies(clang-doc copy-clang-doc-assets) +add_dependencies(clang-doc copy-clang-doc-assets) \ No newline at end of file >From cf993cfeeab18be6aa434e159fb625456183d4da Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Wed, 3 Jul 2024 13:49:26 -0400 Subject: [PATCH 2/6] [clang-doc] modify cmake file to fix asset install path --- clang-tools-extra/clang-doc/tool/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt index 3fd41f187a617..ddaf8cd4cdbd6 100644 --- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt @@ -25,7 +25,7 @@ set(assets ) set(asset_dir "${CMAKE_CURRENT_SOURCE_DIR}/../assets") -if(MSVC) +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") set(resource_dir "${CMAKE_BINARY_DIR}/$/share/clang-doc") else() set(resource_dir "${CMAKE_BINARY_DIR}/share/clang-doc") >From e389b78848127be9753797d355d196c03e3974fd Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Wed, 3 Jul 2024 14:14:56 -0400 Subject: [PATCH 3/6] [clang-doc] fix nit --- clang-tools-extra/clang-doc/tool/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt index ddaf8cd4cdbd6..aaf3c3b8734c8 100644 --- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt @@ -56,4 +56,4 @@ add_custom_target(copy-clang-doc-assets COMMENT "Copying Clang-Doc Assets" ) set_target_properties(copy-clang-doc-assets PROPERTIES FOLDER "Clang-Doc/Assets") -add_dependencies(clang-doc copy-clang-doc-assets) \ No newline at end of file +add_dependencies(clang-doc copy-clang-doc-assets) >From 4733341a26ef3b6faa1a00d2e53b0033de440eb7 Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Wed, 3 Jul 2024 16:04:37 -0400 Subject: [PATCH 4/6] [llvm] modify cmake list to add shared directory --- clang-tools-extra/clang-doc/tool/CMakeLists.txt | 7 +-- llvm/CMakeLists.txt | 6 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt index aaf3c3b8734c8..c908cac9ce2a5 100644 --- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt @@ -25,11 +25,6 @@ set(assets ) set(asset_dir "${CMAKE_CURRENT_SOURCE_DIR}/../assets") -if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") - set(resource_dir "${CMAKE_BINARY_DIR}/$/share/clang-doc") -else() - set(resource_dir "${CMAKE_BINARY_DIR}/share/clang-doc") -endif() set(out_files) function(copy_files_to_dst src_dir dst_dir file) @@ -48,7 +43,7 @@ foreach(f ${assets}) install(FILES ${asset_dir}/${f} DESTINATION "${CMAKE_INSTALL_DATADIR}/clang-doc" COMPONENT clang-doc) - copy_files_to_dst(${asset_dir} ${resource_dir} ${f}) + copy_files_to_dst(${asset_dir} ${LLVM_SHARE_DIR} ${f}) endforeach(f) add_custom_target(copy-clang-doc-assets diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 91a2b6181ce0a..0c02498aa6fce 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -452,6 +452,12 @@ if(WIN32 OR CYGWIN) else() set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) endif() +# set shared directory +if(CMAKE_GENERATOR MATCHES "Visual Studio") + set(LLVM_SHARE_DIR "${CMAKE_BINARY_DIR}/$/share") +else() + set(LLVM_SHARE_DIR "${CMAKE_BINARY_DIR}/share") +endif() # Each of them corresponds to llvm-config's. set(LLVM_TOOLS_BINARY_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) # --bindir >From 3433bfecffe25077fc1749be6c30512e2e47eadb Mon Sep 17 00:00
[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce Realtime Sanitizer (RTSan) backend (PR #92460)
@@ -0,0 +1,67 @@ +import os + +# Setup config name. +config.name = "RTSAN" + config.name_suffix + +# Setup source root. +config.test_source_root = os.path.dirname(__file__) + +# Setup default compiler flags use with -frtsan-instrument option. +clang_rtsan_cflags = ["-frtsan-instrument", config.target_cflags] + +# If libc++ was used to build rtsan libraries, libc++ is needed. Fix applied +# to Linux only since -rpath may not be portable. This can be extended to +# other platforms. +if config.libcxx_used == "1" and config.host_os == "Linux": +clang_rtsan_cflags = clang_rtsan_cflags + ( +["-L%s -lc++ -Wl,-rpath=%s" % (config.llvm_shlib_dir, config.llvm_shlib_dir)] cjappl wrote: Removed! https://github.com/llvm/llvm-project/pull/92460 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] Fix Default Asset File locator for clang docs (PR #97505)
damyanp wrote: I don't think that the current description matches the change? Does this mean that there'll likely be 3 copies of each file. One per configuration, and another copy just in the binary directory? https://github.com/llvm/llvm-project/pull/97505 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] Fix Default Asset File locator for clang docs (PR #97505)
https://github.com/bob80905 updated https://github.com/llvm/llvm-project/pull/97505 >From 1c190c9c6b55aec23bab6d7b2a0f489c59285dc7 Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Tue, 2 Jul 2024 18:38:24 -0700 Subject: [PATCH 1/5] if debug exists, go up an extra dir --- clang-tools-extra/clang-doc/tool/ClangDocMain.cpp | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp index 6198a6e0cdcc32..b97fa715f9e67f 100644 --- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp +++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp @@ -167,7 +167,13 @@ llvm::Error getDefaultAssetFiles(const char *Argv0, llvm::SmallString<128> AssetsPath; AssetsPath = llvm::sys::path::parent_path(NativeClangDocPath); - llvm::sys::path::append(AssetsPath, "..", "share", "clang-doc"); + llvm::sys::path::append(AssetsPath, ".."); + llvm::SmallString<128> tempCopyDbg = AssetsPath; + llvm::sys::path::append(tempCopyDbg, "Debug"); + // index.js may be in the debug + if (!llvm::sys::fs::is_directory(tempCopyDbg)) +llvm::sys::path::append(AssetsPath, ".."); + llvm::sys::path::append(AssetsPath, "share", "clang-doc"); llvm::SmallString<128> DefaultStylesheet; llvm::sys::path::native(AssetsPath, DefaultStylesheet); llvm::sys::path::append(DefaultStylesheet, >From 07662a63e1b3ab2886871f3960246be8219c6ecd Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Tue, 2 Jul 2024 18:45:23 -0700 Subject: [PATCH 2/5] cleanup comment --- clang-tools-extra/clang-doc/tool/ClangDocMain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp index b97fa715f9e67f..ebd0675cd55014 100644 --- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp +++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp @@ -170,7 +170,7 @@ llvm::Error getDefaultAssetFiles(const char *Argv0, llvm::sys::path::append(AssetsPath, ".."); llvm::SmallString<128> tempCopyDbg = AssetsPath; llvm::sys::path::append(tempCopyDbg, "Debug"); - // index.js may be in the debug + // The executable that ran clangDoc may be in the Debug directory. if (!llvm::sys::fs::is_directory(tempCopyDbg)) llvm::sys::path::append(AssetsPath, ".."); llvm::sys::path::append(AssetsPath, "share", "clang-doc"); >From ea1d0ce1c2893297e67eebf0a52885681c6a866d Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Wed, 3 Jul 2024 03:12:38 -0700 Subject: [PATCH 3/5] use native to copy path, instead of assignment operator --- clang-tools-extra/clang-doc/tool/ClangDocMain.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp index ebd0675cd55014..6ec35acfc2db3a 100644 --- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp +++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp @@ -168,7 +168,8 @@ llvm::Error getDefaultAssetFiles(const char *Argv0, llvm::SmallString<128> AssetsPath; AssetsPath = llvm::sys::path::parent_path(NativeClangDocPath); llvm::sys::path::append(AssetsPath, ".."); - llvm::SmallString<128> tempCopyDbg = AssetsPath; + llvm::SmallString<128> tempCopyDbg; + llvm::sys::path::native(AssetsPath, tempCopyDbg); llvm::sys::path::append(tempCopyDbg, "Debug"); // The executable that ran clangDoc may be in the Debug directory. if (!llvm::sys::fs::is_directory(tempCopyDbg)) >From b7484828d96d23dd7d2d88ee8d44f5aad6e23140 Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Wed, 3 Jul 2024 13:37:17 -0700 Subject: [PATCH 4/5] revert change in .cpp, make attempt at fixing cmake --- clang-tools-extra/clang-doc/tool/CMakeLists.txt | 10 -- clang-tools-extra/clang-doc/tool/ClangDocMain.cpp | 9 + 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt index e93a5728d6b6b0..31ff0aca72b88f 100644 --- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt @@ -25,15 +25,16 @@ set(assets ) set(asset_dir "${CMAKE_CURRENT_SOURCE_DIR}/../assets") -set(resource_dir "${CMAKE_BINARY_DIR}/share/clang-doc") set(out_files) function(copy_files_to_dst src_dir dst_dir file) set(src "${src_dir}/${file}") set(dst "${dst_dir}/${file}") + message(here) add_custom_command(OUTPUT ${dst} DEPENDS ${src} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst} +message(here2) COMMENT "Copying ${file} to ${dst_dir}" ) list(APPEND out_files ${dst}) @@ -44,7 +45,12 @@ foreach(f ${assets}) install(FILES ${asset_dir}/${f} DESTINATION "${CMAKE_INSTALL_DATADIR}/clang-doc" COMPONENT clang-doc) - copy_files_to_dst(${asset_dir} ${resource_dir} ${f}) + foreach(config ${CMAKE_CONFIG
[clang] [clang][modules] Fix use-after-free in header serialization (PR #96356)
https://github.com/vsapsai approved this pull request. https://github.com/llvm/llvm-project/pull/96356 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][modules] Fix use-after-free in header serialization (PR #96356)
vsapsai wrote: Looked at this more and haven't found anything sketchy. `ASTWriter::WriteHeaderSearch` writes the same content both with and without `-fno-modules-prune-non-affecting-module-map-files`. `Preprocessor::alreadyIncluded` is called in reasonable places (as for me, ASTWriter is the most questionable spot). As I cannot find any other risks, ensuring memory safety looks good to me. https://github.com/llvm/llvm-project/pull/96356 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Correctly transform dependent operands of overloaded binary operator& (PR #97596)
https://github.com/sdkrystian closed https://github.com/llvm/llvm-project/pull/97596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 10b43f4 - [Clang][Sema] Correctly transform dependent operands of overloaded binary operator& (#97596)
Author: Krystian Stasiowski Date: 2024-07-03T18:19:58-04:00 New Revision: 10b43f429a9f5cc7315c5b0490433647c9a93493 URL: https://github.com/llvm/llvm-project/commit/10b43f429a9f5cc7315c5b0490433647c9a93493 DIFF: https://github.com/llvm/llvm-project/commit/10b43f429a9f5cc7315c5b0490433647c9a93493.diff LOG: [Clang][Sema] Correctly transform dependent operands of overloaded binary operator& (#97596) Currently, `TreeTransform::TransformCXXOperatorCallExpr` calls `TreeTransform::TransformAddressOfOperand` to transform the first operand of a `CXXOperatorCallExpr` when its `OverloadOperatorKind` is `OO_Amp` -- regardless of arity. This results in the first operand of binary `operator&` being incorrectly transformed as if it was the operand of the address of operator in cases such as the following: ``` struct A { int x; }; void operator&(A, A); template struct B { int f() { return T::x & 1; // invalid reference to 'A::x' is not diagnosed because 'T::x' is incorrectly transformed as if it was the operand of unary operator& } }; template struct B; ``` Prior to #92318 we would build a `CXXDependentScopeMemberExpr` for `T::x` (as with most dependent qualified names that were not member qualified names). Since `TreeTransform::TransformAddressOfOperand` only differs from `TransformExpr` for `DependentScopeDeclRefExpr` and `UnresolvedLookupExpr` operands, `T::x` was transformed "correctly". Now that we build a `DependentScopeDeclRefExpr` for `T::x`, it is incorrectly transformed as if it was the operand of the address of operator and we fail to diagnose the invalid reference to a non-static data member. This patch fixes the issue by only calling `TreeTransform::TransformAddressOfOperand` for `CXXOperatorCallExpr`s with a single operand. This fixes #97483. Added: clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.general/p4.cpp Modified: clang/docs/ReleaseNotes.rst clang/lib/Sema/TreeTransform.h Removed: diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index f40fd1cd145bb..f149684214567 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -954,6 +954,8 @@ Bug Fixes to C++ Support forward-declared class. (#GH93512). - Fixed a bug in access checking inside return-type-requirement of compound requirements. (#GH93788). - Fixed an assertion failure about invalid conversion when calling lambda. (#GH96205). +- Fixed a bug where the first operand of binary ``operator&`` would be transformed as if it was the operand + of the address of operator. (#GH97483). Bug Fixes to AST Handling ^ diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 51ba22f99e3a3..4450ebaf615cd 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -12919,7 +12919,7 @@ TreeTransform::TransformCXXOperatorCallExpr(CXXOperatorCallExpr *E) { } ExprResult First; - if (E->getOperator() == OO_Amp) + if (E->getNumArgs() == 1 && E->getOperator() == OO_Amp) First = getDerived().TransformAddressOfOperand(E->getArg(0)); else First = getDerived().TransformExpr(E->getArg(0)); diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.general/p4.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.general/p4.cpp new file mode 100644 index 0..e6d9c171e3893 --- /dev/null +++ b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.general/p4.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -verify %s + +struct A { + int x; +}; + +void operator&(A, A); + +template +struct B { + int f() { +return T::x & 1; // expected-error {{invalid use of non-static data member 'x'}} + } +}; + +template struct B; // expected-note {{in instantiation of}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce Realtime Sanitizer (RTSan) backend (PR #92460)
https://github.com/MaskRay approved this pull request. https://github.com/llvm/llvm-project/pull/92460 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce Realtime Sanitizer (RTSan) backend (PR #92460)
MaskRay wrote: > In the meantime, I commented out compilation of our unit tests that required > the -fsanitize flag, let me know if you'd prefer to see them removed until > later. These unit tests are paired with the code introduced here, so I think > at least by subject it makes sense to introduce them here, even if they are > briefly not being compiled. Yeah, disabling the testsuite should be safe. The tests can be enabled after clangCodeGen and clangDriver patches landed. https://github.com/llvm/llvm-project/pull/92460 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce Realtime Sanitizer (RTSan) backend (PR #92460)
@@ -0,0 +1,67 @@ +import os + +# Setup config name. +config.name = "RTSAN" + config.name_suffix + +# Setup source root. +config.test_source_root = os.path.dirname(__file__) + +# Setup default compiler flags use with -frtsan-instrument option. +clang_rtsan_cflags = ["-frtsan-instrument", config.target_cflags] + +# If libc++ was used to build rtsan libraries, libc++ is needed. Fix applied +# to Linux only since -rpath may not be portable. This can be extended to +# other platforms. +if config.libcxx_used == "1" and config.host_os == "Linux": +clang_rtsan_cflags = clang_rtsan_cflags + ( +["-L%s -lc++ -Wl,-rpath=%s" % (config.llvm_shlib_dir, config.llvm_shlib_dir)] MaskRay wrote: compiler-rt/test/xray/lit.cfg.py uses this construct but other sanitizers don't. Is it needed? https://github.com/llvm/llvm-project/pull/92460 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce Realtime Sanitizer (RTSan) backend (PR #92460)
@@ -0,0 +1,97 @@ +//===--- rtsan_context.cpp - Realtime Sanitizer -*- 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 +// +//===--===// +// +//===--===// + +#include + +#include + +#include +#include + +#include +#include +#include +#include + +static pthread_key_t context_key; +static pthread_once_t key_once = PTHREAD_ONCE_INIT; + +static void internalFree(void *ptr) { __sanitizer::InternalFree(ptr); } MaskRay wrote: `InternalFree`. If there is a name conflict, perhaps pick a different name. https://github.com/llvm/llvm-project/pull/92460 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce Realtime Sanitizer (RTSan) backend (PR #92460)
@@ -0,0 +1,207 @@ +//===--- rtsan_test.cpp - Realtime Sanitizer *- 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 +// +//===--===// +// +// Introduces basic functional tests for the realtime sanitizer. +// Not meant to be exhaustive, testing all interceptors, please see +// test_rtsan_interceptors.cpp for those tests. +// +//===--===// + +#include "gtest/gtest.h" + +#include "rtsan_test_utilities.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \ +__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101200 +#define SI_MAC_DEPLOYMENT_AT_LEAST_10_12 1 +#else +#define SI_MAC_DEPLOYMENT_AT_LEAST_10_12 0 +#endif + +#define RTSAN_TEST_SHARED_MUTEX (!(SI_MAC) || SI_MAC_DEPLOYMENT_AT_LEAST_10_12) + +using namespace testing; +using namespace rtsan_testing; +using namespace std::chrono_literals; + +TEST(TestRtsan, VectorPushBackAllocationDiesWhenRealtime) { + std::vector vec{}; MaskRay wrote: omit `{};` https://github.com/llvm/llvm-project/pull/92460 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce Realtime Sanitizer (RTSan) backend (PR #92460)
@@ -0,0 +1,412 @@ +//===--- rtsan_interceptors.cpp - Realtime Sanitizer *- 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 +// +//===--===// +// +//===--===// + +#include "rtsan/rtsan_interceptors.h" + +#include "sanitizer_common/sanitizer_platform.h" +#include "sanitizer_common/sanitizer_platform_interceptors.h" + +#include "interception/interception.h" +#include "rtsan/rtsan_context.h" + +#if !SANITIZER_LINUX && !SANITIZER_APPLE MaskRay wrote: If other OSes are not supported, the NetBSD/FreeBSD/etc references in `lit.cfg.py` should be removed. https://github.com/llvm/llvm-project/pull/92460 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce Realtime Sanitizer (RTSan) backend (PR #92460)
@@ -0,0 +1,97 @@ +//===--- rtsan_context.cpp - Realtime Sanitizer -*- 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 +// +//===--===// +// +//===--===// + +#include + +#include + +#include +#include + +#include +#include +#include +#include + +static pthread_key_t context_key; +static pthread_once_t key_once = PTHREAD_ONCE_INIT; + +static void internalFree(void *ptr) { __sanitizer::InternalFree(ptr); } + +static __rtsan::Context &GetContextForThisThreadImpl() { + auto make_thread_local_context_key = []() { +CHECK_EQ(pthread_key_create(&context_key, internalFree), 0); + }; + + pthread_once(&key_once, make_thread_local_context_key); + __rtsan::Context *current_thread_context = + static_cast<__rtsan::Context *>(pthread_getspecific(context_key)); + if (current_thread_context == nullptr) { +current_thread_context = static_cast<__rtsan::Context *>( +__sanitizer::InternalAlloc(sizeof(__rtsan::Context))); +new (current_thread_context) __rtsan::Context(); +pthread_setspecific(context_key, current_thread_context); + } + + return *current_thread_context; +} + +/* +This is a placeholder stub for a future feature that will allow +a user to configure RTSan's behaviour when a real-time safety +violation is detected. The RTSan developers intend for the +following choices to be made available, via a RTSAN_OPTIONS +environment variable, in a future PR: + +i) exit, + ii) continue, or + iii) wait for user input from stdin. + +Until then, and to keep the first PRs small, only the exit mode +is available. +*/ +static void InvokeViolationDetectedAction() { exit(EXIT_FAILURE); } + +namespace __rtsan { MaskRay wrote: https://llvm.org/docs/CodingStandards.html#use-namespace-qualifiers-to-implement-previously-declared-functions If `using namespace __rtsan`, `.cpp` files should not need `namespace __rtsan`. https://github.com/llvm/llvm-project/pull/92460 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce Realtime Sanitizer (RTSan) backend (PR #92460)
@@ -0,0 +1,67 @@ +import os + +# Setup config name. +config.name = "RTSAN" + config.name_suffix + +# Setup source root. +config.test_source_root = os.path.dirname(__file__) + +# Setup default compiler flags use with -frtsan-instrument option. +clang_rtsan_cflags = ["-frtsan-instrument", config.target_cflags] + +# If libc++ was used to build rtsan libraries, libc++ is needed. Fix applied +# to Linux only since -rpath may not be portable. This can be extended to +# other platforms. +if config.libcxx_used == "1" and config.host_os == "Linux": +clang_rtsan_cflags = clang_rtsan_cflags + ( +["-L%s -lc++ -Wl,-rpath=%s" % (config.llvm_shlib_dir, config.llvm_shlib_dir)] +) + +clang_rtsan_cxxflags = config.cxx_mode_flags + clang_rtsan_cflags + + +def build_invocation(compile_flags): +return " " + " ".join([config.clang] + compile_flags) + " " + + +# Assume that llvm-rtsan is in the config.llvm_tools_dir. +llvm_rtsan = os.path.join(config.llvm_tools_dir, "llvm-rtsan") + +# Setup substitutions. +if config.host_os == "Linux": +libdl_flag = "-ldl" +else: +libdl_flag = "" + +config.substitutions.append(("%clang ", build_invocation([config.target_cflags]))) +config.substitutions.append( +("%clangxx ", build_invocation(config.cxx_mode_flags + [config.target_cflags])) +) +config.substitutions.append(("%clang_rtsan ", build_invocation(clang_rtsan_cflags))) +config.substitutions.append(("%clangxx_rtsan", build_invocation(clang_rtsan_cxxflags))) +config.substitutions.append(("%llvm_rtsan", llvm_rtsan)) +config.substitutions.append( +( +"%rtsanlib", +( +"-lm -lpthread %s -lrt -L%s " +"-Wl,-whole-archive -lclang_rt.rtsan%s -Wl,-no-whole-archive" MaskRay wrote: clangdriver shall pass these arguments to the linker. lit.cfg.py should not need to do it. https://github.com/llvm/llvm-project/pull/92460 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce Realtime Sanitizer (RTSan) backend (PR #92460)
https://github.com/MaskRay edited https://github.com/llvm/llvm-project/pull/92460 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce Realtime Sanitizer (RTSan) backend (PR #92460)
@@ -0,0 +1,50 @@ +//===--- rtsan_stack.cpp - Realtime Sanitizer ---*- 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 +// +//===--===// +// +//===--===// + +#include "rtsan_stack.h" + +#include +#include + +using namespace __sanitizer; + +// We must define our own implementation of this method for our runtime. +// This one is just copied from UBSan. +namespace __sanitizer { +void BufferedStackTrace::UnwindImpl(uptr pc, uptr bp, void *context, +bool request_fast, u32 max_depth) { + uptr top = 0; + uptr bottom = 0; + GetThreadStackTopAndBottom(false, &top, &bottom); + bool fast = StackTrace::WillUseFastUnwind(request_fast); + Unwind(max_depth, pc, bp, context, top, bottom, fast); +} +} // namespace __sanitizer + +static void SetGlobalStackTraceFormat() { + SetCommonFlagsDefaults(); + CommonFlags cf; + cf.CopyFrom(*common_flags()); + cf.stack_trace_format = "DEFAULT"; + cf.external_symbolizer_path = GetEnv("RTSAN_SYMBOLIZER_PATH"); + OverrideCommonFlags(cf); +} + +using namespace __rtsan; MaskRay wrote: should be moved up, beside `using namespace __sanitizer;` https://github.com/llvm/llvm-project/pull/92460 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce Realtime Sanitizer (RTSan) backend (PR #92460)
https://github.com/MaskRay commented: Sorry for the delay. I have a really huge code review backlog... https://github.com/llvm/llvm-project/pull/92460 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][PAC] Sign block addresses used in indirectbr. (PR #97647)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 4a1fdeb04d10f5562687568ea8c494b3ef46c587 f0d8af86161c6037e9e0d1fe800e5876dd090092 -- clang/include/clang/Basic/PointerAuthOptions.h clang/lib/CodeGen/CodeGenFunction.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/test/CodeGen/ptrauth-function-attributes.c llvm/include/llvm/CodeGen/AsmPrinter.h llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp llvm/lib/Target/AArch64/AArch64FastISel.cpp llvm/lib/Target/AArch64/AArch64ISelLowering.cpp llvm/lib/Target/AArch64/AArch64ISelLowering.h llvm/lib/Target/AArch64/AArch64Subtarget.cpp llvm/lib/Target/AArch64/AArch64Subtarget.h llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp `` View the diff from clang-format here. ``diff diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index 8a373c3a46..8978b254f4 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -10689,8 +10689,7 @@ SDValue AArch64TargetLowering::LowerBR_JT(SDValue Op, return DAG.getNode(ISD::BRIND, DL, MVT::Other, JTInfo, SDValue(Dest, 0)); } -SDValue AArch64TargetLowering::LowerBRIND(SDValue Op, - SelectionDAG &DAG) const { +SDValue AArch64TargetLowering::LowerBRIND(SDValue Op, SelectionDAG &DAG) const { MachineFunction &MF = DAG.getMachineFunction(); std::optional BADisc = Subtarget->getPtrAuthBlockAddressDiscriminator(MF.getFunction()); @@ -10745,8 +10744,8 @@ SDValue AArch64TargetLowering::LowerBlockAddress(SDValue Op, SDValue AddrDisc = DAG.getRegister(AArch64::XZR, MVT::i64); SDNode *MOV = - DAG.getMachineNode(AArch64::MOVaddrPAC, DL, {MVT::Other, MVT::Glue}, - {TargetBA, Key, AddrDisc, Disc}); +DAG.getMachineNode(AArch64::MOVaddrPAC, DL, {MVT::Other, MVT::Glue}, + {TargetBA, Key, AddrDisc, Disc}); return DAG.getCopyFromReg(SDValue(MOV, 0), DL, AArch64::X16, MVT::i64, SDValue(MOV, 1)); } `` https://github.com/llvm/llvm-project/pull/97647 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][PAC] Sign block addresses used in indirectbr. (PR #97647)
https://github.com/ahmedbougacha created https://github.com/llvm/llvm-project/pull/97647 Enabled in clang using: -fptrauth-indirect-gotos and at the IR level using function attribute: "ptrauth-indirect-gotos" Signing uses IA and a per-function integer discriminator. The discriminator isn't ABI-visible, and is currently: ptrauth_string_discriminator(" blockaddress") A sufficiently sophisticated frontend could benefit from per-indirectbr discrimination, which would need additional machinery, such as allowing "ptrauth" bundles on indirectbr. For our purposes, the simple scheme above is sufficient. >From f0d8af86161c6037e9e0d1fe800e5876dd090092 Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Tue, 12 Mar 2024 14:40:17 -0700 Subject: [PATCH] [AArch64][PAC] Sign block addresses used in indirectbr. Enabled in clang using: -fptrauth-indirect-gotos and at the IR level using function attribute: "ptrauth-indirect-gotos" Signing uses IA and a per-function integer discriminator. The discriminator isn't ABI-visible, and is currently: ptrauth_string_discriminator(" blockaddress") A sufficiently sophisticated frontend could benefit from per-indirectbr discrimination, which would need additional machinery, such as allowing "ptrauth" bundles on indirectbr. For our purposes, the simple scheme above is sufficient. --- clang/include/clang/Basic/Features.def| 1 + clang/include/clang/Basic/LangOptions.def | 1 + .../include/clang/Basic/PointerAuthOptions.h | 3 + clang/include/clang/Driver/Options.td | 2 + clang/lib/CodeGen/CodeGenFunction.cpp | 2 + clang/lib/Driver/ToolChains/Clang.cpp | 3 + clang/lib/Frontend/CompilerInvocation.cpp | 6 +- .../CodeGen/ptrauth-function-attributes.c | 5 + llvm/docs/PointerAuth.md | 24 llvm/include/llvm/CodeGen/AsmPrinter.h| 3 + llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp| 6 +- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 35 +- llvm/lib/Target/AArch64/AArch64FastISel.cpp | 4 + .../Target/AArch64/AArch64ISelLowering.cpp| 54 - llvm/lib/Target/AArch64/AArch64ISelLowering.h | 1 + llvm/lib/Target/AArch64/AArch64InstrInfo.td | 18 +++ llvm/lib/Target/AArch64/AArch64Subtarget.cpp | 11 ++ llvm/lib/Target/AArch64/AArch64Subtarget.h| 9 ++ .../GISel/AArch64InstructionSelector.cpp | 26 + .../CodeGen/AArch64/ptrauth-indirectbr.ll | 106 ++ 20 files changed, 309 insertions(+), 11 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/ptrauth-indirectbr.ll diff --git a/clang/include/clang/Basic/Features.def b/clang/include/clang/Basic/Features.def index 53f410d3cb4bd..cf800afe08557 100644 --- a/clang/include/clang/Basic/Features.def +++ b/clang/include/clang/Basic/Features.def @@ -108,6 +108,7 @@ FEATURE(ptrauth_calls, LangOpts.PointerAuthCalls) FEATURE(ptrauth_returns, LangOpts.PointerAuthReturns) FEATURE(ptrauth_vtable_pointer_address_discrimination, LangOpts.PointerAuthVTPtrAddressDiscrimination) FEATURE(ptrauth_vtable_pointer_type_discrimination, LangOpts.PointerAuthVTPtrTypeDiscrimination) +FEATURE(ptrauth_indirect_gotos, LangOpts.PointerAuthIndirectGotos) FEATURE(ptrauth_member_function_pointer_type_discrimination, LangOpts.PointerAuthCalls) FEATURE(ptrauth_init_fini, LangOpts.PointerAuthInitFini) EXTENSION(swiftcc, diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 491759e2fcdbb..bdf77a5b35208 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -165,6 +165,7 @@ LANGOPT(ExperimentalLibrary, 1, 0, "enable unstable and experimental library fea LANGOPT(PointerAuthIntrinsics, 1, 0, "pointer authentication intrinsics") LANGOPT(PointerAuthCalls , 1, 0, "function pointer authentication") LANGOPT(PointerAuthReturns, 1, 0, "return pointer authentication") +LANGOPT(PointerAuthIndirectGotos, 1, 0, "indirect gotos pointer authentication") LANGOPT(PointerAuthAuthTraps, 1, 0, "pointer authentication failure traps") LANGOPT(PointerAuthVTPtrAddressDiscrimination, 1, 0, "incorporate address discrimination in authenticated vtable pointers") LANGOPT(PointerAuthVTPtrTypeDiscrimination, 1, 0, "incorporate type discrimination in authenticated vtable pointers") diff --git a/clang/include/clang/Basic/PointerAuthOptions.h b/clang/include/clang/Basic/PointerAuthOptions.h index 197d63642ca6d..2711639dbe299 100644 --- a/clang/include/clang/Basic/PointerAuthOptions.h +++ b/clang/include/clang/Basic/PointerAuthOptions.h @@ -154,6 +154,9 @@ class PointerAuthSchema { }; struct PointerAuthOptions { + /// Do indirect goto label addresses need to be authenticated? + bool IndirectGotos = false; + /// The ABI for C function pointers. PointerAuthSchema FunctionPointers; diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 58ca6f
[clang] [compiler-rt] [compiler-rt] Realtime Sanitizer: Introduce Realtime Sanitizer (RTSan) backend (PR #92460)
cjappl wrote: > clangDriver changes are usually the last. The expectation is that if > -fsanitize=realtime does not return an error, there should be some basic > functionality. Thanks for the feedback @MaskRay . I removed all of the clang components of this review, leaving only the compiler-rt components. We will re-introduce the clang changes in a future review. In the meantime, I commented out compilation of our unit tests that required the -fsanitize flag, let me know if you'd prefer to see them removed until later. These unit tests are paired with the code introduced here, so I think at least by subject it makes sense to introduce them here, even if they are briefly not being compiled. https://github.com/llvm/llvm-project/pull/92460 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] add ftime profiling (PR #97644)
https://github.com/PeterChou1 updated https://github.com/llvm/llvm-project/pull/97644 >From ff278188403a6f89e8c13f7a2330d978f31b1ab5 Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Wed, 3 Jul 2024 15:42:22 -0400 Subject: [PATCH 1/2] [clang-doc] add ftime trace option --- clang-tools-extra/clang-doc/BitcodeReader.cpp | 8 clang-tools-extra/clang-doc/Mapper.cpp| 11 - .../clang-doc/Representation.cpp | 2 + clang-tools-extra/clang-doc/Representation.h | 5 +- .../clang-doc/tool/ClangDocMain.cpp | 47 ++- 5 files changed, 69 insertions(+), 4 deletions(-) diff --git a/clang-tools-extra/clang-doc/BitcodeReader.cpp b/clang-tools-extra/clang-doc/BitcodeReader.cpp index bfb04e7407b38..975dbca3a2ce2 100644 --- a/clang-tools-extra/clang-doc/BitcodeReader.cpp +++ b/clang-tools-extra/clang-doc/BitcodeReader.cpp @@ -10,6 +10,7 @@ #include "llvm/ADT/IndexedMap.h" #include "llvm/Support/Error.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/TimeProfiler.h" #include namespace clang { @@ -670,6 +671,7 @@ llvm::Error ClangDocBitcodeReader::readRecord(unsigned ID, T I) { template <> llvm::Error ClangDocBitcodeReader::readRecord(unsigned ID, Reference *I) { + llvm::TimeTraceScope("clang-doc", "readRecord Reference"); Record R; llvm::StringRef Blob; llvm::Expected MaybeRecID = Stream.readRecord(ID, R, &Blob); @@ -681,6 +683,7 @@ llvm::Error ClangDocBitcodeReader::readRecord(unsigned ID, Reference *I) { // Read a block of records into a single info. template llvm::Error ClangDocBitcodeReader::readBlock(unsigned ID, T I) { + llvm::TimeTraceScope("clang-doc", "readBlock"); if (llvm::Error Err = Stream.EnterSubBlock(ID)) return Err; @@ -711,6 +714,7 @@ llvm::Error ClangDocBitcodeReader::readBlock(unsigned ID, T I) { template llvm::Error ClangDocBitcodeReader::readSubBlock(unsigned ID, T I) { + llvm::TimeTraceScope("clang-doc", "readSubBlock"); switch (ID) { // Blocks can only have certain types of sub blocks. case BI_COMMENT_BLOCK_ID: { @@ -817,6 +821,7 @@ llvm::Error ClangDocBitcodeReader::readSubBlock(unsigned ID, T I) { ClangDocBitcodeReader::Cursor ClangDocBitcodeReader::skipUntilRecordOrBlock(unsigned &BlockOrRecordID) { + llvm::TimeTraceScope("clang-doc", "skipUntilRecordOrBlock"); BlockOrRecordID = 0; while (!Stream.AtEndOfStream()) { @@ -878,6 +883,7 @@ llvm::Error ClangDocBitcodeReader::validateStream() { } llvm::Error ClangDocBitcodeReader::readBlockInfoBlock() { + llvm::TimeTraceScope("clang-doc", "readBlockInfoBlock"); Expected> MaybeBlockInfo = Stream.ReadBlockInfoBlock(); if (!MaybeBlockInfo) @@ -894,6 +900,7 @@ llvm::Error ClangDocBitcodeReader::readBlockInfoBlock() { template llvm::Expected> ClangDocBitcodeReader::createInfo(unsigned ID) { + llvm::TimeTraceScope("clang-doc", "createInfo"); std::unique_ptr I = std::make_unique(); if (auto Err = readBlock(ID, static_cast(I.get( return std::move(Err); @@ -902,6 +909,7 @@ ClangDocBitcodeReader::createInfo(unsigned ID) { llvm::Expected> ClangDocBitcodeReader::readBlockToInfo(unsigned ID) { + llvm::TimeTraceScope("clang-doc", "readBlockToInfo"); switch (ID) { case BI_NAMESPACE_BLOCK_ID: return createInfo(ID); diff --git a/clang-tools-extra/clang-doc/Mapper.cpp b/clang-tools-extra/clang-doc/Mapper.cpp index bb8b7952980ac..a8875473649c1 100644 --- a/clang-tools-extra/clang-doc/Mapper.cpp +++ b/clang-tools-extra/clang-doc/Mapper.cpp @@ -13,11 +13,14 @@ #include "clang/Index/USRGeneration.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/Error.h" +#include "llvm/Support/TimeProfiler.h" namespace clang { namespace doc { void MapASTVisitor::HandleTranslationUnit(ASTContext &Context) { + if (CDCtx.FTimeTrace) +llvm::timeTraceProfilerInitialize(CDCtx.Granularity, "clang-doc"); TraverseDecl(Context.getTranslationUnitDecl()); } @@ -30,6 +33,7 @@ template bool MapASTVisitor::mapDecl(const T *D) { if (D->getParentFunctionOrMethod()) return true; + llvm::timeTraceProfilerBegin("clang-doc", "emit info"); llvm::SmallString<128> USR; // If there is an error generating a USR for the decl, skip this decl. if (index::generateUSRForDecl(D, USR)) @@ -40,7 +44,9 @@ template bool MapASTVisitor::mapDecl(const T *D) { auto I = serialize::emitInfo(D, getComment(D, D->getASTContext()), getLine(D, D->getASTContext()), File, IsFileInRootDir, CDCtx.PublicOnly); + llvm::timeTraceProfilerEnd(); + llvm::timeTraceProfilerBegin("clang-doc", "serialize info"); // A null in place of I indicates that the serializer is skipping this decl // for some reason (e.g. we're only reporting public decls). if (I.first) @@ -49,6 +55,7 @@ template bool MapASTVisitor::mapDecl(const T *D) { if (I.second) CDCtx.ECtx->reportResult(llvm::toHex(llvm::toStringRef(I.second->USR)),
[clang] [llvm] [Clang][OpenMP] This is addition fix for #92210. (PR #94802)
jyu2-git wrote: Thanks Alexey!! https://github.com/llvm/llvm-project/pull/94802 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][OpenMP] This is addition fix for #92210. (PR #94802)
https://github.com/jyu2-git updated https://github.com/llvm/llvm-project/pull/94802 >From 157744f968ff9bc23efdfd0ee5c9a3e23f9413da Mon Sep 17 00:00:00 2001 From: Jennifer Yu Date: Wed, 5 Jun 2024 13:53:34 -0700 Subject: [PATCH 1/8] [Clang][OpenMP] This is addition fix for #92210. Fix another runtime problem when explicit map both pointer and pointee in target data region. In #92210, problem is only addressed in target region, but missing for target data region. The change just passing AreBothBasePtrAndPteeMapped in generateInfoForComponentList when processing target data. --- clang/lib/CodeGen/CGOpenMPRuntime.cpp | 16 - .../target_data_use_device_addr_codegen.cpp | 12 -- ...arget_map_both_pointer_pointee_codegen.cpp | 24 +++ .../test/mapping/map_both_pointer_pointee.c | 20 4 files changed, 64 insertions(+), 8 deletions(-) diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index f6d12d46cfc07..1fc474f1ae269 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -8025,6 +8025,19 @@ class MappableExprsHandler { MapCombinedInfoTy StructBaseCurInfo; const Decl *D = Data.first; const ValueDecl *VD = cast_or_null(D); + bool HasMapBasePtr = false; + bool HasMapArraySec = false; + for (const auto &M : Data.second) { +for (const MapInfo &L : M) { + const Expr *E = L.VarRef; + if (VD && E && VD->getType()->isAnyPointerType() && +isa(E)) +HasMapBasePtr = true; + if (VD && E && VD->getType()->isAnyPointerType() && + (isa(E) || isa(E))) + HasMapArraySec = true; +} + } for (const auto &M : Data.second) { for (const MapInfo &L : M) { assert(!L.Components.empty() && @@ -8041,7 +8054,8 @@ class MappableExprsHandler { CurInfo, StructBaseCurInfo, PartialStruct, /*IsFirstComponentList=*/false, L.IsImplicit, /*GenerateAllInfoForClauses*/ true, L.Mapper, L.ForDeviceAddr, VD, - L.VarRef); + L.VarRef, /*OverlappedElements*/ std::nullopt, + HasMapBasePtr && HasMapArraySec); // If this entry relates to a device pointer, set the relevant // declaration and add the 'return pointer' flag. diff --git a/clang/test/OpenMP/target_data_use_device_addr_codegen.cpp b/clang/test/OpenMP/target_data_use_device_addr_codegen.cpp index ae0653d0585d4..7c4b96971ae70 100644 --- a/clang/test/OpenMP/target_data_use_device_addr_codegen.cpp +++ b/clang/test/OpenMP/target_data_use_device_addr_codegen.cpp @@ -13,7 +13,7 @@ // CHECK-DAG: [[SIZES1:@.+]] = private unnamed_addr constant [6 x i64] [i64 4, i64 16, i64 4, i64 4, i64 0, i64 4] // 64 = 0x40 = OMP_MAP_RETURN_PARAM -// CHECK-DAG: [[MAPTYPES1:@.+]] = private unnamed_addr constant [6 x i64] [i64 67, i64 67, i64 3, i64 67, i64 67, i64 67] +// CHECK-DAG: [[MAPTYPES1:@.+]] = private unnamed_addr constant [6 x i64] [i64 67, i64 115, i64 51, i64 67, i64 67, i64 67] // CHECK-DAG: [[SIZES2:@.+]] = private unnamed_addr constant [6 x i64] [i64 0, i64 4, i64 16, i64 4, i64 4, i64 0] // 0 = OMP_MAP_NONE // 281474976710720 = 0x10040 = OMP_MAP_MEMBER_OF | OMP_MAP_RETURN_PARAM @@ -54,11 +54,9 @@ int main() { // CHECK: [[SIZES:%.+]] = alloca [6 x i64], // CHECK: [[VLA_ADDR:%.+]] = alloca float, i64 %{{.+}}, // CHECK: [[PTR:%.+]] = load ptr, ptr [[PTR_ADDR]], -// CHECK-NEXT: [[P4:%.+]] = load ptr, ptr [[PTR_ADDR]], align 8 -// CHECK-NEXT: [[ARR_IDX:%.+]] = getelementptr inbounds float, ptr [[P4]], i64 3 +// CHECK-NEXT: [[ARR_IDX:%.+]] = getelementptr inbounds float, ptr [[PTR]], i64 3 // CHECK: [[P5:%.+]] = load ptr, ptr [[PTR_ADDR]], align 8 -// CHECK-NEXT: [[P6:%.+]] = load ptr, ptr [[PTR_ADDR]], align 8 -// CHECK-NEXT: [[ARR_IDX1:%.+]] = getelementptr inbounds float, ptr [[P6]], i64 0 +// CHECK-NEXT: [[ARR_IDX1:%.+]] = getelementptr inbounds float, ptr [[P5]], i64 0 // CHECK: [[P7:%.+]] = load ptr, ptr [[REF_ADDR]], // CHECK-NEXT: [[REF:%.+]] = load ptr, ptr [[REF_ADDR]], // CHECK-NEXT: [[ARR_IDX2:%.+]] = getelementptr inbounds [4 x float], ptr [[ARR_ADDR]], i64 0, i64 0 @@ -70,11 +68,11 @@ int main() { // CHECK: [[PTR0:%.+]] = getelementptr inbounds [6 x ptr], ptr [[PTRS]], i32 0, i32 0 // CHECK: store ptr [[A_ADDR]], ptr [[PTR0]], // CHECK: [[BPTR1:%.+]] = getelementptr inbounds [6 x ptr], ptr [[BPTRS]], i32 0, i32 1 -// CHECK: store ptr [[PTR]], ptr [[BPTR1]], +// CHECK: store ptr [[PTR_ADDR]], ptr [[BPTR1]], // CHECK: [[PTR1:%.+]] = getelementptr inbounds [6 x ptr], ptr [[PTRS]], i32 0, i32 1 // CHECK: store ptr [[ARR_IDX]], ptr [[PTR1]], // CHECK: [[BPTR2:%.+]] = getelementptr inbounds [6 x ptr], ptr [[BPTRS]], i32 0, i32 2 -// CHECK: store ptr [[P5]], ptr [[BPTR2]], +// CHECK: store ptr [[PTR_ADDR]], ptr [[BPTR2]], // CHECK: [[PTR2:%.+]] = getel
[clang-tools-extra] [clang-doc] add ftime profiling (PR #97644)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 10c894cffd0f4bef21b54a43b5780240532e44cf 7462b374a1ec05f84c84ea705fdc98a9d3c02783 -- clang-tools-extra/clang-doc/BitcodeReader.cpp clang-tools-extra/clang-doc/Mapper.cpp clang-tools-extra/clang-doc/Representation.cpp clang-tools-extra/clang-doc/Representation.h clang-tools-extra/clang-doc/tool/ClangDocMain.cpp `` View the diff from clang-format here. ``diff diff --git a/clang-tools-extra/clang-doc/BitcodeReader.cpp b/clang-tools-extra/clang-doc/BitcodeReader.cpp index 2fa228dd7b..eef8c1b6e7 100644 --- a/clang-tools-extra/clang-doc/BitcodeReader.cpp +++ b/clang-tools-extra/clang-doc/BitcodeReader.cpp @@ -9,8 +9,8 @@ #include "BitcodeReader.h" #include "llvm/ADT/IndexedMap.h" #include "llvm/Support/Error.h" -#include "llvm/Support/raw_ostream.h" #include "llvm/Support/TimeProfiler.h" +#include "llvm/Support/raw_ostream.h" #include namespace clang { diff --git a/clang-tools-extra/clang-doc/Mapper.cpp b/clang-tools-extra/clang-doc/Mapper.cpp index d56546dbfa..4a9e8721c9 100644 --- a/clang-tools-extra/clang-doc/Mapper.cpp +++ b/clang-tools-extra/clang-doc/Mapper.cpp @@ -65,9 +65,7 @@ bool MapASTVisitor::VisitNamespaceDecl(const NamespaceDecl *D) { return mapDecl(D); } -bool MapASTVisitor::VisitRecordDecl(const RecordDecl *D) { - return mapDecl(D); -} +bool MapASTVisitor::VisitRecordDecl(const RecordDecl *D) { return mapDecl(D); } bool MapASTVisitor::VisitEnumDecl(const EnumDecl *D) { return mapDecl(D); } diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp index 4cd4a84562..c15323d614 100644 --- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp +++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp @@ -41,8 +41,8 @@ #include "llvm/Support/Process.h" #include "llvm/Support/Signals.h" #include "llvm/Support/ThreadPool.h" -#include "llvm/Support/raw_ostream.h" #include "llvm/Support/TimeProfiler.h" +#include "llvm/Support/raw_ostream.h" #include #include #include @@ -100,15 +100,15 @@ URL of repository that hosts code. Used for links to definition locations.)"), llvm::cl::cat(ClangDocCategory)); -static llvm::cl::opt FTimeTrace( -"ftime-trace", llvm::cl::desc(R"( +static llvm::cl::opt FTimeTrace("ftime-trace", llvm::cl::desc(R"( Turn on time profiler. Generates clang-doc-tracing.json)"), -llvm::cl::init(false), llvm::cl::cat(ClangDocCategory)); + llvm::cl::init(false), + llvm::cl::cat(ClangDocCategory)); -static llvm::cl::opt FTimeGranularity( -"ftime-gran", llvm::cl::desc(R"( +static llvm::cl::opt FTimeGranularity("ftime-gran", llvm::cl::desc(R"( Specify granularity for ftime-trace defaults to 200)"), -llvm::cl::init(200), llvm::cl::cat(ClangDocCategory)); + llvm::cl::init(200), + llvm::cl::cat(ClangDocCategory)); enum OutputFormatTy { md, @@ -271,8 +271,7 @@ Example usage for a project using a compile commands database: OutDirectory, SourceRoot, RepositoryUrl, - {UserStylesheets.begin(), UserStylesheets.end()} - }; + {UserStylesheets.begin(), UserStylesheets.end()}}; if (Format == "html") { if (auto Err = getHtmlAssetFiles(argv[0], CDCtx)) { @@ -353,7 +352,6 @@ Example usage for a project using a compile commands database: } llvm::timeTraceProfilerEnd(); - // Add a reference to this Info in the Index { std::lock_guard Guard(IndexMutex); @@ -368,7 +366,6 @@ Example usage for a project using a compile commands database: if (CDCtx.FTimeTrace) llvm::timeTraceProfilerFinishThread(); - }); } llvm::timeTraceProfilerEnd(); @@ -403,7 +400,8 @@ Example usage for a project using a compile commands database: if (FTimeTrace) { std::error_code EC; -llvm::raw_fd_ostream OS("clang-doc-tracing.json", EC, llvm::sys::fs::OF_Text); +llvm::raw_fd_ostream OS("clang-doc-tracing.json", EC, +llvm::sys::fs::OF_Text); if (!EC) { llvm::timeTraceProfilerWrite(OS); } else { `` https://github.com/llvm/llvm-project/pull/97644 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc] add ftime profiling (PR #97644)
llvmbot wrote: @llvm/pr-subscribers-clang-tools-extra Author: None (PeterChou1) Changes this patches adds ftime-tracing option for clang-doc which was what I used to profile the performance problems we had with clang-doc generating the llvm docs. It introduces two option --ftime-trace and --ftime-gran - ftime-trace produces a time profiler json file called clang-doc-tracing.json - ftime-gran allows the user to specify the granularity of the profiling --- Full diff: https://github.com/llvm/llvm-project/pull/97644.diff 5 Files Affected: - (modified) clang-tools-extra/clang-doc/BitcodeReader.cpp (+8) - (modified) clang-tools-extra/clang-doc/Mapper.cpp (+12-1) - (modified) clang-tools-extra/clang-doc/Representation.cpp (+2) - (modified) clang-tools-extra/clang-doc/Representation.h (+4-1) - (modified) clang-tools-extra/clang-doc/tool/ClangDocMain.cpp (+49-2) ``diff diff --git a/clang-tools-extra/clang-doc/BitcodeReader.cpp b/clang-tools-extra/clang-doc/BitcodeReader.cpp index bfb04e7407b38..2fa228dd7b180 100644 --- a/clang-tools-extra/clang-doc/BitcodeReader.cpp +++ b/clang-tools-extra/clang-doc/BitcodeReader.cpp @@ -10,6 +10,7 @@ #include "llvm/ADT/IndexedMap.h" #include "llvm/Support/Error.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/TimeProfiler.h" #include namespace clang { @@ -670,6 +671,7 @@ llvm::Error ClangDocBitcodeReader::readRecord(unsigned ID, T I) { template <> llvm::Error ClangDocBitcodeReader::readRecord(unsigned ID, Reference *I) { + llvm::TimeTraceScope("clang-doc", "readRecord Reference"); Record R; llvm::StringRef Blob; llvm::Expected MaybeRecID = Stream.readRecord(ID, R, &Blob); @@ -681,6 +683,7 @@ llvm::Error ClangDocBitcodeReader::readRecord(unsigned ID, Reference *I) { // Read a block of records into a single info. template llvm::Error ClangDocBitcodeReader::readBlock(unsigned ID, T I) { + llvm::TimeTraceScope("readBlock", "ClangDocBitcodeReader"); if (llvm::Error Err = Stream.EnterSubBlock(ID)) return Err; @@ -711,6 +714,7 @@ llvm::Error ClangDocBitcodeReader::readBlock(unsigned ID, T I) { template llvm::Error ClangDocBitcodeReader::readSubBlock(unsigned ID, T I) { + llvm::TimeTraceScope("readSubBlock", "ClangDocBitcodeReader"); switch (ID) { // Blocks can only have certain types of sub blocks. case BI_COMMENT_BLOCK_ID: { @@ -817,6 +821,7 @@ llvm::Error ClangDocBitcodeReader::readSubBlock(unsigned ID, T I) { ClangDocBitcodeReader::Cursor ClangDocBitcodeReader::skipUntilRecordOrBlock(unsigned &BlockOrRecordID) { + llvm::TimeTraceScope("skipUntilRecordOrBlock", "ClangDocBitcodeReader"); BlockOrRecordID = 0; while (!Stream.AtEndOfStream()) { @@ -878,6 +883,7 @@ llvm::Error ClangDocBitcodeReader::validateStream() { } llvm::Error ClangDocBitcodeReader::readBlockInfoBlock() { + llvm::TimeTraceScope("readBlockInfoBlock", "ClangDocBitcodeReader"); Expected> MaybeBlockInfo = Stream.ReadBlockInfoBlock(); if (!MaybeBlockInfo) @@ -894,6 +900,7 @@ llvm::Error ClangDocBitcodeReader::readBlockInfoBlock() { template llvm::Expected> ClangDocBitcodeReader::createInfo(unsigned ID) { + llvm::TimeTraceScope("createInfo", "ClangDocBitcodeReader"); std::unique_ptr I = std::make_unique(); if (auto Err = readBlock(ID, static_cast(I.get( return std::move(Err); @@ -902,6 +909,7 @@ ClangDocBitcodeReader::createInfo(unsigned ID) { llvm::Expected> ClangDocBitcodeReader::readBlockToInfo(unsigned ID) { + llvm::TimeTraceScope("readBlockToInfo", "ClangDocBitcodeReader"); switch (ID) { case BI_NAMESPACE_BLOCK_ID: return createInfo(ID); diff --git a/clang-tools-extra/clang-doc/Mapper.cpp b/clang-tools-extra/clang-doc/Mapper.cpp index bb8b7952980ac..d56546dbfa73f 100644 --- a/clang-tools-extra/clang-doc/Mapper.cpp +++ b/clang-tools-extra/clang-doc/Mapper.cpp @@ -13,12 +13,17 @@ #include "clang/Index/USRGeneration.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/Error.h" +#include "llvm/Support/TimeProfiler.h" namespace clang { namespace doc { void MapASTVisitor::HandleTranslationUnit(ASTContext &Context) { + if (CDCtx.FTimeTrace) +llvm::timeTraceProfilerInitialize(CDCtx.Granularity, "clang-doc"); TraverseDecl(Context.getTranslationUnitDecl()); + if (CDCtx.FTimeTrace) +llvm::timeTraceProfilerFinishThread(); } template bool MapASTVisitor::mapDecl(const T *D) { @@ -30,6 +35,7 @@ template bool MapASTVisitor::mapDecl(const T *D) { if (D->getParentFunctionOrMethod()) return true; + llvm::timeTraceProfilerBegin("emit info phase", "emit info"); llvm::SmallString<128> USR; // If there is an error generating a USR for the decl, skip this decl. if (index::generateUSRForDecl(D, USR)) @@ -40,7 +46,9 @@ template bool MapASTVisitor::mapDecl(const T *D) { auto I = serialize::emitInfo(D, getComment(D, D->getASTContext()), getLine(D, D->getASTContext()), File,
[clang-tools-extra] [clang-doc] add ftime profiling (PR #97644)
https://github.com/PeterChou1 created https://github.com/llvm/llvm-project/pull/97644 this patches adds ftime-tracing option for clang-doc which was what I used to profile the performance problems we had with clang-doc generating the llvm docs. It introduces two option --ftime-trace and --ftime-gran - ftime-trace produces a time profiler json file called clang-doc-tracing.json - ftime-gran allows the user to specify the granularity of the profiling >From ff278188403a6f89e8c13f7a2330d978f31b1ab5 Mon Sep 17 00:00:00 2001 From: PeterChou1 Date: Wed, 3 Jul 2024 15:42:22 -0400 Subject: [PATCH 1/3] [clang-doc] add ftime trace option --- clang-tools-extra/clang-doc/BitcodeReader.cpp | 8 clang-tools-extra/clang-doc/Mapper.cpp| 11 - .../clang-doc/Representation.cpp | 2 + clang-tools-extra/clang-doc/Representation.h | 5 +- .../clang-doc/tool/ClangDocMain.cpp | 47 ++- 5 files changed, 69 insertions(+), 4 deletions(-) diff --git a/clang-tools-extra/clang-doc/BitcodeReader.cpp b/clang-tools-extra/clang-doc/BitcodeReader.cpp index bfb04e7407b38..975dbca3a2ce2 100644 --- a/clang-tools-extra/clang-doc/BitcodeReader.cpp +++ b/clang-tools-extra/clang-doc/BitcodeReader.cpp @@ -10,6 +10,7 @@ #include "llvm/ADT/IndexedMap.h" #include "llvm/Support/Error.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/TimeProfiler.h" #include namespace clang { @@ -670,6 +671,7 @@ llvm::Error ClangDocBitcodeReader::readRecord(unsigned ID, T I) { template <> llvm::Error ClangDocBitcodeReader::readRecord(unsigned ID, Reference *I) { + llvm::TimeTraceScope("clang-doc", "readRecord Reference"); Record R; llvm::StringRef Blob; llvm::Expected MaybeRecID = Stream.readRecord(ID, R, &Blob); @@ -681,6 +683,7 @@ llvm::Error ClangDocBitcodeReader::readRecord(unsigned ID, Reference *I) { // Read a block of records into a single info. template llvm::Error ClangDocBitcodeReader::readBlock(unsigned ID, T I) { + llvm::TimeTraceScope("clang-doc", "readBlock"); if (llvm::Error Err = Stream.EnterSubBlock(ID)) return Err; @@ -711,6 +714,7 @@ llvm::Error ClangDocBitcodeReader::readBlock(unsigned ID, T I) { template llvm::Error ClangDocBitcodeReader::readSubBlock(unsigned ID, T I) { + llvm::TimeTraceScope("clang-doc", "readSubBlock"); switch (ID) { // Blocks can only have certain types of sub blocks. case BI_COMMENT_BLOCK_ID: { @@ -817,6 +821,7 @@ llvm::Error ClangDocBitcodeReader::readSubBlock(unsigned ID, T I) { ClangDocBitcodeReader::Cursor ClangDocBitcodeReader::skipUntilRecordOrBlock(unsigned &BlockOrRecordID) { + llvm::TimeTraceScope("clang-doc", "skipUntilRecordOrBlock"); BlockOrRecordID = 0; while (!Stream.AtEndOfStream()) { @@ -878,6 +883,7 @@ llvm::Error ClangDocBitcodeReader::validateStream() { } llvm::Error ClangDocBitcodeReader::readBlockInfoBlock() { + llvm::TimeTraceScope("clang-doc", "readBlockInfoBlock"); Expected> MaybeBlockInfo = Stream.ReadBlockInfoBlock(); if (!MaybeBlockInfo) @@ -894,6 +900,7 @@ llvm::Error ClangDocBitcodeReader::readBlockInfoBlock() { template llvm::Expected> ClangDocBitcodeReader::createInfo(unsigned ID) { + llvm::TimeTraceScope("clang-doc", "createInfo"); std::unique_ptr I = std::make_unique(); if (auto Err = readBlock(ID, static_cast(I.get( return std::move(Err); @@ -902,6 +909,7 @@ ClangDocBitcodeReader::createInfo(unsigned ID) { llvm::Expected> ClangDocBitcodeReader::readBlockToInfo(unsigned ID) { + llvm::TimeTraceScope("clang-doc", "readBlockToInfo"); switch (ID) { case BI_NAMESPACE_BLOCK_ID: return createInfo(ID); diff --git a/clang-tools-extra/clang-doc/Mapper.cpp b/clang-tools-extra/clang-doc/Mapper.cpp index bb8b7952980ac..a8875473649c1 100644 --- a/clang-tools-extra/clang-doc/Mapper.cpp +++ b/clang-tools-extra/clang-doc/Mapper.cpp @@ -13,11 +13,14 @@ #include "clang/Index/USRGeneration.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/Error.h" +#include "llvm/Support/TimeProfiler.h" namespace clang { namespace doc { void MapASTVisitor::HandleTranslationUnit(ASTContext &Context) { + if (CDCtx.FTimeTrace) +llvm::timeTraceProfilerInitialize(CDCtx.Granularity, "clang-doc"); TraverseDecl(Context.getTranslationUnitDecl()); } @@ -30,6 +33,7 @@ template bool MapASTVisitor::mapDecl(const T *D) { if (D->getParentFunctionOrMethod()) return true; + llvm::timeTraceProfilerBegin("clang-doc", "emit info"); llvm::SmallString<128> USR; // If there is an error generating a USR for the decl, skip this decl. if (index::generateUSRForDecl(D, USR)) @@ -40,7 +44,9 @@ template bool MapASTVisitor::mapDecl(const T *D) { auto I = serialize::emitInfo(D, getComment(D, D->getASTContext()), getLine(D, D->getASTContext()), File, IsFileInRootDir, CDCtx.PublicOnly); + llvm::timeTraceProfilerEnd(); + llvm::timeTr