-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang][DepScan] Allow ModuleDep to be const #132968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang][DepScan] Allow ModuleDep to be const #132968
Conversation
* Mark the lazy computation of build arguments mutable. As that is not intended to otherwise mutate the state of the object.
@llvm/pr-subscribers-clang Author: Cyndy Ishida (cyndyishida) ChangesThis type can be exposed from C APIs, where instantiations of this type are not expected to mutate after creation. To support this, mark the lazy computation of build arguments mutable, as that is not intended to otherwise mutate the state of these objects. This was reviewed separately by @jansvoboda11 Full diff: https://github.com/llvm/llvm-project/pull/132968.diff 2 Files Affected:
diff --git a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
index 422202caddfd4..ed150b467e3a1 100644
--- a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -153,7 +153,7 @@ struct ModuleDeps {
/// Get (or compute) the compiler invocation that can be used to build this
/// module. Does not include argv[0].
- const std::vector<std::string> &getBuildArguments();
+ const std::vector<std::string> &getBuildArguments() const;
private:
friend class ModuleDepCollector;
@@ -166,7 +166,8 @@ struct ModuleDeps {
/// including transitive dependencies.
std::vector<std::string> FileDeps;
- std::variant<std::monostate, CowCompilerInvocation, std::vector<std::string>>
+ mutable std::variant<std::monostate, CowCompilerInvocation,
+ std::vector<std::string>>
BuildInfo;
};
diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index d715ef874e002..364f156566855 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -31,7 +31,9 @@ void ModuleDeps::forEachFileDep(llvm::function_ref<void(StringRef)> Cb) const {
}
}
-const std::vector<std::string> &ModuleDeps::getBuildArguments() {
+const std::vector<std::string> &ModuleDeps::getBuildArguments() const {
+ // FIXME: this operation is not thread safe and is expected to be called
+ // on a single thread. Otherwise it should be protected with a lock.
assert(!std::holds_alternative<std::monostate>(BuildInfo) &&
"Using uninitialized ModuleDeps");
if (const auto *CI = std::get_if<CowCompilerInvocation>(&BuildInfo))
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/59/builds/14918 Here is the relevant piece of the build log for the reference
|
This type can be exposed from C APIs, where instantiations of this type are not expected to mutate after creation. To support this, mark the lazy computation of build arguments mutable, as that is not intended to otherwise mutate the state of these objects. This was reviewed separately by @jansvoboda11 (cherry picked from commit 9aecbdf)
This type can be exposed from C APIs, where instantiations of this type are not expected to mutate after creation. To support this, mark the lazy computation of build arguments mutable, as that is not intended to otherwise mutate the state of these objects. This was reviewed separately by @jansvoboda11 (cherry picked from commit 9aecbdf)
This type can be exposed from C APIs, where instantiations of this type are not expected to mutate after creation. To support this, mark the lazy computation of build arguments mutable, as that is not intended to otherwise mutate the state of these objects.
This was reviewed separately by @jansvoboda11