[clang] [clang][dataflow] Tweak styling of iteration tabs. (PR #67637)

2023-09-28 Thread via cfe-commits

https://github.com/martinboehme created 
https://github.com/llvm/llvm-project/pull/67637

- On non-selected tabs, set cursor to 'pointer' to indicate they're clickable

- Selected tab shares the same background as the contents to emphasize that it's
  associated with that content. (Compare with Google Chrome or VS Code, which do
  this similarly.)

- Hovered-over tab becomes slightly brighter to indicate that clicking it will
  make it even brighter (again, Chrome does this in a similar way).


>From fb57c6641cdb4f80df21a7c19d7a1c2fb7f04fdc Mon Sep 17 00:00:00 2001
From: Martin Braenne 
Date: Thu, 28 Sep 2023 06:59:12 +
Subject: [PATCH] [clang][dataflow] Tweak styling of iteration tabs.

- On non-selected tabs, set cursor to 'pointer' to indicate they're clickable

- Selected tab shares the same background as the contents to emphasize that it's
  associated with that content. (Compare with Google Chrome or VS Code, which do
  this similarly.)

- Hovered-over tab becomes slightly brighter to indicate that clicking it will
  make it even brighter (again, Chrome does this in a similar way).
---
 clang/lib/Analysis/FlowSensitive/HTMLLogger.css | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
index c8212df1f94b81a..0ac1902ea4651ec 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
@@ -64,15 +64,16 @@ section h2 {
   text-align: center;
 }
 #iterations .chooser:not(.iter-select).hover {
-  background-color: #aaa;
+  background-color: #ddd;
 }
 #iterations .iter-select {
   font-weight: bold;
-  background-color: #ccc;
 }
 #iterations .chooser:not(.iter-select) {
   text-decoration: underline;
   color: blue;
+  cursor: pointer;
+  background-color: #ccc;
 }
 
 code.filename {

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


[clang] [clang][dataflow] Tweak styling of iteration tabs. (PR #67637)

2023-09-28 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang


Changes

- On non-selected tabs, set cursor to 'pointer' to indicate they're clickable

- Selected tab shares the same background as the contents to emphasize that it's
  associated with that content. (Compare with Google Chrome or VS Code, which do
  this similarly.)

- Hovered-over tab becomes slightly brighter to indicate that clicking it will
  make it even brighter (again, Chrome does this in a similar way).


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


1 Files Affected:

- (modified) clang/lib/Analysis/FlowSensitive/HTMLLogger.css (+3-2) 


``diff
diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
index c8212df1f94b81a..0ac1902ea4651ec 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
@@ -64,15 +64,16 @@ section h2 {
   text-align: center;
 }
 #iterations .chooser:not(.iter-select).hover {
-  background-color: #aaa;
+  background-color: #ddd;
 }
 #iterations .iter-select {
   font-weight: bold;
-  background-color: #ccc;
 }
 #iterations .chooser:not(.iter-select) {
   text-decoration: underline;
   color: blue;
+  cursor: pointer;
+  background-color: #ccc;
 }
 
 code.filename {

``




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


[clang] [clang][dataflow] Tweak styling of iteration tabs. (PR #67637)

2023-09-28 Thread via cfe-commits

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


[clang] [Driver] Support -fsanitize=cfi-icall on loongarch64 (PR #67310)

2023-09-28 Thread via cfe-commits

https://github.com/Ami-zhang updated 
https://github.com/llvm/llvm-project/pull/67310

>From 12ab285601937212be781031c9f828fc334e1047 Mon Sep 17 00:00:00 2001
From: zhanglimin 
Date: Thu, 31 Aug 2023 15:04:17 +0800
Subject: [PATCH] [Driver] Support -fsanitize=cfi-icall on loongarch64

---
 clang/lib/Driver/ToolChain.cpp | 3 ++-
 clang/test/Driver/fsanitize.c  | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 31245964c4baab3..ab19166f18c2dcf 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -1319,7 +1319,8 @@ SanitizerMask ToolChain::getSupportedSanitizers() const {
   if (getTriple().getArch() == llvm::Triple::x86 ||
   getTriple().getArch() == llvm::Triple::x86_64 ||
   getTriple().getArch() == llvm::Triple::arm || getTriple().isWasm() ||
-  getTriple().isAArch64() || getTriple().isRISCV())
+  getTriple().isAArch64() || getTriple().isRISCV() ||
+  getTriple().isLoongArch64())
 Res |= SanitizerKind::CFIICall;
   if (getTriple().getArch() == llvm::Triple::x86_64 ||
   getTriple().isAArch64(64) || getTriple().isRISCV())
diff --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index 19e10f6043123fb..9eb800b0d9e2c7f 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -600,6 +600,7 @@
 // RUN: %clang --target=aarch64_be -fvisibility=hidden -fsanitize=cfi -flto 
-resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-CFI
 // RUN: %clang --target=riscv32 -fvisibility=hidden -fsanitize=cfi -flto 
-resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-CFI
 // RUN: %clang --target=riscv64 -fvisibility=hidden -fsanitize=cfi -flto 
-resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-CFI
+// RUN: %clang --target=loongarch64 -fvisibility=hidden -fsanitize=cfi -flto 
-resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-CFI
 // CHECK-CFI: 
-emit-llvm-bc{{.*}}-fsanitize=cfi-derived-cast,cfi-icall,cfi-mfcall,cfi-unrelated-cast,cfi-nvcall,cfi-vcall
 // CHECK-CFI-NOMFCALL: 
-emit-llvm-bc{{.*}}-fsanitize=cfi-derived-cast,cfi-icall,cfi-unrelated-cast,cfi-nvcall,cfi-vcall
 // CHECK-CFI-DCAST: -emit-llvm-bc{{.*}}-fsanitize=cfi-derived-cast

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


[clang] 55accc8 - [Driver] Support -fsanitize=cfi-icall on loongarch64 (#67310)

2023-09-28 Thread via cfe-commits

Author: Ami-zhang
Date: 2023-09-28T15:20:27+08:00
New Revision: 55accc82bec48acae769b086ad9a5dc29da77f02

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

LOG: [Driver] Support -fsanitize=cfi-icall on loongarch64 (#67310)

Added: 


Modified: 
clang/lib/Driver/ToolChain.cpp
clang/test/Driver/fsanitize.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 31245964c4baab3..ab19166f18c2dcf 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -1319,7 +1319,8 @@ SanitizerMask ToolChain::getSupportedSanitizers() const {
   if (getTriple().getArch() == llvm::Triple::x86 ||
   getTriple().getArch() == llvm::Triple::x86_64 ||
   getTriple().getArch() == llvm::Triple::arm || getTriple().isWasm() ||
-  getTriple().isAArch64() || getTriple().isRISCV())
+  getTriple().isAArch64() || getTriple().isRISCV() ||
+  getTriple().isLoongArch64())
 Res |= SanitizerKind::CFIICall;
   if (getTriple().getArch() == llvm::Triple::x86_64 ||
   getTriple().isAArch64(64) || getTriple().isRISCV())

diff  --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index 19e10f6043123fb..9eb800b0d9e2c7f 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -600,6 +600,7 @@
 // RUN: %clang --target=aarch64_be -fvisibility=hidden -fsanitize=cfi -flto 
-resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-CFI
 // RUN: %clang --target=riscv32 -fvisibility=hidden -fsanitize=cfi -flto 
-resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-CFI
 // RUN: %clang --target=riscv64 -fvisibility=hidden -fsanitize=cfi -flto 
-resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-CFI
+// RUN: %clang --target=loongarch64 -fvisibility=hidden -fsanitize=cfi -flto 
-resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-CFI
 // CHECK-CFI: 
-emit-llvm-bc{{.*}}-fsanitize=cfi-derived-cast,cfi-icall,cfi-mfcall,cfi-unrelated-cast,cfi-nvcall,cfi-vcall
 // CHECK-CFI-NOMFCALL: 
-emit-llvm-bc{{.*}}-fsanitize=cfi-derived-cast,cfi-icall,cfi-unrelated-cast,cfi-nvcall,cfi-vcall
 // CHECK-CFI-DCAST: -emit-llvm-bc{{.*}}-fsanitize=cfi-derived-cast



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


[clang] [Driver] Support -fsanitize=cfi-icall on loongarch64 (PR #67310)

2023-09-28 Thread via cfe-commits

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


[clang] [C++20] [Modules] Don't generate call to an imported module that dont init anything (PR #67638)

2023-09-28 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 created 
https://github.com/llvm/llvm-project/pull/67638



Close https://github.com/llvm/llvm-project/issues/56794

And see https://github.com/llvm/llvm-project/issues/67582 for a detailed 
backgrond for the issue.

As required by the Itanium ABI, the module units have to generate the 
initialization function. However, the importers are allowed to elide the call 
to the initialization function if they are sure the initialization function 
doesn't do anything.

This patch implemented this semantics.

>From 2448304b847da467a2a81c33daa7fb789948edf1 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Thu, 28 Sep 2023 15:32:31 +0800
Subject: [PATCH] [C++20] [Modules] Don't generate call to an imported module
 that don't init anything

Close https://github.com/llvm/llvm-project/issues/56794

And see https://github.com/llvm/llvm-project/issues/67582 for a detailed
backgrond for the issue.

As required by the Itanium ABI, the module units have to generate the
initialization function. However, the importers are allowed to elide the
call to the initialization function if they are sure the initialization
function doesn't do anything.

This patch implemented this semantics.
---
 clang/include/clang/Basic/Module.h|  8 +++
 clang/lib/Basic/Module.cpp|  2 +-
 clang/lib/CodeGen/CGDeclCXX.cpp   |  7 ++-
 clang/lib/Sema/Sema.cpp   | 20 +++
 clang/lib/Serialization/ASTReader.cpp |  2 +
 clang/lib/Serialization/ASTWriter.cpp |  4 +-
 .../module-initializer-guard-elision.cpp  | 53 ++-
 7 files changed, 80 insertions(+), 16 deletions(-)

diff --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index edbd2dfc2973e92..fc8c39719979ecf 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -358,6 +358,10 @@ class alignas(8) Module {
   /// to a regular (public) module map.
   unsigned ModuleMapIsPrivate : 1;
 
+  /// Whether this C++20 named modules doesn't need an initializer.
+  /// This is only meaningful for C++20 modules.
+  unsigned NamedModuleNoInit : 1;
+
   /// Describes the visibility of the various names within a
   /// particular module.
   enum NameVisibilityKind {
@@ -596,6 +600,10 @@ class alignas(8) Module {
 return Kind == ModuleInterfaceUnit || Kind == ModulePartitionInterface;
   }
 
+  bool isNamedModuleInterfaceNoInit() const {
+return NamedModuleNoInit;
+  }
+
   /// Get the primary module interface name from a partition.
   StringRef getPrimaryModuleInterfaceName() const {
 // Technically, global module fragment belongs to global module. And global
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index 4e6fbfc754b9173..82769f95bca90aa 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -44,7 +44,7 @@ Module::Module(StringRef Name, SourceLocation DefinitionLoc, 
Module *Parent,
   InferSubmodules(false), InferExplicitSubmodules(false),
   InferExportWildcard(false), ConfigMacrosExhaustive(false),
   NoUndeclaredIncludes(false), ModuleMapIsPrivate(false),
-  NameVisibility(Hidden) {
+  NamedModuleNoInit(false), NameVisibility(Hidden) {
   if (Parent) {
 IsAvailable = Parent->isAvailable();
 IsUnimportable = Parent->isUnimportable();
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 80543ba6311de45..a163069adf7c62c 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -675,6 +675,10 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) 
{
 // No Itanium initializer in header like modules.
 if (M->isHeaderLikeModule())
   continue; // TODO: warn of mixed use of module map modules and C++20?
+// We're allowed to skip the initialization if we are sure it doesn't
+// do any thing.
+if (M->isNamedModuleInterfaceNoInit())
+  continue;
 llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
 SmallString<256> FnName;
 {
@@ -731,8 +735,7 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
 // If we have a completely empty initializer then we do not want to create
 // the guard variable.
 ConstantAddress GuardAddr = ConstantAddress::invalid();
-if (!AllImports.empty() || !PrioritizedCXXGlobalInits.empty() ||
-!CXXGlobalInits.empty()) {
+if (!ModuleInits.empty()) {
   // Create the guard var.
   llvm::GlobalVariable *Guard = new llvm::GlobalVariable(
   getModule(), Int8Ty, /*isConstant=*/false,
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index a401017d4c1c0b8..d2a7fcb0ee27d89 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -1245,6 +1245,26 @@ void Sema::ActOnEndOfTranslationUnit() {
   }
 }
 
+// Now we can decide whether the modules we're building need an 
initializer.
+if (Module *CurrentModule = getCurrentM

[clang-tools-extra] [clang-tidy]: Add TagDecl only when it is a definition && Fix issue 6… (PR #67639)

2023-09-28 Thread Qizhi Hu via cfe-commits

https://github.com/jcsxky created 
https://github.com/llvm/llvm-project/pull/67639

Fix issue 67529, [clang-tidy: modernize-use-using fails when type is implicitly 
forward declared](https://github.com/llvm/llvm-project/issues/67529)

>From ce645a61b73005a90cc7a0d2cdded632dd047b08 Mon Sep 17 00:00:00 2001
From: huqizhi 
Date: Thu, 28 Sep 2023 15:35:35 +0800
Subject: [PATCH] [clang-tidy]: Add TagDecl only when it is a definition && Fix
 issue 67529

---
 clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp  | 3 ++-
 .../test/clang-tidy/checkers/modernize/use-using.cpp  | 4 
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
index 22dc9e21cab9d5a..e6293ed48bfddbb 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -61,7 +61,8 @@ void UseUsingCheck::check(const MatchFinder::MatchResult 
&Result) {
 // before the typedef will be the nested one (PR#50990). Therefore, we also
 // keep track of the parent declaration, so that we can look up the last
 // TagDecl that is a sibling of the typedef in the AST.
-LastTagDeclRanges[ParentDecl] = MatchedTagDecl->getSourceRange();
+if (MatchedTagDecl->isThisDeclarationADefinition())
+  LastTagDeclRanges[ParentDecl] = MatchedTagDecl->getSourceRange();
 return;
   }
 
diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
index f7db0af6434ac42..422abee11a71962 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
@@ -321,3 +321,7 @@ typedef bool (*ISSUE_65055_2)(int);
 // CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use 'using' instead of 'typedef'
 // CHECK-FIXES: {{^}}using ISSUE_65055_1 = void (*)(int);{{$}}
 // CHECK-FIXES: {{^}}using ISSUE_65055_2 = bool (*)(int);{{$}}
+
+typedef class ISSUE_67529_1 *ISSUE_67529;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using ISSUE_67529 = class ISSUE_67529_1 *;

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


[clang] [C++20] [Modules] Don't generate call to an imported module that dont init anything (PR #67638)

2023-09-28 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-modules


Changes



Close https://github.com/llvm/llvm-project/issues/56794

And see https://github.com/llvm/llvm-project/issues/67582 for a detailed 
backgrond for the issue.

As required by the Itanium ABI, the module units have to generate the 
initialization function. However, the importers are allowed to elide the call 
to the initialization function if they are sure the initialization function 
doesn't do anything.

This patch implemented this semantics.

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


7 Files Affected:

- (modified) clang/include/clang/Basic/Module.h (+8) 
- (modified) clang/lib/Basic/Module.cpp (+1-1) 
- (modified) clang/lib/CodeGen/CGDeclCXX.cpp (+5-2) 
- (modified) clang/lib/Sema/Sema.cpp (+20) 
- (modified) clang/lib/Serialization/ASTReader.cpp (+2) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+3-1) 
- (modified) clang/test/CodeGenCXX/module-initializer-guard-elision.cpp 
(+41-12) 


``diff
diff --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index edbd2dfc2973e92..fc8c39719979ecf 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -358,6 +358,10 @@ class alignas(8) Module {
   /// to a regular (public) module map.
   unsigned ModuleMapIsPrivate : 1;
 
+  /// Whether this C++20 named modules doesn't need an initializer.
+  /// This is only meaningful for C++20 modules.
+  unsigned NamedModuleNoInit : 1;
+
   /// Describes the visibility of the various names within a
   /// particular module.
   enum NameVisibilityKind {
@@ -596,6 +600,10 @@ class alignas(8) Module {
 return Kind == ModuleInterfaceUnit || Kind == ModulePartitionInterface;
   }
 
+  bool isNamedModuleInterfaceNoInit() const {
+return NamedModuleNoInit;
+  }
+
   /// Get the primary module interface name from a partition.
   StringRef getPrimaryModuleInterfaceName() const {
 // Technically, global module fragment belongs to global module. And global
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index 4e6fbfc754b9173..82769f95bca90aa 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -44,7 +44,7 @@ Module::Module(StringRef Name, SourceLocation DefinitionLoc, 
Module *Parent,
   InferSubmodules(false), InferExplicitSubmodules(false),
   InferExportWildcard(false), ConfigMacrosExhaustive(false),
   NoUndeclaredIncludes(false), ModuleMapIsPrivate(false),
-  NameVisibility(Hidden) {
+  NamedModuleNoInit(false), NameVisibility(Hidden) {
   if (Parent) {
 IsAvailable = Parent->isAvailable();
 IsUnimportable = Parent->isUnimportable();
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 80543ba6311de45..a163069adf7c62c 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -675,6 +675,10 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) 
{
 // No Itanium initializer in header like modules.
 if (M->isHeaderLikeModule())
   continue; // TODO: warn of mixed use of module map modules and C++20?
+// We're allowed to skip the initialization if we are sure it doesn't
+// do any thing.
+if (M->isNamedModuleInterfaceNoInit())
+  continue;
 llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
 SmallString<256> FnName;
 {
@@ -731,8 +735,7 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
 // If we have a completely empty initializer then we do not want to create
 // the guard variable.
 ConstantAddress GuardAddr = ConstantAddress::invalid();
-if (!AllImports.empty() || !PrioritizedCXXGlobalInits.empty() ||
-!CXXGlobalInits.empty()) {
+if (!ModuleInits.empty()) {
   // Create the guard var.
   llvm::GlobalVariable *Guard = new llvm::GlobalVariable(
   getModule(), Int8Ty, /*isConstant=*/false,
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index a401017d4c1c0b8..d2a7fcb0ee27d89 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -1245,6 +1245,26 @@ void Sema::ActOnEndOfTranslationUnit() {
   }
 }
 
+// Now we can decide whether the modules we're building need an 
initializer.
+if (Module *CurrentModule = getCurrentModule(); CurrentModule && 
CurrentModule->isInterfaceOrPartition()) {  
+  auto DoesModNeedInit = [this] (Module *M) {
+if (!getASTContext().getModuleInitializers(M).empty())
+  return false;
+for (auto [Exported, _] : M->Exports)
+  if (!Exported->isNamedModuleInterfaceNoInit())
+return false;
+for (Module *I : M->Imports)
+  if (!I->isNamedModuleInterfaceNoInit())
+return false;
+
+return true;
+  };
+
+  CurrentModule->NamedModuleNoInit = DoesModNeedInit(CurrentModule);
+  for (Module *SubModules : CurrentModule->submodules())
+CurrentModul

[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

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


[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

https://github.com/ktf updated https://github.com/llvm/llvm-project/pull/66430

>From ca0e66a95212a9a6186cd856906a47c97d67a47a Mon Sep 17 00:00:00 2001
From: Giulio Eulisse <10544+...@users.noreply.github.com>
Date: Thu, 14 Sep 2023 21:58:21 +0200
Subject: [PATCH 1/2] Introduce PagedVector class

The goal of the class is to be an (almost) drop in replacement for
SmallVector and std::vector when those are presized and filled later,
as it happens in SourceManager and ASTReader.

By splitting the actual vector in pages of the same size and allocating
the pages only when they are needed, using this containers reduces the
memory usage by a factor 4 for the cases relevant to the ALICE
experiment ROOT / cling usage.
---
 clang/include/clang/Basic/SourceManager.h |   3 +-
 clang/include/clang/Serialization/ASTReader.h |   5 +-
 clang/lib/Basic/SourceManager.cpp |  10 +-
 clang/lib/Serialization/ASTReader.cpp |   5 +-
 llvm/docs/ProgrammersManual.rst   |  34 ++
 llvm/include/llvm/ADT/PagedVector.h   | 302 
 llvm/unittests/ADT/CMakeLists.txt |   1 +
 llvm/unittests/ADT/PagedVectorTest.cpp| 342 ++
 8 files changed, 692 insertions(+), 10 deletions(-)
 create mode 100644 llvm/include/llvm/ADT/PagedVector.h
 create mode 100644 llvm/unittests/ADT/PagedVectorTest.cpp

diff --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index 2f846502d6f3327..e37caa2252532f9 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -43,6 +43,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -699,7 +700,7 @@ class SourceManager : public RefCountedBase {
   ///
   /// Negative FileIDs are indexes into this table. To get from ID to an index,
   /// use (-ID - 2).
-  SmallVector LoadedSLocEntryTable;
+  llvm::PagedVector LoadedSLocEntryTable;
 
   /// The starting offset of the next local SLocEntry.
   ///
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index dc1eb21c27801fe..65e19c6e44cf571 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -38,6 +38,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -487,7 +488,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the type with
   /// ID = (I + 1) << FastQual::Width has already been loaded
-  std::vector TypesLoaded;
+  llvm::PagedVector TypesLoaded;
 
   using GlobalTypeMapType =
   ContinuousRangeMap;
@@ -501,7 +502,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the declaration with ID
   /// = I + 1 has already been loaded.
-  std::vector DeclsLoaded;
+  llvm::PagedVector DeclsLoaded;
 
   using GlobalDeclMapType =
   ContinuousRangeMap;
diff --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 0521ac7b30339ab..7fa8b8096ac4931 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -2344,11 +2344,11 @@ SourceManager::MemoryBufferSizes 
SourceManager::getMemoryBufferSizes() const {
 }
 
 size_t SourceManager::getDataStructureSizes() const {
-  size_t size = llvm::capacity_in_bytes(MemBufferInfos)
-+ llvm::capacity_in_bytes(LocalSLocEntryTable)
-+ llvm::capacity_in_bytes(LoadedSLocEntryTable)
-+ llvm::capacity_in_bytes(SLocEntryLoaded)
-+ llvm::capacity_in_bytes(FileInfos);
+  size_t size = llvm::capacity_in_bytes(MemBufferInfos) +
+llvm::capacity_in_bytes(LocalSLocEntryTable) +
+llvm::capacity_in_bytes(LoadedSLocEntryTable) +
+llvm::capacity_in_bytes(SLocEntryLoaded) +
+llvm::capacity_in_bytes(FileInfos);
 
   if (OverriddenFilesInfo)
 size += llvm::capacity_in_bytes(OverriddenFilesInfo->OverriddenFiles);
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 0952244d037a77c..badd54987af18dd 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -7944,9 +7944,10 @@ void ASTReader::PrintStats() {
   std::fprintf(stderr, "*** AST File Statistics:\n");
 
   unsigned NumTypesLoaded =
-  TypesLoaded.size() - llvm::count(TypesLoaded, QualType());
+  TypesLoaded.size() - llvm::count(TypesLoaded.materialised(), QualType());
   unsigned NumDeclsLoaded =
-  DeclsLoaded.size() - llvm::count(DeclsLoaded, (Decl *)nullptr);
+  DeclsLoaded.size() -
+  llvm::count(DeclsLoaded.materialised(

[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

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


[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

https://github.com/ktf updated https://github.com/llvm/llvm-project/pull/66430

>From ca0e66a95212a9a6186cd856906a47c97d67a47a Mon Sep 17 00:00:00 2001
From: Giulio Eulisse <10544+...@users.noreply.github.com>
Date: Thu, 14 Sep 2023 21:58:21 +0200
Subject: [PATCH 1/3] Introduce PagedVector class

The goal of the class is to be an (almost) drop in replacement for
SmallVector and std::vector when those are presized and filled later,
as it happens in SourceManager and ASTReader.

By splitting the actual vector in pages of the same size and allocating
the pages only when they are needed, using this containers reduces the
memory usage by a factor 4 for the cases relevant to the ALICE
experiment ROOT / cling usage.
---
 clang/include/clang/Basic/SourceManager.h |   3 +-
 clang/include/clang/Serialization/ASTReader.h |   5 +-
 clang/lib/Basic/SourceManager.cpp |  10 +-
 clang/lib/Serialization/ASTReader.cpp |   5 +-
 llvm/docs/ProgrammersManual.rst   |  34 ++
 llvm/include/llvm/ADT/PagedVector.h   | 302 
 llvm/unittests/ADT/CMakeLists.txt |   1 +
 llvm/unittests/ADT/PagedVectorTest.cpp| 342 ++
 8 files changed, 692 insertions(+), 10 deletions(-)
 create mode 100644 llvm/include/llvm/ADT/PagedVector.h
 create mode 100644 llvm/unittests/ADT/PagedVectorTest.cpp

diff --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index 2f846502d6f3327..e37caa2252532f9 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -43,6 +43,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -699,7 +700,7 @@ class SourceManager : public RefCountedBase {
   ///
   /// Negative FileIDs are indexes into this table. To get from ID to an index,
   /// use (-ID - 2).
-  SmallVector LoadedSLocEntryTable;
+  llvm::PagedVector LoadedSLocEntryTable;
 
   /// The starting offset of the next local SLocEntry.
   ///
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index dc1eb21c27801fe..65e19c6e44cf571 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -38,6 +38,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -487,7 +488,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the type with
   /// ID = (I + 1) << FastQual::Width has already been loaded
-  std::vector TypesLoaded;
+  llvm::PagedVector TypesLoaded;
 
   using GlobalTypeMapType =
   ContinuousRangeMap;
@@ -501,7 +502,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the declaration with ID
   /// = I + 1 has already been loaded.
-  std::vector DeclsLoaded;
+  llvm::PagedVector DeclsLoaded;
 
   using GlobalDeclMapType =
   ContinuousRangeMap;
diff --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 0521ac7b30339ab..7fa8b8096ac4931 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -2344,11 +2344,11 @@ SourceManager::MemoryBufferSizes 
SourceManager::getMemoryBufferSizes() const {
 }
 
 size_t SourceManager::getDataStructureSizes() const {
-  size_t size = llvm::capacity_in_bytes(MemBufferInfos)
-+ llvm::capacity_in_bytes(LocalSLocEntryTable)
-+ llvm::capacity_in_bytes(LoadedSLocEntryTable)
-+ llvm::capacity_in_bytes(SLocEntryLoaded)
-+ llvm::capacity_in_bytes(FileInfos);
+  size_t size = llvm::capacity_in_bytes(MemBufferInfos) +
+llvm::capacity_in_bytes(LocalSLocEntryTable) +
+llvm::capacity_in_bytes(LoadedSLocEntryTable) +
+llvm::capacity_in_bytes(SLocEntryLoaded) +
+llvm::capacity_in_bytes(FileInfos);
 
   if (OverriddenFilesInfo)
 size += llvm::capacity_in_bytes(OverriddenFilesInfo->OverriddenFiles);
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 0952244d037a77c..badd54987af18dd 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -7944,9 +7944,10 @@ void ASTReader::PrintStats() {
   std::fprintf(stderr, "*** AST File Statistics:\n");
 
   unsigned NumTypesLoaded =
-  TypesLoaded.size() - llvm::count(TypesLoaded, QualType());
+  TypesLoaded.size() - llvm::count(TypesLoaded.materialised(), QualType());
   unsigned NumDeclsLoaded =
-  DeclsLoaded.size() - llvm::count(DeclsLoaded, (Decl *)nullptr);
+  DeclsLoaded.size() -
+  llvm::count(DeclsLoaded.materialised(

[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

https://github.com/ktf updated https://github.com/llvm/llvm-project/pull/66430

>From ca0e66a95212a9a6186cd856906a47c97d67a47a Mon Sep 17 00:00:00 2001
From: Giulio Eulisse <10544+...@users.noreply.github.com>
Date: Thu, 14 Sep 2023 21:58:21 +0200
Subject: [PATCH 1/4] Introduce PagedVector class

The goal of the class is to be an (almost) drop in replacement for
SmallVector and std::vector when those are presized and filled later,
as it happens in SourceManager and ASTReader.

By splitting the actual vector in pages of the same size and allocating
the pages only when they are needed, using this containers reduces the
memory usage by a factor 4 for the cases relevant to the ALICE
experiment ROOT / cling usage.
---
 clang/include/clang/Basic/SourceManager.h |   3 +-
 clang/include/clang/Serialization/ASTReader.h |   5 +-
 clang/lib/Basic/SourceManager.cpp |  10 +-
 clang/lib/Serialization/ASTReader.cpp |   5 +-
 llvm/docs/ProgrammersManual.rst   |  34 ++
 llvm/include/llvm/ADT/PagedVector.h   | 302 
 llvm/unittests/ADT/CMakeLists.txt |   1 +
 llvm/unittests/ADT/PagedVectorTest.cpp| 342 ++
 8 files changed, 692 insertions(+), 10 deletions(-)
 create mode 100644 llvm/include/llvm/ADT/PagedVector.h
 create mode 100644 llvm/unittests/ADT/PagedVectorTest.cpp

diff --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index 2f846502d6f3327..e37caa2252532f9 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -43,6 +43,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -699,7 +700,7 @@ class SourceManager : public RefCountedBase {
   ///
   /// Negative FileIDs are indexes into this table. To get from ID to an index,
   /// use (-ID - 2).
-  SmallVector LoadedSLocEntryTable;
+  llvm::PagedVector LoadedSLocEntryTable;
 
   /// The starting offset of the next local SLocEntry.
   ///
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index dc1eb21c27801fe..65e19c6e44cf571 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -38,6 +38,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -487,7 +488,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the type with
   /// ID = (I + 1) << FastQual::Width has already been loaded
-  std::vector TypesLoaded;
+  llvm::PagedVector TypesLoaded;
 
   using GlobalTypeMapType =
   ContinuousRangeMap;
@@ -501,7 +502,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the declaration with ID
   /// = I + 1 has already been loaded.
-  std::vector DeclsLoaded;
+  llvm::PagedVector DeclsLoaded;
 
   using GlobalDeclMapType =
   ContinuousRangeMap;
diff --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 0521ac7b30339ab..7fa8b8096ac4931 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -2344,11 +2344,11 @@ SourceManager::MemoryBufferSizes 
SourceManager::getMemoryBufferSizes() const {
 }
 
 size_t SourceManager::getDataStructureSizes() const {
-  size_t size = llvm::capacity_in_bytes(MemBufferInfos)
-+ llvm::capacity_in_bytes(LocalSLocEntryTable)
-+ llvm::capacity_in_bytes(LoadedSLocEntryTable)
-+ llvm::capacity_in_bytes(SLocEntryLoaded)
-+ llvm::capacity_in_bytes(FileInfos);
+  size_t size = llvm::capacity_in_bytes(MemBufferInfos) +
+llvm::capacity_in_bytes(LocalSLocEntryTable) +
+llvm::capacity_in_bytes(LoadedSLocEntryTable) +
+llvm::capacity_in_bytes(SLocEntryLoaded) +
+llvm::capacity_in_bytes(FileInfos);
 
   if (OverriddenFilesInfo)
 size += llvm::capacity_in_bytes(OverriddenFilesInfo->OverriddenFiles);
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 0952244d037a77c..badd54987af18dd 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -7944,9 +7944,10 @@ void ASTReader::PrintStats() {
   std::fprintf(stderr, "*** AST File Statistics:\n");
 
   unsigned NumTypesLoaded =
-  TypesLoaded.size() - llvm::count(TypesLoaded, QualType());
+  TypesLoaded.size() - llvm::count(TypesLoaded.materialised(), QualType());
   unsigned NumDeclsLoaded =
-  DeclsLoaded.size() - llvm::count(DeclsLoaded, (Decl *)nullptr);
+  DeclsLoaded.size() -
+  llvm::count(DeclsLoaded.materialised(

[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

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


[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

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


[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

https://github.com/ktf updated https://github.com/llvm/llvm-project/pull/66430

>From ca0e66a95212a9a6186cd856906a47c97d67a47a Mon Sep 17 00:00:00 2001
From: Giulio Eulisse <10544+...@users.noreply.github.com>
Date: Thu, 14 Sep 2023 21:58:21 +0200
Subject: [PATCH 1/5] Introduce PagedVector class

The goal of the class is to be an (almost) drop in replacement for
SmallVector and std::vector when those are presized and filled later,
as it happens in SourceManager and ASTReader.

By splitting the actual vector in pages of the same size and allocating
the pages only when they are needed, using this containers reduces the
memory usage by a factor 4 for the cases relevant to the ALICE
experiment ROOT / cling usage.
---
 clang/include/clang/Basic/SourceManager.h |   3 +-
 clang/include/clang/Serialization/ASTReader.h |   5 +-
 clang/lib/Basic/SourceManager.cpp |  10 +-
 clang/lib/Serialization/ASTReader.cpp |   5 +-
 llvm/docs/ProgrammersManual.rst   |  34 ++
 llvm/include/llvm/ADT/PagedVector.h   | 302 
 llvm/unittests/ADT/CMakeLists.txt |   1 +
 llvm/unittests/ADT/PagedVectorTest.cpp| 342 ++
 8 files changed, 692 insertions(+), 10 deletions(-)
 create mode 100644 llvm/include/llvm/ADT/PagedVector.h
 create mode 100644 llvm/unittests/ADT/PagedVectorTest.cpp

diff --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index 2f846502d6f3327..e37caa2252532f9 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -43,6 +43,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -699,7 +700,7 @@ class SourceManager : public RefCountedBase {
   ///
   /// Negative FileIDs are indexes into this table. To get from ID to an index,
   /// use (-ID - 2).
-  SmallVector LoadedSLocEntryTable;
+  llvm::PagedVector LoadedSLocEntryTable;
 
   /// The starting offset of the next local SLocEntry.
   ///
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index dc1eb21c27801fe..65e19c6e44cf571 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -38,6 +38,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -487,7 +488,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the type with
   /// ID = (I + 1) << FastQual::Width has already been loaded
-  std::vector TypesLoaded;
+  llvm::PagedVector TypesLoaded;
 
   using GlobalTypeMapType =
   ContinuousRangeMap;
@@ -501,7 +502,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the declaration with ID
   /// = I + 1 has already been loaded.
-  std::vector DeclsLoaded;
+  llvm::PagedVector DeclsLoaded;
 
   using GlobalDeclMapType =
   ContinuousRangeMap;
diff --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 0521ac7b30339ab..7fa8b8096ac4931 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -2344,11 +2344,11 @@ SourceManager::MemoryBufferSizes 
SourceManager::getMemoryBufferSizes() const {
 }
 
 size_t SourceManager::getDataStructureSizes() const {
-  size_t size = llvm::capacity_in_bytes(MemBufferInfos)
-+ llvm::capacity_in_bytes(LocalSLocEntryTable)
-+ llvm::capacity_in_bytes(LoadedSLocEntryTable)
-+ llvm::capacity_in_bytes(SLocEntryLoaded)
-+ llvm::capacity_in_bytes(FileInfos);
+  size_t size = llvm::capacity_in_bytes(MemBufferInfos) +
+llvm::capacity_in_bytes(LocalSLocEntryTable) +
+llvm::capacity_in_bytes(LoadedSLocEntryTable) +
+llvm::capacity_in_bytes(SLocEntryLoaded) +
+llvm::capacity_in_bytes(FileInfos);
 
   if (OverriddenFilesInfo)
 size += llvm::capacity_in_bytes(OverriddenFilesInfo->OverriddenFiles);
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 0952244d037a77c..badd54987af18dd 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -7944,9 +7944,10 @@ void ASTReader::PrintStats() {
   std::fprintf(stderr, "*** AST File Statistics:\n");
 
   unsigned NumTypesLoaded =
-  TypesLoaded.size() - llvm::count(TypesLoaded, QualType());
+  TypesLoaded.size() - llvm::count(TypesLoaded.materialised(), QualType());
   unsigned NumDeclsLoaded =
-  DeclsLoaded.size() - llvm::count(DeclsLoaded, (Decl *)nullptr);
+  DeclsLoaded.size() -
+  llvm::count(DeclsLoaded.materialised(

[clang-tools-extra] [clang-tidy]: Add TagDecl only when it is a definition && Fix issue 6… (PR #67639)

2023-09-28 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy


Changes

Fix issue 67529, [clang-tidy: modernize-use-using fails when type is implicitly 
forward declared](https://github.com/llvm/llvm-project/issues/67529)

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


2 Files Affected:

- (modified) clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp (+2-1) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp 
(+4) 


``diff
diff --git a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
index 22dc9e21cab9d5a..e6293ed48bfddbb 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -61,7 +61,8 @@ void UseUsingCheck::check(const MatchFinder::MatchResult 
&Result) {
 // before the typedef will be the nested one (PR#50990). Therefore, we also
 // keep track of the parent declaration, so that we can look up the last
 // TagDecl that is a sibling of the typedef in the AST.
-LastTagDeclRanges[ParentDecl] = MatchedTagDecl->getSourceRange();
+if (MatchedTagDecl->isThisDeclarationADefinition())
+  LastTagDeclRanges[ParentDecl] = MatchedTagDecl->getSourceRange();
 return;
   }
 
diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
index f7db0af6434ac42..422abee11a71962 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
@@ -321,3 +321,7 @@ typedef bool (*ISSUE_65055_2)(int);
 // CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use 'using' instead of 'typedef'
 // CHECK-FIXES: {{^}}using ISSUE_65055_1 = void (*)(int);{{$}}
 // CHECK-FIXES: {{^}}using ISSUE_65055_2 = bool (*)(int);{{$}}
+
+typedef class ISSUE_67529_1 *ISSUE_67529;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using ISSUE_67529 = class ISSUE_67529_1 *;

``




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


[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

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


[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

https://github.com/ktf updated https://github.com/llvm/llvm-project/pull/66430

>From ca0e66a95212a9a6186cd856906a47c97d67a47a Mon Sep 17 00:00:00 2001
From: Giulio Eulisse <10544+...@users.noreply.github.com>
Date: Thu, 14 Sep 2023 21:58:21 +0200
Subject: [PATCH 1/6] Introduce PagedVector class

The goal of the class is to be an (almost) drop in replacement for
SmallVector and std::vector when those are presized and filled later,
as it happens in SourceManager and ASTReader.

By splitting the actual vector in pages of the same size and allocating
the pages only when they are needed, using this containers reduces the
memory usage by a factor 4 for the cases relevant to the ALICE
experiment ROOT / cling usage.
---
 clang/include/clang/Basic/SourceManager.h |   3 +-
 clang/include/clang/Serialization/ASTReader.h |   5 +-
 clang/lib/Basic/SourceManager.cpp |  10 +-
 clang/lib/Serialization/ASTReader.cpp |   5 +-
 llvm/docs/ProgrammersManual.rst   |  34 ++
 llvm/include/llvm/ADT/PagedVector.h   | 302 
 llvm/unittests/ADT/CMakeLists.txt |   1 +
 llvm/unittests/ADT/PagedVectorTest.cpp| 342 ++
 8 files changed, 692 insertions(+), 10 deletions(-)
 create mode 100644 llvm/include/llvm/ADT/PagedVector.h
 create mode 100644 llvm/unittests/ADT/PagedVectorTest.cpp

diff --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index 2f846502d6f3327..e37caa2252532f9 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -43,6 +43,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -699,7 +700,7 @@ class SourceManager : public RefCountedBase {
   ///
   /// Negative FileIDs are indexes into this table. To get from ID to an index,
   /// use (-ID - 2).
-  SmallVector LoadedSLocEntryTable;
+  llvm::PagedVector LoadedSLocEntryTable;
 
   /// The starting offset of the next local SLocEntry.
   ///
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index dc1eb21c27801fe..65e19c6e44cf571 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -38,6 +38,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -487,7 +488,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the type with
   /// ID = (I + 1) << FastQual::Width has already been loaded
-  std::vector TypesLoaded;
+  llvm::PagedVector TypesLoaded;
 
   using GlobalTypeMapType =
   ContinuousRangeMap;
@@ -501,7 +502,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the declaration with ID
   /// = I + 1 has already been loaded.
-  std::vector DeclsLoaded;
+  llvm::PagedVector DeclsLoaded;
 
   using GlobalDeclMapType =
   ContinuousRangeMap;
diff --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 0521ac7b30339ab..7fa8b8096ac4931 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -2344,11 +2344,11 @@ SourceManager::MemoryBufferSizes 
SourceManager::getMemoryBufferSizes() const {
 }
 
 size_t SourceManager::getDataStructureSizes() const {
-  size_t size = llvm::capacity_in_bytes(MemBufferInfos)
-+ llvm::capacity_in_bytes(LocalSLocEntryTable)
-+ llvm::capacity_in_bytes(LoadedSLocEntryTable)
-+ llvm::capacity_in_bytes(SLocEntryLoaded)
-+ llvm::capacity_in_bytes(FileInfos);
+  size_t size = llvm::capacity_in_bytes(MemBufferInfos) +
+llvm::capacity_in_bytes(LocalSLocEntryTable) +
+llvm::capacity_in_bytes(LoadedSLocEntryTable) +
+llvm::capacity_in_bytes(SLocEntryLoaded) +
+llvm::capacity_in_bytes(FileInfos);
 
   if (OverriddenFilesInfo)
 size += llvm::capacity_in_bytes(OverriddenFilesInfo->OverriddenFiles);
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 0952244d037a77c..badd54987af18dd 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -7944,9 +7944,10 @@ void ASTReader::PrintStats() {
   std::fprintf(stderr, "*** AST File Statistics:\n");
 
   unsigned NumTypesLoaded =
-  TypesLoaded.size() - llvm::count(TypesLoaded, QualType());
+  TypesLoaded.size() - llvm::count(TypesLoaded.materialised(), QualType());
   unsigned NumDeclsLoaded =
-  DeclsLoaded.size() - llvm::count(DeclsLoaded, (Decl *)nullptr);
+  DeclsLoaded.size() -
+  llvm::count(DeclsLoaded.materialised(

[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

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


[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

https://github.com/ktf updated https://github.com/llvm/llvm-project/pull/66430

>From ca0e66a95212a9a6186cd856906a47c97d67a47a Mon Sep 17 00:00:00 2001
From: Giulio Eulisse <10544+...@users.noreply.github.com>
Date: Thu, 14 Sep 2023 21:58:21 +0200
Subject: [PATCH 1/7] Introduce PagedVector class

The goal of the class is to be an (almost) drop in replacement for
SmallVector and std::vector when those are presized and filled later,
as it happens in SourceManager and ASTReader.

By splitting the actual vector in pages of the same size and allocating
the pages only when they are needed, using this containers reduces the
memory usage by a factor 4 for the cases relevant to the ALICE
experiment ROOT / cling usage.
---
 clang/include/clang/Basic/SourceManager.h |   3 +-
 clang/include/clang/Serialization/ASTReader.h |   5 +-
 clang/lib/Basic/SourceManager.cpp |  10 +-
 clang/lib/Serialization/ASTReader.cpp |   5 +-
 llvm/docs/ProgrammersManual.rst   |  34 ++
 llvm/include/llvm/ADT/PagedVector.h   | 302 
 llvm/unittests/ADT/CMakeLists.txt |   1 +
 llvm/unittests/ADT/PagedVectorTest.cpp| 342 ++
 8 files changed, 692 insertions(+), 10 deletions(-)
 create mode 100644 llvm/include/llvm/ADT/PagedVector.h
 create mode 100644 llvm/unittests/ADT/PagedVectorTest.cpp

diff --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index 2f846502d6f3327..e37caa2252532f9 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -43,6 +43,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -699,7 +700,7 @@ class SourceManager : public RefCountedBase {
   ///
   /// Negative FileIDs are indexes into this table. To get from ID to an index,
   /// use (-ID - 2).
-  SmallVector LoadedSLocEntryTable;
+  llvm::PagedVector LoadedSLocEntryTable;
 
   /// The starting offset of the next local SLocEntry.
   ///
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index dc1eb21c27801fe..65e19c6e44cf571 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -38,6 +38,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -487,7 +488,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the type with
   /// ID = (I + 1) << FastQual::Width has already been loaded
-  std::vector TypesLoaded;
+  llvm::PagedVector TypesLoaded;
 
   using GlobalTypeMapType =
   ContinuousRangeMap;
@@ -501,7 +502,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the declaration with ID
   /// = I + 1 has already been loaded.
-  std::vector DeclsLoaded;
+  llvm::PagedVector DeclsLoaded;
 
   using GlobalDeclMapType =
   ContinuousRangeMap;
diff --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 0521ac7b30339ab..7fa8b8096ac4931 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -2344,11 +2344,11 @@ SourceManager::MemoryBufferSizes 
SourceManager::getMemoryBufferSizes() const {
 }
 
 size_t SourceManager::getDataStructureSizes() const {
-  size_t size = llvm::capacity_in_bytes(MemBufferInfos)
-+ llvm::capacity_in_bytes(LocalSLocEntryTable)
-+ llvm::capacity_in_bytes(LoadedSLocEntryTable)
-+ llvm::capacity_in_bytes(SLocEntryLoaded)
-+ llvm::capacity_in_bytes(FileInfos);
+  size_t size = llvm::capacity_in_bytes(MemBufferInfos) +
+llvm::capacity_in_bytes(LocalSLocEntryTable) +
+llvm::capacity_in_bytes(LoadedSLocEntryTable) +
+llvm::capacity_in_bytes(SLocEntryLoaded) +
+llvm::capacity_in_bytes(FileInfos);
 
   if (OverriddenFilesInfo)
 size += llvm::capacity_in_bytes(OverriddenFilesInfo->OverriddenFiles);
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 0952244d037a77c..badd54987af18dd 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -7944,9 +7944,10 @@ void ASTReader::PrintStats() {
   std::fprintf(stderr, "*** AST File Statistics:\n");
 
   unsigned NumTypesLoaded =
-  TypesLoaded.size() - llvm::count(TypesLoaded, QualType());
+  TypesLoaded.size() - llvm::count(TypesLoaded.materialised(), QualType());
   unsigned NumDeclsLoaded =
-  DeclsLoaded.size() - llvm::count(DeclsLoaded, (Decl *)nullptr);
+  DeclsLoaded.size() -
+  llvm::count(DeclsLoaded.materialised(

[clang] [clang][dataflow] Show triangle in `` element. (PR #67431)

2023-09-28 Thread via cfe-commits

https://github.com/martinboehme updated 
https://github.com/llvm/llvm-project/pull/67431

>From fe52a064d08bb9e328eafe70ddd7edf21931408e Mon Sep 17 00:00:00 2001
From: Martin Braenne 
Date: Tue, 26 Sep 2023 14:07:14 +
Subject: [PATCH 1/2] [clang][dataflow] Show triangle in `` element.

Also, change the mouse cursor into a pointer instead of a text cursor.

This makes it more discoverable that the element can be opened and closed.
---
 clang/lib/Analysis/FlowSensitive/HTMLLogger.css  | 14 +-
 clang/lib/Analysis/FlowSensitive/HTMLLogger.html |  2 +-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
index c8212df1f94b81a..73f639eac6836ec 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
@@ -122,10 +122,22 @@ code.line:has(.bb-select):before {
   font-size: x-small;
   flex-grow: 1;
 }
-.value summary {
+.value > summary {
   background-color: #ace;
   display: flex;
   justify-content: space-between;
+  cursor: pointer;
+}
+.value > summary::before {
+  content: '►';
+  margin-right: 0.5em;
+  font-size: 0.9em;
+}
+.value[open] > summary::before {
+  content: '▼';
+}
+.value > summary > .location {
+  margin-left: auto;
 }
 .value .address {
   font-size: xx-small;
diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.html 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
index 87695623cb318b2..6d866d57e144866 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
@@ -18,7 +18,7 @@
 #{{v.value_id}}
   
   
-{{v.type}} @{{v.location}}
+{{v.type}} @{{v.location}}
   
 
 From a46b2cda38ea1c913b146621d12f0023dac8d28b Mon Sep 17 00:00:00 2001
From: Martin Braenne 
Date: Thu, 28 Sep 2023 07:41:19 +
Subject: [PATCH 2/2] Change `justify-content` from `space-between` to `start`

---
 clang/lib/Analysis/FlowSensitive/HTMLLogger.css | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
index 73f639eac6836ec..d8952531bb79582 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
@@ -125,7 +125,7 @@ code.line:has(.bb-select):before {
 .value > summary {
   background-color: #ace;
   display: flex;
-  justify-content: space-between;
+  justify-content: start;
   cursor: pointer;
 }
 .value > summary::before {

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


[clang] [clang][dataflow] Show triangle in `` element. (PR #67431)

2023-09-28 Thread via cfe-commits


@@ -122,10 +122,22 @@ code.line:has(.bb-select):before {
   font-size: x-small;
   flex-grow: 1;
 }
-.value summary {
+.value > summary {
   background-color: #ace;
   display: flex;
   justify-content: space-between;

martinboehme wrote:

Ah, true! Changed to `start`, which appears to solve this:

![image](https://github.com/llvm/llvm-project/assets/29098113/f9349b1d-767e-48ed-ae61-77eefb67b210)


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


[PATCH] D155064: [clang][SemaCXX] Diagnose tautological uses of consteval if and is_constant_evaluated

2023-09-28 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added a comment.

Thank you for the revert!

This looks like a general issue of clang on template deduction in 
constant-evaluated context (https://godbolt.org/z/zTro7Ycfa). Pushing 
constant-evaluated context against initializer of instantiated constexpr 
variables made this bug appear in broader scenarios.
I can circumvent this problem by not pushing constant-evaluated context on 
instantiated constexpr variable initializers, but that in turn would force me 
to do tricky workaround in warnings on narrowing conversions in global 
constexpr variable templates.

@cor3ntin
The constant-evaluated-context miscompilation bisected to 
https://reviews.llvm.org/D140554
Is this the intended result of that patch?
I'm at lost how to proceed further on this patch. The only way looks like some 
workarounds in narrowing conversion warning mechanism, but is it acceptable?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155064

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


[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

https://github.com/ktf updated https://github.com/llvm/llvm-project/pull/66430

>From ca0e66a95212a9a6186cd856906a47c97d67a47a Mon Sep 17 00:00:00 2001
From: Giulio Eulisse <10544+...@users.noreply.github.com>
Date: Thu, 14 Sep 2023 21:58:21 +0200
Subject: [PATCH 1/8] Introduce PagedVector class

The goal of the class is to be an (almost) drop in replacement for
SmallVector and std::vector when those are presized and filled later,
as it happens in SourceManager and ASTReader.

By splitting the actual vector in pages of the same size and allocating
the pages only when they are needed, using this containers reduces the
memory usage by a factor 4 for the cases relevant to the ALICE
experiment ROOT / cling usage.
---
 clang/include/clang/Basic/SourceManager.h |   3 +-
 clang/include/clang/Serialization/ASTReader.h |   5 +-
 clang/lib/Basic/SourceManager.cpp |  10 +-
 clang/lib/Serialization/ASTReader.cpp |   5 +-
 llvm/docs/ProgrammersManual.rst   |  34 ++
 llvm/include/llvm/ADT/PagedVector.h   | 302 
 llvm/unittests/ADT/CMakeLists.txt |   1 +
 llvm/unittests/ADT/PagedVectorTest.cpp| 342 ++
 8 files changed, 692 insertions(+), 10 deletions(-)
 create mode 100644 llvm/include/llvm/ADT/PagedVector.h
 create mode 100644 llvm/unittests/ADT/PagedVectorTest.cpp

diff --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index 2f846502d6f3327..e37caa2252532f9 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -43,6 +43,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -699,7 +700,7 @@ class SourceManager : public RefCountedBase {
   ///
   /// Negative FileIDs are indexes into this table. To get from ID to an index,
   /// use (-ID - 2).
-  SmallVector LoadedSLocEntryTable;
+  llvm::PagedVector LoadedSLocEntryTable;
 
   /// The starting offset of the next local SLocEntry.
   ///
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index dc1eb21c27801fe..65e19c6e44cf571 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -38,6 +38,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -487,7 +488,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the type with
   /// ID = (I + 1) << FastQual::Width has already been loaded
-  std::vector TypesLoaded;
+  llvm::PagedVector TypesLoaded;
 
   using GlobalTypeMapType =
   ContinuousRangeMap;
@@ -501,7 +502,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the declaration with ID
   /// = I + 1 has already been loaded.
-  std::vector DeclsLoaded;
+  llvm::PagedVector DeclsLoaded;
 
   using GlobalDeclMapType =
   ContinuousRangeMap;
diff --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 0521ac7b30339ab..7fa8b8096ac4931 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -2344,11 +2344,11 @@ SourceManager::MemoryBufferSizes 
SourceManager::getMemoryBufferSizes() const {
 }
 
 size_t SourceManager::getDataStructureSizes() const {
-  size_t size = llvm::capacity_in_bytes(MemBufferInfos)
-+ llvm::capacity_in_bytes(LocalSLocEntryTable)
-+ llvm::capacity_in_bytes(LoadedSLocEntryTable)
-+ llvm::capacity_in_bytes(SLocEntryLoaded)
-+ llvm::capacity_in_bytes(FileInfos);
+  size_t size = llvm::capacity_in_bytes(MemBufferInfos) +
+llvm::capacity_in_bytes(LocalSLocEntryTable) +
+llvm::capacity_in_bytes(LoadedSLocEntryTable) +
+llvm::capacity_in_bytes(SLocEntryLoaded) +
+llvm::capacity_in_bytes(FileInfos);
 
   if (OverriddenFilesInfo)
 size += llvm::capacity_in_bytes(OverriddenFilesInfo->OverriddenFiles);
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 0952244d037a77c..badd54987af18dd 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -7944,9 +7944,10 @@ void ASTReader::PrintStats() {
   std::fprintf(stderr, "*** AST File Statistics:\n");
 
   unsigned NumTypesLoaded =
-  TypesLoaded.size() - llvm::count(TypesLoaded, QualType());
+  TypesLoaded.size() - llvm::count(TypesLoaded.materialised(), QualType());
   unsigned NumDeclsLoaded =
-  DeclsLoaded.size() - llvm::count(DeclsLoaded, (Decl *)nullptr);
+  DeclsLoaded.size() -
+  llvm::count(DeclsLoaded.materialised(

[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

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


[clang] [clang][dataflow] Show triangle in `` element. (PR #67431)

2023-09-28 Thread via cfe-commits


@@ -122,10 +122,22 @@ code.line:has(.bb-select):before {
   font-size: x-small;
   flex-grow: 1;
 }
-.value summary {
+.value > summary {
   background-color: #ace;
   display: flex;
   justify-content: space-between;
+  cursor: pointer;
+}
+.value > summary::before {
+  content: '►';
+  margin-right: 0.5em;
+  font-size: 0.9em;
+}
+.value[open] > summary::before {
+  content: '▼';
+}
+.value > summary > .location {

martinboehme wrote:

True, it doesn't solve a problem ("space" would work just as well), but as the 
`.location` is always a direct child of the ``, it seemed more 
specific to do it this way.

Is "descendant", rather than "child", considered to be the default in CSS? The 
former is syntactically shorter, but "child" is arguably the simpler concept. 
Or is "child" problematic because it makes the CSS more brittle (i.e. less 
resilient in the fact of changes to the HTML)?

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


[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

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


[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

https://github.com/ktf updated https://github.com/llvm/llvm-project/pull/66430

>From ca0e66a95212a9a6186cd856906a47c97d67a47a Mon Sep 17 00:00:00 2001
From: Giulio Eulisse <10544+...@users.noreply.github.com>
Date: Thu, 14 Sep 2023 21:58:21 +0200
Subject: [PATCH 1/9] Introduce PagedVector class

The goal of the class is to be an (almost) drop in replacement for
SmallVector and std::vector when those are presized and filled later,
as it happens in SourceManager and ASTReader.

By splitting the actual vector in pages of the same size and allocating
the pages only when they are needed, using this containers reduces the
memory usage by a factor 4 for the cases relevant to the ALICE
experiment ROOT / cling usage.
---
 clang/include/clang/Basic/SourceManager.h |   3 +-
 clang/include/clang/Serialization/ASTReader.h |   5 +-
 clang/lib/Basic/SourceManager.cpp |  10 +-
 clang/lib/Serialization/ASTReader.cpp |   5 +-
 llvm/docs/ProgrammersManual.rst   |  34 ++
 llvm/include/llvm/ADT/PagedVector.h   | 302 
 llvm/unittests/ADT/CMakeLists.txt |   1 +
 llvm/unittests/ADT/PagedVectorTest.cpp| 342 ++
 8 files changed, 692 insertions(+), 10 deletions(-)
 create mode 100644 llvm/include/llvm/ADT/PagedVector.h
 create mode 100644 llvm/unittests/ADT/PagedVectorTest.cpp

diff --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index 2f846502d6f3327..e37caa2252532f9 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -43,6 +43,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -699,7 +700,7 @@ class SourceManager : public RefCountedBase {
   ///
   /// Negative FileIDs are indexes into this table. To get from ID to an index,
   /// use (-ID - 2).
-  SmallVector LoadedSLocEntryTable;
+  llvm::PagedVector LoadedSLocEntryTable;
 
   /// The starting offset of the next local SLocEntry.
   ///
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index dc1eb21c27801fe..65e19c6e44cf571 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -38,6 +38,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -487,7 +488,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the type with
   /// ID = (I + 1) << FastQual::Width has already been loaded
-  std::vector TypesLoaded;
+  llvm::PagedVector TypesLoaded;
 
   using GlobalTypeMapType =
   ContinuousRangeMap;
@@ -501,7 +502,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the declaration with ID
   /// = I + 1 has already been loaded.
-  std::vector DeclsLoaded;
+  llvm::PagedVector DeclsLoaded;
 
   using GlobalDeclMapType =
   ContinuousRangeMap;
diff --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 0521ac7b30339ab..7fa8b8096ac4931 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -2344,11 +2344,11 @@ SourceManager::MemoryBufferSizes 
SourceManager::getMemoryBufferSizes() const {
 }
 
 size_t SourceManager::getDataStructureSizes() const {
-  size_t size = llvm::capacity_in_bytes(MemBufferInfos)
-+ llvm::capacity_in_bytes(LocalSLocEntryTable)
-+ llvm::capacity_in_bytes(LoadedSLocEntryTable)
-+ llvm::capacity_in_bytes(SLocEntryLoaded)
-+ llvm::capacity_in_bytes(FileInfos);
+  size_t size = llvm::capacity_in_bytes(MemBufferInfos) +
+llvm::capacity_in_bytes(LocalSLocEntryTable) +
+llvm::capacity_in_bytes(LoadedSLocEntryTable) +
+llvm::capacity_in_bytes(SLocEntryLoaded) +
+llvm::capacity_in_bytes(FileInfos);
 
   if (OverriddenFilesInfo)
 size += llvm::capacity_in_bytes(OverriddenFilesInfo->OverriddenFiles);
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 0952244d037a77c..badd54987af18dd 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -7944,9 +7944,10 @@ void ASTReader::PrintStats() {
   std::fprintf(stderr, "*** AST File Statistics:\n");
 
   unsigned NumTypesLoaded =
-  TypesLoaded.size() - llvm::count(TypesLoaded, QualType());
+  TypesLoaded.size() - llvm::count(TypesLoaded.materialised(), QualType());
   unsigned NumDeclsLoaded =
-  DeclsLoaded.size() - llvm::count(DeclsLoaded, (Decl *)nullptr);
+  DeclsLoaded.size() -
+  llvm::count(DeclsLoaded.materialised(

[clang] [C++20] [Modules] Don't generate call to an imported module that dont init anything (PR #67638)

2023-09-28 Thread via cfe-commits

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 0e8a8c85f8765c086c573f36e60c895920381e18 
2448304b847da467a2a81c33daa7fb789948edf1 -- clang/include/clang/Basic/Module.h 
clang/lib/Basic/Module.cpp clang/lib/CodeGen/CGDeclCXX.cpp 
clang/lib/Sema/Sema.cpp clang/lib/Serialization/ASTReader.cpp 
clang/lib/Serialization/ASTWriter.cpp 
clang/test/CodeGenCXX/module-initializer-guard-elision.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index fc8c39719979..b6303cb54b94 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -600,9 +600,7 @@ public:
 return Kind == ModuleInterfaceUnit || Kind == ModulePartitionInterface;
   }
 
-  bool isNamedModuleInterfaceNoInit() const {
-return NamedModuleNoInit;
-  }
+  bool isNamedModuleInterfaceNoInit() const { return NamedModuleNoInit; }
 
   /// Get the primary module interface name from a partition.
   StringRef getPrimaryModuleInterfaceName() const {
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index d2a7fcb0ee27..faecaa755f1b 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -1246,8 +1246,9 @@ void Sema::ActOnEndOfTranslationUnit() {
 }
 
 // Now we can decide whether the modules we're building need an 
initializer.
-if (Module *CurrentModule = getCurrentModule(); CurrentModule && 
CurrentModule->isInterfaceOrPartition()) {  
-  auto DoesModNeedInit = [this] (Module *M) {
+if (Module *CurrentModule = getCurrentModule();
+CurrentModule && CurrentModule->isInterfaceOrPartition()) {
+  auto DoesModNeedInit = [this](Module *M) {
 if (!getASTContext().getModuleInitializers(M).empty())
   return false;
 for (auto [Exported, _] : M->Exports)

``




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


[clang] [C++20] [Modules] Don't generate call to an imported module that dont init anything (PR #67638)

2023-09-28 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 updated 
https://github.com/llvm/llvm-project/pull/67638

>From 51c53a1aaed8fef470e699513a0f44187fbb623d Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Thu, 28 Sep 2023 15:32:31 +0800
Subject: [PATCH] [C++20] [Modules] Don't generate call to an imported module
 that don't init anything

Close https://github.com/llvm/llvm-project/issues/56794

And see https://github.com/llvm/llvm-project/issues/67582 for a detailed
backgrond for the issue.

As required by the Itanium ABI, the module units have to generate the
initialization function. However, the importers are allowed to elide the
call to the initialization function if they are sure the initialization
function doesn't do anything.

This patch implemented this semantics.
---
 clang/include/clang/Basic/Module.h|  6 +++
 clang/lib/Basic/Module.cpp|  2 +-
 clang/lib/CodeGen/CGDeclCXX.cpp   |  7 ++-
 clang/lib/Sema/Sema.cpp   | 21 
 clang/lib/Serialization/ASTReader.cpp |  2 +
 clang/lib/Serialization/ASTWriter.cpp |  4 +-
 .../module-initializer-guard-elision.cpp  | 53 ++-
 7 files changed, 79 insertions(+), 16 deletions(-)

diff --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index edbd2dfc2973e92..b6303cb54b9434f 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -358,6 +358,10 @@ class alignas(8) Module {
   /// to a regular (public) module map.
   unsigned ModuleMapIsPrivate : 1;
 
+  /// Whether this C++20 named modules doesn't need an initializer.
+  /// This is only meaningful for C++20 modules.
+  unsigned NamedModuleNoInit : 1;
+
   /// Describes the visibility of the various names within a
   /// particular module.
   enum NameVisibilityKind {
@@ -596,6 +600,8 @@ class alignas(8) Module {
 return Kind == ModuleInterfaceUnit || Kind == ModulePartitionInterface;
   }
 
+  bool isNamedModuleInterfaceNoInit() const { return NamedModuleNoInit; }
+
   /// Get the primary module interface name from a partition.
   StringRef getPrimaryModuleInterfaceName() const {
 // Technically, global module fragment belongs to global module. And global
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index 4e6fbfc754b9173..82769f95bca90aa 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -44,7 +44,7 @@ Module::Module(StringRef Name, SourceLocation DefinitionLoc, 
Module *Parent,
   InferSubmodules(false), InferExplicitSubmodules(false),
   InferExportWildcard(false), ConfigMacrosExhaustive(false),
   NoUndeclaredIncludes(false), ModuleMapIsPrivate(false),
-  NameVisibility(Hidden) {
+  NamedModuleNoInit(false), NameVisibility(Hidden) {
   if (Parent) {
 IsAvailable = Parent->isAvailable();
 IsUnimportable = Parent->isUnimportable();
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 80543ba6311de45..a163069adf7c62c 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -675,6 +675,10 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) 
{
 // No Itanium initializer in header like modules.
 if (M->isHeaderLikeModule())
   continue; // TODO: warn of mixed use of module map modules and C++20?
+// We're allowed to skip the initialization if we are sure it doesn't
+// do any thing.
+if (M->isNamedModuleInterfaceNoInit())
+  continue;
 llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
 SmallString<256> FnName;
 {
@@ -731,8 +735,7 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
 // If we have a completely empty initializer then we do not want to create
 // the guard variable.
 ConstantAddress GuardAddr = ConstantAddress::invalid();
-if (!AllImports.empty() || !PrioritizedCXXGlobalInits.empty() ||
-!CXXGlobalInits.empty()) {
+if (!ModuleInits.empty()) {
   // Create the guard var.
   llvm::GlobalVariable *Guard = new llvm::GlobalVariable(
   getModule(), Int8Ty, /*isConstant=*/false,
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index a401017d4c1c0b8..faecaa755f1bd8c 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -1245,6 +1245,27 @@ void Sema::ActOnEndOfTranslationUnit() {
   }
 }
 
+// Now we can decide whether the modules we're building need an 
initializer.
+if (Module *CurrentModule = getCurrentModule();
+CurrentModule && CurrentModule->isInterfaceOrPartition()) {
+  auto DoesModNeedInit = [this](Module *M) {
+if (!getASTContext().getModuleInitializers(M).empty())
+  return false;
+for (auto [Exported, _] : M->Exports)
+  if (!Exported->isNamedModuleInterfaceNoInit())
+return false;
+for (Module *I : M->Imports)
+  if (!I->isNamedModuleInterfaceNoInit())
+retur

[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits


@@ -0,0 +1,320 @@
+//===- llvm/ADT/PagedVector.h - 'Lazyly allocated' vectors *- 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 defines the PagedVector class.
+//
+//===--===//
+#ifndef LLVM_ADT_PAGEDVECTOR_H
+#define LLVM_ADT_PAGEDVECTOR_H
+
+#include "llvm/ADT/PointerIntPair.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/Allocator.h"
+#include 
+#include 
+
+namespace llvm {
+/// A vector that allocates memory in pages.
+///
+/// Order is kept, but memory is allocated only when one element of the page is
+/// accessed. This introduces a level of indirection, but it is useful when you
+/// have a sparsely initialised vector where the full size is allocated 
upfront.
+///
+/// As a side effect the elements are initialised later than in a normal 
vector.
+/// On the first access to one of the elements of a given page all, the 
elements
+/// of the page are initialised. This also means that the elements of the page
+/// are initialised beyond the size of the vector.
+///
+/// Similarly on destruction the elements are destroyed only when the page is
+/// not needed anymore, delaying invoking the destructor of the elements.
+///
+/// Notice that this does not have iterators, because if you have iterators it
+/// probably means you are going to touch all the memory in any case, so better
+/// use a std::vector in the first place.
+template  class PagedVector {
+  static_assert(PageSize > 1, "PageSize must be greater than 0. Most likely "
+  "you want it to be greater than 16.");
+  /// The actual number of element in the vector which can be accessed.
+  size_t Size = 0;
+
+  /// The position of the initial element of the page in the Data vector.
+  /// Pages are allocated contiguously in the Data vector.
+  mutable SmallVector PageToDataPtrs;
+  /// Actual page data. All the page elements are added to this vector on the
+  /// first access of any of the elements of the page. Elements default
+  /// constructed and elements of the page are stored contiguously. The order 
of
+  /// the elements however depends on the order of access of the pages.
+  PointerIntPair Allocator;
+
+  constexpr static T *InvalidPage = nullptr;
+
+public:
+  using value_type = T;
+
+  /// Default constructor. We build our own allocator and mark it as such with
+  /// `true` in the second pair element.
+  PagedVector() : Allocator(new BumpPtrAllocator, true) {}
+  PagedVector(BumpPtrAllocator *A) : Allocator(A, false) {
+assert(A != nullptr && "Allocator cannot be null");
+  }
+
+  ~PagedVector() {
+clear();
+// If we own the allocator, delete it.
+if (Allocator.getInt())
+  delete Allocator.getPointer();
+  }
+
+  /// Look up an element at position `Index`.
+  /// If the associated page is not filled, it will be filled with default
+  /// constructed elements. If the associated page is filled, return the
+  /// element.
+  T &operator[](size_t Index) const {
+assert(Index < Size);
+assert(Index / PageSize < PageToDataPtrs.size());
+T *&PagePtr = PageToDataPtrs[Index / PageSize];
+// If the page was not yet allocated, allocate it.
+if (PagePtr == InvalidPage) {
+  T *NewPagePtr = Allocator.getPointer()->template Allocate(PageSize);
+  // We need to invoke the default constructor on all the elements of the
+  // page.
+  std::uninitialized_value_construct_n(NewPagePtr, PageSize);
+
+  PagePtr = NewPagePtr;
+}
+// Dereference the element in the page.
+return PagePtr[Index % PageSize];
+  }
+
+  /// Return the capacity of the vector. I.e. the maximum size it can be
+  /// expanded to with the resize method without allocating more pages.
+  [[nodiscard]] size_t capacity() const {
+return PageToDataPtrs.size() * PageSize;
+  }
+
+  /// Return the size of the vector. I.e. the maximum index that can be
+  /// accessed, i.e. the maximum value which was used as argument of the
+  /// resize method.
+  [[nodiscard]] size_t size() const { return Size; }
+
+  /// Resize the vector. Notice that the constructor of the elements will not
+  /// be invoked until an element of a given page is accessed, at which point
+  /// all the elements of the page will be constructed.
+  ///
+  /// If the new size is smaller than the current size, the elements of the
+  /// pages that are not needed anymore will be destroyed, however, elements of
+  /// the last page will not be destroyed.
+  ///
+  /// For these reason the usage of this vector is discouraged if you rely
+  /// on the construction / destructor of the elements to be invoked.
+ 

[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

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


[clang-tools-extra] [clang-tidy]: Add TagDecl into LastTagDeclRanges in UseUsingCheck only when it is a definition (PR #67639)

2023-09-28 Thread Qizhi Hu via cfe-commits

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


[clang] [clang][dataflow] Tweak styling of iteration tabs. (PR #67637)

2023-09-28 Thread Sam McCall via cfe-commits

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

thanks!

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


[clang] [analyzer] Move alpha checker EnumCastOutOfRange to optin (PR #67157)

2023-09-28 Thread Endre Fülöp via cfe-commits

gamesh411 wrote:

| OpenSource Project name | New Reports | Reports Lost | Evaluation of reports |
|||||
| memcached_1.6.8 | [New 
reports](https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=memcached_1.6.8_baseline&newcheck=memcached_1.6.8_with_enum_cast&is-unique=on&diff-mode=New)
 | [Lost 
reports](https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=memcached_1.6.8_baseline&newcheck=memcached_1.6.8_with_enum_cast&is-unique=on&diff-mode=Resolved)
 | no reports |
| tmux_2.6 | [New 
reports](https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=tmux_2.6_baseline&newcheck=tmux_2.6_with_enum_cast&is-unique=on&diff-mode=New)
 | [Lost 
reports](https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=tmux_2.6_baseline&newcheck=tmux_2.6_with_enum_cast&is-unique=on&diff-mode=Resolved)
 | no reports |
| curl_curl-7_66_0 | [New 
reports](https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=curl_curl-7_66_0_baseline&newcheck=curl_curl-7_66_0_with_enum_cast&is-unique=on&diff-mode=New)
 | [Lost 
reports](https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=curl_curl-7_66_0_baseline&newcheck=curl_curl-7_66_0_with_enum_cast&is-unique=on&diff-mode=Resolved)
 | 18 reports, all seem valid, even if some of them are just plain ugly macro 
expansion-wrapped madness |
| twin_v0.8.1 | [New 
reports](https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=twin_v0.8.1_baseline&newcheck=twin_v0.8.1_with_enum_cast&is-unique=on&diff-mode=New)
 | [Lost 
reports](https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=twin_v0.8.1_baseline&newcheck=twin_v0.8.1_with_enum_cast&is-unique=on&diff-mode=Resolved)
 | 2 reports, 1 is flag type usage, so this project would want NOT want to opt 
into this checker
| vim_v8.2.1920 | [New 
reports](https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=vim_v8.2.1920_baseline&newcheck=vim_v8.2.1920_with_enum_cast&is-unique=on&diff-mode=New)
 | [Lost 
reports](https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=vim_v8.2.1920_baseline&newcheck=vim_v8.2.1920_with_enum_cast&is-unique=on&diff-mode=Resolved)
 | 29 reports, valid, but not really useful for this project |
| openssl_openssl-3.0.0 | [New 
reports](https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=openssl_openssl-3.0.0-alpha7_baseline&newcheck=openssl_openssl-3.0.0-alpha7_with_enum_cast&is-unique=on&diff-mode=New)
 | [Lost 
reports](https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=openssl_openssl-3.0.0-alpha7_baseline&newcheck=openssl_openssl-3.0.0-alpha7_with_enum_cast&is-unique=on&diff-mode=Resolved)
 | no reports |
| sqlite_version-3.33.0 | [New 
reports](https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=sqlite_version-3.33.0_baseline&newcheck=sqlite_version-3.33.0_with_enum_cast&is-unique=on&diff-mode=New)
 | [Lost 
reports](https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=sqlite_version-3.33.0_baseline&newcheck=sqlite_version-3.33.0_with_enum_cast&is-unique=on&diff-mode=Resolved)
 | no reports |
| ffmpeg_n4.3.1 | [New 
reports](https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=ffmpeg_n4.3.1_baseline&newcheck=ffmpeg_n4.3.1_with_enum_cast&is-unique=on&diff-mode=New)
 | [Lost 
reports](https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=ffmpeg_n4.3.1_baseline&newcheck=ffmpeg_n4.3.1_with_enum_cast&is-unique=on&diff-mode=Resolved)
 | 39 reports, not really useful or understandable |
| postgres_REL_13_0 | [New 
reports](https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=postgres_REL_13_0_baseline&newcheck=postgres_REL_13_0_with_enum_cast&is-unique=on&diff-mode=New)
 | [Lost 
reports](https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=postgres_REL_13_0_baseline&newcheck=postgres_REL_13_0_with_enum_cast&is-unique=on&diff-mode=Resolved)
 | 16 reports, they valid from the coding style enforcing POV |
| tinyxml2_8.0.0 | [New 
reports](https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=tinyxml2_8.0.0_baseline&newcheck=tinyxml2_8.0.0_with_enum_cast&is-unique=on&diff-mode=New)
 | [Lost 
reports](https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=tinyxml2_8.0.0_baseline&newcheck=tinyxml2_8.0.0_with_enum_cast&is-unique=on&diff-mode=Resolved)
 | no reports |
| libwebm_libwebm-1.0.0.27 | [New 
reports](https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=libwebm_libwebm-1.0.0.27_baseline&newcheck=libwebm_libwebm-1.0.0.27_with_enum_cast&is-unique=on&diff-mode=New)
 | [Lost 
reports](https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=libwebm_libwebm-1.0.0.27_baseline&newcheck=libwebm_libwebm-1.0.0.27_with_enum_cast&is-unique=on&diff-mode=Resolved)
 | no reports |
| xerces_v3.2.3 | [New 
reports](https://codechecker-de

[clang] [clang][dataflow] Show triangle in `` element. (PR #67431)

2023-09-28 Thread Sam McCall via cfe-commits


@@ -122,10 +122,22 @@ code.line:has(.bb-select):before {
   font-size: x-small;
   flex-grow: 1;
 }
-.value summary {
+.value > summary {
   background-color: #ace;
   display: flex;
-  justify-content: space-between;
+  justify-content: start;

sam-mccall wrote:

this should be `flex-start` rather than `start`, but it doesn't matter because 
`flex-start` is the default, you can just remove it

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


[clang] [C++20] [Modules] Don't generate call to an imported module that dont init anything (PR #67638)

2023-09-28 Thread Iain Sandoe via cfe-commits

https://github.com/iains commented:

Thanks for working on this.

Generally, this LGTM, but perhaps we can choose names that are unambiguously 
related to state - the current one could be read like an action.

maybe something like:

`NamedModuleHasNoInit`
and
`namedModuleHasNoInit()`

(or I'm open to other suggestions) .. 


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


[clang] 3cbadc5 - [clang][dataflow] Tweak styling of iteration tabs. (#67637)

2023-09-28 Thread via cfe-commits

Author: martinboehme
Date: 2023-09-28T10:34:00+02:00
New Revision: 3cbadc5cdac0bef79c0a640eb015eed93fd6a909

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

LOG: [clang][dataflow] Tweak styling of iteration tabs. (#67637)

- On non-selected tabs, set cursor to 'pointer' to indicate they're
clickable

- Selected tab shares the same background as the contents to emphasize
that it's
associated with that content. (Compare with Google Chrome or VS Code,
which do
  this similarly.)

- Hovered-over tab becomes slightly brighter to indicate that clicking
it will
  make it even brighter (again, Chrome does this in a similar way).

Example:


![image](https://github.com/llvm/llvm-project/assets/29098113/e588068d-edff-49a8-b468-09dbb3255c3e)

(Mouse cursor is over "Iteration 2", but unfortunately I couldn't get
the screenshot to include the cursor.)

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/HTMLLogger.css

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
index c8212df1f94b81a..0ac1902ea4651ec 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
@@ -64,15 +64,16 @@ section h2 {
   text-align: center;
 }
 #iterations .chooser:not(.iter-select).hover {
-  background-color: #aaa;
+  background-color: #ddd;
 }
 #iterations .iter-select {
   font-weight: bold;
-  background-color: #ccc;
 }
 #iterations .chooser:not(.iter-select) {
   text-decoration: underline;
   color: blue;
+  cursor: pointer;
+  background-color: #ccc;
 }
 
 code.filename {



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


[clang] [clang][dataflow] Tweak styling of iteration tabs. (PR #67637)

2023-09-28 Thread via cfe-commits

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


[clang-tools-extra] [clang-tidy]: Add TagDecl into LastTagDeclRanges in UseUsingCheck only when it is a definition (PR #67639)

2023-09-28 Thread Piotr Zegar via cfe-commits

PiotrZSL wrote:

Release note entry would be welcome.

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


[PATCH] D156344: Disable call to fma for soft-float

2023-09-28 Thread Kishan Parmar via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG696ea67f197f: Disable call to fma for soft-float (authored 
by long5hot).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156344

Files:
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/ppcsoftops.ll


Index: llvm/test/CodeGen/PowerPC/ppcsoftops.ll
===
--- llvm/test/CodeGen/PowerPC/ppcsoftops.ll
+++ llvm/test/CodeGen/PowerPC/ppcsoftops.ll
@@ -51,4 +51,25 @@
   ; CHECK-LABEL:  __divdf3
 }
 
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local zeroext i32 @func(double noundef %0, double noundef %1) #0 {
+  %3 = alloca double, align 8
+  %4 = alloca double, align 8
+  store double %0, ptr %3, align 8
+  store double %1, ptr %4, align 8
+  %5 = load double, ptr %3, align 8
+  %6 = load double, ptr %4, align 8
+  %7 = fneg double %6
+  %8 = call double @llvm.fmuladd.f64(double %7, double 0x41F0, 
double %5)
+  %9 = fptoui double %8 to i32
+  ret i32 %9
+
+  ; CHECK-LABEL:  __muldf3
+  ; CHECK-LABEL:  __adddf3
+}
+
+; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn 
memory(none)
+declare double @llvm.fmuladd.f64(double, double, double) #1
+
 attributes #0 = {"use-soft-float"="true" }
+attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn 
memory(none) }
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -17297,7 +17297,7 @@
 
 bool PPCTargetLowering::isFMAFasterThanFMulAndFAdd(const Function &F,
Type *Ty) const {
-  if (Subtarget.hasSPE())
+  if (Subtarget.hasSPE() || Subtarget.useSoftFloat())
 return false;
   switch (Ty->getScalarType()->getTypeID()) {
   case Type::FloatTyID:


Index: llvm/test/CodeGen/PowerPC/ppcsoftops.ll
===
--- llvm/test/CodeGen/PowerPC/ppcsoftops.ll
+++ llvm/test/CodeGen/PowerPC/ppcsoftops.ll
@@ -51,4 +51,25 @@
   ; CHECK-LABEL:  __divdf3
 }
 
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local zeroext i32 @func(double noundef %0, double noundef %1) #0 {
+  %3 = alloca double, align 8
+  %4 = alloca double, align 8
+  store double %0, ptr %3, align 8
+  store double %1, ptr %4, align 8
+  %5 = load double, ptr %3, align 8
+  %6 = load double, ptr %4, align 8
+  %7 = fneg double %6
+  %8 = call double @llvm.fmuladd.f64(double %7, double 0x41F0, double %5)
+  %9 = fptoui double %8 to i32
+  ret i32 %9
+
+  ; CHECK-LABEL:  __muldf3
+  ; CHECK-LABEL:  __adddf3
+}
+
+; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
+declare double @llvm.fmuladd.f64(double, double, double) #1
+
 attributes #0 = {"use-soft-float"="true" }
+attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -17297,7 +17297,7 @@
 
 bool PPCTargetLowering::isFMAFasterThanFMulAndFAdd(const Function &F,
Type *Ty) const {
-  if (Subtarget.hasSPE())
+  if (Subtarget.hasSPE() || Subtarget.useSoftFloat())
 return false;
   switch (Ty->getScalarType()->getTypeID()) {
   case Type::FloatTyID:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-repl] Emit const variables only once (PR #65257)

2023-09-28 Thread Iain Sandoe via cfe-commits

https://github.com/iains commented:

(still getting used to the revised system)
I have no comments on this patch.


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


[clang-tools-extra] [clang-tidy]: Add TagDecl into LastTagDeclRanges in UseUsingCheck only when it is a definition (PR #67639)

2023-09-28 Thread Qizhi Hu via cfe-commits

https://github.com/jcsxky updated 
https://github.com/llvm/llvm-project/pull/67639

>From 208ecd283322e5533b91d04a6a057062e14f4e18 Mon Sep 17 00:00:00 2001
From: huqizhi 
Date: Thu, 28 Sep 2023 15:35:35 +0800
Subject: [PATCH] [clang-tidy]: Add TagDecl into LastTagDeclRanges in
 UseUsingCheck only when it is a definition

---
 clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp  | 3 ++-
 clang-tools-extra/docs/ReleaseNotes.rst   | 4 
 .../test/clang-tidy/checkers/modernize/use-using.cpp  | 4 
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
index 22dc9e21cab9d5a..e6293ed48bfddbb 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -61,7 +61,8 @@ void UseUsingCheck::check(const MatchFinder::MatchResult 
&Result) {
 // before the typedef will be the nested one (PR#50990). Therefore, we also
 // keep track of the parent declaration, so that we can look up the last
 // TagDecl that is a sibling of the typedef in the AST.
-LastTagDeclRanges[ParentDecl] = MatchedTagDecl->getSourceRange();
+if (MatchedTagDecl->isThisDeclarationADefinition())
+  LastTagDeclRanges[ParentDecl] = MatchedTagDecl->getSourceRange();
 return;
   }
 
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 8fc28c090341802..ae9896778a9119f 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -321,6 +321,10 @@ Changes in existing checks
   ` check to
   identify calls to static member functions with out-of-class inline 
definitions.
 
+- Improved :doc:`modernize-use-using
+  ` check to fix forward declared
+  ``typedef`` correctly.
+
 Removed checks
 ^^
 
diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
index f7db0af6434ac42..422abee11a71962 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
@@ -321,3 +321,7 @@ typedef bool (*ISSUE_65055_2)(int);
 // CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use 'using' instead of 'typedef'
 // CHECK-FIXES: {{^}}using ISSUE_65055_1 = void (*)(int);{{$}}
 // CHECK-FIXES: {{^}}using ISSUE_65055_2 = bool (*)(int);{{$}}
+
+typedef class ISSUE_67529_1 *ISSUE_67529;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using ISSUE_67529 = class ISSUE_67529_1 *;

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


[clang-tools-extra] [clang-tidy]: Add TagDecl into LastTagDeclRanges in UseUsingCheck only when it is a definition (PR #67639)

2023-09-28 Thread Qizhi Hu via cfe-commits

jcsxky wrote:

> Release note entry would be welcome.

updated

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


[clang] [clang][dataflow] Show triangle in `` element. (PR #67431)

2023-09-28 Thread via cfe-commits

https://github.com/martinboehme updated 
https://github.com/llvm/llvm-project/pull/67431

>From fe52a064d08bb9e328eafe70ddd7edf21931408e Mon Sep 17 00:00:00 2001
From: Martin Braenne 
Date: Tue, 26 Sep 2023 14:07:14 +
Subject: [PATCH 1/3] [clang][dataflow] Show triangle in `` element.

Also, change the mouse cursor into a pointer instead of a text cursor.

This makes it more discoverable that the element can be opened and closed.
---
 clang/lib/Analysis/FlowSensitive/HTMLLogger.css  | 14 +-
 clang/lib/Analysis/FlowSensitive/HTMLLogger.html |  2 +-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
index c8212df1f94b81a..73f639eac6836ec 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
@@ -122,10 +122,22 @@ code.line:has(.bb-select):before {
   font-size: x-small;
   flex-grow: 1;
 }
-.value summary {
+.value > summary {
   background-color: #ace;
   display: flex;
   justify-content: space-between;
+  cursor: pointer;
+}
+.value > summary::before {
+  content: '►';
+  margin-right: 0.5em;
+  font-size: 0.9em;
+}
+.value[open] > summary::before {
+  content: '▼';
+}
+.value > summary > .location {
+  margin-left: auto;
 }
 .value .address {
   font-size: xx-small;
diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.html 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
index 87695623cb318b2..6d866d57e144866 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
@@ -18,7 +18,7 @@
 #{{v.value_id}}
   
   
-{{v.type}} @{{v.location}}
+{{v.type}} @{{v.location}}
   
 
 From a46b2cda38ea1c913b146621d12f0023dac8d28b Mon Sep 17 00:00:00 2001
From: Martin Braenne 
Date: Thu, 28 Sep 2023 07:41:19 +
Subject: [PATCH 2/3] Change `justify-content` from `space-between` to `start`

---
 clang/lib/Analysis/FlowSensitive/HTMLLogger.css | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
index 73f639eac6836ec..d8952531bb79582 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
@@ -125,7 +125,7 @@ code.line:has(.bb-select):before {
 .value > summary {
   background-color: #ace;
   display: flex;
-  justify-content: space-between;
+  justify-content: start;
   cursor: pointer;
 }
 .value > summary::before {

>From ef42baa8532487c66c19ee5d72fc3a574fe7880c Mon Sep 17 00:00:00 2001
From: Martin Braenne 
Date: Thu, 28 Sep 2023 08:45:21 +
Subject: [PATCH 3/3] Remove `justify-content` entirely. The default works for
 us.

---
 clang/lib/Analysis/FlowSensitive/HTMLLogger.css | 1 -
 1 file changed, 1 deletion(-)

diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
index d8952531bb79582..ee8bcebbcbc532d 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
@@ -125,7 +125,6 @@ code.line:has(.bb-select):before {
 .value > summary {
   background-color: #ace;
   display: flex;
-  justify-content: start;
   cursor: pointer;
 }
 .value > summary::before {

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


[clang] [analyzer] Move alpha checker EnumCastOutOfRange to optin (PR #67157)

2023-09-28 Thread Endre Fülöp via cfe-commits

https://github.com/gamesh411 approved this pull request.


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


[clang] [clang][dataflow] Show triangle in `` element. (PR #67431)

2023-09-28 Thread via cfe-commits


@@ -122,10 +122,22 @@ code.line:has(.bb-select):before {
   font-size: x-small;
   flex-grow: 1;
 }
-.value summary {
+.value > summary {
   background-color: #ace;
   display: flex;
-  justify-content: space-between;
+  justify-content: start;

martinboehme wrote:

Got it -- done.

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


[clang] [clang][dataflow] Show triangle in `` element. (PR #67431)

2023-09-28 Thread via cfe-commits

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


[clang-tools-extra] [clangd] Add tweak for turning an unscoped into a scoped enum (PR #67645)

2023-09-28 Thread via cfe-commits

https://github.com/ckandeler created 
https://github.com/llvm/llvm-project/pull/67645

None

>From c61f7907dc30927ae6e7819f4eb7e003cd47e256 Mon Sep 17 00:00:00 2001
From: Christian Kandeler 
Date: Mon, 25 Sep 2023 16:55:53 +0200
Subject: [PATCH] [clangd] Add tweak for turning an unscoped into a scoped enum

---
 .../clangd/refactor/tweaks/CMakeLists.txt |   1 +
 .../clangd/refactor/tweaks/ScopifyEnum.cpp| 222 ++
 .../clangd/unittests/CMakeLists.txt   |   1 +
 .../unittests/tweaks/ScopifyEnumTests.cpp |  58 +
 4 files changed, 282 insertions(+)
 create mode 100644 clang-tools-extra/clangd/refactor/tweaks/ScopifyEnum.cpp
 create mode 100644 
clang-tools-extra/clangd/unittests/tweaks/ScopifyEnumTests.cpp

diff --git a/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt 
b/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
index 526a073f619ea34..2e948c23569f686 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
+++ b/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
@@ -27,6 +27,7 @@ add_clang_library(clangDaemonTweaks OBJECT
   PopulateSwitch.cpp
   RawStringLiteral.cpp
   RemoveUsingNamespace.cpp
+  ScopifyEnum.cpp
   SpecialMembers.cpp
   SwapIfBranches.cpp
 
diff --git a/clang-tools-extra/clangd/refactor/tweaks/ScopifyEnum.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/ScopifyEnum.cpp
new file mode 100644
index 000..e2df1f9a9f11e32
--- /dev/null
+++ b/clang-tools-extra/clangd/refactor/tweaks/ScopifyEnum.cpp
@@ -0,0 +1,222 @@
+//===--- ScopifyEnum.cpp --- -*- 
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 "ParsedAST.h"
+#include "XRefs.h"
+#include "refactor/Tweak.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+
+#include 
+
+namespace clang::clangd {
+namespace {
+
+/// Turns an unscoped into a scoped enum type.
+/// Before:
+///   enum E { EV1, EV2 };
+///^
+///   void f() { E e1 = EV1; }
+///
+/// After:
+///   enum class E { EV1, EV2 };
+///   void f() { E e1 = E::EV1; }
+///
+/// Note that the respective project code might not compile anymore
+/// if it made use of the now-gone implicit conversion to int.
+/// This is out of scope for this tweak.
+///
+/// TODO: In the above example, we could detect that the values
+///   start with the enum name, and remove that prefix.
+
+class ScopifyEnum : public Tweak {
+  const char *id() const final;
+  std::string title() const override { return "Convert to scoped enum"; }
+  llvm::StringLiteral kind() const override {
+return CodeAction::REFACTOR_KIND;
+  }
+  bool prepare(const Selection &Inputs) override;
+  Expected apply(const Selection &Inputs) override;
+
+  using MakeReplacement =
+  std::function;
+  llvm::Error addClassKeywordToDeclarations();
+  llvm::Error scopifyEnumValues();
+  llvm::Error scopifyEnumValue(const EnumConstantDecl &CD, StringRef Prefix);
+  llvm::Expected getContentForFile(StringRef FilePath);
+  unsigned getOffsetFromPosition(const Position &Pos, StringRef Content) const;
+  llvm::Error addReplacementForReference(const ReferencesResult::Reference 
&Ref,
+ const MakeReplacement 
&GetReplacement);
+  llvm::Error addReplacement(StringRef FilePath, StringRef Content,
+ const tooling::Replacement &Replacement);
+  Position getPosition(const Decl &D) const;
+
+  const EnumDecl *D = nullptr;
+  const Selection *S = nullptr;
+  SourceManager *SM = nullptr;
+  llvm::SmallVector> ExtraBuffers;
+  llvm::StringMap ContentPerFile;
+  Effect E;
+};
+
+REGISTER_TWEAK(ScopifyEnum)
+
+bool ScopifyEnum::prepare(const Selection &Inputs) {
+  if (!Inputs.AST->getLangOpts().CPlusPlus11)
+return false;
+  const SelectionTree::Node *N = Inputs.ASTSelection.commonAncestor();
+  if (!N)
+return false;
+  D = N->ASTNode.get();
+  return D && !D->isScoped() && D->isThisDeclarationADefinition();
+}
+
+Expected ScopifyEnum::apply(const Selection &Inputs) {
+  S = &Inputs;
+  SM = &S->AST->getSourceManager();
+  E.FormatEdits = false;
+  ContentPerFile.insert(std::make_pair(SM->getFilename(D->getLocation()),
+   
SM->getBufferData(SM->getMainFileID(;
+
+  if (auto Err = addClassKeywordToDeclarations())
+return Err;
+  if (auto Err = scopifyEnumValues())
+return Err;
+
+  return E;
+}
+
+llvm::Error ScopifyEnum::addClassKeywordToDeclarations() {
+  for (const auto &Ref :
+   findReferences(*S->AST, getPosition(*D), 0, S->Index, false)
+   .References) {
+if (!(Ref.Attribu

[clang-tools-extra] [clang-tidy]: Add TagDecl into LastTagDeclRanges in UseUsingCheck only when it is a definition (PR #67639)

2023-09-28 Thread Piotr Zegar via cfe-commits


@@ -321,6 +321,10 @@ Changes in existing checks
   ` check to
   identify calls to static member functions with out-of-class inline 
definitions.
 
+- Improved :doc:`modernize-use-using

PiotrZSL wrote:

put this in alphabetical order

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


[clang-tools-extra] [clang-tidy]: Add TagDecl into LastTagDeclRanges in UseUsingCheck only when it is a definition (PR #67639)

2023-09-28 Thread Piotr Zegar via cfe-commits

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


[clang] [clang][dataflow] Show triangle in `` element. (PR #67431)

2023-09-28 Thread via cfe-commits

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


[clang] fb933fc - [clang][dataflow] Show triangle in `` element. (#67431)

2023-09-28 Thread via cfe-commits

Author: martinboehme
Date: 2023-09-28T10:55:02+02:00
New Revision: fb933fc6d76de854cb9eadf984f8900b9304d347

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

LOG: [clang][dataflow] Show triangle in `` element. (#67431)

Also, change the mouse cursor into a pointer instead of a text cursor.

This makes it more discoverable that the element can be opened and
closed.

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/HTMLLogger.css
clang/lib/Analysis/FlowSensitive/HTMLLogger.html

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
index 0ac1902ea4651ec..9737d1416f22abe 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
@@ -123,10 +123,21 @@ code.line:has(.bb-select):before {
   font-size: x-small;
   flex-grow: 1;
 }
-.value summary {
+.value > summary {
   background-color: #ace;
   display: flex;
-  justify-content: space-between;
+  cursor: pointer;
+}
+.value > summary::before {
+  content: '►';
+  margin-right: 0.5em;
+  font-size: 0.9em;
+}
+.value[open] > summary::before {
+  content: '▼';
+}
+.value > summary > .location {
+  margin-left: auto;
 }
 .value .address {
   font-size: xx-small;

diff  --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.html 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
index 87695623cb318b2..6d866d57e144866 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
@@ -18,7 +18,7 @@
 #{{v.value_id}}
   
   
-{{v.type}} @{{v.location}}
+{{v.type}} @{{v.location}}
   
 
 https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy]: Add TagDecl into LastTagDeclRanges in UseUsingCheck only when it is a definition (PR #67639)

2023-09-28 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL approved this pull request.

Fix release notes, update change description (commit) to describe what was a 
problem. Mainly why isThisDeclarationADefinition is needed.
After that leave it open for few days before pushing, so someone else could 
also look into this and provide some comments if needed.

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


[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits


@@ -0,0 +1,301 @@
+//===- llvm/ADT/PagedVector.h - 'Lazyly allocated' vectors *- 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 defines the PagedVector class.
+//
+//===--===//
+#ifndef LLVM_ADT_PAGEDVECTOR_H
+#define LLVM_ADT_PAGEDVECTOR_H
+
+#include "llvm/ADT/PointerIntPair.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/Allocator.h"
+#include 
+#include 
+
+namespace llvm {
+/// A vector that allocates memory in pages.
+///
+/// Order is kept, but memory is allocated only when one element of the page is
+/// accessed. This introduces a level of indirection, but it is useful when you
+/// have a sparsely initialised vector where the full size is allocated 
upfront.
+///
+/// As a side effect the elements are initialised later than in a normal 
vector.
+/// On the first access to one of the elements of a given page, all the 
elements
+/// of the page are initialised. This also means that the elements of the page
+/// are initialised beyond the size of the vector.
+///
+/// Similarly on destruction the elements are destroyed only when the page is
+/// not needed anymore, delaying invoking the destructor of the elements.
+///
+/// Notice that this has iterators only on materialised elements. This
+/// is deliberately done under the assumption you would dereference the 
elements
+/// while iterating, therefore materialising them and losing the gains in terms
+/// of memory usage this container provides. If you have such a use case, you
+/// probably want to use a normal std::vector or a llvm::SmallVector.
+template  class PagedVector {
+  static_assert(PageSize > 1, "PageSize must be greater than 0. Most likely "
+  "you want it to be greater than 16.");
+  /// The actual number of elements in the vector which can be accessed.
+  size_t Size = 0;
+
+  /// The position of the initial element of the page in the Data vector.
+  /// Pages are allocated contiguously in the Data vector.
+  mutable SmallVector PageToDataPtrs;
+  /// Actual page data. All the page elements are allocated on the
+  /// first access of any of the elements of the page. Elements are default
+  /// constructed and elements of the page are stored contiguously. The order 
of
+  /// the elements however depends on the order of access of the pages.
+  PointerIntPair Allocator;
+
+  constexpr static T *InvalidPage = nullptr;
+
+public:
+  using value_type = T;
+
+  /// Default constructor. We build our own allocator and mark it as such with
+  /// `true` in the second pair element.
+  PagedVector() : Allocator(new BumpPtrAllocator, true) {}
+  PagedVector(BumpPtrAllocator *A) : Allocator(A, false) {
+assert(A != nullptr && "Allocator cannot be null");
+  }
+
+  ~PagedVector() {
+clear();
+// If we own the allocator, delete it.
+if (Allocator.getInt())
+  delete Allocator.getPointer();
+  }
+
+  // Forbid copy and move as we do not need them for the current use case.
+  PagedVector(const PagedVector &) = delete;
+  PagedVector(PagedVector &&) = delete;
+  PagedVector &operator=(const PagedVector &) = delete;
+  PagedVector &operator=(PagedVector &&) = delete;
+
+  /// Look up an element at position `Index`.
+  /// If the associated page is not filled, it will be filled with default
+  /// constructed elements.
+  T &operator[](size_t Index) const {
+assert(Index < Size);
+assert(Index / PageSize < PageToDataPtrs.size());
+T *&PagePtr = PageToDataPtrs[Index / PageSize];
+// If the page was not yet allocated, allocate it.
+if (PagePtr == InvalidPage) {
+  T *NewPagePtr = Allocator.getPointer()->template Allocate(PageSize);
+  // We need to invoke the default constructor on all the elements of the
+  // page.
+  std::uninitialized_value_construct_n(NewPagePtr, PageSize);
+
+  PagePtr = NewPagePtr;
+}
+// Dereference the element in the page.
+return PagePtr[Index % PageSize];
+  }
+
+  /// Return the capacity of the vector. I.e. the maximum size it can be
+  /// expanded to with the resize method without allocating more pages.
+  [[nodiscard]] size_t capacity() const {
+return PageToDataPtrs.size() * PageSize;
+  }
+
+  /// Return the size of the vector. I.e. the maximum index that can be
+  /// accessed, i.e. the maximum value which was used as argument of the
+  /// resize method.
+  [[nodiscard]] size_t size() const { return Size; }
+
+  /// Resize the vector. Notice that the constructor of the elements will not
+  /// be invoked until an element of a given page is accessed, at which point
+  /// all the elements of the pa

[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits


@@ -0,0 +1,323 @@
+//===- llvm/ADT/PagedVector.h - 'Lazyly allocated' vectors *- 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 defines the PagedVector class.
+//
+//===--===//
+#ifndef LLVM_ADT_PAGEDVECTOR_H
+#define LLVM_ADT_PAGEDVECTOR_H
+
+#include "llvm/ADT/PointerIntPair.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/Allocator.h"
+#include 
+#include 
+
+namespace llvm {
+/// A vector that allocates memory in pages.
+///
+/// Order is kept, but memory is allocated only when one element of the page is
+/// accessed. This introduces a level of indirection, but it is useful when you
+/// have a sparsely initialised vector where the full size is allocated 
upfront.
+///
+/// As a side effect the elements are initialised later than in a normal 
vector.
+/// On the first access to one of the elements of a given page all, the 
elements
+/// of the page are initialised. This also means that the elements of the page
+/// are initialised beyond the size of the vector.
+///
+/// Similarly on destruction the elements are destroyed only when the page is
+/// not needed anymore, delaying invoking the destructor of the elements.
+///
+/// Notice that this does not have iterators, because if you have iterators it
+/// probably means you are going to touch all the memory in any case, so better
+/// use a std::vector in the first place.
+template  class PagedVector {
+  static_assert(PageSize > 1, "PageSize must be greater than 0. Most likely "
+  "you want it to be greater than 16.");
+  /// The actual number of element in the vector which can be accessed.
+  size_t Size = 0;
+
+  /// The position of the initial element of the page in the Data vector.
+  /// Pages are allocated contiguously in the Data vector.
+  mutable SmallVector PageToDataPtrs;

ktf wrote:

I will switch everything to nullptr and switch back.

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


[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

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


[clang-tools-extra] [clang-tidy]: Add TagDecl into LastTagDeclRanges in UseUsingCheck only when it is a definition (PR #67639)

2023-09-28 Thread Qizhi Hu via cfe-commits

https://github.com/jcsxky updated 
https://github.com/llvm/llvm-project/pull/67639

>From ee966ceb8d52c000ece8c04b87f791a71a5bfb07 Mon Sep 17 00:00:00 2001
From: huqizhi 
Date: Thu, 28 Sep 2023 15:35:35 +0800
Subject: [PATCH] [clang-tidy]: Add TagDecl into LastTagDeclRanges in
 UseUsingCheck only when it is a definition

---
 clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp  | 3 ++-
 clang-tools-extra/docs/ReleaseNotes.rst   | 4 ++--
 .../test/clang-tidy/checkers/modernize/use-using.cpp  | 4 
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
index 22dc9e21cab9d5a..e6293ed48bfddbb 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -61,7 +61,8 @@ void UseUsingCheck::check(const MatchFinder::MatchResult 
&Result) {
 // before the typedef will be the nested one (PR#50990). Therefore, we also
 // keep track of the parent declaration, so that we can look up the last
 // TagDecl that is a sibling of the typedef in the AST.
-LastTagDeclRanges[ParentDecl] = MatchedTagDecl->getSourceRange();
+if (MatchedTagDecl->isThisDeclarationADefinition())
+  LastTagDeclRanges[ParentDecl] = MatchedTagDecl->getSourceRange();
 return;
   }
 
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 8fc28c090341802..f921d408bf5d540 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -279,8 +279,8 @@ Changes in existing checks
   fixes for reordering arguments.
 
 - Improved :doc:`modernize-use-using
-  ` check to fix function pointer
-  ``typedef`` correctly.
+  ` check to fix function pointer and
+  forward declared ``typedef`` correctly.
 
 - Improved :doc:`performance-faster-string-find
   ` check to properly escape
diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
index f7db0af6434ac42..422abee11a71962 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-using.cpp
@@ -321,3 +321,7 @@ typedef bool (*ISSUE_65055_2)(int);
 // CHECK-MESSAGES: :[[@LINE-2]]:1: warning: use 'using' instead of 'typedef'
 // CHECK-FIXES: {{^}}using ISSUE_65055_1 = void (*)(int);{{$}}
 // CHECK-FIXES: {{^}}using ISSUE_65055_2 = bool (*)(int);{{$}}
+
+typedef class ISSUE_67529_1 *ISSUE_67529;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using ISSUE_67529 = class ISSUE_67529_1 *;

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


[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

https://github.com/ktf updated https://github.com/llvm/llvm-project/pull/66430

>From ccc518093f482dae800a9c3686e37d07b8b33895 Mon Sep 17 00:00:00 2001
From: Giulio Eulisse <10544+...@users.noreply.github.com>
Date: Thu, 14 Sep 2023 21:58:21 +0200
Subject: [PATCH] Introduce PagedVector class

The goal of the class is to be an (almost) drop in replacement for
SmallVector and std::vector when those are presized and filled later,
as it happens in SourceManager and ASTReader.

By splitting the actual vector in pages of the same size and allocating
the pages only when they are needed, using this containers reduces the
memory usage by a factor 4 for the cases relevant to the ALICE
experiment ROOT / cling usage.
---
 clang/include/clang/Basic/SourceManager.h |   3 +-
 clang/include/clang/Serialization/ASTReader.h |   5 +-
 clang/lib/Basic/SourceManager.cpp |  10 +-
 clang/lib/Serialization/ASTReader.cpp |   5 +-
 llvm/docs/ProgrammersManual.rst   |  34 ++
 llvm/include/llvm/ADT/PagedVector.h   | 282 +++
 llvm/unittests/ADT/CMakeLists.txt |   1 +
 llvm/unittests/ADT/PagedVectorTest.cpp| 342 ++
 8 files changed, 672 insertions(+), 10 deletions(-)
 create mode 100644 llvm/include/llvm/ADT/PagedVector.h
 create mode 100644 llvm/unittests/ADT/PagedVectorTest.cpp

diff --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index 2f846502d6f3327..e37caa2252532f9 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -43,6 +43,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -699,7 +700,7 @@ class SourceManager : public RefCountedBase {
   ///
   /// Negative FileIDs are indexes into this table. To get from ID to an index,
   /// use (-ID - 2).
-  SmallVector LoadedSLocEntryTable;
+  llvm::PagedVector LoadedSLocEntryTable;
 
   /// The starting offset of the next local SLocEntry.
   ///
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index dc1eb21c27801fe..65e19c6e44cf571 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -38,6 +38,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -487,7 +488,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the type with
   /// ID = (I + 1) << FastQual::Width has already been loaded
-  std::vector TypesLoaded;
+  llvm::PagedVector TypesLoaded;
 
   using GlobalTypeMapType =
   ContinuousRangeMap;
@@ -501,7 +502,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the declaration with ID
   /// = I + 1 has already been loaded.
-  std::vector DeclsLoaded;
+  llvm::PagedVector DeclsLoaded;
 
   using GlobalDeclMapType =
   ContinuousRangeMap;
diff --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 0521ac7b30339ab..7fa8b8096ac4931 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -2344,11 +2344,11 @@ SourceManager::MemoryBufferSizes 
SourceManager::getMemoryBufferSizes() const {
 }
 
 size_t SourceManager::getDataStructureSizes() const {
-  size_t size = llvm::capacity_in_bytes(MemBufferInfos)
-+ llvm::capacity_in_bytes(LocalSLocEntryTable)
-+ llvm::capacity_in_bytes(LoadedSLocEntryTable)
-+ llvm::capacity_in_bytes(SLocEntryLoaded)
-+ llvm::capacity_in_bytes(FileInfos);
+  size_t size = llvm::capacity_in_bytes(MemBufferInfos) +
+llvm::capacity_in_bytes(LocalSLocEntryTable) +
+llvm::capacity_in_bytes(LoadedSLocEntryTable) +
+llvm::capacity_in_bytes(SLocEntryLoaded) +
+llvm::capacity_in_bytes(FileInfos);
 
   if (OverriddenFilesInfo)
 size += llvm::capacity_in_bytes(OverriddenFilesInfo->OverriddenFiles);
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 0952244d037a77c..bb2a32ade0a0d7c 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -7944,9 +7944,10 @@ void ASTReader::PrintStats() {
   std::fprintf(stderr, "*** AST File Statistics:\n");
 
   unsigned NumTypesLoaded =
-  TypesLoaded.size() - llvm::count(TypesLoaded, QualType());
+  TypesLoaded.size() - llvm::count(TypesLoaded.materialized(), QualType());
   unsigned NumDeclsLoaded =
-  DeclsLoaded.size() - llvm::count(DeclsLoaded, (Decl *)nullptr);
+  DeclsLoaded.size() -
+  llvm::count(DeclsLoaded.materialized(), (D

[clang-tools-extra] [clang-tidy]: Add TagDecl into LastTagDeclRanges in UseUsingCheck only when it is a definition (PR #67639)

2023-09-28 Thread Piotr Zegar via cfe-commits

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


[libunwind] 63c1208 - [libunwind][nfc] Avoid type warning of debug printf (#67390)

2023-09-28 Thread via cfe-commits

Author: Kazushi Marukawa
Date: 2023-09-28T18:02:41+09:00
New Revision: 63c1208bce31ecf091fec922e56966b2af4f6839

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

LOG: [libunwind][nfc] Avoid type warning of debug printf (#67390)

Change PRIu32 to PRIxPTR to avoid type warning of debug printf since VE
uses 64 bits SjLj. I don't use PRIuPTR since the print message has
0x-prefix from the beginning. I also change related PRIuPTR to PRIxPTR
since those uses 0x-prefix too.

Added: 


Modified: 
libunwind/src/Unwind-sjlj.c

Removed: 




diff  --git a/libunwind/src/Unwind-sjlj.c b/libunwind/src/Unwind-sjlj.c
index 4d9a02699cddd78..7e8faf098fe14b1 100644
--- a/libunwind/src/Unwind-sjlj.c
+++ b/libunwind/src/Unwind-sjlj.c
@@ -427,7 +427,7 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetGR(struct 
_Unwind_Context *context,
 /// Called by personality handler during phase 2 to alter register values.
 _LIBUNWIND_EXPORT void _Unwind_SetGR(struct _Unwind_Context *context, int 
index,
  uintptr_t new_value) {
-  _LIBUNWIND_TRACE_API("_Unwind_SetGR(context=%p, reg=%d, value=0x%" PRIuPTR
+  _LIBUNWIND_TRACE_API("_Unwind_SetGR(context=%p, reg=%d, value=0x%" PRIxPTR
")",
(void *)context, index, new_value);
   _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
@@ -438,7 +438,7 @@ _LIBUNWIND_EXPORT void _Unwind_SetGR(struct _Unwind_Context 
*context, int index,
 /// Called by personality handler during phase 2 to get instruction pointer.
 _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) {
   _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
-  _LIBUNWIND_TRACE_API("_Unwind_GetIP(context=%p) => 0x%" PRIu32,
+  _LIBUNWIND_TRACE_API("_Unwind_GetIP(context=%p) => 0x%" PRIxPTR,
(void *)context, ufc->resumeLocation + 1);
   return ufc->resumeLocation + 1;
 }
@@ -451,7 +451,7 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIPInfo(struct 
_Unwind_Context *context,
   int *ipBefore) {
   _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
   *ipBefore = 0;
-  _LIBUNWIND_TRACE_API("_Unwind_GetIPInfo(context=%p, %p) => 0x%" PRIu32,
+  _LIBUNWIND_TRACE_API("_Unwind_GetIPInfo(context=%p, %p) => 0x%" PRIxPTR,
(void *)context, (void *)ipBefore,
ufc->resumeLocation + 1);
   return ufc->resumeLocation + 1;
@@ -461,7 +461,7 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIPInfo(struct 
_Unwind_Context *context,
 /// Called by personality handler during phase 2 to alter instruction pointer.
 _LIBUNWIND_EXPORT void _Unwind_SetIP(struct _Unwind_Context *context,
  uintptr_t new_value) {
-  _LIBUNWIND_TRACE_API("_Unwind_SetIP(context=%p, value=0x%" PRIuPTR ")",
+  _LIBUNWIND_TRACE_API("_Unwind_SetIP(context=%p, value=0x%" PRIxPTR ")",
(void *)context, new_value);
   _Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t) context;
   ufc->resumeLocation = new_value - 1;



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


[libunwind] [libunwind][nfc] Avoid type warning of debug printf (PR #67390)

2023-09-28 Thread Kazushi Marukawa via cfe-commits

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


[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

https://github.com/ktf updated https://github.com/llvm/llvm-project/pull/66430

>From c14aaf14cbcd292165aece38ebdae74ce92a4d32 Mon Sep 17 00:00:00 2001
From: Giulio Eulisse <10544+...@users.noreply.github.com>
Date: Thu, 14 Sep 2023 21:58:21 +0200
Subject: [PATCH] Introduce PagedVector class

The goal of the class is to be an (almost) drop in replacement for
SmallVector and std::vector when those are presized and filled later, as
it happens in SourceManager and ASTReader.

By doing so, sparsely accessed PagedVector can profit from reduced
memory footprint.
---
 clang/include/clang/Basic/SourceManager.h |   3 +-
 clang/include/clang/Serialization/ASTReader.h |   5 +-
 clang/lib/Basic/SourceManager.cpp |  10 +-
 clang/lib/Serialization/ASTReader.cpp |   5 +-
 llvm/docs/ProgrammersManual.rst   |  34 ++
 llvm/include/llvm/ADT/PagedVector.h   | 282 +++
 llvm/unittests/ADT/CMakeLists.txt |   1 +
 llvm/unittests/ADT/PagedVectorTest.cpp| 342 ++
 8 files changed, 672 insertions(+), 10 deletions(-)
 create mode 100644 llvm/include/llvm/ADT/PagedVector.h
 create mode 100644 llvm/unittests/ADT/PagedVectorTest.cpp

diff --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index 2f846502d6f3327..e37caa2252532f9 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -43,6 +43,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -699,7 +700,7 @@ class SourceManager : public RefCountedBase {
   ///
   /// Negative FileIDs are indexes into this table. To get from ID to an index,
   /// use (-ID - 2).
-  SmallVector LoadedSLocEntryTable;
+  llvm::PagedVector LoadedSLocEntryTable;
 
   /// The starting offset of the next local SLocEntry.
   ///
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index dc1eb21c27801fe..65e19c6e44cf571 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -38,6 +38,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -487,7 +488,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the type with
   /// ID = (I + 1) << FastQual::Width has already been loaded
-  std::vector TypesLoaded;
+  llvm::PagedVector TypesLoaded;
 
   using GlobalTypeMapType =
   ContinuousRangeMap;
@@ -501,7 +502,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the declaration with ID
   /// = I + 1 has already been loaded.
-  std::vector DeclsLoaded;
+  llvm::PagedVector DeclsLoaded;
 
   using GlobalDeclMapType =
   ContinuousRangeMap;
diff --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 0521ac7b30339ab..7fa8b8096ac4931 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -2344,11 +2344,11 @@ SourceManager::MemoryBufferSizes 
SourceManager::getMemoryBufferSizes() const {
 }
 
 size_t SourceManager::getDataStructureSizes() const {
-  size_t size = llvm::capacity_in_bytes(MemBufferInfos)
-+ llvm::capacity_in_bytes(LocalSLocEntryTable)
-+ llvm::capacity_in_bytes(LoadedSLocEntryTable)
-+ llvm::capacity_in_bytes(SLocEntryLoaded)
-+ llvm::capacity_in_bytes(FileInfos);
+  size_t size = llvm::capacity_in_bytes(MemBufferInfos) +
+llvm::capacity_in_bytes(LocalSLocEntryTable) +
+llvm::capacity_in_bytes(LoadedSLocEntryTable) +
+llvm::capacity_in_bytes(SLocEntryLoaded) +
+llvm::capacity_in_bytes(FileInfos);
 
   if (OverriddenFilesInfo)
 size += llvm::capacity_in_bytes(OverriddenFilesInfo->OverriddenFiles);
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 0952244d037a77c..bb2a32ade0a0d7c 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -7944,9 +7944,10 @@ void ASTReader::PrintStats() {
   std::fprintf(stderr, "*** AST File Statistics:\n");
 
   unsigned NumTypesLoaded =
-  TypesLoaded.size() - llvm::count(TypesLoaded, QualType());
+  TypesLoaded.size() - llvm::count(TypesLoaded.materialized(), QualType());
   unsigned NumDeclsLoaded =
-  DeclsLoaded.size() - llvm::count(DeclsLoaded, (Decl *)nullptr);
+  DeclsLoaded.size() -
+  llvm::count(DeclsLoaded.materialized(), (Decl *)nullptr);
   unsigned NumIdentifiersLoaded =
   IdentifiersLoaded.size() -
   llvm::count(IdentifiersLoaded, (IdentifierInfo *)nullptr);
d

[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

ktf wrote:

@zygoloid Ping. I think I have addressed all the remaining comments.

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


[clang-tools-extra] [clang-tidy]: Add TagDecl into LastTagDeclRanges in UseUsingCheck only when it is a definition (PR #67639)

2023-09-28 Thread Qizhi Hu via cfe-commits

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


[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

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


[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

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


[clang] 3214f7b - Revert "[clang][dataflow] Show triangle in `` element. (#67431)"

2023-09-28 Thread Martin Braenne via cfe-commits

Author: Martin Braenne
Date: 2023-09-28T09:07:20Z
New Revision: 3214f7bf6c6f1218404584b6c36bd3d4033eb22d

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

LOG: Revert "[clang][dataflow] Show triangle in `` element. (#67431)"

This reverts commit fb933fc6d76de854cb9eadf984f8900b9304d347.

The commit broke buildbots due to non-ASCII characters in
HTMLLogger.css.

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/HTMLLogger.css
clang/lib/Analysis/FlowSensitive/HTMLLogger.html

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
index 9737d1416f22abe..0ac1902ea4651ec 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
@@ -123,21 +123,10 @@ code.line:has(.bb-select):before {
   font-size: x-small;
   flex-grow: 1;
 }
-.value > summary {
+.value summary {
   background-color: #ace;
   display: flex;
-  cursor: pointer;
-}
-.value > summary::before {
-  content: '►';
-  margin-right: 0.5em;
-  font-size: 0.9em;
-}
-.value[open] > summary::before {
-  content: '▼';
-}
-.value > summary > .location {
-  margin-left: auto;
+  justify-content: space-between;
 }
 .value .address {
   font-size: xx-small;

diff  --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.html 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
index 6d866d57e144866..87695623cb318b2 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
@@ -18,7 +18,7 @@
 #{{v.value_id}}
   
   
-{{v.type}} @{{v.location}}
+{{v.type}} @{{v.location}}
   
 
 https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][RISCV] Support CSRs in clobbered registers of inline assembly (PR #67646)

2023-09-28 Thread Wang Pengcheng via cfe-commits

https://github.com/wangpc-pp created 
https://github.com/llvm/llvm-project/pull/67646

To match GCC's behaviors.

Fixes #67596


>From d37c233588aaa1ba0df29ffc9bc402a98254f2d2 Mon Sep 17 00:00:00 2001
From: wangpc 
Date: Thu, 28 Sep 2023 16:50:31 +0800
Subject: [PATCH] [Clang][RISCV] Support CSRs in clobbered registers of inline
 assembly

To match GCC's behaviors.

Fixes #67596
---
 clang/lib/Basic/Targets/RISCV.cpp |  8 +++-
 .../CodeGen/RISCV/riscv-inline-asm-clobber.c  | 44 +++
 2 files changed, 51 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGen/RISCV/riscv-inline-asm-clobber.c

diff --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index d55ab76395c8271..b8f0c262493c0b2 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -23,6 +23,7 @@ using namespace clang;
 using namespace clang::targets;
 
 ArrayRef RISCVTargetInfo::getGCCRegNames() const {
+  // clang-format off
   static const char *const GCCRegNames[] = {
   // Integer registers
   "x0",  "x1",  "x2",  "x3",  "x4",  "x5",  "x6",  "x7",
@@ -40,7 +41,12 @@ ArrayRef RISCVTargetInfo::getGCCRegNames() 
const {
   "v0",  "v1",  "v2",  "v3",  "v4",  "v5",  "v6",  "v7",
   "v8",  "v9",  "v10", "v11", "v12", "v13", "v14", "v15",
   "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23",
-  "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31"};
+  "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
+
+  // CSRs
+  "fflags", "frm", "vtype", "vl", "vxsat", "vxrm"
+  };
+  // clang-format on
   return llvm::ArrayRef(GCCRegNames);
 }
 
diff --git a/clang/test/CodeGen/RISCV/riscv-inline-asm-clobber.c 
b/clang/test/CodeGen/RISCV/riscv-inline-asm-clobber.c
new file mode 100644
index 000..8aa80386f205f8a
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/riscv-inline-asm-clobber.c
@@ -0,0 +1,44 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv32 -O2 -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+// RUN: %clang_cc1 -triple riscv64 -O2 -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+
+// Test RISC-V specific clobbered registers in inline assembly.
+
+// CHECK-LABEL: define {{.*}} void @test_fflags
+// CHECK:tail call void asm sideeffect "", "~{fflags}"()
+void test_fflags(void) {
+  asm volatile ("" :::"fflags");
+}
+
+// CHECK-LABEL: define {{.*}} void @test_frm
+// CHECK:tail call void asm sideeffect "", "~{frm}"()
+void test_frm(void) {
+  asm volatile ("" :::"frm");
+}
+
+// CHECK-LABEL: define {{.*}} void @test_vtype
+// CHECK:tail call void asm sideeffect "", "~{vtype}"()
+void test_vtype(void) {
+  asm volatile ("" :::"vtype");
+}
+
+// CHECK-LABEL: define {{.*}} void @test_vl
+// CHECK:tail call void asm sideeffect "", "~{vl}"()
+void test_vl(void) {
+  asm volatile ("" :::"vl");
+}
+
+// CHECK-LABEL: define {{.*}} void @test_vxsat
+// CHECK:tail call void asm sideeffect "", "~{vxsat}"()
+void test_vxsat(void) {
+  asm volatile ("" :::"vxsat");
+}
+
+// CHECK-LABEL: define {{.*}} void @test_vxrm
+// CHECK:tail call void asm sideeffect "", "~{vxrm}"()
+void test_vxrm(void) {
+  asm volatile ("" :::"vxrm");
+}

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


[clang] [ASAN] Adjust asan instrumented GlobalVariable size to not include redzone (PR #66666)

2023-09-28 Thread Mitch Phillips via cfe-commits

https://github.com/hctim requested changes to this pull request.

Yeah, `clang/test/CodeGen/memtag-globals-asm.cpp` is for MTE Globals, not ASan 
- and the sizes of the GVs should be multiple-of-16 bytes: 
https://github.com/ARM-software/abi-aa/blob/main/memtagabielf64/memtagabielf64.rst#compilation

What problem are you trying to solve here?

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


[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

2023-09-28 Thread Jakub Chlanda via cfe-commits


@@ -10,6 +10,7 @@
 //
 
//===--===//
 
+#include "../Basic/Targets/NVPTX.h"

jchlanda wrote:

@sam-mccall, apologies for introducing the bug and thank you for drawing my 
attention to it.

I've got the fix for the problem:
```diff
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 10d1c910d9cd..3b87300e24bc 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -10,7 +10,6 @@
 //
 
//===--===//

-#include "../Basic/Targets/NVPTX.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTMutationListener.h"
@@ -5612,7 +5611,8 @@ bool Sema::CheckRegparmAttr(const ParsedAttr &AL, 
unsigned &numParams) {
 static CudaArch getCudaArch(const TargetInfo &TI) {
   if (!TI.getTriple().isNVPTX())
 llvm_unreachable("getCudaArch is only valid for NVPTX triple");
-  return static_cast(&TI)->getGPU();
+  auto &TO = TI.getTargetOpts();
+  return StringToCudaArch(TO.CPU);
 }

 // Checks whether an argument of launch_bounds attribute is
```

Would you be so king and point me to the process for "reverting the revert" and 
folding the fix into the original patch?

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


[clang] [Clang][RISCV] Support CSRs in clobbered registers of inline assembly (PR #67646)

2023-09-28 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-risc-v


Changes

To match GCC's behaviors.

Fixes #67596


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


2 Files Affected:

- (modified) clang/lib/Basic/Targets/RISCV.cpp (+7-1) 
- (added) clang/test/CodeGen/RISCV/riscv-inline-asm-clobber.c (+44) 


``diff
diff --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index d55ab76395c8271..b8f0c262493c0b2 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -23,6 +23,7 @@ using namespace clang;
 using namespace clang::targets;
 
 ArrayRef RISCVTargetInfo::getGCCRegNames() const {
+  // clang-format off
   static const char *const GCCRegNames[] = {
   // Integer registers
   "x0",  "x1",  "x2",  "x3",  "x4",  "x5",  "x6",  "x7",
@@ -40,7 +41,12 @@ ArrayRef RISCVTargetInfo::getGCCRegNames() 
const {
   "v0",  "v1",  "v2",  "v3",  "v4",  "v5",  "v6",  "v7",
   "v8",  "v9",  "v10", "v11", "v12", "v13", "v14", "v15",
   "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23",
-  "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31"};
+  "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
+
+  // CSRs
+  "fflags", "frm", "vtype", "vl", "vxsat", "vxrm"
+  };
+  // clang-format on
   return llvm::ArrayRef(GCCRegNames);
 }
 
diff --git a/clang/test/CodeGen/RISCV/riscv-inline-asm-clobber.c 
b/clang/test/CodeGen/RISCV/riscv-inline-asm-clobber.c
new file mode 100644
index 000..8aa80386f205f8a
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/riscv-inline-asm-clobber.c
@@ -0,0 +1,44 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv32 -O2 -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+// RUN: %clang_cc1 -triple riscv64 -O2 -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+
+// Test RISC-V specific clobbered registers in inline assembly.
+
+// CHECK-LABEL: define {{.*}} void @test_fflags
+// CHECK:tail call void asm sideeffect "", "~{fflags}"()
+void test_fflags(void) {
+  asm volatile ("" :::"fflags");
+}
+
+// CHECK-LABEL: define {{.*}} void @test_frm
+// CHECK:tail call void asm sideeffect "", "~{frm}"()
+void test_frm(void) {
+  asm volatile ("" :::"frm");
+}
+
+// CHECK-LABEL: define {{.*}} void @test_vtype
+// CHECK:tail call void asm sideeffect "", "~{vtype}"()
+void test_vtype(void) {
+  asm volatile ("" :::"vtype");
+}
+
+// CHECK-LABEL: define {{.*}} void @test_vl
+// CHECK:tail call void asm sideeffect "", "~{vl}"()
+void test_vl(void) {
+  asm volatile ("" :::"vl");
+}
+
+// CHECK-LABEL: define {{.*}} void @test_vxsat
+// CHECK:tail call void asm sideeffect "", "~{vxsat}"()
+void test_vxsat(void) {
+  asm volatile ("" :::"vxsat");
+}
+
+// CHECK-LABEL: define {{.*}} void @test_vxrm
+// CHECK:tail call void asm sideeffect "", "~{vxrm}"()
+void test_vxrm(void) {
+  asm volatile ("" :::"vxrm");
+}

``




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


[clang] [Clang][RISCV] Support CSRs in clobbered registers of inline assembly (PR #67646)

2023-09-28 Thread Wang Pengcheng via cfe-commits

https://github.com/wangpc-pp updated 
https://github.com/llvm/llvm-project/pull/67646

>From a82026fb50d3dafd4955aba8d193de62d881960f Mon Sep 17 00:00:00 2001
From: wangpc 
Date: Thu, 28 Sep 2023 16:50:31 +0800
Subject: [PATCH] [Clang][RISCV] Support CSRs in clobbered registers of inline
 assembly

To match GCC's behaviors.

Fixes #67596
---
 clang/lib/Basic/Targets/RISCV.cpp |  8 +++-
 .../CodeGen/RISCV/riscv-inline-asm-clobber.c  | 44 +++
 2 files changed, 51 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGen/RISCV/riscv-inline-asm-clobber.c

diff --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index d55ab76395c8271..5f75619b745546c 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -23,6 +23,7 @@ using namespace clang;
 using namespace clang::targets;
 
 ArrayRef RISCVTargetInfo::getGCCRegNames() const {
+  // clang-format off
   static const char *const GCCRegNames[] = {
   // Integer registers
   "x0",  "x1",  "x2",  "x3",  "x4",  "x5",  "x6",  "x7",
@@ -40,7 +41,12 @@ ArrayRef RISCVTargetInfo::getGCCRegNames() 
const {
   "v0",  "v1",  "v2",  "v3",  "v4",  "v5",  "v6",  "v7",
   "v8",  "v9",  "v10", "v11", "v12", "v13", "v14", "v15",
   "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23",
-  "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31"};
+  "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
+
+  // CSRs
+  "fflags", "frm", "vtype", "vl", "vxsat", "vxrm"
+};
+  // clang-format on
   return llvm::ArrayRef(GCCRegNames);
 }
 
diff --git a/clang/test/CodeGen/RISCV/riscv-inline-asm-clobber.c 
b/clang/test/CodeGen/RISCV/riscv-inline-asm-clobber.c
new file mode 100644
index 000..8aa80386f205f8a
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/riscv-inline-asm-clobber.c
@@ -0,0 +1,44 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv32 -O2 -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+// RUN: %clang_cc1 -triple riscv64 -O2 -emit-llvm %s -o - \
+// RUN: | FileCheck %s
+
+// Test RISC-V specific clobbered registers in inline assembly.
+
+// CHECK-LABEL: define {{.*}} void @test_fflags
+// CHECK:tail call void asm sideeffect "", "~{fflags}"()
+void test_fflags(void) {
+  asm volatile ("" :::"fflags");
+}
+
+// CHECK-LABEL: define {{.*}} void @test_frm
+// CHECK:tail call void asm sideeffect "", "~{frm}"()
+void test_frm(void) {
+  asm volatile ("" :::"frm");
+}
+
+// CHECK-LABEL: define {{.*}} void @test_vtype
+// CHECK:tail call void asm sideeffect "", "~{vtype}"()
+void test_vtype(void) {
+  asm volatile ("" :::"vtype");
+}
+
+// CHECK-LABEL: define {{.*}} void @test_vl
+// CHECK:tail call void asm sideeffect "", "~{vl}"()
+void test_vl(void) {
+  asm volatile ("" :::"vl");
+}
+
+// CHECK-LABEL: define {{.*}} void @test_vxsat
+// CHECK:tail call void asm sideeffect "", "~{vxsat}"()
+void test_vxsat(void) {
+  asm volatile ("" :::"vxsat");
+}
+
+// CHECK-LABEL: define {{.*}} void @test_vxrm
+// CHECK:tail call void asm sideeffect "", "~{vxrm}"()
+void test_vxrm(void) {
+  asm volatile ("" :::"vxrm");
+}

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


[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-28 Thread via cfe-commits

https://github.com/kasuga-fj updated 
https://github.com/llvm/llvm-project/pull/65246

>From cc6f7f7cb125f544de708830b3a9c0f39745ed1f Mon Sep 17 00:00:00 2001
From: "kasuga.ryotaro" 
Date: Wed, 30 Aug 2023 13:26:31 +0900
Subject: [PATCH 1/7] [Clang] Fix missing diagnostic for non-standard layout
 type in `offsetof`

Fixes #64619

Clang warns diagnostic for non-standard layout types in `offsetof` only
if they are in evaluated context. With this patch, you'll also get
  diagnostic if you use `offsetof` on non-standard layout types in any
  other contexts
---
 clang/lib/Sema/SemaExpr.cpp |  9 -
 clang/test/SemaCXX/class-layout.cpp | 30 ++---
 clang/test/SemaCXX/ms_struct.cpp|  5 ++---
 clang/test/SemaCXX/offsetof.cpp | 10 +-
 4 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 92496b03ecabe54..6537b085aa46c5b 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16766,12 +16766,11 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation 
BuiltinLoc,
 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
 : diag::ext_offsetof_non_pod_type;
 
-  if (!IsSafe && !DidWarnAboutNonPOD &&
-  DiagRuntimeBehavior(BuiltinLoc, nullptr,
-  PDiag(DiagID)
-  << SourceRange(Components[0].LocStart, OC.LocEnd)
-  << CurrentType))
+  if (!IsSafe && !DidWarnAboutNonPOD) {
+Diag(BuiltinLoc, DiagID)
+<< SourceRange(Components[0].LocStart, OC.LocEnd) << CurrentType;
 DidWarnAboutNonPOD = true;
+  }
 }
 
 // Look for the field.
diff --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index 9782ff08100b2d6..23b3dbe24249378 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -1,18 +1,18 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base
-// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-invalid-offsetof -Wno-c++11-extensions
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof
+// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -DCLANG_ABI_COMPAT=6
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof -fclang-abi-compat=6

[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

2023-09-28 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-libcxx


Changes

Fixes #64619

Clang warns diagnostic for non-standard layout types in `offsetof` only if they 
are in evaluated context. With this patch, you'll also get diagnostic if you 
use `offsetof` on non-standard layout types in any other contexts

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


6 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+2) 
- (modified) clang/lib/Sema/SemaExpr.cpp (+4-5) 
- (modified) clang/test/SemaCXX/class-layout.cpp (+15-15) 
- (modified) clang/test/SemaCXX/ms_struct.cpp (+3-3) 
- (modified) clang/test/SemaCXX/offsetof.cpp (+5-4) 
- (modified) libcxx/include/__type_traits/datasizeof.h (+4) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f314c9c72fa28b7..abc36bac05d788d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -208,6 +208,8 @@ Improvements to Clang's diagnostics
   (`#54678: `_).
 - Clang now prints its 'note' diagnostic in cyan instead of black, to be more 
compatible
   with terminals with dark background colors. This is also more consistent 
with GCC.
+- Clang now always diagnoses when using non-standard layout types in 
``offsetof`` .
+  (`#64619: `_)
 
 Bug Fixes in This Version
 -
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 92496b03ecabe54..fedea932c5e15fe 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16766,12 +16766,11 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation 
BuiltinLoc,
 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
 : diag::ext_offsetof_non_pod_type;
 
-  if (!IsSafe && !DidWarnAboutNonPOD &&
-  DiagRuntimeBehavior(BuiltinLoc, nullptr,
-  PDiag(DiagID)
-  << SourceRange(Components[0].LocStart, OC.LocEnd)
-  << CurrentType))
+  if (!IsSafe && !DidWarnAboutNonPOD && !isUnevaluatedContext()) {
+Diag(BuiltinLoc, DiagID)
+<< SourceRange(Components[0].LocStart, OC.LocEnd) << CurrentType;
 DidWarnAboutNonPOD = true;
+  }
 }
 
 // Look for the field.
diff --git a/clang/test/SemaCXX/class-layout.cpp 
b/clang/test/SemaCXX/class-layout.cpp
index 9782ff08100b2d6..23b3dbe24249378 100644
--- a/clang/test/SemaCXX/class-layout.cpp
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -1,18 +1,18 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-c++11-extensions
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base
-// RUN: %clang_cc1 -triple x86_64-apple-darwin%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-scei-ps4%s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-sie-ps5 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=6 -DCLANG_ABI_COMPAT=6
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=14 -DCLANG_ABI_COMPAT=14
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=16 -DCLANG_ABI_COMPAT=16
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple powerpc64-ibm-aix7.3.0.0 %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base
-// RUN: %clang_cc1 -triple s390x-none-zos %s -fsyntax-only -verify -std=c++11 
-Wno-inaccessible-base -fclang-abi-compat=15 -DCLANG_ABI_COMPAT=15
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++98 -Wno-inaccessible-base -Wno-invalid-offsetof -Wno-c++11-extensions
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify 
-std=c++11 -Wno-inaccessible-base -Wno-invalid-offsetof
+// R

[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

https://github.com/ktf updated https://github.com/llvm/llvm-project/pull/66430

>From c14aaf14cbcd292165aece38ebdae74ce92a4d32 Mon Sep 17 00:00:00 2001
From: Giulio Eulisse <10544+...@users.noreply.github.com>
Date: Thu, 14 Sep 2023 21:58:21 +0200
Subject: [PATCH 1/2] Introduce PagedVector class

The goal of the class is to be an (almost) drop in replacement for
SmallVector and std::vector when those are presized and filled later, as
it happens in SourceManager and ASTReader.

By doing so, sparsely accessed PagedVector can profit from reduced
memory footprint.
---
 clang/include/clang/Basic/SourceManager.h |   3 +-
 clang/include/clang/Serialization/ASTReader.h |   5 +-
 clang/lib/Basic/SourceManager.cpp |  10 +-
 clang/lib/Serialization/ASTReader.cpp |   5 +-
 llvm/docs/ProgrammersManual.rst   |  34 ++
 llvm/include/llvm/ADT/PagedVector.h   | 282 +++
 llvm/unittests/ADT/CMakeLists.txt |   1 +
 llvm/unittests/ADT/PagedVectorTest.cpp| 342 ++
 8 files changed, 672 insertions(+), 10 deletions(-)
 create mode 100644 llvm/include/llvm/ADT/PagedVector.h
 create mode 100644 llvm/unittests/ADT/PagedVectorTest.cpp

diff --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index 2f846502d6f3327..e37caa2252532f9 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -43,6 +43,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -699,7 +700,7 @@ class SourceManager : public RefCountedBase {
   ///
   /// Negative FileIDs are indexes into this table. To get from ID to an index,
   /// use (-ID - 2).
-  SmallVector LoadedSLocEntryTable;
+  llvm::PagedVector LoadedSLocEntryTable;
 
   /// The starting offset of the next local SLocEntry.
   ///
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index dc1eb21c27801fe..65e19c6e44cf571 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -38,6 +38,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -487,7 +488,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the type with
   /// ID = (I + 1) << FastQual::Width has already been loaded
-  std::vector TypesLoaded;
+  llvm::PagedVector TypesLoaded;
 
   using GlobalTypeMapType =
   ContinuousRangeMap;
@@ -501,7 +502,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the declaration with ID
   /// = I + 1 has already been loaded.
-  std::vector DeclsLoaded;
+  llvm::PagedVector DeclsLoaded;
 
   using GlobalDeclMapType =
   ContinuousRangeMap;
diff --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 0521ac7b30339ab..7fa8b8096ac4931 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -2344,11 +2344,11 @@ SourceManager::MemoryBufferSizes 
SourceManager::getMemoryBufferSizes() const {
 }
 
 size_t SourceManager::getDataStructureSizes() const {
-  size_t size = llvm::capacity_in_bytes(MemBufferInfos)
-+ llvm::capacity_in_bytes(LocalSLocEntryTable)
-+ llvm::capacity_in_bytes(LoadedSLocEntryTable)
-+ llvm::capacity_in_bytes(SLocEntryLoaded)
-+ llvm::capacity_in_bytes(FileInfos);
+  size_t size = llvm::capacity_in_bytes(MemBufferInfos) +
+llvm::capacity_in_bytes(LocalSLocEntryTable) +
+llvm::capacity_in_bytes(LoadedSLocEntryTable) +
+llvm::capacity_in_bytes(SLocEntryLoaded) +
+llvm::capacity_in_bytes(FileInfos);
 
   if (OverriddenFilesInfo)
 size += llvm::capacity_in_bytes(OverriddenFilesInfo->OverriddenFiles);
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 0952244d037a77c..bb2a32ade0a0d7c 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -7944,9 +7944,10 @@ void ASTReader::PrintStats() {
   std::fprintf(stderr, "*** AST File Statistics:\n");
 
   unsigned NumTypesLoaded =
-  TypesLoaded.size() - llvm::count(TypesLoaded, QualType());
+  TypesLoaded.size() - llvm::count(TypesLoaded.materialized(), QualType());
   unsigned NumDeclsLoaded =
-  DeclsLoaded.size() - llvm::count(DeclsLoaded, (Decl *)nullptr);
+  DeclsLoaded.size() -
+  llvm::count(DeclsLoaded.materialized(), (Decl *)nullptr);
   unsigned NumIdentifiersLoaded =
   IdentifiersLoaded.size() -
   llvm::count(IdentifiersLoaded, (IdentifierInfo *)nullptr

[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

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


[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

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


[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

https://github.com/ktf updated https://github.com/llvm/llvm-project/pull/66430

>From c14aaf14cbcd292165aece38ebdae74ce92a4d32 Mon Sep 17 00:00:00 2001
From: Giulio Eulisse <10544+...@users.noreply.github.com>
Date: Thu, 14 Sep 2023 21:58:21 +0200
Subject: [PATCH 1/3] Introduce PagedVector class

The goal of the class is to be an (almost) drop in replacement for
SmallVector and std::vector when those are presized and filled later, as
it happens in SourceManager and ASTReader.

By doing so, sparsely accessed PagedVector can profit from reduced
memory footprint.
---
 clang/include/clang/Basic/SourceManager.h |   3 +-
 clang/include/clang/Serialization/ASTReader.h |   5 +-
 clang/lib/Basic/SourceManager.cpp |  10 +-
 clang/lib/Serialization/ASTReader.cpp |   5 +-
 llvm/docs/ProgrammersManual.rst   |  34 ++
 llvm/include/llvm/ADT/PagedVector.h   | 282 +++
 llvm/unittests/ADT/CMakeLists.txt |   1 +
 llvm/unittests/ADT/PagedVectorTest.cpp| 342 ++
 8 files changed, 672 insertions(+), 10 deletions(-)
 create mode 100644 llvm/include/llvm/ADT/PagedVector.h
 create mode 100644 llvm/unittests/ADT/PagedVectorTest.cpp

diff --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index 2f846502d6f3327..e37caa2252532f9 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -43,6 +43,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -699,7 +700,7 @@ class SourceManager : public RefCountedBase {
   ///
   /// Negative FileIDs are indexes into this table. To get from ID to an index,
   /// use (-ID - 2).
-  SmallVector LoadedSLocEntryTable;
+  llvm::PagedVector LoadedSLocEntryTable;
 
   /// The starting offset of the next local SLocEntry.
   ///
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index dc1eb21c27801fe..65e19c6e44cf571 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -38,6 +38,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -487,7 +488,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the type with
   /// ID = (I + 1) << FastQual::Width has already been loaded
-  std::vector TypesLoaded;
+  llvm::PagedVector TypesLoaded;
 
   using GlobalTypeMapType =
   ContinuousRangeMap;
@@ -501,7 +502,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the declaration with ID
   /// = I + 1 has already been loaded.
-  std::vector DeclsLoaded;
+  llvm::PagedVector DeclsLoaded;
 
   using GlobalDeclMapType =
   ContinuousRangeMap;
diff --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 0521ac7b30339ab..7fa8b8096ac4931 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -2344,11 +2344,11 @@ SourceManager::MemoryBufferSizes 
SourceManager::getMemoryBufferSizes() const {
 }
 
 size_t SourceManager::getDataStructureSizes() const {
-  size_t size = llvm::capacity_in_bytes(MemBufferInfos)
-+ llvm::capacity_in_bytes(LocalSLocEntryTable)
-+ llvm::capacity_in_bytes(LoadedSLocEntryTable)
-+ llvm::capacity_in_bytes(SLocEntryLoaded)
-+ llvm::capacity_in_bytes(FileInfos);
+  size_t size = llvm::capacity_in_bytes(MemBufferInfos) +
+llvm::capacity_in_bytes(LocalSLocEntryTable) +
+llvm::capacity_in_bytes(LoadedSLocEntryTable) +
+llvm::capacity_in_bytes(SLocEntryLoaded) +
+llvm::capacity_in_bytes(FileInfos);
 
   if (OverriddenFilesInfo)
 size += llvm::capacity_in_bytes(OverriddenFilesInfo->OverriddenFiles);
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 0952244d037a77c..bb2a32ade0a0d7c 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -7944,9 +7944,10 @@ void ASTReader::PrintStats() {
   std::fprintf(stderr, "*** AST File Statistics:\n");
 
   unsigned NumTypesLoaded =
-  TypesLoaded.size() - llvm::count(TypesLoaded, QualType());
+  TypesLoaded.size() - llvm::count(TypesLoaded.materialized(), QualType());
   unsigned NumDeclsLoaded =
-  DeclsLoaded.size() - llvm::count(DeclsLoaded, (Decl *)nullptr);
+  DeclsLoaded.size() -
+  llvm::count(DeclsLoaded.materialized(), (Decl *)nullptr);
   unsigned NumIdentifiersLoaded =
   IdentifiersLoaded.size() -
   llvm::count(IdentifiersLoaded, (IdentifierInfo *)nullptr

[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

https://github.com/ktf updated https://github.com/llvm/llvm-project/pull/66430

>From c14aaf14cbcd292165aece38ebdae74ce92a4d32 Mon Sep 17 00:00:00 2001
From: Giulio Eulisse <10544+...@users.noreply.github.com>
Date: Thu, 14 Sep 2023 21:58:21 +0200
Subject: [PATCH 1/4] Introduce PagedVector class

The goal of the class is to be an (almost) drop in replacement for
SmallVector and std::vector when those are presized and filled later, as
it happens in SourceManager and ASTReader.

By doing so, sparsely accessed PagedVector can profit from reduced
memory footprint.
---
 clang/include/clang/Basic/SourceManager.h |   3 +-
 clang/include/clang/Serialization/ASTReader.h |   5 +-
 clang/lib/Basic/SourceManager.cpp |  10 +-
 clang/lib/Serialization/ASTReader.cpp |   5 +-
 llvm/docs/ProgrammersManual.rst   |  34 ++
 llvm/include/llvm/ADT/PagedVector.h   | 282 +++
 llvm/unittests/ADT/CMakeLists.txt |   1 +
 llvm/unittests/ADT/PagedVectorTest.cpp| 342 ++
 8 files changed, 672 insertions(+), 10 deletions(-)
 create mode 100644 llvm/include/llvm/ADT/PagedVector.h
 create mode 100644 llvm/unittests/ADT/PagedVectorTest.cpp

diff --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index 2f846502d6f3327..e37caa2252532f9 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -43,6 +43,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -699,7 +700,7 @@ class SourceManager : public RefCountedBase {
   ///
   /// Negative FileIDs are indexes into this table. To get from ID to an index,
   /// use (-ID - 2).
-  SmallVector LoadedSLocEntryTable;
+  llvm::PagedVector LoadedSLocEntryTable;
 
   /// The starting offset of the next local SLocEntry.
   ///
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index dc1eb21c27801fe..65e19c6e44cf571 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -38,6 +38,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -487,7 +488,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the type with
   /// ID = (I + 1) << FastQual::Width has already been loaded
-  std::vector TypesLoaded;
+  llvm::PagedVector TypesLoaded;
 
   using GlobalTypeMapType =
   ContinuousRangeMap;
@@ -501,7 +502,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the declaration with ID
   /// = I + 1 has already been loaded.
-  std::vector DeclsLoaded;
+  llvm::PagedVector DeclsLoaded;
 
   using GlobalDeclMapType =
   ContinuousRangeMap;
diff --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 0521ac7b30339ab..7fa8b8096ac4931 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -2344,11 +2344,11 @@ SourceManager::MemoryBufferSizes 
SourceManager::getMemoryBufferSizes() const {
 }
 
 size_t SourceManager::getDataStructureSizes() const {
-  size_t size = llvm::capacity_in_bytes(MemBufferInfos)
-+ llvm::capacity_in_bytes(LocalSLocEntryTable)
-+ llvm::capacity_in_bytes(LoadedSLocEntryTable)
-+ llvm::capacity_in_bytes(SLocEntryLoaded)
-+ llvm::capacity_in_bytes(FileInfos);
+  size_t size = llvm::capacity_in_bytes(MemBufferInfos) +
+llvm::capacity_in_bytes(LocalSLocEntryTable) +
+llvm::capacity_in_bytes(LoadedSLocEntryTable) +
+llvm::capacity_in_bytes(SLocEntryLoaded) +
+llvm::capacity_in_bytes(FileInfos);
 
   if (OverriddenFilesInfo)
 size += llvm::capacity_in_bytes(OverriddenFilesInfo->OverriddenFiles);
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 0952244d037a77c..bb2a32ade0a0d7c 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -7944,9 +7944,10 @@ void ASTReader::PrintStats() {
   std::fprintf(stderr, "*** AST File Statistics:\n");
 
   unsigned NumTypesLoaded =
-  TypesLoaded.size() - llvm::count(TypesLoaded, QualType());
+  TypesLoaded.size() - llvm::count(TypesLoaded.materialized(), QualType());
   unsigned NumDeclsLoaded =
-  DeclsLoaded.size() - llvm::count(DeclsLoaded, (Decl *)nullptr);
+  DeclsLoaded.size() -
+  llvm::count(DeclsLoaded.materialized(), (Decl *)nullptr);
   unsigned NumIdentifiersLoaded =
   IdentifiersLoaded.size() -
   llvm::count(IdentifiersLoaded, (IdentifierInfo *)nullptr

[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

https://github.com/ktf updated https://github.com/llvm/llvm-project/pull/66430

>From c14aaf14cbcd292165aece38ebdae74ce92a4d32 Mon Sep 17 00:00:00 2001
From: Giulio Eulisse <10544+...@users.noreply.github.com>
Date: Thu, 14 Sep 2023 21:58:21 +0200
Subject: [PATCH 1/5] Introduce PagedVector class

The goal of the class is to be an (almost) drop in replacement for
SmallVector and std::vector when those are presized and filled later, as
it happens in SourceManager and ASTReader.

By doing so, sparsely accessed PagedVector can profit from reduced
memory footprint.
---
 clang/include/clang/Basic/SourceManager.h |   3 +-
 clang/include/clang/Serialization/ASTReader.h |   5 +-
 clang/lib/Basic/SourceManager.cpp |  10 +-
 clang/lib/Serialization/ASTReader.cpp |   5 +-
 llvm/docs/ProgrammersManual.rst   |  34 ++
 llvm/include/llvm/ADT/PagedVector.h   | 282 +++
 llvm/unittests/ADT/CMakeLists.txt |   1 +
 llvm/unittests/ADT/PagedVectorTest.cpp| 342 ++
 8 files changed, 672 insertions(+), 10 deletions(-)
 create mode 100644 llvm/include/llvm/ADT/PagedVector.h
 create mode 100644 llvm/unittests/ADT/PagedVectorTest.cpp

diff --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index 2f846502d6f3327..e37caa2252532f9 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -43,6 +43,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -699,7 +700,7 @@ class SourceManager : public RefCountedBase {
   ///
   /// Negative FileIDs are indexes into this table. To get from ID to an index,
   /// use (-ID - 2).
-  SmallVector LoadedSLocEntryTable;
+  llvm::PagedVector LoadedSLocEntryTable;
 
   /// The starting offset of the next local SLocEntry.
   ///
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index dc1eb21c27801fe..65e19c6e44cf571 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -38,6 +38,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -487,7 +488,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the type with
   /// ID = (I + 1) << FastQual::Width has already been loaded
-  std::vector TypesLoaded;
+  llvm::PagedVector TypesLoaded;
 
   using GlobalTypeMapType =
   ContinuousRangeMap;
@@ -501,7 +502,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the declaration with ID
   /// = I + 1 has already been loaded.
-  std::vector DeclsLoaded;
+  llvm::PagedVector DeclsLoaded;
 
   using GlobalDeclMapType =
   ContinuousRangeMap;
diff --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 0521ac7b30339ab..7fa8b8096ac4931 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -2344,11 +2344,11 @@ SourceManager::MemoryBufferSizes 
SourceManager::getMemoryBufferSizes() const {
 }
 
 size_t SourceManager::getDataStructureSizes() const {
-  size_t size = llvm::capacity_in_bytes(MemBufferInfos)
-+ llvm::capacity_in_bytes(LocalSLocEntryTable)
-+ llvm::capacity_in_bytes(LoadedSLocEntryTable)
-+ llvm::capacity_in_bytes(SLocEntryLoaded)
-+ llvm::capacity_in_bytes(FileInfos);
+  size_t size = llvm::capacity_in_bytes(MemBufferInfos) +
+llvm::capacity_in_bytes(LocalSLocEntryTable) +
+llvm::capacity_in_bytes(LoadedSLocEntryTable) +
+llvm::capacity_in_bytes(SLocEntryLoaded) +
+llvm::capacity_in_bytes(FileInfos);
 
   if (OverriddenFilesInfo)
 size += llvm::capacity_in_bytes(OverriddenFilesInfo->OverriddenFiles);
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 0952244d037a77c..bb2a32ade0a0d7c 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -7944,9 +7944,10 @@ void ASTReader::PrintStats() {
   std::fprintf(stderr, "*** AST File Statistics:\n");
 
   unsigned NumTypesLoaded =
-  TypesLoaded.size() - llvm::count(TypesLoaded, QualType());
+  TypesLoaded.size() - llvm::count(TypesLoaded.materialized(), QualType());
   unsigned NumDeclsLoaded =
-  DeclsLoaded.size() - llvm::count(DeclsLoaded, (Decl *)nullptr);
+  DeclsLoaded.size() -
+  llvm::count(DeclsLoaded.materialized(), (Decl *)nullptr);
   unsigned NumIdentifiersLoaded =
   IdentifiersLoaded.size() -
   llvm::count(IdentifiersLoaded, (IdentifierInfo *)nullptr

[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

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


[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

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


[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

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


[clang] [C++20] [Modules] Don't generate call to an imported module that dont init anything (PR #67638)

2023-09-28 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

Opinions addressed.

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


[clang] Introduce paged vector (PR #66430)

2023-09-28 Thread Giulio Eulisse via cfe-commits

https://github.com/ktf updated https://github.com/llvm/llvm-project/pull/66430

>From 07da9379065daab62d43ba453ba6b71f3880a089 Mon Sep 17 00:00:00 2001
From: Giulio Eulisse <10544+...@users.noreply.github.com>
Date: Thu, 14 Sep 2023 21:58:21 +0200
Subject: [PATCH] Introduce PagedVector class

The goal of the class is to be an (almost) drop in replacement for
SmallVector and std::vector when those are presized and filled later, as
it happens in SourceManager and ASTReader.

By doing so, sparsely accessed PagedVector can profit from reduced
memory footprint.
---
 clang/include/clang/Basic/SourceManager.h |   3 +-
 clang/include/clang/Serialization/ASTReader.h |   5 +-
 clang/lib/Basic/SourceManager.cpp |  10 +-
 clang/lib/Serialization/ASTReader.cpp |   5 +-
 llvm/docs/ProgrammersManual.rst   |  34 ++
 llvm/include/llvm/ADT/PagedVector.h   | 282 +++
 llvm/unittests/ADT/CMakeLists.txt |   1 +
 llvm/unittests/ADT/PagedVectorTest.cpp| 342 ++
 8 files changed, 672 insertions(+), 10 deletions(-)
 create mode 100644 llvm/include/llvm/ADT/PagedVector.h
 create mode 100644 llvm/unittests/ADT/PagedVectorTest.cpp

diff --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index 2f846502d6f3327..e37caa2252532f9 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -43,6 +43,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -699,7 +700,7 @@ class SourceManager : public RefCountedBase {
   ///
   /// Negative FileIDs are indexes into this table. To get from ID to an index,
   /// use (-ID - 2).
-  SmallVector LoadedSLocEntryTable;
+  llvm::PagedVector LoadedSLocEntryTable;
 
   /// The starting offset of the next local SLocEntry.
   ///
diff --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index dc1eb21c27801fe..65e19c6e44cf571 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -38,6 +38,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/PagedVector.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -487,7 +488,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the type with
   /// ID = (I + 1) << FastQual::Width has already been loaded
-  std::vector TypesLoaded;
+  llvm::PagedVector TypesLoaded;
 
   using GlobalTypeMapType =
   ContinuousRangeMap;
@@ -501,7 +502,7 @@ class ASTReader
   ///
   /// When the pointer at index I is non-NULL, the declaration with ID
   /// = I + 1 has already been loaded.
-  std::vector DeclsLoaded;
+  llvm::PagedVector DeclsLoaded;
 
   using GlobalDeclMapType =
   ContinuousRangeMap;
diff --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index 0521ac7b30339ab..7fa8b8096ac4931 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -2344,11 +2344,11 @@ SourceManager::MemoryBufferSizes 
SourceManager::getMemoryBufferSizes() const {
 }
 
 size_t SourceManager::getDataStructureSizes() const {
-  size_t size = llvm::capacity_in_bytes(MemBufferInfos)
-+ llvm::capacity_in_bytes(LocalSLocEntryTable)
-+ llvm::capacity_in_bytes(LoadedSLocEntryTable)
-+ llvm::capacity_in_bytes(SLocEntryLoaded)
-+ llvm::capacity_in_bytes(FileInfos);
+  size_t size = llvm::capacity_in_bytes(MemBufferInfos) +
+llvm::capacity_in_bytes(LocalSLocEntryTable) +
+llvm::capacity_in_bytes(LoadedSLocEntryTable) +
+llvm::capacity_in_bytes(SLocEntryLoaded) +
+llvm::capacity_in_bytes(FileInfos);
 
   if (OverriddenFilesInfo)
 size += llvm::capacity_in_bytes(OverriddenFilesInfo->OverriddenFiles);
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 0952244d037a77c..bb2a32ade0a0d7c 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -7944,9 +7944,10 @@ void ASTReader::PrintStats() {
   std::fprintf(stderr, "*** AST File Statistics:\n");
 
   unsigned NumTypesLoaded =
-  TypesLoaded.size() - llvm::count(TypesLoaded, QualType());
+  TypesLoaded.size() - llvm::count(TypesLoaded.materialized(), QualType());
   unsigned NumDeclsLoaded =
-  DeclsLoaded.size() - llvm::count(DeclsLoaded, (Decl *)nullptr);
+  DeclsLoaded.size() -
+  llvm::count(DeclsLoaded.materialized(), (Decl *)nullptr);
   unsigned NumIdentifiersLoaded =
   IdentifiersLoaded.size() -
   llvm::count(IdentifiersLoaded, (IdentifierInfo *)nullptr);
d

[clang] [C++20] [Modules] Don't generate call to an imported module that dont init anything (PR #67638)

2023-09-28 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 updated 
https://github.com/llvm/llvm-project/pull/67638

>From 02b65f03b80470078107194fc1ce28680b804dab Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Thu, 28 Sep 2023 15:32:31 +0800
Subject: [PATCH] [C++20] [Modules] Don't generate call to an imported module
 that don't init anything

Close https://github.com/llvm/llvm-project/issues/56794

And see https://github.com/llvm/llvm-project/issues/67582 for a detailed
backgrond for the issue.

As required by the Itanium ABI, the module units have to generate the
initialization function. However, the importers are allowed to elide the
call to the initialization function if they are sure the initialization
function doesn't do anything.

This patch implemented this semantics.
---
 clang/include/clang/Basic/Module.h|  6 +++
 clang/lib/Basic/Module.cpp|  2 +-
 clang/lib/CodeGen/CGDeclCXX.cpp   |  7 ++-
 clang/lib/Sema/Sema.cpp   | 21 
 clang/lib/Serialization/ASTReader.cpp |  2 +
 clang/lib/Serialization/ASTWriter.cpp |  4 +-
 .../module-initializer-guard-elision.cpp  | 53 ++-
 7 files changed, 79 insertions(+), 16 deletions(-)

diff --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index edbd2dfc2973e92..cd86927d214fc85 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -358,6 +358,10 @@ class alignas(8) Module {
   /// to a regular (public) module map.
   unsigned ModuleMapIsPrivate : 1;
 
+  /// Whether this C++20 named modules doesn't need an initializer.
+  /// This is only meaningful for C++20 modules.
+  unsigned NamedModuleHasNoInit : 1;
+
   /// Describes the visibility of the various names within a
   /// particular module.
   enum NameVisibilityKind {
@@ -596,6 +600,8 @@ class alignas(8) Module {
 return Kind == ModuleInterfaceUnit || Kind == ModulePartitionInterface;
   }
 
+  bool isNamedModuleInterfaceHasNoInit() const { return NamedModuleHasNoInit; }
+
   /// Get the primary module interface name from a partition.
   StringRef getPrimaryModuleInterfaceName() const {
 // Technically, global module fragment belongs to global module. And global
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index 4e6fbfc754b9173..23683eae955bd62 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -44,7 +44,7 @@ Module::Module(StringRef Name, SourceLocation DefinitionLoc, 
Module *Parent,
   InferSubmodules(false), InferExplicitSubmodules(false),
   InferExportWildcard(false), ConfigMacrosExhaustive(false),
   NoUndeclaredIncludes(false), ModuleMapIsPrivate(false),
-  NameVisibility(Hidden) {
+  NamedModuleHasNoInit(false), NameVisibility(Hidden) {
   if (Parent) {
 IsAvailable = Parent->isAvailable();
 IsUnimportable = Parent->isUnimportable();
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 80543ba6311de45..18d4ed4f5290300 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -675,6 +675,10 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) 
{
 // No Itanium initializer in header like modules.
 if (M->isHeaderLikeModule())
   continue; // TODO: warn of mixed use of module map modules and C++20?
+// We're allowed to skip the initialization if we are sure it doesn't
+// do any thing.
+if (M->isNamedModuleInterfaceHasNoInit())
+  continue;
 llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
 SmallString<256> FnName;
 {
@@ -731,8 +735,7 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
 // If we have a completely empty initializer then we do not want to create
 // the guard variable.
 ConstantAddress GuardAddr = ConstantAddress::invalid();
-if (!AllImports.empty() || !PrioritizedCXXGlobalInits.empty() ||
-!CXXGlobalInits.empty()) {
+if (!ModuleInits.empty()) {
   // Create the guard var.
   llvm::GlobalVariable *Guard = new llvm::GlobalVariable(
   getModule(), Int8Ty, /*isConstant=*/false,
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index a401017d4c1c0b8..ad85a9264d57d31 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -1245,6 +1245,27 @@ void Sema::ActOnEndOfTranslationUnit() {
   }
 }
 
+// Now we can decide whether the modules we're building need an 
initializer.
+if (Module *CurrentModule = getCurrentModule();
+CurrentModule && CurrentModule->isInterfaceOrPartition()) {
+  auto DoesModNeedInit = [this](Module *M) {
+if (!getASTContext().getModuleInitializers(M).empty())
+  return false;
+for (auto [Exported, _] : M->Exports)
+  if (!Exported->isNamedModuleInterfaceHasNoInit())
+return false;
+for (Module *I : M->Imports)
+  if (!I->isNamedModuleInterfaceHasNoInit(

[clang] [clang][dataflow] Show triangle in `` element. (#67431) (PR #67655)

2023-09-28 Thread via cfe-commits

https://github.com/martinboehme created 
https://github.com/llvm/llvm-project/pull/67655

Also, change the mouse cursor into a pointer instead of a text cursor.

This makes it more discoverable that the element can be opened and
closed.


>From 4a426e1e88cfa5cb41632e381d4905853928b6b1 Mon Sep 17 00:00:00 2001
From: martinboehme 
Date: Thu, 28 Sep 2023 10:55:02 +0200
Subject: [PATCH] [clang][dataflow] Show triangle in `` element.
 (#67431)

Also, change the mouse cursor into a pointer instead of a text cursor.

This makes it more discoverable that the element can be opened and
closed.
---
 clang/lib/Analysis/FlowSensitive/HTMLLogger.css  | 15 +--
 clang/lib/Analysis/FlowSensitive/HTMLLogger.html |  2 +-
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
index 0ac1902ea4651ec..60c9ee251a425e8 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
@@ -123,10 +123,21 @@ code.line:has(.bb-select):before {
   font-size: x-small;
   flex-grow: 1;
 }
-.value summary {
+.value > summary {
   background-color: #ace;
   display: flex;
-  justify-content: space-between;
+  cursor: pointer;
+}
+.value > summary::before {
+  content: '\25ba';
+  margin-right: 0.5em;
+  font-size: 0.9em;
+}
+.value[open] > summary::before {
+  content: '\25bc';
+}
+.value > summary > .location {
+  margin-left: auto;
 }
 .value .address {
   font-size: xx-small;
diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.html 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
index 87695623cb318b2..6d866d57e144866 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
@@ -18,7 +18,7 @@
 #{{v.value_id}}
   
   
-{{v.type}} @{{v.location}}
+{{v.type}} @{{v.location}}
   
 
 https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][dataflow] Show triangle in `` element. (#67431) (PR #67655)

2023-09-28 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-analysis


Changes

Also, change the mouse cursor into a pointer instead of a text cursor.

This makes it more discoverable that the element can be opened and
closed.


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


2 Files Affected:

- (modified) clang/lib/Analysis/FlowSensitive/HTMLLogger.css (+13-2) 
- (modified) clang/lib/Analysis/FlowSensitive/HTMLLogger.html (+1-1) 


``diff
diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
index 0ac1902ea4651ec..60c9ee251a425e8 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.css
@@ -123,10 +123,21 @@ code.line:has(.bb-select):before {
   font-size: x-small;
   flex-grow: 1;
 }
-.value summary {
+.value > summary {
   background-color: #ace;
   display: flex;
-  justify-content: space-between;
+  cursor: pointer;
+}
+.value > summary::before {
+  content: '\25ba';
+  margin-right: 0.5em;
+  font-size: 0.9em;
+}
+.value[open] > summary::before {
+  content: '\25bc';
+}
+.value > summary > .location {
+  margin-left: auto;
 }
 .value .address {
   font-size: xx-small;
diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.html 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
index 87695623cb318b2..6d866d57e144866 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.html
@@ -18,7 +18,7 @@
 #{{v.value_id}}
   
   
-{{v.type}} @{{v.location}}
+{{v.type}} @{{v.location}}
   
 
 


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


[clang] [clang][dataflow] Show triangle in `` element (PR #67655)

2023-09-28 Thread via cfe-commits

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


[clang] [clang][dataflow] Show triangle in `` element (PR #67655)

2023-09-28 Thread via cfe-commits

martinboehme wrote:

Next attempt after reverting #67431.

#67431 caused buildbots to fail because it contained non-ASCII characters in a 
CSS file. I have now escaped these.



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


[clang] [PowerPC] Fix use of FPSCR builtins in smmintrin.h (PR #67299)

2023-09-28 Thread Qiu Chaofan via cfe-commits

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


[clang-tools-extra] [clangd] Add tweak for turning an unscoped into a scoped enum (PR #67645)

2023-09-28 Thread via cfe-commits

https://github.com/5chmidti commented:

I just found small nits, and could you please add this to the release notes? 
Looks nice overall

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


[clang-tools-extra] [clangd] Add tweak for turning an unscoped into a scoped enum (PR #67645)

2023-09-28 Thread via cfe-commits

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


[clang-tools-extra] [clangd] Add tweak for turning an unscoped into a scoped enum (PR #67645)

2023-09-28 Thread via cfe-commits


@@ -0,0 +1,222 @@
+//===--- ScopifyEnum.cpp --- -*- 
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 "ParsedAST.h"
+#include "XRefs.h"
+#include "refactor/Tweak.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+
+#include 
+
+namespace clang::clangd {
+namespace {
+
+/// Turns an unscoped into a scoped enum type.
+/// Before:
+///   enum E { EV1, EV2 };
+///^
+///   void f() { E e1 = EV1; }
+///
+/// After:
+///   enum class E { EV1, EV2 };
+///   void f() { E e1 = E::EV1; }
+///
+/// Note that the respective project code might not compile anymore
+/// if it made use of the now-gone implicit conversion to int.
+/// This is out of scope for this tweak.
+///
+/// TODO: In the above example, we could detect that the values
+///   start with the enum name, and remove that prefix.
+
+class ScopifyEnum : public Tweak {
+  const char *id() const final;
+  std::string title() const override { return "Convert to scoped enum"; }
+  llvm::StringLiteral kind() const override {
+return CodeAction::REFACTOR_KIND;
+  }
+  bool prepare(const Selection &Inputs) override;
+  Expected apply(const Selection &Inputs) override;
+
+  using MakeReplacement =
+  std::function;
+  llvm::Error addClassKeywordToDeclarations();
+  llvm::Error scopifyEnumValues();
+  llvm::Error scopifyEnumValue(const EnumConstantDecl &CD, StringRef Prefix);
+  llvm::Expected getContentForFile(StringRef FilePath);
+  unsigned getOffsetFromPosition(const Position &Pos, StringRef Content) const;
+  llvm::Error addReplacementForReference(const ReferencesResult::Reference 
&Ref,
+ const MakeReplacement 
&GetReplacement);
+  llvm::Error addReplacement(StringRef FilePath, StringRef Content,
+ const tooling::Replacement &Replacement);
+  Position getPosition(const Decl &D) const;
+
+  const EnumDecl *D = nullptr;
+  const Selection *S = nullptr;
+  SourceManager *SM = nullptr;
+  llvm::SmallVector> ExtraBuffers;
+  llvm::StringMap ContentPerFile;
+  Effect E;
+};
+
+REGISTER_TWEAK(ScopifyEnum)
+
+bool ScopifyEnum::prepare(const Selection &Inputs) {
+  if (!Inputs.AST->getLangOpts().CPlusPlus11)
+return false;
+  const SelectionTree::Node *N = Inputs.ASTSelection.commonAncestor();
+  if (!N)
+return false;
+  D = N->ASTNode.get();
+  return D && !D->isScoped() && D->isThisDeclarationADefinition();
+}
+
+Expected ScopifyEnum::apply(const Selection &Inputs) {
+  S = &Inputs;
+  SM = &S->AST->getSourceManager();
+  E.FormatEdits = false;
+  ContentPerFile.insert(std::make_pair(SM->getFilename(D->getLocation()),
+   
SM->getBufferData(SM->getMainFileID(;
+
+  if (auto Err = addClassKeywordToDeclarations())
+return Err;
+  if (auto Err = scopifyEnumValues())
+return Err;
+
+  return E;
+}
+
+llvm::Error ScopifyEnum::addClassKeywordToDeclarations() {
+  for (const auto &Ref :
+   findReferences(*S->AST, getPosition(*D), 0, S->Index, false)
+   .References) {
+if (!(Ref.Attributes & ReferencesResult::Declaration))
+  continue;
+
+static const auto MakeReplacement = [](StringRef FilePath,
+   StringRef Content, unsigned Offset) 
{
+  return tooling::Replacement(FilePath, Offset, 0, "class ");
+};
+if (auto Err = addReplacementForReference(Ref, MakeReplacement))
+  return Err;
+  }
+  return llvm::Error::success();
+}
+
+llvm::Error ScopifyEnum::scopifyEnumValues() {
+  std::string PrefixToInsert(D->getName().data());
+  PrefixToInsert += "::";
+  for (auto It = D->enumerator_begin(); It != D->enumerator_end(); ++It) {

5chmidti wrote:

You can use `EnumDecl::enumerators` for a range-for here

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


[clang-tools-extra] [clangd] Add tweak for turning an unscoped into a scoped enum (PR #67645)

2023-09-28 Thread via cfe-commits


@@ -0,0 +1,222 @@
+//===--- ScopifyEnum.cpp --- -*- 
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 "ParsedAST.h"
+#include "XRefs.h"
+#include "refactor/Tweak.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+
+#include 
+
+namespace clang::clangd {
+namespace {
+
+/// Turns an unscoped into a scoped enum type.
+/// Before:
+///   enum E { EV1, EV2 };
+///^
+///   void f() { E e1 = EV1; }
+///
+/// After:
+///   enum class E { EV1, EV2 };
+///   void f() { E e1 = E::EV1; }
+///
+/// Note that the respective project code might not compile anymore
+/// if it made use of the now-gone implicit conversion to int.
+/// This is out of scope for this tweak.
+///
+/// TODO: In the above example, we could detect that the values
+///   start with the enum name, and remove that prefix.
+
+class ScopifyEnum : public Tweak {
+  const char *id() const final;
+  std::string title() const override { return "Convert to scoped enum"; }
+  llvm::StringLiteral kind() const override {
+return CodeAction::REFACTOR_KIND;
+  }
+  bool prepare(const Selection &Inputs) override;
+  Expected apply(const Selection &Inputs) override;
+
+  using MakeReplacement =
+  std::function;
+  llvm::Error addClassKeywordToDeclarations();
+  llvm::Error scopifyEnumValues();
+  llvm::Error scopifyEnumValue(const EnumConstantDecl &CD, StringRef Prefix);
+  llvm::Expected getContentForFile(StringRef FilePath);
+  unsigned getOffsetFromPosition(const Position &Pos, StringRef Content) const;
+  llvm::Error addReplacementForReference(const ReferencesResult::Reference 
&Ref,
+ const MakeReplacement 
&GetReplacement);
+  llvm::Error addReplacement(StringRef FilePath, StringRef Content,
+ const tooling::Replacement &Replacement);
+  Position getPosition(const Decl &D) const;
+
+  const EnumDecl *D = nullptr;
+  const Selection *S = nullptr;
+  SourceManager *SM = nullptr;
+  llvm::SmallVector> ExtraBuffers;

5chmidti wrote:

This looks unused, you only ever push into it.

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


[clang-tools-extra] [clangd] Add tweak for turning an unscoped into a scoped enum (PR #67645)

2023-09-28 Thread via cfe-commits


@@ -0,0 +1,222 @@
+//===--- ScopifyEnum.cpp --- -*- 
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 "ParsedAST.h"
+#include "XRefs.h"
+#include "refactor/Tweak.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+
+#include 
+
+namespace clang::clangd {
+namespace {
+
+/// Turns an unscoped into a scoped enum type.
+/// Before:
+///   enum E { EV1, EV2 };
+///^
+///   void f() { E e1 = EV1; }
+///
+/// After:
+///   enum class E { EV1, EV2 };
+///   void f() { E e1 = E::EV1; }
+///
+/// Note that the respective project code might not compile anymore
+/// if it made use of the now-gone implicit conversion to int.
+/// This is out of scope for this tweak.
+///
+/// TODO: In the above example, we could detect that the values
+///   start with the enum name, and remove that prefix.
+
+class ScopifyEnum : public Tweak {
+  const char *id() const final;
+  std::string title() const override { return "Convert to scoped enum"; }
+  llvm::StringLiteral kind() const override {
+return CodeAction::REFACTOR_KIND;
+  }
+  bool prepare(const Selection &Inputs) override;
+  Expected apply(const Selection &Inputs) override;
+
+  using MakeReplacement =
+  std::function;
+  llvm::Error addClassKeywordToDeclarations();
+  llvm::Error scopifyEnumValues();
+  llvm::Error scopifyEnumValue(const EnumConstantDecl &CD, StringRef Prefix);
+  llvm::Expected getContentForFile(StringRef FilePath);
+  unsigned getOffsetFromPosition(const Position &Pos, StringRef Content) const;
+  llvm::Error addReplacementForReference(const ReferencesResult::Reference 
&Ref,
+ const MakeReplacement 
&GetReplacement);
+  llvm::Error addReplacement(StringRef FilePath, StringRef Content,
+ const tooling::Replacement &Replacement);
+  Position getPosition(const Decl &D) const;
+
+  const EnumDecl *D = nullptr;
+  const Selection *S = nullptr;
+  SourceManager *SM = nullptr;
+  llvm::SmallVector> ExtraBuffers;
+  llvm::StringMap ContentPerFile;
+  Effect E;
+};
+
+REGISTER_TWEAK(ScopifyEnum)
+
+bool ScopifyEnum::prepare(const Selection &Inputs) {
+  if (!Inputs.AST->getLangOpts().CPlusPlus11)
+return false;
+  const SelectionTree::Node *N = Inputs.ASTSelection.commonAncestor();
+  if (!N)
+return false;
+  D = N->ASTNode.get();
+  return D && !D->isScoped() && D->isThisDeclarationADefinition();
+}
+
+Expected ScopifyEnum::apply(const Selection &Inputs) {
+  S = &Inputs;
+  SM = &S->AST->getSourceManager();
+  E.FormatEdits = false;
+  ContentPerFile.insert(std::make_pair(SM->getFilename(D->getLocation()),
+   
SM->getBufferData(SM->getMainFileID(;
+
+  if (auto Err = addClassKeywordToDeclarations())
+return Err;
+  if (auto Err = scopifyEnumValues())
+return Err;
+
+  return E;
+}
+
+llvm::Error ScopifyEnum::addClassKeywordToDeclarations() {
+  for (const auto &Ref :
+   findReferences(*S->AST, getPosition(*D), 0, S->Index, false)
+   .References) {
+if (!(Ref.Attributes & ReferencesResult::Declaration))
+  continue;
+
+static const auto MakeReplacement = [](StringRef FilePath,
+   StringRef Content, unsigned Offset) 
{
+  return tooling::Replacement(FilePath, Offset, 0, "class ");
+};
+if (auto Err = addReplacementForReference(Ref, MakeReplacement))
+  return Err;
+  }
+  return llvm::Error::success();
+}
+
+llvm::Error ScopifyEnum::scopifyEnumValues() {
+  std::string PrefixToInsert(D->getName().data());

5chmidti wrote:

`D->getNameAsString()` is better than `.data()` imo

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


[clang-tools-extra] [clangd] Add tweak for turning an unscoped into a scoped enum (PR #67645)

2023-09-28 Thread via cfe-commits

https://github.com/ckandeler updated 
https://github.com/llvm/llvm-project/pull/67645

>From df429597ae38c9d3da487ad0069b3a9e8b33bc25 Mon Sep 17 00:00:00 2001
From: Christian Kandeler 
Date: Mon, 25 Sep 2023 16:55:53 +0200
Subject: [PATCH] [clangd] Add tweak for turning an unscoped into a scoped enum

---
 .../clangd/refactor/tweaks/CMakeLists.txt |   1 +
 .../clangd/refactor/tweaks/ScopifyEnum.cpp| 222 ++
 .../clangd/unittests/CMakeLists.txt   |   1 +
 .../unittests/tweaks/ScopifyEnumTests.cpp |  58 +
 clang-tools-extra/docs/ReleaseNotes.rst   |   3 +-
 5 files changed, 284 insertions(+), 1 deletion(-)
 create mode 100644 clang-tools-extra/clangd/refactor/tweaks/ScopifyEnum.cpp
 create mode 100644 
clang-tools-extra/clangd/unittests/tweaks/ScopifyEnumTests.cpp

diff --git a/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt 
b/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
index 526a073f619ea34..2e948c23569f686 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
+++ b/clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
@@ -27,6 +27,7 @@ add_clang_library(clangDaemonTweaks OBJECT
   PopulateSwitch.cpp
   RawStringLiteral.cpp
   RemoveUsingNamespace.cpp
+  ScopifyEnum.cpp
   SpecialMembers.cpp
   SwapIfBranches.cpp
 
diff --git a/clang-tools-extra/clangd/refactor/tweaks/ScopifyEnum.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/ScopifyEnum.cpp
new file mode 100644
index 000..357af8c9b679a99
--- /dev/null
+++ b/clang-tools-extra/clangd/refactor/tweaks/ScopifyEnum.cpp
@@ -0,0 +1,222 @@
+//===--- ScopifyEnum.cpp --- -*- 
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 "ParsedAST.h"
+#include "XRefs.h"
+#include "refactor/Tweak.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+
+#include 
+
+namespace clang::clangd {
+namespace {
+
+/// Turns an unscoped into a scoped enum type.
+/// Before:
+///   enum E { EV1, EV2 };
+///^
+///   void f() { E e1 = EV1; }
+///
+/// After:
+///   enum class E { EV1, EV2 };
+///   void f() { E e1 = E::EV1; }
+///
+/// Note that the respective project code might not compile anymore
+/// if it made use of the now-gone implicit conversion to int.
+/// This is out of scope for this tweak.
+///
+/// TODO: In the above example, we could detect that the values
+///   start with the enum name, and remove that prefix.
+
+class ScopifyEnum : public Tweak {
+  const char *id() const final;
+  std::string title() const override { return "Convert to scoped enum"; }
+  llvm::StringLiteral kind() const override {
+return CodeAction::REFACTOR_KIND;
+  }
+  bool prepare(const Selection &Inputs) override;
+  Expected apply(const Selection &Inputs) override;
+
+  using MakeReplacement =
+  std::function;
+  llvm::Error addClassKeywordToDeclarations();
+  llvm::Error scopifyEnumValues();
+  llvm::Error scopifyEnumValue(const EnumConstantDecl &CD, StringRef Prefix);
+  llvm::Expected getContentForFile(StringRef FilePath);
+  unsigned getOffsetFromPosition(const Position &Pos, StringRef Content) const;
+  llvm::Error addReplacementForReference(const ReferencesResult::Reference 
&Ref,
+ const MakeReplacement 
&GetReplacement);
+  llvm::Error addReplacement(StringRef FilePath, StringRef Content,
+ const tooling::Replacement &Replacement);
+  Position getPosition(const Decl &D) const;
+
+  const EnumDecl *D = nullptr;
+  const Selection *S = nullptr;
+  SourceManager *SM = nullptr;
+  llvm::SmallVector> ExtraBuffers;
+  llvm::StringMap ContentPerFile;
+  Effect E;
+};
+
+REGISTER_TWEAK(ScopifyEnum)
+
+bool ScopifyEnum::prepare(const Selection &Inputs) {
+  if (!Inputs.AST->getLangOpts().CPlusPlus11)
+return false;
+  const SelectionTree::Node *N = Inputs.ASTSelection.commonAncestor();
+  if (!N)
+return false;
+  D = N->ASTNode.get();
+  return D && !D->isScoped() && D->isThisDeclarationADefinition();
+}
+
+Expected ScopifyEnum::apply(const Selection &Inputs) {
+  S = &Inputs;
+  SM = &S->AST->getSourceManager();
+  E.FormatEdits = false;
+  ContentPerFile.insert(std::make_pair(SM->getFilename(D->getLocation()),
+   
SM->getBufferData(SM->getMainFileID(;
+
+  if (auto Err = addClassKeywordToDeclarations())
+return Err;
+  if (auto Err = scopifyEnumValues())
+return Err;
+
+  return E;
+}
+
+llvm::Error ScopifyEnum::addClassKeywordToDeclarations() {
+  for (const auto &Ref :
+   findReferences(*S->AST, getPosition(*D), 0, S

  1   2   3   4   5   >