Skip to content

Commit 9f3fdb0

Browse files
committed
Revert "[Driver] Use VFS to check if sanitizer blacklists exist"
This reverts commit ba6f906. Commit caused compilation errors on llvm tests. Will fix and re-land.
1 parent 2229391 commit 9f3fdb0

File tree

9 files changed

+23
-175
lines changed

9 files changed

+23
-175
lines changed

clang/lib/Basic/SanitizerSpecialCaseList.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ SanitizerSpecialCaseList::create(const std::vector<std::string> &Paths,
2020
std::string &Error) {
2121
std::unique_ptr<clang::SanitizerSpecialCaseList> SSCL(
2222
new SanitizerSpecialCaseList());
23-
if (SSCL->createInternal(Paths, VFS, Error)) {
23+
if (SSCL->createInternal(Paths, Error, VFS)) {
2424
SSCL->createSanitizerSections();
2525
return SSCL;
2626
}

clang/lib/Basic/XRayLists.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@ XRayFunctionFilter::XRayFunctionFilter(
1717
ArrayRef<std::string> AlwaysInstrumentPaths,
1818
ArrayRef<std::string> NeverInstrumentPaths,
1919
ArrayRef<std::string> AttrListPaths, SourceManager &SM)
20-
: AlwaysInstrument(llvm::SpecialCaseList::createOrDie(
21-
AlwaysInstrumentPaths, SM.getFileManager().getVirtualFileSystem())),
22-
NeverInstrument(llvm::SpecialCaseList::createOrDie(
23-
NeverInstrumentPaths, SM.getFileManager().getVirtualFileSystem())),
24-
AttrList(llvm::SpecialCaseList::createOrDie(
25-
AttrListPaths, SM.getFileManager().getVirtualFileSystem())),
26-
SM(SM) {}
20+
: AlwaysInstrument(
21+
llvm::SpecialCaseList::createOrDie(AlwaysInstrumentPaths)),
22+
NeverInstrument(llvm::SpecialCaseList::createOrDie(NeverInstrumentPaths)),
23+
AttrList(llvm::SpecialCaseList::createOrDie(AttrListPaths)), SM(SM) {}
2724

2825
XRayFunctionFilter::ImbueAttribute
2926
XRayFunctionFilter::shouldImbueFunction(StringRef FunctionName) const {

clang/lib/Driver/SanitizerArgs.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ static void addDefaultBlacklists(const Driver &D, SanitizerMask Kinds,
141141

142142
clang::SmallString<64> Path(D.ResourceDir);
143143
llvm::sys::path::append(Path, "share", BL.File);
144-
if (D.getVFS().exists(Path))
144+
if (llvm::sys::fs::exists(Path))
145145
BlacklistFiles.push_back(Path.str());
146146
else if (BL.Mask == SanitizerKind::CFI)
147147
// If cfi_blacklist.txt cannot be found in the resource dir, driver
@@ -563,7 +563,7 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
563563
if (Arg->getOption().matches(options::OPT_fsanitize_blacklist)) {
564564
Arg->claim();
565565
std::string BLPath = Arg->getValue();
566-
if (D.getVFS().exists(BLPath)) {
566+
if (llvm::sys::fs::exists(BLPath)) {
567567
UserBlacklistFiles.push_back(BLPath);
568568
} else {
569569
D.Diag(clang::diag::err_drv_no_such_file) << BLPath;
@@ -578,14 +578,14 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
578578
{
579579
std::string BLError;
580580
std::unique_ptr<llvm::SpecialCaseList> SCL(
581-
llvm::SpecialCaseList::create(UserBlacklistFiles, D.getVFS(), BLError));
581+
llvm::SpecialCaseList::create(UserBlacklistFiles, BLError));
582582
if (!SCL.get())
583583
D.Diag(clang::diag::err_drv_malformed_sanitizer_blacklist) << BLError;
584584
}
585585
{
586586
std::string BLError;
587-
std::unique_ptr<llvm::SpecialCaseList> SCL(llvm::SpecialCaseList::create(
588-
SystemBlacklistFiles, D.getVFS(), BLError));
587+
std::unique_ptr<llvm::SpecialCaseList> SCL(
588+
llvm::SpecialCaseList::create(SystemBlacklistFiles, BLError));
589589
if (!SCL.get())
590590
D.Diag(clang::diag::err_drv_malformed_sanitizer_blacklist) << BLError;
591591
}

clang/lib/Driver/XRayArgs.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ XRayArgs::XRayArgs(const ToolChain &TC, const ArgList &Args) {
129129
// are treated as actual dependencies.
130130
for (const auto &Filename :
131131
Args.getAllArgValues(options::OPT_fxray_always_instrument)) {
132-
if (D.getVFS().exists(Filename)) {
132+
if (llvm::sys::fs::exists(Filename)) {
133133
AlwaysInstrumentFiles.push_back(Filename);
134134
ExtraDeps.push_back(Filename);
135135
} else
@@ -138,7 +138,7 @@ XRayArgs::XRayArgs(const ToolChain &TC, const ArgList &Args) {
138138

139139
for (const auto &Filename :
140140
Args.getAllArgValues(options::OPT_fxray_never_instrument)) {
141-
if (D.getVFS().exists(Filename)) {
141+
if (llvm::sys::fs::exists(Filename)) {
142142
NeverInstrumentFiles.push_back(Filename);
143143
ExtraDeps.push_back(Filename);
144144
} else
@@ -147,7 +147,7 @@ XRayArgs::XRayArgs(const ToolChain &TC, const ArgList &Args) {
147147

148148
for (const auto &Filename :
149149
Args.getAllArgValues(options::OPT_fxray_attr_list)) {
150-
if (D.getVFS().exists(Filename)) {
150+
if (llvm::sys::fs::exists(Filename)) {
151151
AttrListFiles.push_back(Filename);
152152
ExtraDeps.push_back(Filename);
153153
} else

clang/unittests/Driver/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ add_clang_unittest(ClangDriverTests
99
ToolChainTest.cpp
1010
ModuleCacheTest.cpp
1111
MultilibTest.cpp
12-
SanitizerArgsTest.cpp
1312
)
1413

1514
clang_target_link_libraries(ClangDriverTests
1615
PRIVATE
1716
clangDriver
1817
clangBasic
19-
clangFrontend # For TextDiagnosticPrinter.
2018
)

clang/unittests/Driver/SanitizerArgsTest.cpp

Lines changed: 0 additions & 141 deletions
This file was deleted.

llvm/include/llvm/Support/SpecialCaseList.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,15 @@ class SpecialCaseList {
6969
/// Parses the special case list entries from files. On failure, returns
7070
/// 0 and writes an error message to string.
7171
static std::unique_ptr<SpecialCaseList>
72-
create(const std::vector<std::string> &Paths, llvm::vfs::FileSystem &FS,
73-
std::string &Error);
72+
create(const std::vector<std::string> &Paths, std::string &Error);
7473
/// Parses the special case list from a memory buffer. On failure, returns
7574
/// 0 and writes an error message to string.
7675
static std::unique_ptr<SpecialCaseList> create(const MemoryBuffer *MB,
7776
std::string &Error);
7877
/// Parses the special case list entries from files. On failure, reports a
7978
/// fatal error.
8079
static std::unique_ptr<SpecialCaseList>
81-
createOrDie(const std::vector<std::string> &Paths, llvm::vfs::FileSystem &FS);
80+
createOrDie(const std::vector<std::string> &Paths);
8281

8382
~SpecialCaseList();
8483

@@ -104,8 +103,8 @@ class SpecialCaseList {
104103
protected:
105104
// Implementations of the create*() functions that can also be used by derived
106105
// classes.
107-
bool createInternal(const std::vector<std::string> &Paths,
108-
vfs::FileSystem &VFS, std::string &Error);
106+
bool createInternal(const std::vector<std::string> &Paths, std::string &Error,
107+
vfs::FileSystem &VFS = *vfs::getRealFileSystem());
109108
bool createInternal(const MemoryBuffer *MB, std::string &Error);
110109

111110
SpecialCaseList() = default;

llvm/lib/Support/SpecialCaseList.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "llvm/ADT/StringExtras.h"
1919
#include "llvm/Support/MemoryBuffer.h"
2020
#include "llvm/Support/Regex.h"
21-
#include "llvm/Support/VirtualFileSystem.h"
2221
#include <string>
2322
#include <system_error>
2423
#include <utility>
@@ -72,9 +71,9 @@ unsigned SpecialCaseList::Matcher::match(StringRef Query) const {
7271

7372
std::unique_ptr<SpecialCaseList>
7473
SpecialCaseList::create(const std::vector<std::string> &Paths,
75-
llvm::vfs::FileSystem &FS, std::string &Error) {
74+
std::string &Error) {
7675
std::unique_ptr<SpecialCaseList> SCL(new SpecialCaseList());
77-
if (SCL->createInternal(Paths, FS, Error))
76+
if (SCL->createInternal(Paths, Error))
7877
return SCL;
7978
return nullptr;
8079
}
@@ -88,16 +87,15 @@ std::unique_ptr<SpecialCaseList> SpecialCaseList::create(const MemoryBuffer *MB,
8887
}
8988

9089
std::unique_ptr<SpecialCaseList>
91-
SpecialCaseList::createOrDie(const std::vector<std::string> &Paths,
92-
llvm::vfs::FileSystem &FS) {
90+
SpecialCaseList::createOrDie(const std::vector<std::string> &Paths) {
9391
std::string Error;
94-
if (auto SCL = create(Paths, FS, Error))
92+
if (auto SCL = create(Paths, Error))
9593
return SCL;
9694
report_fatal_error(Error);
9795
}
9896

9997
bool SpecialCaseList::createInternal(const std::vector<std::string> &Paths,
100-
vfs::FileSystem &VFS, std::string &Error) {
98+
std::string &Error, vfs::FileSystem &VFS) {
10199
StringMap<size_t> Sections;
102100
for (const auto &Path : Paths) {
103101
ErrorOr<std::unique_ptr<MemoryBuffer>> FileOrErr =

llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
#include "llvm/Support/CommandLine.h"
8989
#include "llvm/Support/ErrorHandling.h"
9090
#include "llvm/Support/SpecialCaseList.h"
91-
#include "llvm/Support/VirtualFileSystem.h"
9291
#include "llvm/Transforms/Instrumentation.h"
9392
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
9493
#include "llvm/Transforms/Utils/Local.h"
@@ -481,9 +480,7 @@ DataFlowSanitizer::DataFlowSanitizer(
481480
std::vector<std::string> AllABIListFiles(std::move(ABIListFiles));
482481
AllABIListFiles.insert(AllABIListFiles.end(), ClABIListFiles.begin(),
483482
ClABIListFiles.end());
484-
// FIXME: should we propagate vfs::FileSystem to this constructor?
485-
ABIList.set(
486-
SpecialCaseList::createOrDie(AllABIListFiles, *vfs::getRealFileSystem()));
483+
ABIList.set(SpecialCaseList::createOrDie(AllABIListFiles));
487484
}
488485

489486
FunctionType *DataFlowSanitizer::getArgsFunctionType(FunctionType *T) {

0 commit comments

Comments
 (0)