-
Couldn't load subscription status.
- Fork 15k
[clang][analyzer] Load config through the proper VFS #159164
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
Conversation
|
@llvm/pr-subscribers-clang-static-analyzer-1 Author: Jan Svoboda (jansvoboda11) ChangesThis PR ensures that the Clang static analyzer loads the config file through the properly-configured VFS rather than through the bare real file system. This enables correctly going through VFS overlays, unifying the behavior with the rest of the compiler. Full diff: https://github.com/llvm/llvm-project/pull/159164.diff 1 Files Affected:
diff --git a/clang/lib/StaticAnalyzer/Checkers/Yaml.h b/clang/lib/StaticAnalyzer/Checkers/Yaml.h
index b2d17420686ee..ec521cbfcdc8e 100644
--- a/clang/lib/StaticAnalyzer/Checkers/Yaml.h
+++ b/clang/lib/StaticAnalyzer/Checkers/Yaml.h
@@ -14,6 +14,7 @@
#ifndef LLVM_CLANG_LIB_STATICANALYZER_CHECKER_YAML_H
#define LLVM_CLANG_LIB_STATICANALYZER_CHECKER_YAML_H
+#include "clang/Basic/SourceManager.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/YAMLTraits.h"
@@ -31,9 +32,12 @@ std::optional<T> getConfiguration(CheckerManager &Mgr, Checker *Chk,
if (ConfigFile.trim().empty())
return std::nullopt;
- llvm::vfs::FileSystem *FS = llvm::vfs::getRealFileSystem().get();
+ auto &VFS = Mgr.getASTContext()
+ .getSourceManager()
+ .getFileManager()
+ .getVirtualFileSystem();
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Buffer =
- FS->getBufferForFile(ConfigFile.str());
+ VFS.getBufferForFile(ConfigFile.str());
if (Buffer.getError()) {
Mgr.reportInvalidCheckerOptionValue(Chk, Option,
|
|
@llvm/pr-subscribers-clang Author: Jan Svoboda (jansvoboda11) ChangesThis PR ensures that the Clang static analyzer loads the config file through the properly-configured VFS rather than through the bare real file system. This enables correctly going through VFS overlays, unifying the behavior with the rest of the compiler. Full diff: https://github.com/llvm/llvm-project/pull/159164.diff 1 Files Affected:
diff --git a/clang/lib/StaticAnalyzer/Checkers/Yaml.h b/clang/lib/StaticAnalyzer/Checkers/Yaml.h
index b2d17420686ee..ec521cbfcdc8e 100644
--- a/clang/lib/StaticAnalyzer/Checkers/Yaml.h
+++ b/clang/lib/StaticAnalyzer/Checkers/Yaml.h
@@ -14,6 +14,7 @@
#ifndef LLVM_CLANG_LIB_STATICANALYZER_CHECKER_YAML_H
#define LLVM_CLANG_LIB_STATICANALYZER_CHECKER_YAML_H
+#include "clang/Basic/SourceManager.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/YAMLTraits.h"
@@ -31,9 +32,12 @@ std::optional<T> getConfiguration(CheckerManager &Mgr, Checker *Chk,
if (ConfigFile.trim().empty())
return std::nullopt;
- llvm::vfs::FileSystem *FS = llvm::vfs::getRealFileSystem().get();
+ auto &VFS = Mgr.getASTContext()
+ .getSourceManager()
+ .getFileManager()
+ .getVirtualFileSystem();
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Buffer =
- FS->getBufferForFile(ConfigFile.str());
+ VFS.getBufferForFile(ConfigFile.str());
if (Buffer.getError()) {
Mgr.reportInvalidCheckerOptionValue(Chk, Option,
|
|
Can you add a test case? |
This PR ensures that the Clang static analyzer loads the config file through the properly-configured VFS rather than through the bare real file system. This enables correctly going through VFS overlays, unifying the behavior with the rest of the compiler.
This PR ensures that the Clang static analyzer loads the config file through the properly-configured VFS rather than through the bare real file system. This enables correctly going through VFS overlays, unifying the behavior with the rest of the compiler.
This PR ensures that the Clang static analyzer loads the config file through the properly-configured VFS rather than through the bare real file system. This enables correctly going through VFS overlays, unifying the behavior with the rest of the compiler.