[clang] [Sema] Add check for bitfield assignments to larger integral types (PR #68276)

2023-10-23 Thread David Stone via cfe-commits

davidstone wrote:

The documentation for this should also explain how to write code such that the 
warning does not fire (by giving an example with `x & bitmask`)

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


[clang] [lldb] [clang][Modules] Move `ASTSourceDescriptor` into its own file (PR #67930)

2024-05-25 Thread David Stone via cfe-commits

https://github.com/davidstone updated 
https://github.com/llvm/llvm-project/pull/67930

>From 0933b8e0f3161c0037516f677f1de2e72811d921 Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sat, 25 May 2024 14:13:30 -0600
Subject: [PATCH] [clang][Modules] Move `ASTSourceDescriptor` into its own file

---
 .../include/clang/Basic/ASTSourceDescriptor.h | 52 +++
 clang/include/clang/Basic/Module.h| 26 --
 clang/lib/AST/ExternalASTSource.cpp   |  2 +-
 clang/lib/Basic/ASTSourceDescriptor.cpp   | 33 
 clang/lib/Basic/CMakeLists.txt|  1 +
 clang/lib/Basic/Module.cpp| 15 --
 clang/lib/CodeGen/CGDebugInfo.h   |  3 +-
 clang/lib/Serialization/ASTReader.cpp |  1 +
 .../Plugins/ExpressionParser/Clang/ASTUtils.h |  8 ++-
 .../Clang/ClangExternalASTSourceCallbacks.cpp |  1 +
 .../Clang/ClangExternalASTSourceCallbacks.h   |  8 ++-
 11 files changed, 105 insertions(+), 45 deletions(-)
 create mode 100644 clang/include/clang/Basic/ASTSourceDescriptor.h
 create mode 100644 clang/lib/Basic/ASTSourceDescriptor.cpp

diff --git a/clang/include/clang/Basic/ASTSourceDescriptor.h 
b/clang/include/clang/Basic/ASTSourceDescriptor.h
new file mode 100644
index 0..175e0551db765
--- /dev/null
+++ b/clang/include/clang/Basic/ASTSourceDescriptor.h
@@ -0,0 +1,52 @@
+//===- ASTSourceDescriptor.h -*- 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
+//
+//===--===//
+//
+/// \file
+/// Defines the clang::ASTSourceDescriptor class, which abstracts clang modules
+/// and precompiled header files
+//
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
+#define LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
+
+#include "clang/Basic/Module.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+
+namespace clang {
+
+/// Abstracts clang modules and precompiled header files and holds
+/// everything needed to generate debug info for an imported module
+/// or PCH.
+class ASTSourceDescriptor {
+  StringRef PCHModuleName;
+  StringRef Path;
+  StringRef ASTFile;
+  ASTFileSignature Signature;
+  Module *ClangModule = nullptr;
+
+public:
+  ASTSourceDescriptor() = default;
+  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
+  ASTFileSignature Signature)
+  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
+ASTFile(std::move(ASTFile)), Signature(Signature) {}
+  ASTSourceDescriptor(Module &M);
+
+  std::string getModuleName() const;
+  StringRef getPath() const { return Path; }
+  StringRef getASTFile() const { return ASTFile; }
+  ASTFileSignature getSignature() const { return Signature; }
+  Module *getModuleOrNull() const { return ClangModule; }
+};
+
+} // namespace clang
+
+#endif // LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
diff --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 2d62d05cd9190..e86f4303d732b 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -868,32 +868,6 @@ class VisibleModuleSet {
   unsigned Generation = 0;
 };
 
-/// Abstracts clang modules and precompiled header files and holds
-/// everything needed to generate debug info for an imported module
-/// or PCH.
-class ASTSourceDescriptor {
-  StringRef PCHModuleName;
-  StringRef Path;
-  StringRef ASTFile;
-  ASTFileSignature Signature;
-  Module *ClangModule = nullptr;
-
-public:
-  ASTSourceDescriptor() = default;
-  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
-  ASTFileSignature Signature)
-  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
-ASTFile(std::move(ASTFile)), Signature(Signature) {}
-  ASTSourceDescriptor(Module &M);
-
-  std::string getModuleName() const;
-  StringRef getPath() const { return Path; }
-  StringRef getASTFile() const { return ASTFile; }
-  ASTFileSignature getSignature() const { return Signature; }
-  Module *getModuleOrNull() const { return ClangModule; }
-};
-
-
 } // namespace clang
 
 #endif // LLVM_CLANG_BASIC_MODULE_H
diff --git a/clang/lib/AST/ExternalASTSource.cpp 
b/clang/lib/AST/ExternalASTSource.cpp
index e96a474968511..a5b6f80bde694 100644
--- a/clang/lib/AST/ExternalASTSource.cpp
+++ b/clang/lib/AST/ExternalASTSource.cpp
@@ -15,10 +15,10 @@
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclarationName.h"
+#include "clang/Basic/ASTSourceDescriptor.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/Module.h"
 #include "clang/Basic/Source

[clang] Remove dangling conversion to `optional &` (PR #93385)

2024-05-25 Thread David Stone via cfe-commits

https://github.com/davidstone created 
https://github.com/llvm/llvm-project/pull/93385

None

>From 8c2ae501a09df7248117fa7d69cb0621aef14c1f Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sat, 25 May 2024 14:32:56 -0600
Subject: [PATCH] Remove dangling conversion to `optional &`

---
 clang/include/clang/Basic/CustomizableOptional.h | 8 
 1 file changed, 8 deletions(-)

diff --git a/clang/include/clang/Basic/CustomizableOptional.h 
b/clang/include/clang/Basic/CustomizableOptional.h
index 84d40025ee41b..2d6ae6a781a55 100644
--- a/clang/include/clang/Basic/CustomizableOptional.h
+++ b/clang/include/clang/Basic/CustomizableOptional.h
@@ -97,14 +97,6 @@ template  class CustomizableOptional {
   template  T value_or(U &&alt) && {
 return has_value() ? std::move(operator*()) : std::forward(alt);
   }
-
-  // Allow conversion to std::optional.
-  explicit operator std::optional &() const & {
-return *this ? **this : std::optional();
-  }
-  explicit operator std::optional &&() const && {
-return *this ? std::move(**this) : std::optional();
-  }
 };
 
 template 

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


[clang] [clang-tools-extra] [libcxx] [lldb] [llvm] Add clang basic module directory (PR #93388)

2024-05-25 Thread David Stone via cfe-commits

https://github.com/davidstone created 
https://github.com/llvm/llvm-project/pull/93388

Depends on https://github.com/llvm/llvm-project/pull/67930

>From 0933b8e0f3161c0037516f677f1de2e72811d921 Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sat, 25 May 2024 14:13:30 -0600
Subject: [PATCH 1/2] [clang][Modules] Move `ASTSourceDescriptor` into its own
 file

---
 .../include/clang/Basic/ASTSourceDescriptor.h | 52 +++
 clang/include/clang/Basic/Module.h| 26 --
 clang/lib/AST/ExternalASTSource.cpp   |  2 +-
 clang/lib/Basic/ASTSourceDescriptor.cpp   | 33 
 clang/lib/Basic/CMakeLists.txt|  1 +
 clang/lib/Basic/Module.cpp| 15 --
 clang/lib/CodeGen/CGDebugInfo.h   |  3 +-
 clang/lib/Serialization/ASTReader.cpp |  1 +
 .../Plugins/ExpressionParser/Clang/ASTUtils.h |  8 ++-
 .../Clang/ClangExternalASTSourceCallbacks.cpp |  1 +
 .../Clang/ClangExternalASTSourceCallbacks.h   |  8 ++-
 11 files changed, 105 insertions(+), 45 deletions(-)
 create mode 100644 clang/include/clang/Basic/ASTSourceDescriptor.h
 create mode 100644 clang/lib/Basic/ASTSourceDescriptor.cpp

diff --git a/clang/include/clang/Basic/ASTSourceDescriptor.h 
b/clang/include/clang/Basic/ASTSourceDescriptor.h
new file mode 100644
index 0..175e0551db765
--- /dev/null
+++ b/clang/include/clang/Basic/ASTSourceDescriptor.h
@@ -0,0 +1,52 @@
+//===- ASTSourceDescriptor.h -*- 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
+//
+//===--===//
+//
+/// \file
+/// Defines the clang::ASTSourceDescriptor class, which abstracts clang modules
+/// and precompiled header files
+//
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
+#define LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
+
+#include "clang/Basic/Module.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+
+namespace clang {
+
+/// Abstracts clang modules and precompiled header files and holds
+/// everything needed to generate debug info for an imported module
+/// or PCH.
+class ASTSourceDescriptor {
+  StringRef PCHModuleName;
+  StringRef Path;
+  StringRef ASTFile;
+  ASTFileSignature Signature;
+  Module *ClangModule = nullptr;
+
+public:
+  ASTSourceDescriptor() = default;
+  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
+  ASTFileSignature Signature)
+  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
+ASTFile(std::move(ASTFile)), Signature(Signature) {}
+  ASTSourceDescriptor(Module &M);
+
+  std::string getModuleName() const;
+  StringRef getPath() const { return Path; }
+  StringRef getASTFile() const { return ASTFile; }
+  ASTFileSignature getSignature() const { return Signature; }
+  Module *getModuleOrNull() const { return ClangModule; }
+};
+
+} // namespace clang
+
+#endif // LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
diff --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 2d62d05cd9190..e86f4303d732b 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -868,32 +868,6 @@ class VisibleModuleSet {
   unsigned Generation = 0;
 };
 
-/// Abstracts clang modules and precompiled header files and holds
-/// everything needed to generate debug info for an imported module
-/// or PCH.
-class ASTSourceDescriptor {
-  StringRef PCHModuleName;
-  StringRef Path;
-  StringRef ASTFile;
-  ASTFileSignature Signature;
-  Module *ClangModule = nullptr;
-
-public:
-  ASTSourceDescriptor() = default;
-  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
-  ASTFileSignature Signature)
-  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
-ASTFile(std::move(ASTFile)), Signature(Signature) {}
-  ASTSourceDescriptor(Module &M);
-
-  std::string getModuleName() const;
-  StringRef getPath() const { return Path; }
-  StringRef getASTFile() const { return ASTFile; }
-  ASTFileSignature getSignature() const { return Signature; }
-  Module *getModuleOrNull() const { return ClangModule; }
-};
-
-
 } // namespace clang
 
 #endif // LLVM_CLANG_BASIC_MODULE_H
diff --git a/clang/lib/AST/ExternalASTSource.cpp 
b/clang/lib/AST/ExternalASTSource.cpp
index e96a474968511..a5b6f80bde694 100644
--- a/clang/lib/AST/ExternalASTSource.cpp
+++ b/clang/lib/AST/ExternalASTSource.cpp
@@ -15,10 +15,10 @@
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclarationName.h"
+#include "clang/Basic/ASTSourceDescriptor.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.

[clang] [clang-tools-extra] [libcxx] [lldb] [llvm] Add clang basic module directory (PR #93388)

2024-05-25 Thread David Stone via cfe-commits

https://github.com/davidstone updated 
https://github.com/llvm/llvm-project/pull/93388

>From 0933b8e0f3161c0037516f677f1de2e72811d921 Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sat, 25 May 2024 14:13:30 -0600
Subject: [PATCH 1/3] [clang][Modules] Move `ASTSourceDescriptor` into its own
 file

---
 .../include/clang/Basic/ASTSourceDescriptor.h | 52 +++
 clang/include/clang/Basic/Module.h| 26 --
 clang/lib/AST/ExternalASTSource.cpp   |  2 +-
 clang/lib/Basic/ASTSourceDescriptor.cpp   | 33 
 clang/lib/Basic/CMakeLists.txt|  1 +
 clang/lib/Basic/Module.cpp| 15 --
 clang/lib/CodeGen/CGDebugInfo.h   |  3 +-
 clang/lib/Serialization/ASTReader.cpp |  1 +
 .../Plugins/ExpressionParser/Clang/ASTUtils.h |  8 ++-
 .../Clang/ClangExternalASTSourceCallbacks.cpp |  1 +
 .../Clang/ClangExternalASTSourceCallbacks.h   |  8 ++-
 11 files changed, 105 insertions(+), 45 deletions(-)
 create mode 100644 clang/include/clang/Basic/ASTSourceDescriptor.h
 create mode 100644 clang/lib/Basic/ASTSourceDescriptor.cpp

diff --git a/clang/include/clang/Basic/ASTSourceDescriptor.h 
b/clang/include/clang/Basic/ASTSourceDescriptor.h
new file mode 100644
index 0..175e0551db765
--- /dev/null
+++ b/clang/include/clang/Basic/ASTSourceDescriptor.h
@@ -0,0 +1,52 @@
+//===- ASTSourceDescriptor.h -*- 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
+//
+//===--===//
+//
+/// \file
+/// Defines the clang::ASTSourceDescriptor class, which abstracts clang modules
+/// and precompiled header files
+//
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
+#define LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
+
+#include "clang/Basic/Module.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+
+namespace clang {
+
+/// Abstracts clang modules and precompiled header files and holds
+/// everything needed to generate debug info for an imported module
+/// or PCH.
+class ASTSourceDescriptor {
+  StringRef PCHModuleName;
+  StringRef Path;
+  StringRef ASTFile;
+  ASTFileSignature Signature;
+  Module *ClangModule = nullptr;
+
+public:
+  ASTSourceDescriptor() = default;
+  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
+  ASTFileSignature Signature)
+  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
+ASTFile(std::move(ASTFile)), Signature(Signature) {}
+  ASTSourceDescriptor(Module &M);
+
+  std::string getModuleName() const;
+  StringRef getPath() const { return Path; }
+  StringRef getASTFile() const { return ASTFile; }
+  ASTFileSignature getSignature() const { return Signature; }
+  Module *getModuleOrNull() const { return ClangModule; }
+};
+
+} // namespace clang
+
+#endif // LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
diff --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 2d62d05cd9190..e86f4303d732b 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -868,32 +868,6 @@ class VisibleModuleSet {
   unsigned Generation = 0;
 };
 
-/// Abstracts clang modules and precompiled header files and holds
-/// everything needed to generate debug info for an imported module
-/// or PCH.
-class ASTSourceDescriptor {
-  StringRef PCHModuleName;
-  StringRef Path;
-  StringRef ASTFile;
-  ASTFileSignature Signature;
-  Module *ClangModule = nullptr;
-
-public:
-  ASTSourceDescriptor() = default;
-  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
-  ASTFileSignature Signature)
-  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
-ASTFile(std::move(ASTFile)), Signature(Signature) {}
-  ASTSourceDescriptor(Module &M);
-
-  std::string getModuleName() const;
-  StringRef getPath() const { return Path; }
-  StringRef getASTFile() const { return ASTFile; }
-  ASTFileSignature getSignature() const { return Signature; }
-  Module *getModuleOrNull() const { return ClangModule; }
-};
-
-
 } // namespace clang
 
 #endif // LLVM_CLANG_BASIC_MODULE_H
diff --git a/clang/lib/AST/ExternalASTSource.cpp 
b/clang/lib/AST/ExternalASTSource.cpp
index e96a474968511..a5b6f80bde694 100644
--- a/clang/lib/AST/ExternalASTSource.cpp
+++ b/clang/lib/AST/ExternalASTSource.cpp
@@ -15,10 +15,10 @@
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclarationName.h"
+#include "clang/Basic/ASTSourceDescriptor.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/Module.h"
 #include "clang/Basic/S

[clang] [clang-tools-extra] [libcxx] [lldb] [llvm] Add clang basic module directory (PR #93388)

2024-05-25 Thread David Stone via cfe-commits

https://github.com/davidstone updated 
https://github.com/llvm/llvm-project/pull/93388

>From 0933b8e0f3161c0037516f677f1de2e72811d921 Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sat, 25 May 2024 14:13:30 -0600
Subject: [PATCH 1/4] [clang][Modules] Move `ASTSourceDescriptor` into its own
 file

---
 .../include/clang/Basic/ASTSourceDescriptor.h | 52 +++
 clang/include/clang/Basic/Module.h| 26 --
 clang/lib/AST/ExternalASTSource.cpp   |  2 +-
 clang/lib/Basic/ASTSourceDescriptor.cpp   | 33 
 clang/lib/Basic/CMakeLists.txt|  1 +
 clang/lib/Basic/Module.cpp| 15 --
 clang/lib/CodeGen/CGDebugInfo.h   |  3 +-
 clang/lib/Serialization/ASTReader.cpp |  1 +
 .../Plugins/ExpressionParser/Clang/ASTUtils.h |  8 ++-
 .../Clang/ClangExternalASTSourceCallbacks.cpp |  1 +
 .../Clang/ClangExternalASTSourceCallbacks.h   |  8 ++-
 11 files changed, 105 insertions(+), 45 deletions(-)
 create mode 100644 clang/include/clang/Basic/ASTSourceDescriptor.h
 create mode 100644 clang/lib/Basic/ASTSourceDescriptor.cpp

diff --git a/clang/include/clang/Basic/ASTSourceDescriptor.h 
b/clang/include/clang/Basic/ASTSourceDescriptor.h
new file mode 100644
index 0..175e0551db765
--- /dev/null
+++ b/clang/include/clang/Basic/ASTSourceDescriptor.h
@@ -0,0 +1,52 @@
+//===- ASTSourceDescriptor.h -*- 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
+//
+//===--===//
+//
+/// \file
+/// Defines the clang::ASTSourceDescriptor class, which abstracts clang modules
+/// and precompiled header files
+//
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
+#define LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
+
+#include "clang/Basic/Module.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+
+namespace clang {
+
+/// Abstracts clang modules and precompiled header files and holds
+/// everything needed to generate debug info for an imported module
+/// or PCH.
+class ASTSourceDescriptor {
+  StringRef PCHModuleName;
+  StringRef Path;
+  StringRef ASTFile;
+  ASTFileSignature Signature;
+  Module *ClangModule = nullptr;
+
+public:
+  ASTSourceDescriptor() = default;
+  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
+  ASTFileSignature Signature)
+  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
+ASTFile(std::move(ASTFile)), Signature(Signature) {}
+  ASTSourceDescriptor(Module &M);
+
+  std::string getModuleName() const;
+  StringRef getPath() const { return Path; }
+  StringRef getASTFile() const { return ASTFile; }
+  ASTFileSignature getSignature() const { return Signature; }
+  Module *getModuleOrNull() const { return ClangModule; }
+};
+
+} // namespace clang
+
+#endif // LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
diff --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 2d62d05cd9190..e86f4303d732b 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -868,32 +868,6 @@ class VisibleModuleSet {
   unsigned Generation = 0;
 };
 
-/// Abstracts clang modules and precompiled header files and holds
-/// everything needed to generate debug info for an imported module
-/// or PCH.
-class ASTSourceDescriptor {
-  StringRef PCHModuleName;
-  StringRef Path;
-  StringRef ASTFile;
-  ASTFileSignature Signature;
-  Module *ClangModule = nullptr;
-
-public:
-  ASTSourceDescriptor() = default;
-  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
-  ASTFileSignature Signature)
-  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
-ASTFile(std::move(ASTFile)), Signature(Signature) {}
-  ASTSourceDescriptor(Module &M);
-
-  std::string getModuleName() const;
-  StringRef getPath() const { return Path; }
-  StringRef getASTFile() const { return ASTFile; }
-  ASTFileSignature getSignature() const { return Signature; }
-  Module *getModuleOrNull() const { return ClangModule; }
-};
-
-
 } // namespace clang
 
 #endif // LLVM_CLANG_BASIC_MODULE_H
diff --git a/clang/lib/AST/ExternalASTSource.cpp 
b/clang/lib/AST/ExternalASTSource.cpp
index e96a474968511..a5b6f80bde694 100644
--- a/clang/lib/AST/ExternalASTSource.cpp
+++ b/clang/lib/AST/ExternalASTSource.cpp
@@ -15,10 +15,10 @@
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclarationName.h"
+#include "clang/Basic/ASTSourceDescriptor.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/Module.h"
 #include "clang/Basic/S

[clang] [clang-tools-extra] [libcxx] [lldb] [llvm] Add clang basic module directory (PR #93388)

2024-05-25 Thread David Stone via cfe-commits

https://github.com/davidstone updated 
https://github.com/llvm/llvm-project/pull/93388

>From 0933b8e0f3161c0037516f677f1de2e72811d921 Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sat, 25 May 2024 14:13:30 -0600
Subject: [PATCH 1/5] [clang][Modules] Move `ASTSourceDescriptor` into its own
 file

---
 .../include/clang/Basic/ASTSourceDescriptor.h | 52 +++
 clang/include/clang/Basic/Module.h| 26 --
 clang/lib/AST/ExternalASTSource.cpp   |  2 +-
 clang/lib/Basic/ASTSourceDescriptor.cpp   | 33 
 clang/lib/Basic/CMakeLists.txt|  1 +
 clang/lib/Basic/Module.cpp| 15 --
 clang/lib/CodeGen/CGDebugInfo.h   |  3 +-
 clang/lib/Serialization/ASTReader.cpp |  1 +
 .../Plugins/ExpressionParser/Clang/ASTUtils.h |  8 ++-
 .../Clang/ClangExternalASTSourceCallbacks.cpp |  1 +
 .../Clang/ClangExternalASTSourceCallbacks.h   |  8 ++-
 11 files changed, 105 insertions(+), 45 deletions(-)
 create mode 100644 clang/include/clang/Basic/ASTSourceDescriptor.h
 create mode 100644 clang/lib/Basic/ASTSourceDescriptor.cpp

diff --git a/clang/include/clang/Basic/ASTSourceDescriptor.h 
b/clang/include/clang/Basic/ASTSourceDescriptor.h
new file mode 100644
index 0..175e0551db765
--- /dev/null
+++ b/clang/include/clang/Basic/ASTSourceDescriptor.h
@@ -0,0 +1,52 @@
+//===- ASTSourceDescriptor.h -*- 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
+//
+//===--===//
+//
+/// \file
+/// Defines the clang::ASTSourceDescriptor class, which abstracts clang modules
+/// and precompiled header files
+//
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
+#define LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
+
+#include "clang/Basic/Module.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+
+namespace clang {
+
+/// Abstracts clang modules and precompiled header files and holds
+/// everything needed to generate debug info for an imported module
+/// or PCH.
+class ASTSourceDescriptor {
+  StringRef PCHModuleName;
+  StringRef Path;
+  StringRef ASTFile;
+  ASTFileSignature Signature;
+  Module *ClangModule = nullptr;
+
+public:
+  ASTSourceDescriptor() = default;
+  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
+  ASTFileSignature Signature)
+  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
+ASTFile(std::move(ASTFile)), Signature(Signature) {}
+  ASTSourceDescriptor(Module &M);
+
+  std::string getModuleName() const;
+  StringRef getPath() const { return Path; }
+  StringRef getASTFile() const { return ASTFile; }
+  ASTFileSignature getSignature() const { return Signature; }
+  Module *getModuleOrNull() const { return ClangModule; }
+};
+
+} // namespace clang
+
+#endif // LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
diff --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 2d62d05cd9190..e86f4303d732b 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -868,32 +868,6 @@ class VisibleModuleSet {
   unsigned Generation = 0;
 };
 
-/// Abstracts clang modules and precompiled header files and holds
-/// everything needed to generate debug info for an imported module
-/// or PCH.
-class ASTSourceDescriptor {
-  StringRef PCHModuleName;
-  StringRef Path;
-  StringRef ASTFile;
-  ASTFileSignature Signature;
-  Module *ClangModule = nullptr;
-
-public:
-  ASTSourceDescriptor() = default;
-  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
-  ASTFileSignature Signature)
-  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
-ASTFile(std::move(ASTFile)), Signature(Signature) {}
-  ASTSourceDescriptor(Module &M);
-
-  std::string getModuleName() const;
-  StringRef getPath() const { return Path; }
-  StringRef getASTFile() const { return ASTFile; }
-  ASTFileSignature getSignature() const { return Signature; }
-  Module *getModuleOrNull() const { return ClangModule; }
-};
-
-
 } // namespace clang
 
 #endif // LLVM_CLANG_BASIC_MODULE_H
diff --git a/clang/lib/AST/ExternalASTSource.cpp 
b/clang/lib/AST/ExternalASTSource.cpp
index e96a474968511..a5b6f80bde694 100644
--- a/clang/lib/AST/ExternalASTSource.cpp
+++ b/clang/lib/AST/ExternalASTSource.cpp
@@ -15,10 +15,10 @@
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclarationName.h"
+#include "clang/Basic/ASTSourceDescriptor.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/Module.h"
 #include "clang/Basic/S

[clang] [clang-tools-extra] [libcxx] [clang][Modules] Remove unnecessary includes of `Module.h` (PR #93417)

2024-05-26 Thread David Stone via cfe-commits

https://github.com/davidstone created 
https://github.com/llvm/llvm-project/pull/93417

None

>From f4b9852b0c11a9b5087c5fdb7794b5cab7f4d22c Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sun, 26 May 2024 10:34:09 -0600
Subject: [PATCH] [clang][Modules] Remove unnecessary includes of `Module.h`

---
 .../clangd/unittests/ReplayPeambleTests.cpp   |  10 +-
 .../include/clang/APINotes/APINotesManager.h  |   5 +-
 .../Serialization/SymbolGraphSerializer.h |   1 -
 clang/include/clang/Serialization/ASTWriter.h |  32 ++---
 .../clang/Serialization/ModuleManager.h   |  14 +-
 clang/lib/APINotes/APINotesManager.cpp|   1 +
 clang/lib/AST/ASTDumper.cpp   |  12 +-
 clang/lib/CodeGen/CodeGenModule.h | 126 --
 clang/lib/ExtractAPI/API.cpp  |   1 -
 .../header_exportable_declarations.cpp|   2 -
 10 files changed, 93 insertions(+), 111 deletions(-)

diff --git a/clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp 
b/clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp
index 147d9abe69137..32942e6bbfdc8 100644
--- a/clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp
@@ -25,7 +25,6 @@
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/FileEntry.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/Module.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
@@ -42,7 +41,11 @@
 #include 
 #include 
 
-namespace clang::clangd {
+namespace clang {
+
+class Module;
+
+namespace clangd {
 namespace {
 struct Inclusion {
   Inclusion(const SourceManager &SM, SourceLocation HashLoc,
@@ -170,4 +173,5 @@ TEST(ReplayPreambleTest, IncludesAndSkippedFiles) {
   }
 }
 } // namespace
-} // namespace clang::clangd
+} // namespace clangd
+} // namespace clang
diff --git a/clang/include/clang/APINotes/APINotesManager.h 
b/clang/include/clang/APINotes/APINotesManager.h
index 18375c9e51a17..40c6328319dbd 100644
--- a/clang/include/clang/APINotes/APINotesManager.h
+++ b/clang/include/clang/APINotes/APINotesManager.h
@@ -9,7 +9,6 @@
 #ifndef LLVM_CLANG_APINOTES_APINOTESMANAGER_H
 #define LLVM_CLANG_APINOTES_APINOTESMANAGER_H
 
-#include "clang/Basic/Module.h"
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
@@ -24,6 +23,7 @@ namespace clang {
 class DirectoryEntry;
 class FileEntry;
 class LangOptions;
+class Module;
 class SourceManager;
 
 namespace api_notes {
@@ -159,7 +159,8 @@ class APINotesManager {
   ArrayRef getCurrentModuleReaders() const {
 bool HasPublic = CurrentModuleReaders[ReaderKind::Public];
 bool HasPrivate = CurrentModuleReaders[ReaderKind::Private];
-assert((!HasPrivate || HasPublic) && "private module requires public 
module");
+assert((!HasPrivate || HasPublic) &&
+   "private module requires public module");
 if (!HasPrivate && !HasPublic)
   return {};
 return ArrayRef(CurrentModuleReaders).slice(0, HasPrivate ? 2 : 1);
diff --git 
a/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h 
b/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
index 27e9167ca1ad0..f8759bf2d8f25 100644
--- a/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
+++ b/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
@@ -17,7 +17,6 @@
 #ifndef LLVM_CLANG_EXTRACTAPI_SERIALIZATION_SYMBOLGRAPHSERIALIZER_H
 #define LLVM_CLANG_EXTRACTAPI_SERIALIZATION_SYMBOLGRAPHSERIALIZER_H
 
-#include "clang/Basic/Module.h"
 #include "clang/ExtractAPI/API.h"
 #include "clang/ExtractAPI/APIIgnoresList.h"
 #include "clang/ExtractAPI/Serialization/APISetVisitor.h"
diff --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index 88192e439a3f0..ddd3514b3c2db 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -18,7 +18,6 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/Module.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/SemaConsumer.h"
@@ -277,7 +276,8 @@ class ASTWriter : public ASTDeserializationListener,
   std::vector TypeOffsets;
 
   /// The first ID number we can use for our own identifiers.
-  serialization::IdentifierID FirstIdentID = 
serialization::NUM_PREDEF_IDENT_IDS;
+  serialization::IdentifierID FirstIdentID =
+  serialization::NUM_PREDEF_IDENT_IDS;
 
   /// The identifier ID that will be assigned to the next new identifier.
   serialization::IdentifierID NextIdentID = FirstIdentID;
@@ -288,7 +288,8 @@ class ASTWriter : public ASTDeserializationListener,
   /// The ID numbers for identifiers are consecutive (in order of
   /// discovery), starting at 1. An ID of zero refers to a NULL
   /// IdentifierInfo.
-  llvm::MapVec

[clang] [clang-tools-extra] [libcxx] [lldb] [llvm] Add clang basic module directory (PR #93388)

2024-05-26 Thread David Stone via cfe-commits

https://github.com/davidstone updated 
https://github.com/llvm/llvm-project/pull/93388

>From f4b9852b0c11a9b5087c5fdb7794b5cab7f4d22c Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sun, 26 May 2024 10:34:09 -0600
Subject: [PATCH 1/3] [clang][Modules] Remove unnecessary includes of
 `Module.h`

---
 .../clangd/unittests/ReplayPeambleTests.cpp   |  10 +-
 .../include/clang/APINotes/APINotesManager.h  |   5 +-
 .../Serialization/SymbolGraphSerializer.h |   1 -
 clang/include/clang/Serialization/ASTWriter.h |  32 ++---
 .../clang/Serialization/ModuleManager.h   |  14 +-
 clang/lib/APINotes/APINotesManager.cpp|   1 +
 clang/lib/AST/ASTDumper.cpp   |  12 +-
 clang/lib/CodeGen/CodeGenModule.h | 126 --
 clang/lib/ExtractAPI/API.cpp  |   1 -
 .../header_exportable_declarations.cpp|   2 -
 10 files changed, 93 insertions(+), 111 deletions(-)

diff --git a/clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp 
b/clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp
index 147d9abe69137..32942e6bbfdc8 100644
--- a/clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp
@@ -25,7 +25,6 @@
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/FileEntry.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/Module.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
@@ -42,7 +41,11 @@
 #include 
 #include 
 
-namespace clang::clangd {
+namespace clang {
+
+class Module;
+
+namespace clangd {
 namespace {
 struct Inclusion {
   Inclusion(const SourceManager &SM, SourceLocation HashLoc,
@@ -170,4 +173,5 @@ TEST(ReplayPreambleTest, IncludesAndSkippedFiles) {
   }
 }
 } // namespace
-} // namespace clang::clangd
+} // namespace clangd
+} // namespace clang
diff --git a/clang/include/clang/APINotes/APINotesManager.h 
b/clang/include/clang/APINotes/APINotesManager.h
index 18375c9e51a17..40c6328319dbd 100644
--- a/clang/include/clang/APINotes/APINotesManager.h
+++ b/clang/include/clang/APINotes/APINotesManager.h
@@ -9,7 +9,6 @@
 #ifndef LLVM_CLANG_APINOTES_APINOTESMANAGER_H
 #define LLVM_CLANG_APINOTES_APINOTESMANAGER_H
 
-#include "clang/Basic/Module.h"
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
@@ -24,6 +23,7 @@ namespace clang {
 class DirectoryEntry;
 class FileEntry;
 class LangOptions;
+class Module;
 class SourceManager;
 
 namespace api_notes {
@@ -159,7 +159,8 @@ class APINotesManager {
   ArrayRef getCurrentModuleReaders() const {
 bool HasPublic = CurrentModuleReaders[ReaderKind::Public];
 bool HasPrivate = CurrentModuleReaders[ReaderKind::Private];
-assert((!HasPrivate || HasPublic) && "private module requires public 
module");
+assert((!HasPrivate || HasPublic) &&
+   "private module requires public module");
 if (!HasPrivate && !HasPublic)
   return {};
 return ArrayRef(CurrentModuleReaders).slice(0, HasPrivate ? 2 : 1);
diff --git 
a/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h 
b/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
index 27e9167ca1ad0..f8759bf2d8f25 100644
--- a/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
+++ b/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
@@ -17,7 +17,6 @@
 #ifndef LLVM_CLANG_EXTRACTAPI_SERIALIZATION_SYMBOLGRAPHSERIALIZER_H
 #define LLVM_CLANG_EXTRACTAPI_SERIALIZATION_SYMBOLGRAPHSERIALIZER_H
 
-#include "clang/Basic/Module.h"
 #include "clang/ExtractAPI/API.h"
 #include "clang/ExtractAPI/APIIgnoresList.h"
 #include "clang/ExtractAPI/Serialization/APISetVisitor.h"
diff --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index 88192e439a3f0..ddd3514b3c2db 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -18,7 +18,6 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/Module.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/SemaConsumer.h"
@@ -277,7 +276,8 @@ class ASTWriter : public ASTDeserializationListener,
   std::vector TypeOffsets;
 
   /// The first ID number we can use for our own identifiers.
-  serialization::IdentifierID FirstIdentID = 
serialization::NUM_PREDEF_IDENT_IDS;
+  serialization::IdentifierID FirstIdentID =
+  serialization::NUM_PREDEF_IDENT_IDS;
 
   /// The identifier ID that will be assigned to the next new identifier.
   serialization::IdentifierID NextIdentID = FirstIdentID;
@@ -288,7 +288,8 @@ class ASTWriter : public ASTDeserializationListener,
   /// The ID numbers for identifiers are consecutive (in order of
   /// discovery), starting at 1. An ID of zero refers to a NULL
   /// IdentifierInfo.
-  llvm::MapVect

[clang] [clang-tools-extra] [libcxx] [lldb] [llvm] Add clang basic module directory (PR #93388)

2024-05-26 Thread David Stone via cfe-commits

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


[clang] [clang-tools-extra] [libcxx] [lldb] [llvm] Add clang basic module directory (PR #93388)

2024-05-26 Thread David Stone via cfe-commits

davidstone wrote:

> I don't like the PR since I don't feel it makes the code cleaner and it may 
> make the downstream suffering backporting.
> 
> If there are deeper reasons or following patches, we can discuss them 
> seperately.

On its own, I would agree. My goal is to split several more things out of 
`Module.h` but still keep all the module things together. I'm fine letting this 
sit until I get some of those other changes together and we can look over a 
broader set of changes and see if the direction is good.

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


[clang] [clang-tools-extra] [libcxx] [lldb] [llvm] Add clang basic module directory (PR #93388)

2024-05-26 Thread David Stone via cfe-commits

davidstone wrote:

To give a little more detail about my plans as of right now:

* Move `VisibleModuleSet` into its own file
* Move `ASTFileSignature` into its own file
* Take some of the related members of `Module`, group them together into their 
own class, and move the resulting classes into their own headers

That last one is the most vague, because until I actually do some of the work I 
won't really know what the proper divisions are. But even if that last bullet 
ends up being two things split out, the `Module` directory ends up with 6 files 
in it, which is a much more reasonable organizational structure than the 2 
files in this commit.

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


[clang] [clang-tools-extra] [libcxx] [clang][Modules] Remove unnecessary includes of `Module.h` (PR #93417)

2024-05-27 Thread David Stone via cfe-commits


@@ -159,7 +159,8 @@ class APINotesManager {
   ArrayRef getCurrentModuleReaders() const {
 bool HasPublic = CurrentModuleReaders[ReaderKind::Public];
 bool HasPrivate = CurrentModuleReaders[ReaderKind::Private];
-assert((!HasPrivate || HasPublic) && "private module requires public 
module");
+assert((!HasPrivate || HasPublic) &&
+   "private module requires public module");

davidstone wrote:

clang-format did that when I touched the file. Does the formatting requirement 
apply to a narrower set of changes than the entire file?

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


[clang] [clang-tools-extra] [libcxx] [clang][Modules] Remove unnecessary includes of `Module.h` (PR #93417)

2024-05-27 Thread David Stone via cfe-commits


@@ -42,7 +41,11 @@
 #include 
 #include 
 
-namespace clang::clangd {
+namespace clang {
+
+class Module;

davidstone wrote:

Is that a clangd preference or llvm-wide? I see a lot of forward declarations 
in other parts of the code so I want to understand when I should and shouldn't 
use them in this project.

The motivation is that I'm making a bunch of changes to Module.h, and reducing 
the number of files that include it speeds up my local development (and full 
builds, too) by requiring less rebuilding.

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


[clang] [clang-tools-extra] [libcxx] [clang][Modules] Remove unnecessary includes of `Module.h` (PR #93417)

2024-05-27 Thread David Stone via cfe-commits


@@ -42,7 +41,11 @@
 #include 
 #include 
 
-namespace clang::clangd {
+namespace clang {
+
+class Module;

davidstone wrote:

Specifically I'm following the guidance at: 
https://llvm.org/docs/CodingStandards.html#include-as-little-as-possible

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


[clang] [clang] Be const-correct with all uses of `Module *`. (PR #93493)

2024-05-27 Thread David Stone via cfe-commits

davidstone wrote:

> Can you make sure that at every place this PR touches `const` makes sense? I 
> found out recently that we can be quite good at pretending that something is 
> `const`, all the way down until we realize we need a `const_cast`, because 
> modification is required in that one place.

I'm not quite sure I understand the question. This PR doesn't add any 
`const_cast`, and `const` is checked by the compiler so a successful build 
shows that we're never modifying something declared `const`. What additional 
work are you wanting?

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


[clang] [clang] Be const-correct with all uses of `Module *`. (PR #93493)

2024-05-27 Thread David Stone via cfe-commits

davidstone wrote:

> Can you make sure that at every place this PR touches `const` makes sense? I 
> found out recently that we can be quite good at pretending that something is 
> `const`, all the way down until we realize we need a `const_cast`, because 
> modification is required in that one place.

To add a little more flavor to my response, this PR is a precursor to a larger 
refactoring of `Module` itself. I plan on making some changes to it that 
require even less mutation for use (in other words, there are places in the 
code that I could not mark `const` in this PR but in the future we will be able 
to). I wanted to get all the trivial `const` stuff correct now so that my 
future changes will be smaller.

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


[clang] [clang] Be const-correct with all uses of `Module *`. (PR #93493)

2024-05-27 Thread David Stone via cfe-commits

davidstone wrote:

Yes. Is there anything else you want to see in this PR before it can be merged? 
(I don't have merge permissions). This is the type of PR likely to get lots of 
conflicts if it stays open for long, so I'd like to get it wrapped up as fast 
as possible.

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


[clang] [clang] Be const-correct with all uses of `Module *`. (PR #93493)

2024-05-28 Thread David Stone via cfe-commits

davidstone wrote:

I'll admit, I'm surprised this PR has any push-back at all since this feels 
like just applying a very generally accepted principle. Things should be const 
by default -- you need a reason to declare something as not const, you should 
never need a reason to declare something as const.

It's perfectly normal for a function named `setFoo` to accept a pointer to 
const: just because we are changing which Module something refers to does not 
mean that object needs to be able to modify the Module itself. It's just saying 
"Here is the thing we need to be able to read from later".

Right now, a lot of the clang code is designed as "Here is a whole bunch of 
state that huge chunks of the program have access to", which means that 
understanding how any part works requires understanding how everything works -- 
you cannot reason about anything in isolation. This is a problem.

The first step in fixing that is constraining who can modify the object. This 
commit is one of the sub-steps in that step. The next major commit I am working 
on tries to better encapsulate `Module` itself so that it gives out mutable 
access to less of its data. The biggest limitation to writing encapsulated 
classes is when they give out mutable references to any of their data because 
at that point you cannot control any invariants involving that piece of data.

Once we have that, the understanding how the state of a Module changes over 
time requires understanding a significantly smaller part of the codebase, which 
will then allow another follow-up commit that changes `Module` to conceptually 
represent a module, rather than just being a chunk of state. At that point, 
understanding how a `Module` works will require just reading the source of 
`Module` rather than the source of `clang/`.

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


[clang] [clang] Be const-correct with all uses of `Module *`. (PR #93493)

2024-05-28 Thread David Stone via cfe-commits

davidstone wrote:

My philosophy on problems like that is that the first step to getting out of a 
hole is to stop digging the hole. We aren't going to make all of clang 
const-correct overnight, right? My goal here is starting with this one type: 
`Module`, and working on it. To me, this commit *is* considering the bigger 
picture. Rather than just saying "Oh, I am going to change the interface of 
`Module` so that it can control its invariants and to do that I need to make 
just these parts const-correct", I noticed I needed to make that change in some 
parts so as a preparatory commit (this one) I first make sure we are as 
const-correct as we can be with the current `Module` interface. Then I'll be 
going through and adding more const later on as I refactor more of `Module`.

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


[clang] [clang] Be const-correct with all uses of `Module *`. (PR #93493)

2024-05-28 Thread David Stone via cfe-commits

davidstone wrote:

> > Errr, not certain I agree with this -- that basically is "admit defeat and 
> > stop aiming for const correctness."
> 
> Well, I am saying, add const to places we are pretty sure we will never 
> change, and leave const out when in doubt. Don't add const just because we 
> don't need mutation today.

That's the opposite of my view. Mutation needs to be justified. "What if we 
need it later" can be used to justify anything, and if we do need it later then 
we change the code then. Until that point, readers can see `const` and know 
that things aren't being changed out from under them while reasoning about what 
the code does.

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


[clang] [clang] Be const-correct with all uses of `Module *`. (PR #93493)

2024-05-28 Thread David Stone via cfe-commits


@@ -817,11 +817,11 @@ class alignas(8) Decl {
"owned local decl but no local module storage");
 return reinterpret_cast(this)[-1];
   }
-  void setLocalOwningModule(Module *M) {
+  void setLocalOwningModule(const Module *M) {

davidstone wrote:

Hmm yes I should have been more careful around that `reinterpret_cast`.

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


[clang] [clang-tools-extra] [libcxx] [clang][Modules] Remove unnecessary includes of `Module.h` (PR #93417)

2024-05-31 Thread David Stone via cfe-commits

https://github.com/davidstone updated 
https://github.com/llvm/llvm-project/pull/93417

>From 19b59231951b3ef48e36b0342f15d61687b72d8d Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Fri, 31 May 2024 09:40:02 -0600
Subject: [PATCH] [clang][Modules] Remove unnecessary includes of `Module.h`

---
 .../clangd/unittests/ReplayPeambleTests.cpp| 10 +++---
 clang/include/clang/APINotes/APINotesManager.h |  2 +-
 .../ExtractAPI/Serialization/SymbolGraphSerializer.h   |  1 -
 clang/include/clang/Serialization/ASTWriter.h  |  1 -
 clang/include/clang/Serialization/ModuleManager.h  |  1 -
 clang/lib/APINotes/APINotesManager.cpp |  1 +
 clang/lib/AST/ASTDumper.cpp|  1 -
 clang/lib/CodeGen/CodeGenModule.h  |  1 -
 clang/lib/ExtractAPI/API.cpp   |  1 -
 .../header_exportable_declarations.cpp |  2 --
 10 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp 
b/clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp
index 147d9abe69137..32942e6bbfdc8 100644
--- a/clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp
@@ -25,7 +25,6 @@
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/FileEntry.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/Module.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
@@ -42,7 +41,11 @@
 #include 
 #include 
 
-namespace clang::clangd {
+namespace clang {
+
+class Module;
+
+namespace clangd {
 namespace {
 struct Inclusion {
   Inclusion(const SourceManager &SM, SourceLocation HashLoc,
@@ -170,4 +173,5 @@ TEST(ReplayPreambleTest, IncludesAndSkippedFiles) {
   }
 }
 } // namespace
-} // namespace clang::clangd
+} // namespace clangd
+} // namespace clang
diff --git a/clang/include/clang/APINotes/APINotesManager.h 
b/clang/include/clang/APINotes/APINotesManager.h
index 18375c9e51a17..98592438e90ea 100644
--- a/clang/include/clang/APINotes/APINotesManager.h
+++ b/clang/include/clang/APINotes/APINotesManager.h
@@ -9,7 +9,6 @@
 #ifndef LLVM_CLANG_APINOTES_APINOTESMANAGER_H
 #define LLVM_CLANG_APINOTES_APINOTESMANAGER_H
 
-#include "clang/Basic/Module.h"
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
@@ -24,6 +23,7 @@ namespace clang {
 class DirectoryEntry;
 class FileEntry;
 class LangOptions;
+class Module;
 class SourceManager;
 
 namespace api_notes {
diff --git 
a/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h 
b/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
index 27e9167ca1ad0..f8759bf2d8f25 100644
--- a/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
+++ b/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
@@ -17,7 +17,6 @@
 #ifndef LLVM_CLANG_EXTRACTAPI_SERIALIZATION_SYMBOLGRAPHSERIALIZER_H
 #define LLVM_CLANG_EXTRACTAPI_SERIALIZATION_SYMBOLGRAPHSERIALIZER_H
 
-#include "clang/Basic/Module.h"
 #include "clang/ExtractAPI/API.h"
 #include "clang/ExtractAPI/APIIgnoresList.h"
 #include "clang/ExtractAPI/Serialization/APISetVisitor.h"
diff --git a/clang/include/clang/Serialization/ASTWriter.h 
b/clang/include/clang/Serialization/ASTWriter.h
index 88192e439a3f0..fcc007d6f8637 100644
--- a/clang/include/clang/Serialization/ASTWriter.h
+++ b/clang/include/clang/Serialization/ASTWriter.h
@@ -18,7 +18,6 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/Module.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/SemaConsumer.h"
diff --git a/clang/include/clang/Serialization/ModuleManager.h 
b/clang/include/clang/Serialization/ModuleManager.h
index 3bd379acf7eda..d770bc52eaf4f 100644
--- a/clang/include/clang/Serialization/ModuleManager.h
+++ b/clang/include/clang/Serialization/ModuleManager.h
@@ -15,7 +15,6 @@
 #define LLVM_CLANG_SERIALIZATION_MODULEMANAGER_H
 
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/Module.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Serialization/ModuleFile.h"
 #include "llvm/ADT/DenseMap.h"
diff --git a/clang/lib/APINotes/APINotesManager.cpp 
b/clang/lib/APINotes/APINotesManager.cpp
index 789bb97d81de0..039d09fa7cf57 100644
--- a/clang/lib/APINotes/APINotesManager.cpp
+++ b/clang/lib/APINotes/APINotesManager.cpp
@@ -12,6 +12,7 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
+#include "clang/Basic/Module.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/SourceMgrAdapter.h"
 #include "clang/Basic/Version.h"
diff --git a/clang/lib/AST/ASTDumper.cpp b/clang/lib/AST/ASTDumper.cpp
index 6efc5bb92e28d..c8973fdeda352 100644
--- a/clang/lib/AST/ASTDumper.cpp
+++ b/clang/l

[clang] [clang-tools-extra] [libcxx] [clang][Modules] Remove unnecessary includes of `Module.h` (PR #93417)

2024-05-31 Thread David Stone via cfe-commits


@@ -159,7 +159,8 @@ class APINotesManager {
   ArrayRef getCurrentModuleReaders() const {
 bool HasPublic = CurrentModuleReaders[ReaderKind::Public];
 bool HasPrivate = CurrentModuleReaders[ReaderKind::Private];
-assert((!HasPrivate || HasPublic) && "private module requires public 
module");
+assert((!HasPrivate || HasPublic) &&
+   "private module requires public module");

davidstone wrote:

OK, I set my VS Code to just format changed lines, looks like I have it working 
now.

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


[clang] Remove dangling conversion to `optional &` (PR #93385)

2024-05-31 Thread David Stone via cfe-commits

davidstone wrote:

Yes please

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


[clang] [lldb] [clang][Modules] Move `ASTSourceDescriptor` into its own file (PR #67930)

2024-06-02 Thread David Stone via cfe-commits

davidstone wrote:

Could I get someone to merge this for me if there are no other changes required?

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


[clang] [clang-tools-extra] [libcxx] [clang][Modules] Remove unnecessary includes of `Module.h` (PR #93417)

2024-06-02 Thread David Stone via cfe-commits

davidstone wrote:

Is there any additional work needed on this before it can be merged?

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


[clang] remove duplicate ModuleId alias (PR #67899)

2023-09-30 Thread David Stone via cfe-commits

https://github.com/davidstone created 
https://github.com/llvm/llvm-project/pull/67899

- [ADT] Guard PagedVector death tests
- [InstSimplify] Avoid use of ConstantExpr::getICmp. NFC (#67873)
- [RISCV][MC] Recognise that fcvt.d.s with frm != 0b000 is valid (#67555)
- [lipo] Support creating Universal 64 bit Mach-O files. (#67737)
- Fix -Wcovered-switch-default in MachOUniversalWriter.cpp (NFC)
- [lldb][windows] Cover more symbols in LLDB_EXPORT_ALL_SYMBOLS
- [clang] Remove duplicate `ModuleId` alias


>From 60646e9e3bf60cef57c97f7ded56520c8088bf58 Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sat, 30 Sep 2023 17:43:55 -0600
Subject: [PATCH] [clang] Remove duplicate `ModuleId` alias

---
 clang/lib/Lex/ModuleMap.cpp | 2 --
 1 file changed, 2 deletions(-)

diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index e8437572ebf4bf6..f65a5f145c04395 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -1551,8 +1551,6 @@ namespace clang {
 /// (or the end of the file).
 void skipUntil(MMToken::TokenKind K);
 
-using ModuleId = SmallVector, 2>;
-
 bool parseModuleId(ModuleId &Id);
 void parseModuleDecl();
 void parseExternModuleDecl();

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


[clang] remove duplicate ModuleId alias (PR #67899)

2023-09-30 Thread David Stone via cfe-commits

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


[clang] remove duplicate ModuleId alias (PR #67899)

2023-09-30 Thread David Stone via cfe-commits

https://github.com/davidstone updated 
https://github.com/llvm/llvm-project/pull/67899

>From 9bce0ece5bf8adaa094475305c44bcd06cd79e7f Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sat, 30 Sep 2023 22:30:29 -0600
Subject: [PATCH] [clang] Remove duplicate `ModuleId` alias

This alias is already defined in `clang/Basic/Module.h` to the same value.
---
 clang/lib/Lex/ModuleMap.cpp | 2 --
 1 file changed, 2 deletions(-)

diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index e8437572ebf4bf6..f65a5f145c04395 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -1551,8 +1551,6 @@ namespace clang {
 /// (or the end of the file).
 void skipUntil(MMToken::TokenKind K);
 
-using ModuleId = SmallVector, 2>;
-
 bool parseModuleId(ModuleId &Id);
 void parseModuleDecl();
 void parseExternModuleDecl();

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


[clang] remove duplicate ModuleId alias (PR #67899)

2023-09-30 Thread David Stone via cfe-commits

davidstone wrote:

The description got a little messed up somehow, but should be fixed.

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


[clang] [clang][Modules] Make `Module::Requirement` a struct (PR #67900)

2023-09-30 Thread David Stone via cfe-commits

https://github.com/davidstone created 
https://github.com/llvm/llvm-project/pull/67900

`Module::Requirement` was defined as a `std::pair`. This 
required a comment to explain what the data members mean and makes the usage 
harder to understand. Replace this with a struct with two members, 
`FeatureName` and `RequiredState`.

>From 0253be550776631980d77e7847c6337786d64911 Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sat, 30 Sep 2023 22:57:34 -0600
Subject: [PATCH] [clang][Modules] Make `Module::Requirement` a struct

`Module::Requirement` was defined as a `std::pair`. This 
required a comment to explain what the data members mean and makes the usage 
harder to understand. Replace this with a struct with two members, 
`FeatureName` and `RequiredState`.
---
 clang/include/clang/Basic/Module.h|  7 ---
 clang/lib/Basic/Module.cpp| 10 +-
 clang/lib/Lex/PPDirectives.cpp|  2 +-
 clang/lib/Serialization/ASTWriter.cpp |  4 ++--
 4 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 676fd372493a3aa..0a134b53d3d9801 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -281,9 +281,10 @@ class alignas(8) Module {
   /// found on the file system.
   SmallVector MissingHeaders;
 
-  /// An individual requirement: a feature name and a flag indicating
-  /// the required state of that feature.
-  using Requirement = std::pair;
+  struct Requirement {
+std::string FeatureName;
+bool RequiredState;
+  };
 
   /// The set of language features required to use this module.
   ///
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index 0455304ef7f2b1a..fff0067bc9f818f 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -140,8 +140,8 @@ bool Module::isUnimportable(const LangOptions &LangOpts,
   return true;
 }
 for (unsigned I = 0, N = Current->Requirements.size(); I != N; ++I) {
-  if (hasFeature(Current->Requirements[I].first, LangOpts, Target) !=
-  Current->Requirements[I].second) {
+  if (hasFeature(Current->Requirements[I].FeatureName, LangOpts, Target) !=
+  Current->Requirements[I].RequiredState) {
 Req = Current->Requirements[I];
 return true;
   }
@@ -312,7 +312,7 @@ bool Module::directlyUses(const Module *Requested) {
 void Module::addRequirement(StringRef Feature, bool RequiredState,
 const LangOptions &LangOpts,
 const TargetInfo &Target) {
-  Requirements.push_back(Requirement(std::string(Feature), RequiredState));
+  Requirements.push_back(Requirement{std::string(Feature), RequiredState});
 
   // If this feature is currently available, we're done.
   if (hasFeature(Feature, LangOpts, Target) == RequiredState)
@@ -497,9 +497,9 @@ void Module::print(raw_ostream &OS, unsigned Indent, bool 
Dump) const {
 for (unsigned I = 0, N = Requirements.size(); I != N; ++I) {
   if (I)
 OS << ", ";
-  if (!Requirements[I].second)
+  if (!Requirements[I].RequiredState)
 OS << "!";
-  OS << Requirements[I].first;
+  OS << Requirements[I].FeatureName;
 }
 OS << "\n";
   }
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 7899bfa1c4f5842..579836d47201355 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -1915,7 +1915,7 @@ bool Preprocessor::checkModuleIsAvailable(const 
LangOptions &LangOpts,
 // FIXME: Track the location at which the requirement was specified, and
 // use it here.
 Diags.Report(M->DefinitionLoc, diag::err_module_unavailable)
-<< M->getFullModuleName() << Requirement.second << Requirement.first;
+<< M->getFullModuleName() << Requirement.RequiredState << 
Requirement.FeatureName;
   }
   return true;
 }
diff --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 201e2fcaaec91aa..f03b47ec3214d1b 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -2896,8 +2896,8 @@ void ASTWriter::WriteSubmodules(Module *WritingModule) {
 
 // Emit the requirements.
 for (const auto &R : Mod->Requirements) {
-  RecordData::value_type Record[] = {SUBMODULE_REQUIRES, R.second};
-  Stream.EmitRecordWithBlob(RequiresAbbrev, Record, R.first);
+  RecordData::value_type Record[] = {SUBMODULE_REQUIRES, R.RequiredState};
+  Stream.EmitRecordWithBlob(RequiresAbbrev, Record, R.FeatureName);
 }
 
 // Emit the umbrella header, if there is one.

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


[clang] [clang][Modules] Make `Module::Requirement` a struct (PR #67900)

2023-09-30 Thread David Stone via cfe-commits

https://github.com/davidstone updated 
https://github.com/llvm/llvm-project/pull/67900

>From 0253be550776631980d77e7847c6337786d64911 Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sat, 30 Sep 2023 22:57:34 -0600
Subject: [PATCH 1/2] [clang][Modules] Make `Module::Requirement` a struct

`Module::Requirement` was defined as a `std::pair`. This 
required a comment to explain what the data members mean and makes the usage 
harder to understand. Replace this with a struct with two members, 
`FeatureName` and `RequiredState`.
---
 clang/include/clang/Basic/Module.h|  7 ---
 clang/lib/Basic/Module.cpp| 10 +-
 clang/lib/Lex/PPDirectives.cpp|  2 +-
 clang/lib/Serialization/ASTWriter.cpp |  4 ++--
 4 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 676fd372493a3aa..0a134b53d3d9801 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -281,9 +281,10 @@ class alignas(8) Module {
   /// found on the file system.
   SmallVector MissingHeaders;
 
-  /// An individual requirement: a feature name and a flag indicating
-  /// the required state of that feature.
-  using Requirement = std::pair;
+  struct Requirement {
+std::string FeatureName;
+bool RequiredState;
+  };
 
   /// The set of language features required to use this module.
   ///
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index 0455304ef7f2b1a..fff0067bc9f818f 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -140,8 +140,8 @@ bool Module::isUnimportable(const LangOptions &LangOpts,
   return true;
 }
 for (unsigned I = 0, N = Current->Requirements.size(); I != N; ++I) {
-  if (hasFeature(Current->Requirements[I].first, LangOpts, Target) !=
-  Current->Requirements[I].second) {
+  if (hasFeature(Current->Requirements[I].FeatureName, LangOpts, Target) !=
+  Current->Requirements[I].RequiredState) {
 Req = Current->Requirements[I];
 return true;
   }
@@ -312,7 +312,7 @@ bool Module::directlyUses(const Module *Requested) {
 void Module::addRequirement(StringRef Feature, bool RequiredState,
 const LangOptions &LangOpts,
 const TargetInfo &Target) {
-  Requirements.push_back(Requirement(std::string(Feature), RequiredState));
+  Requirements.push_back(Requirement{std::string(Feature), RequiredState});
 
   // If this feature is currently available, we're done.
   if (hasFeature(Feature, LangOpts, Target) == RequiredState)
@@ -497,9 +497,9 @@ void Module::print(raw_ostream &OS, unsigned Indent, bool 
Dump) const {
 for (unsigned I = 0, N = Requirements.size(); I != N; ++I) {
   if (I)
 OS << ", ";
-  if (!Requirements[I].second)
+  if (!Requirements[I].RequiredState)
 OS << "!";
-  OS << Requirements[I].first;
+  OS << Requirements[I].FeatureName;
 }
 OS << "\n";
   }
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 7899bfa1c4f5842..579836d47201355 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -1915,7 +1915,7 @@ bool Preprocessor::checkModuleIsAvailable(const 
LangOptions &LangOpts,
 // FIXME: Track the location at which the requirement was specified, and
 // use it here.
 Diags.Report(M->DefinitionLoc, diag::err_module_unavailable)
-<< M->getFullModuleName() << Requirement.second << Requirement.first;
+<< M->getFullModuleName() << Requirement.RequiredState << 
Requirement.FeatureName;
   }
   return true;
 }
diff --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 201e2fcaaec91aa..f03b47ec3214d1b 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -2896,8 +2896,8 @@ void ASTWriter::WriteSubmodules(Module *WritingModule) {
 
 // Emit the requirements.
 for (const auto &R : Mod->Requirements) {
-  RecordData::value_type Record[] = {SUBMODULE_REQUIRES, R.second};
-  Stream.EmitRecordWithBlob(RequiresAbbrev, Record, R.first);
+  RecordData::value_type Record[] = {SUBMODULE_REQUIRES, R.RequiredState};
+  Stream.EmitRecordWithBlob(RequiresAbbrev, Record, R.FeatureName);
 }
 
 // Emit the umbrella header, if there is one.

>From 46e59890368f66ae4ba6b1d242d08c1a7ec7676a Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sat, 30 Sep 2023 23:08:58 -0600
Subject: [PATCH 2/2] amend! [clang][Modules] Make `Module::Requirement` a
 struct

[clang][Modules] Make `Module::Requirement` a struct

`Module::Requirement` was defined as a `std::pair`. This 
required a comment to explain what the data members mean and makes the usage 
harder to understand. Replace this with a struct with two members, 
`FeatureName` and `RequiredState`.
---
 clang/lib/Basic/Module.cpp | 2 +-
 clang

[clang] [clang][Modules] `checkModuleIsAvailable` should use a const & parameter instead of pointer (PR #67902)

2023-09-30 Thread David Stone via cfe-commits

https://github.com/davidstone created 
https://github.com/llvm/llvm-project/pull/67902

The `Module` parameter to `checkModuleIsAvailable` is currently passed by 
pointer to non-const. However, it requires only const access and it cannot be 
null. Change this to be a reference to const instead.

This then makes it obvious that it is an input-only parameter, so move it to be 
before the in-out parameter for diagnostics.

>From 3b7cf88ddf78a1f7fbb15e51a288d7265e262b0d Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sun, 1 Oct 2023 00:41:34 -0600
Subject: [PATCH] [clang][Modules] `checkModuleIsAvailable` should use a const
 & parameter instead of pointer

The `Module` parameter to `checkModuleIsAvailable` is currently passed by 
pointer to non-const. However, it requires only const access and it cannot be 
null. Change this to be a reference to const instead.

This then makes it obvious that it is an input-only parameter, so move it to be 
before the in-out parameter for diagnostics.
---
 clang/include/clang/Lex/Preprocessor.h  |  2 +-
 clang/lib/Frontend/CompilerInstance.cpp |  2 +-
 clang/lib/Frontend/FrontendAction.cpp   |  4 ++--
 clang/lib/Lex/PPDirectives.cpp  | 18 ++
 clang/lib/Lex/Pragma.cpp|  2 +-
 5 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index e88164f196c1f7c..b9423640d62f741 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -2697,7 +2697,7 @@ class Preprocessor {
   /// \c false if the module appears to be usable.
   static bool checkModuleIsAvailable(const LangOptions &LangOpts,
  const TargetInfo &TargetInfo,
- DiagnosticsEngine &Diags, Module *M);
+ const Module &M, DiagnosticsEngine 
&Diags);
 
   // Module inclusion testing.
   /// Find the module that owns the source or header file that
diff --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index d18371f21a9d86e..d749195585eca5b 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -2116,7 +2116,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
 
 // Check whether this module is available.
 if (Preprocessor::checkModuleIsAvailable(getLangOpts(), getTarget(),
- getDiagnostics(), Module)) {
+ *Module, getDiagnostics())) {
   getDiagnostics().Report(ImportLoc, diag::note_module_import_here)
 << SourceRange(Path.front().second, Path.back().second);
   LastModuleImportLoc = ImportLoc;
diff --git a/clang/lib/Frontend/FrontendAction.cpp 
b/clang/lib/Frontend/FrontendAction.cpp
index 60eac0c6d353048..eb8a96627bb7076 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -510,8 +510,8 @@ static Module *prepareToBuildModule(CompilerInstance &CI,
   }
 
   // Check whether we can build this module at all.
-  if (Preprocessor::checkModuleIsAvailable(CI.getLangOpts(), CI.getTarget(),
-   CI.getDiagnostics(), M))
+  if (Preprocessor::checkModuleIsAvailable(CI.getLangOpts(), CI.getTarget(), 
*M,
+   CI.getDiagnostics()))
 return nullptr;
 
   // Inform the preprocessor that includes from within the input buffer should
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 7899bfa1c4f5842..e3065c17dc70b43 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -1896,26 +1896,27 @@ static bool trySimplifyPath(SmallVectorImpl 
&Components,
 
 bool Preprocessor::checkModuleIsAvailable(const LangOptions &LangOpts,
   const TargetInfo &TargetInfo,
-  DiagnosticsEngine &Diags, Module *M) 
{
+  const Module &M,
+  DiagnosticsEngine &Diags) {
   Module::Requirement Requirement;
   Module::UnresolvedHeaderDirective MissingHeader;
   Module *ShadowingModule = nullptr;
-  if (M->isAvailable(LangOpts, TargetInfo, Requirement, MissingHeader,
- ShadowingModule))
+  if (M.isAvailable(LangOpts, TargetInfo, Requirement, MissingHeader,
+ShadowingModule))
 return false;
 
   if (MissingHeader.FileNameLoc.isValid()) {
 Diags.Report(MissingHeader.FileNameLoc, diag::err_module_header_missing)
 << MissingHeader.IsUmbrella << MissingHeader.FileName;
   } else if (ShadowingModule) {
-Diags.Report(M->DefinitionLoc, diag::err_module_shadowed) << M->Name;
+Diags.Report(M.DefinitionLoc, diag::err_module_shadowed) << M.Name;
 Diags.Report(ShadowingModule->DefinitionLoc,

[clang] [clang][Modules] `checkModuleIsAvailable` should use a const & parameter instead of pointer (PR #67902)

2023-10-01 Thread David Stone via cfe-commits

https://github.com/davidstone updated 
https://github.com/llvm/llvm-project/pull/67902

>From 63c7f357cedd2633feac36ec07892243661764d9 Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sun, 1 Oct 2023 00:41:34 -0600
Subject: [PATCH] [clang][Modules] `checkModuleIsAvailable` should use a const
 & parameter instead of pointer

The `Module` parameter to `checkModuleIsAvailable` is currently passed by 
pointer to non-const. However, it requires only const access and it cannot be 
null. Change this to be a reference to const instead.

This then makes it obvious that it is an input-only parameter, so move it to be 
before the in-out parameter for diagnostics.
---
 clang/include/clang/Lex/Preprocessor.h  |  2 +-
 clang/lib/Frontend/CompilerInstance.cpp |  2 +-
 clang/lib/Frontend/FrontendAction.cpp   |  4 ++--
 clang/lib/Lex/PPDirectives.cpp  | 18 ++
 clang/lib/Lex/Pragma.cpp|  2 +-
 5 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index e88164f196c1f7c..b9423640d62f741 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -2697,7 +2697,7 @@ class Preprocessor {
   /// \c false if the module appears to be usable.
   static bool checkModuleIsAvailable(const LangOptions &LangOpts,
  const TargetInfo &TargetInfo,
- DiagnosticsEngine &Diags, Module *M);
+ const Module &M, DiagnosticsEngine 
&Diags);
 
   // Module inclusion testing.
   /// Find the module that owns the source or header file that
diff --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index d18371f21a9d86e..d749195585eca5b 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -2116,7 +2116,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
 
 // Check whether this module is available.
 if (Preprocessor::checkModuleIsAvailable(getLangOpts(), getTarget(),
- getDiagnostics(), Module)) {
+ *Module, getDiagnostics())) {
   getDiagnostics().Report(ImportLoc, diag::note_module_import_here)
 << SourceRange(Path.front().second, Path.back().second);
   LastModuleImportLoc = ImportLoc;
diff --git a/clang/lib/Frontend/FrontendAction.cpp 
b/clang/lib/Frontend/FrontendAction.cpp
index 60eac0c6d353048..eb8a96627bb7076 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -510,8 +510,8 @@ static Module *prepareToBuildModule(CompilerInstance &CI,
   }
 
   // Check whether we can build this module at all.
-  if (Preprocessor::checkModuleIsAvailable(CI.getLangOpts(), CI.getTarget(),
-   CI.getDiagnostics(), M))
+  if (Preprocessor::checkModuleIsAvailable(CI.getLangOpts(), CI.getTarget(), 
*M,
+   CI.getDiagnostics()))
 return nullptr;
 
   // Inform the preprocessor that includes from within the input buffer should
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 7899bfa1c4f5842..e3065c17dc70b43 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -1896,26 +1896,27 @@ static bool trySimplifyPath(SmallVectorImpl 
&Components,
 
 bool Preprocessor::checkModuleIsAvailable(const LangOptions &LangOpts,
   const TargetInfo &TargetInfo,
-  DiagnosticsEngine &Diags, Module *M) 
{
+  const Module &M,
+  DiagnosticsEngine &Diags) {
   Module::Requirement Requirement;
   Module::UnresolvedHeaderDirective MissingHeader;
   Module *ShadowingModule = nullptr;
-  if (M->isAvailable(LangOpts, TargetInfo, Requirement, MissingHeader,
- ShadowingModule))
+  if (M.isAvailable(LangOpts, TargetInfo, Requirement, MissingHeader,
+ShadowingModule))
 return false;
 
   if (MissingHeader.FileNameLoc.isValid()) {
 Diags.Report(MissingHeader.FileNameLoc, diag::err_module_header_missing)
 << MissingHeader.IsUmbrella << MissingHeader.FileName;
   } else if (ShadowingModule) {
-Diags.Report(M->DefinitionLoc, diag::err_module_shadowed) << M->Name;
+Diags.Report(M.DefinitionLoc, diag::err_module_shadowed) << M.Name;
 Diags.Report(ShadowingModule->DefinitionLoc,
  diag::note_previous_definition);
   } else {
 // FIXME: Track the location at which the requirement was specified, and
 // use it here.
-Diags.Report(M->DefinitionLoc, diag::err_module_unavailable)
-<< M->getFullModuleName() << Requirement.second << Requirement.first;
+Diags.Report(M.Definiti

[clang] [clang][Modules] Make `Module::Requirement` a struct (PR #67900)

2023-10-01 Thread David Stone via cfe-commits

https://github.com/davidstone updated 
https://github.com/llvm/llvm-project/pull/67900

>From 858a76e16a772078b29452645c5beb223c06dc8e Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sat, 30 Sep 2023 22:57:34 -0600
Subject: [PATCH 1/2] [clang][Modules] Make `Module::Requirement` a struct

`Module::Requirement` was defined as a `std::pair`. This 
required a comment to explain what the data members mean and makes the usage 
harder to understand. Replace this with a struct with two members, 
`FeatureName` and `RequiredState`.
---
 clang/include/clang/Basic/Module.h|  7 ---
 clang/lib/Basic/Module.cpp| 10 +-
 clang/lib/Lex/PPDirectives.cpp|  2 +-
 clang/lib/Serialization/ASTWriter.cpp |  4 ++--
 4 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 676fd372493a3aa..0a134b53d3d9801 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -281,9 +281,10 @@ class alignas(8) Module {
   /// found on the file system.
   SmallVector MissingHeaders;
 
-  /// An individual requirement: a feature name and a flag indicating
-  /// the required state of that feature.
-  using Requirement = std::pair;
+  struct Requirement {
+std::string FeatureName;
+bool RequiredState;
+  };
 
   /// The set of language features required to use this module.
   ///
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index 0455304ef7f2b1a..fff0067bc9f818f 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -140,8 +140,8 @@ bool Module::isUnimportable(const LangOptions &LangOpts,
   return true;
 }
 for (unsigned I = 0, N = Current->Requirements.size(); I != N; ++I) {
-  if (hasFeature(Current->Requirements[I].first, LangOpts, Target) !=
-  Current->Requirements[I].second) {
+  if (hasFeature(Current->Requirements[I].FeatureName, LangOpts, Target) !=
+  Current->Requirements[I].RequiredState) {
 Req = Current->Requirements[I];
 return true;
   }
@@ -312,7 +312,7 @@ bool Module::directlyUses(const Module *Requested) {
 void Module::addRequirement(StringRef Feature, bool RequiredState,
 const LangOptions &LangOpts,
 const TargetInfo &Target) {
-  Requirements.push_back(Requirement(std::string(Feature), RequiredState));
+  Requirements.push_back(Requirement{std::string(Feature), RequiredState});
 
   // If this feature is currently available, we're done.
   if (hasFeature(Feature, LangOpts, Target) == RequiredState)
@@ -497,9 +497,9 @@ void Module::print(raw_ostream &OS, unsigned Indent, bool 
Dump) const {
 for (unsigned I = 0, N = Requirements.size(); I != N; ++I) {
   if (I)
 OS << ", ";
-  if (!Requirements[I].second)
+  if (!Requirements[I].RequiredState)
 OS << "!";
-  OS << Requirements[I].first;
+  OS << Requirements[I].FeatureName;
 }
 OS << "\n";
   }
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 7899bfa1c4f5842..579836d47201355 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -1915,7 +1915,7 @@ bool Preprocessor::checkModuleIsAvailable(const 
LangOptions &LangOpts,
 // FIXME: Track the location at which the requirement was specified, and
 // use it here.
 Diags.Report(M->DefinitionLoc, diag::err_module_unavailable)
-<< M->getFullModuleName() << Requirement.second << Requirement.first;
+<< M->getFullModuleName() << Requirement.RequiredState << 
Requirement.FeatureName;
   }
   return true;
 }
diff --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 201e2fcaaec91aa..f03b47ec3214d1b 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -2896,8 +2896,8 @@ void ASTWriter::WriteSubmodules(Module *WritingModule) {
 
 // Emit the requirements.
 for (const auto &R : Mod->Requirements) {
-  RecordData::value_type Record[] = {SUBMODULE_REQUIRES, R.second};
-  Stream.EmitRecordWithBlob(RequiresAbbrev, Record, R.first);
+  RecordData::value_type Record[] = {SUBMODULE_REQUIRES, R.RequiredState};
+  Stream.EmitRecordWithBlob(RequiresAbbrev, Record, R.FeatureName);
 }
 
 // Emit the umbrella header, if there is one.

>From 6ca9fe84266c9d4257ba0102c571f4f4771f8bb2 Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sat, 30 Sep 2023 23:08:58 -0600
Subject: [PATCH 2/2] amend! [clang][Modules] Make `Module::Requirement` a
 struct

[clang][Modules] Make `Module::Requirement` a struct

`Module::Requirement` was defined as a `std::pair`. This 
required a comment to explain what the data members mean and makes the usage 
harder to understand. Replace this with a struct with two members, 
`FeatureName` and `RequiredState`.
---
 clang/lib/Basic/Module.cpp | 2 +-
 clang

[clang] remove duplicate ModuleId alias (PR #67899)

2023-10-01 Thread David Stone via cfe-commits

https://github.com/davidstone updated 
https://github.com/llvm/llvm-project/pull/67899

>From 3583e0420b5de21a88f3e7d1289f3b272e680a98 Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sat, 30 Sep 2023 22:30:29 -0600
Subject: [PATCH] [clang] Remove duplicate `ModuleId` alias

This alias is already defined in `clang/Basic/Module.h` to the same value.
---
 clang/lib/Lex/ModuleMap.cpp | 2 --
 1 file changed, 2 deletions(-)

diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index e8437572ebf4bf6..f65a5f145c04395 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -1551,8 +1551,6 @@ namespace clang {
 /// (or the end of the file).
 void skipUntil(MMToken::TokenKind K);
 
-using ModuleId = SmallVector, 2>;
-
 bool parseModuleId(ModuleId &Id);
 void parseModuleDecl();
 void parseExternModuleDecl();

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


[clang] [clang][Modules] Move `ASTSourceDescriptor` into its own file (PR #67930)

2023-10-01 Thread David Stone via cfe-commits

https://github.com/davidstone created 
https://github.com/llvm/llvm-project/pull/67930

None

>From a52da2e5889f14bcc36ae4263518a49e1e85c244 Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sun, 1 Oct 2023 12:02:48 -0600
Subject: [PATCH] [clang][Modules] Move `ASTSourceDescriptor` into its own file

---
 .../include/clang/Basic/ASTSourceDescriptor.h | 52 +++
 clang/include/clang/Basic/Module.h| 26 --
 clang/lib/AST/ExternalASTSource.cpp   |  2 +-
 clang/lib/Basic/ASTSourceDescriptor.cpp   | 33 
 clang/lib/Basic/CMakeLists.txt|  1 +
 clang/lib/Basic/Module.cpp| 15 --
 clang/lib/CodeGen/CGDebugInfo.h   |  3 +-
 clang/lib/Serialization/ASTReader.cpp |  1 +
 .../Plugins/ExpressionParser/Clang/ASTUtils.h |  8 ++-
 .../Clang/ClangExternalASTSourceCallbacks.cpp |  1 +
 .../Clang/ClangExternalASTSourceCallbacks.h   |  8 ++-
 11 files changed, 105 insertions(+), 45 deletions(-)
 create mode 100644 clang/include/clang/Basic/ASTSourceDescriptor.h
 create mode 100644 clang/lib/Basic/ASTSourceDescriptor.cpp

diff --git a/clang/include/clang/Basic/ASTSourceDescriptor.h 
b/clang/include/clang/Basic/ASTSourceDescriptor.h
new file mode 100644
index 000..175e0551db76562
--- /dev/null
+++ b/clang/include/clang/Basic/ASTSourceDescriptor.h
@@ -0,0 +1,52 @@
+//===- ASTSourceDescriptor.h -*- 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
+//
+//===--===//
+//
+/// \file
+/// Defines the clang::ASTSourceDescriptor class, which abstracts clang modules
+/// and precompiled header files
+//
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
+#define LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
+
+#include "clang/Basic/Module.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+
+namespace clang {
+
+/// Abstracts clang modules and precompiled header files and holds
+/// everything needed to generate debug info for an imported module
+/// or PCH.
+class ASTSourceDescriptor {
+  StringRef PCHModuleName;
+  StringRef Path;
+  StringRef ASTFile;
+  ASTFileSignature Signature;
+  Module *ClangModule = nullptr;
+
+public:
+  ASTSourceDescriptor() = default;
+  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
+  ASTFileSignature Signature)
+  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
+ASTFile(std::move(ASTFile)), Signature(Signature) {}
+  ASTSourceDescriptor(Module &M);
+
+  std::string getModuleName() const;
+  StringRef getPath() const { return Path; }
+  StringRef getASTFile() const { return ASTFile; }
+  ASTFileSignature getSignature() const { return Signature; }
+  Module *getModuleOrNull() const { return ClangModule; }
+};
+
+} // namespace clang
+
+#endif // LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
diff --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 676fd372493a3aa..60381472bbd4e59 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -850,32 +850,6 @@ class VisibleModuleSet {
   unsigned Generation = 0;
 };
 
-/// Abstracts clang modules and precompiled header files and holds
-/// everything needed to generate debug info for an imported module
-/// or PCH.
-class ASTSourceDescriptor {
-  StringRef PCHModuleName;
-  StringRef Path;
-  StringRef ASTFile;
-  ASTFileSignature Signature;
-  Module *ClangModule = nullptr;
-
-public:
-  ASTSourceDescriptor() = default;
-  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
-  ASTFileSignature Signature)
-  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
-ASTFile(std::move(ASTFile)), Signature(Signature) {}
-  ASTSourceDescriptor(Module &M);
-
-  std::string getModuleName() const;
-  StringRef getPath() const { return Path; }
-  StringRef getASTFile() const { return ASTFile; }
-  ASTFileSignature getSignature() const { return Signature; }
-  Module *getModuleOrNull() const { return ClangModule; }
-};
-
-
 } // namespace clang
 
 #endif // LLVM_CLANG_BASIC_MODULE_H
diff --git a/clang/lib/AST/ExternalASTSource.cpp 
b/clang/lib/AST/ExternalASTSource.cpp
index 090ef02aa4224d6..00bc6b4b919abf7 100644
--- a/clang/lib/AST/ExternalASTSource.cpp
+++ b/clang/lib/AST/ExternalASTSource.cpp
@@ -15,10 +15,10 @@
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclarationName.h"
+#include "clang/Basic/ASTSourceDescriptor.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/Module.h"
 #include "c

[clang] [clang][Modules] `checkModuleIsAvailable` should use a const & parameter instead of pointer (PR #67902)

2023-10-01 Thread David Stone via cfe-commits

davidstone wrote:

@ChuanqiXu9 

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


[clang] [clang][Modules] Make `Module::Requirement` a struct (PR #67900)

2023-10-01 Thread David Stone via cfe-commits

davidstone wrote:

@ChuanqiXu9 

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


[clang] remove duplicate ModuleId alias (PR #67899)

2023-10-01 Thread David Stone via cfe-commits

davidstone wrote:

@ChuanqiXu9 

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


[clang] remove duplicate ModuleId alias (PR #67899)

2023-10-02 Thread David Stone via cfe-commits

https://github.com/davidstone updated 
https://github.com/llvm/llvm-project/pull/67899

>From 07dd53a92efe420466b747dae821f892622e621f Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sat, 30 Sep 2023 22:30:29 -0600
Subject: [PATCH] [clang] Remove duplicate `ModuleId` alias

This alias is already defined in `clang/Basic/Module.h` to the same value.
---
 clang/lib/Lex/ModuleMap.cpp | 2 --
 1 file changed, 2 deletions(-)

diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index e8437572ebf4bf6..f65a5f145c04395 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -1551,8 +1551,6 @@ namespace clang {
 /// (or the end of the file).
 void skipUntil(MMToken::TokenKind K);
 
-using ModuleId = SmallVector, 2>;
-
 bool parseModuleId(ModuleId &Id);
 void parseModuleDecl();
 void parseExternModuleDecl();

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


[clang] [clang][Modules] Make `Module::Requirement` a struct (PR #67900)

2023-10-03 Thread David Stone via cfe-commits

https://github.com/davidstone updated 
https://github.com/llvm/llvm-project/pull/67900

>From b5e64ac8d36fef66cb8ef698f74997616d2957bc Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sat, 30 Sep 2023 22:57:34 -0600
Subject: [PATCH 1/2] [clang][Modules] Make `Module::Requirement` a struct

`Module::Requirement` was defined as a `std::pair`. This 
required a comment to explain what the data members mean and makes the usage 
harder to understand. Replace this with a struct with two members, 
`FeatureName` and `RequiredState`.
---
 clang/include/clang/Basic/Module.h|  7 ---
 clang/lib/Basic/Module.cpp| 10 +-
 clang/lib/Lex/PPDirectives.cpp|  2 +-
 clang/lib/Serialization/ASTWriter.cpp |  4 ++--
 4 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 676fd372493a3aa..0a134b53d3d9801 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -281,9 +281,10 @@ class alignas(8) Module {
   /// found on the file system.
   SmallVector MissingHeaders;
 
-  /// An individual requirement: a feature name and a flag indicating
-  /// the required state of that feature.
-  using Requirement = std::pair;
+  struct Requirement {
+std::string FeatureName;
+bool RequiredState;
+  };
 
   /// The set of language features required to use this module.
   ///
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index 0455304ef7f2b1a..fff0067bc9f818f 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -140,8 +140,8 @@ bool Module::isUnimportable(const LangOptions &LangOpts,
   return true;
 }
 for (unsigned I = 0, N = Current->Requirements.size(); I != N; ++I) {
-  if (hasFeature(Current->Requirements[I].first, LangOpts, Target) !=
-  Current->Requirements[I].second) {
+  if (hasFeature(Current->Requirements[I].FeatureName, LangOpts, Target) !=
+  Current->Requirements[I].RequiredState) {
 Req = Current->Requirements[I];
 return true;
   }
@@ -312,7 +312,7 @@ bool Module::directlyUses(const Module *Requested) {
 void Module::addRequirement(StringRef Feature, bool RequiredState,
 const LangOptions &LangOpts,
 const TargetInfo &Target) {
-  Requirements.push_back(Requirement(std::string(Feature), RequiredState));
+  Requirements.push_back(Requirement{std::string(Feature), RequiredState});
 
   // If this feature is currently available, we're done.
   if (hasFeature(Feature, LangOpts, Target) == RequiredState)
@@ -497,9 +497,9 @@ void Module::print(raw_ostream &OS, unsigned Indent, bool 
Dump) const {
 for (unsigned I = 0, N = Requirements.size(); I != N; ++I) {
   if (I)
 OS << ", ";
-  if (!Requirements[I].second)
+  if (!Requirements[I].RequiredState)
 OS << "!";
-  OS << Requirements[I].first;
+  OS << Requirements[I].FeatureName;
 }
 OS << "\n";
   }
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 7899bfa1c4f5842..579836d47201355 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -1915,7 +1915,7 @@ bool Preprocessor::checkModuleIsAvailable(const 
LangOptions &LangOpts,
 // FIXME: Track the location at which the requirement was specified, and
 // use it here.
 Diags.Report(M->DefinitionLoc, diag::err_module_unavailable)
-<< M->getFullModuleName() << Requirement.second << Requirement.first;
+<< M->getFullModuleName() << Requirement.RequiredState << 
Requirement.FeatureName;
   }
   return true;
 }
diff --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 201e2fcaaec91aa..f03b47ec3214d1b 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -2896,8 +2896,8 @@ void ASTWriter::WriteSubmodules(Module *WritingModule) {
 
 // Emit the requirements.
 for (const auto &R : Mod->Requirements) {
-  RecordData::value_type Record[] = {SUBMODULE_REQUIRES, R.second};
-  Stream.EmitRecordWithBlob(RequiresAbbrev, Record, R.first);
+  RecordData::value_type Record[] = {SUBMODULE_REQUIRES, R.RequiredState};
+  Stream.EmitRecordWithBlob(RequiresAbbrev, Record, R.FeatureName);
 }
 
 // Emit the umbrella header, if there is one.

>From c74e03c6c3df6aef31dc343a3732d5327b37338f Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sat, 30 Sep 2023 23:08:58 -0600
Subject: [PATCH 2/2] amend! [clang][Modules] Make `Module::Requirement` a
 struct

[clang][Modules] Make `Module::Requirement` a struct

`Module::Requirement` was defined as a `std::pair`. This 
required a comment to explain what the data members mean and makes the usage 
harder to understand. Replace this with a struct with two members, 
`FeatureName` and `RequiredState`.
---
 clang/lib/Basic/Module.cpp | 2 +-
 clang

[clang] [clang][Modules] `checkModuleIsAvailable` should use a const & parameter instead of pointer (PR #67902)

2023-10-03 Thread David Stone via cfe-commits

https://github.com/davidstone updated 
https://github.com/llvm/llvm-project/pull/67902

>From 43d6a4e8e07ef3dba977e3e3c2adf05ac184ba85 Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sun, 1 Oct 2023 00:41:34 -0600
Subject: [PATCH] [clang][Modules] `checkModuleIsAvailable` should use a const
 & parameter instead of pointer

The `Module` parameter to `checkModuleIsAvailable` is currently passed by 
pointer to non-const. However, it requires only const access and it cannot be 
null. Change this to be a reference to const instead.

This then makes it obvious that it is an input-only parameter, so move it to be 
before the in-out parameter for diagnostics.
---
 clang/include/clang/Lex/Preprocessor.h  |  2 +-
 clang/lib/Frontend/CompilerInstance.cpp |  2 +-
 clang/lib/Frontend/FrontendAction.cpp   |  4 ++--
 clang/lib/Lex/PPDirectives.cpp  | 18 ++
 clang/lib/Lex/Pragma.cpp|  2 +-
 5 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index e88164f196c1f7c..b9423640d62f741 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -2697,7 +2697,7 @@ class Preprocessor {
   /// \c false if the module appears to be usable.
   static bool checkModuleIsAvailable(const LangOptions &LangOpts,
  const TargetInfo &TargetInfo,
- DiagnosticsEngine &Diags, Module *M);
+ const Module &M, DiagnosticsEngine 
&Diags);
 
   // Module inclusion testing.
   /// Find the module that owns the source or header file that
diff --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index d18371f21a9d86e..d749195585eca5b 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -2116,7 +2116,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
 
 // Check whether this module is available.
 if (Preprocessor::checkModuleIsAvailable(getLangOpts(), getTarget(),
- getDiagnostics(), Module)) {
+ *Module, getDiagnostics())) {
   getDiagnostics().Report(ImportLoc, diag::note_module_import_here)
 << SourceRange(Path.front().second, Path.back().second);
   LastModuleImportLoc = ImportLoc;
diff --git a/clang/lib/Frontend/FrontendAction.cpp 
b/clang/lib/Frontend/FrontendAction.cpp
index 60eac0c6d353048..eb8a96627bb7076 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -510,8 +510,8 @@ static Module *prepareToBuildModule(CompilerInstance &CI,
   }
 
   // Check whether we can build this module at all.
-  if (Preprocessor::checkModuleIsAvailable(CI.getLangOpts(), CI.getTarget(),
-   CI.getDiagnostics(), M))
+  if (Preprocessor::checkModuleIsAvailable(CI.getLangOpts(), CI.getTarget(), 
*M,
+   CI.getDiagnostics()))
 return nullptr;
 
   // Inform the preprocessor that includes from within the input buffer should
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 7899bfa1c4f5842..e3065c17dc70b43 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -1896,26 +1896,27 @@ static bool trySimplifyPath(SmallVectorImpl 
&Components,
 
 bool Preprocessor::checkModuleIsAvailable(const LangOptions &LangOpts,
   const TargetInfo &TargetInfo,
-  DiagnosticsEngine &Diags, Module *M) 
{
+  const Module &M,
+  DiagnosticsEngine &Diags) {
   Module::Requirement Requirement;
   Module::UnresolvedHeaderDirective MissingHeader;
   Module *ShadowingModule = nullptr;
-  if (M->isAvailable(LangOpts, TargetInfo, Requirement, MissingHeader,
- ShadowingModule))
+  if (M.isAvailable(LangOpts, TargetInfo, Requirement, MissingHeader,
+ShadowingModule))
 return false;
 
   if (MissingHeader.FileNameLoc.isValid()) {
 Diags.Report(MissingHeader.FileNameLoc, diag::err_module_header_missing)
 << MissingHeader.IsUmbrella << MissingHeader.FileName;
   } else if (ShadowingModule) {
-Diags.Report(M->DefinitionLoc, diag::err_module_shadowed) << M->Name;
+Diags.Report(M.DefinitionLoc, diag::err_module_shadowed) << M.Name;
 Diags.Report(ShadowingModule->DefinitionLoc,
  diag::note_previous_definition);
   } else {
 // FIXME: Track the location at which the requirement was specified, and
 // use it here.
-Diags.Report(M->DefinitionLoc, diag::err_module_unavailable)
-<< M->getFullModuleName() << Requirement.second << Requirement.first;
+Diags.Report(M.Definiti

[clang] [clang][Modules] Move `ASTSourceDescriptor` into its own file (PR #67930)

2023-10-03 Thread David Stone via cfe-commits

https://github.com/davidstone updated 
https://github.com/llvm/llvm-project/pull/67930

>From 3cb09af262cf53cecb73e2da342a7891bc9fe853 Mon Sep 17 00:00:00 2001
From: David Stone 
Date: Sun, 1 Oct 2023 12:02:48 -0600
Subject: [PATCH] [clang][Modules] Move `ASTSourceDescriptor` into its own file

---
 .../include/clang/Basic/ASTSourceDescriptor.h | 52 +++
 clang/include/clang/Basic/Module.h| 26 --
 clang/lib/AST/ExternalASTSource.cpp   |  2 +-
 clang/lib/Basic/ASTSourceDescriptor.cpp   | 33 
 clang/lib/Basic/CMakeLists.txt|  1 +
 clang/lib/Basic/Module.cpp| 15 --
 clang/lib/CodeGen/CGDebugInfo.h   |  3 +-
 clang/lib/Serialization/ASTReader.cpp |  1 +
 .../Plugins/ExpressionParser/Clang/ASTUtils.h |  8 ++-
 .../Clang/ClangExternalASTSourceCallbacks.cpp |  1 +
 .../Clang/ClangExternalASTSourceCallbacks.h   |  8 ++-
 11 files changed, 105 insertions(+), 45 deletions(-)
 create mode 100644 clang/include/clang/Basic/ASTSourceDescriptor.h
 create mode 100644 clang/lib/Basic/ASTSourceDescriptor.cpp

diff --git a/clang/include/clang/Basic/ASTSourceDescriptor.h 
b/clang/include/clang/Basic/ASTSourceDescriptor.h
new file mode 100644
index 000..175e0551db76562
--- /dev/null
+++ b/clang/include/clang/Basic/ASTSourceDescriptor.h
@@ -0,0 +1,52 @@
+//===- ASTSourceDescriptor.h -*- 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
+//
+//===--===//
+//
+/// \file
+/// Defines the clang::ASTSourceDescriptor class, which abstracts clang modules
+/// and precompiled header files
+//
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
+#define LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
+
+#include "clang/Basic/Module.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+
+namespace clang {
+
+/// Abstracts clang modules and precompiled header files and holds
+/// everything needed to generate debug info for an imported module
+/// or PCH.
+class ASTSourceDescriptor {
+  StringRef PCHModuleName;
+  StringRef Path;
+  StringRef ASTFile;
+  ASTFileSignature Signature;
+  Module *ClangModule = nullptr;
+
+public:
+  ASTSourceDescriptor() = default;
+  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
+  ASTFileSignature Signature)
+  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
+ASTFile(std::move(ASTFile)), Signature(Signature) {}
+  ASTSourceDescriptor(Module &M);
+
+  std::string getModuleName() const;
+  StringRef getPath() const { return Path; }
+  StringRef getASTFile() const { return ASTFile; }
+  ASTFileSignature getSignature() const { return Signature; }
+  Module *getModuleOrNull() const { return ClangModule; }
+};
+
+} // namespace clang
+
+#endif // LLVM_CLANG_BASIC_ASTSOURCEDESCRIPTOR_H
diff --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 676fd372493a3aa..60381472bbd4e59 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -850,32 +850,6 @@ class VisibleModuleSet {
   unsigned Generation = 0;
 };
 
-/// Abstracts clang modules and precompiled header files and holds
-/// everything needed to generate debug info for an imported module
-/// or PCH.
-class ASTSourceDescriptor {
-  StringRef PCHModuleName;
-  StringRef Path;
-  StringRef ASTFile;
-  ASTFileSignature Signature;
-  Module *ClangModule = nullptr;
-
-public:
-  ASTSourceDescriptor() = default;
-  ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
-  ASTFileSignature Signature)
-  : PCHModuleName(std::move(Name)), Path(std::move(Path)),
-ASTFile(std::move(ASTFile)), Signature(Signature) {}
-  ASTSourceDescriptor(Module &M);
-
-  std::string getModuleName() const;
-  StringRef getPath() const { return Path; }
-  StringRef getASTFile() const { return ASTFile; }
-  ASTFileSignature getSignature() const { return Signature; }
-  Module *getModuleOrNull() const { return ClangModule; }
-};
-
-
 } // namespace clang
 
 #endif // LLVM_CLANG_BASIC_MODULE_H
diff --git a/clang/lib/AST/ExternalASTSource.cpp 
b/clang/lib/AST/ExternalASTSource.cpp
index 090ef02aa4224d6..00bc6b4b919abf7 100644
--- a/clang/lib/AST/ExternalASTSource.cpp
+++ b/clang/lib/AST/ExternalASTSource.cpp
@@ -15,10 +15,10 @@
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclarationName.h"
+#include "clang/Basic/ASTSourceDescriptor.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/Module.h"
 #include "clang/B

[clang] [clang][Modules] Make `Module::Requirement` a struct (PR #67900)

2023-10-04 Thread David Stone via cfe-commits

davidstone wrote:

Would someone be able to merge this for me? I do not have permission.

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


[clang] [clang][Modules] `checkModuleIsAvailable` should use a const & parameter instead of pointer (PR #67902)

2023-10-04 Thread David Stone via cfe-commits

davidstone wrote:

Would someone be able to merge this for me? I do not have permission.

https://github.com/llvm/llvm-project/pull/67902
___
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 emit function bodies which is noinline and av… (PR #68501)

2023-10-07 Thread David Stone via cfe-commits

davidstone wrote:

This looks reasonable to me. I'll try to test this out by Monday evening or 
earlier to see what practical effect it has for some of my programs.

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