Skip to content

Commit fc161b1

Browse files
committed
[[maybe_unused]], proper CMake flag setup
1 parent 0a1d473 commit fc161b1

File tree

15 files changed

+31
-28
lines changed

15 files changed

+31
-28
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,7 @@ void clang::emitBackendOutput(CompilerInstance &CI, CodeGenOptions &CGOpts,
14361436
std::unique_ptr<llvm::Module> EmptyModule;
14371437
if (!CGOpts.ThinLTOIndexFile.empty()) {
14381438
// FIXME(sandboxing): Figure out how to support distributed indexing.
1439-
auto BypassSandbox = sys::sandbox::scopedDisable();
1439+
[[maybe_unused]] auto BypassSandbox = sys::sandbox::scopedDisable();
14401440
// If we are performing a ThinLTO importing compile, load the function index
14411441
// into memory and pass it into runThinLTOBackend, which will run the
14421442
// function importer and invoke LTO passes.

clang/lib/Driver/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1872,7 +1872,7 @@ bool Driver::getCrashDiagnosticFile(StringRef ReproCrashFilename,
18721872
assert(llvm::Triple(llvm::sys::getProcessTriple()).isOSDarwin() &&
18731873
"Only knows about .crash files on Darwin");
18741874
// This is not a formal output of the compiler, let's bypass the sandbox.
1875-
auto BypassSandbox = sandbox::scopedDisable();
1875+
[[maybe_unused]] auto BypassSandbox = sandbox::scopedDisable();
18761876

18771877
// The .crash file can be found on at ~/Library/Logs/DiagnosticReports/
18781878
// (or /Library/Logs/DiagnosticReports for root) and has the filename pattern

clang/lib/Driver/Job.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ int CC1Command::Execute(ArrayRef<std::optional<StringRef>> Redirects,
429429

430430
// Enabling the sandbox here allows us to restore its previous state even when
431431
// this cc1 invocation crashes.
432-
auto EnableSandbox = llvm::sys::sandbox::scopedEnable();
432+
[[maybe_unused]] auto EnableSandbox = llvm::sys::sandbox::scopedEnable();
433433

434434
llvm::CrashRecoveryContext CRC;
435435
CRC.DumpStackAndCleanupOnFailure = true;

clang/lib/Serialization/GlobalModuleIndex.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ GlobalModuleIndex::~GlobalModuleIndex() {
252252
std::pair<GlobalModuleIndex *, llvm::Error>
253253
GlobalModuleIndex::readIndex(StringRef Path) {
254254
// This is a compiler-internal input/output, let's bypass the sandbox.
255-
auto BypassSandbox = llvm::sys::sandbox::scopedDisable();
255+
[[maybe_unused]] auto BypassSandbox = llvm::sys::sandbox::scopedDisable();
256256

257257
// Load the index file, if it's there.
258258
llvm::SmallString<128> IndexPath;
@@ -848,7 +848,7 @@ GlobalModuleIndex::writeIndex(FileManager &FileMgr,
848848
const PCHContainerReader &PCHContainerRdr,
849849
StringRef Path) {
850850
// This is a compiler-internal input/output, let's bypass the sandbox.
851-
auto BypassSandbox = llvm::sys::sandbox::scopedDisable();
851+
[[maybe_unused]] auto BypassSandbox = llvm::sys::sandbox::scopedDisable();
852852

853853
llvm::SmallString<128> IndexPath;
854854
IndexPath += Path;

clang/lib/Serialization/ModuleCache.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void clang::maybePruneImpl(StringRef Path, time_t PruneInterval,
2929
return;
3030

3131
// This is a compiler-internal input/output, let's bypass the sandbox.
32-
auto BypassSandbox = llvm::sys::sandbox::scopedDisable();
32+
[[maybe_unused]] auto BypassSandbox = llvm::sys::sandbox::scopedDisable();
3333

3434
llvm::SmallString<128> TimestampFile(Path);
3535
llvm::sys::path::append(TimestampFile, "modules.timestamp");
@@ -120,7 +120,7 @@ class CrossProcessModuleCache : public ModuleCache {
120120

121121
std::time_t getModuleTimestamp(StringRef ModuleFilename) override {
122122
// This is a compiler-internal input/output, let's bypass the sandbox.
123-
auto SandboxBypass = llvm::sys::sandbox::scopedDisable();
123+
[[maybe_unused]] auto BypassSandbox = llvm::sys::sandbox::scopedDisable();
124124
std::string TimestampFilename =
125125
serialization::ModuleFile::getTimestampFilename(ModuleFilename);
126126
llvm::sys::fs::file_status Status;

clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ void HTMLDiagnostics::FlushDiagnosticsImpl(
259259
void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D,
260260
FilesMade *filesMade) {
261261
// FIXME(sandboxing): Remove this by adopting `llvm::vfs::OutputBackend`.
262-
auto SandboxBypass = llvm::sys::sandbox::scopedDisable();
262+
[[maybe_unused]] auto BypassSandbox = llvm::sys::sandbox::scopedDisable();
263263

264264
// Create the HTML directory if it is missing.
265265
if (!createdDir) {

clang/tools/driver/cc1_main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
274274

275275
/// Create the actual file system.
276276
auto VFS = [] {
277-
auto BypassSandbox = llvm::sys::sandbox::scopedDisable();
277+
[[maybe_unused]] auto BypassSandbox = llvm::sys::sandbox::scopedDisable();
278278
return llvm::vfs::getRealFileSystem();
279279
}();
280280
Clang->createVirtualFileSystem(std::move(VFS), DiagsBuffer);
@@ -309,7 +309,7 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
309309
// results now. This happens in -disable-free mode.
310310
{
311311
// This isn't a formal input or output of the compiler.
312-
auto BypassSandbox = llvm::sys::sandbox::scopedDisable();
312+
[[maybe_unused]] auto BypassSandbox = llvm::sys::sandbox::scopedDisable();
313313
std::unique_ptr<raw_ostream> IOFile = llvm::CreateInfoOutputFile();
314314
if (Clang->getCodeGenOpts().TimePassesJson) {
315315
*IOFile << "{\n";

clang/tools/driver/cc1as_main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
428428

429429
ErrorOr<std::unique_ptr<MemoryBuffer>> Buffer = [=] {
430430
// FIXME(sandboxing): Make this a proper input file.
431-
auto BypassSandbox = sys::sandbox::scopedDisable();
431+
[[maybe_unused]] auto BypassSandbox = sys::sandbox::scopedDisable();
432432
return MemoryBuffer::getFileOrSTDIN(Opts.InputFile, /*IsText=*/true);
433433
}();
434434

@@ -677,7 +677,7 @@ int cc1as_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
677677
DiagnosticsEngine Diags(DiagnosticIDs::create(), DiagOpts, DiagClient);
678678

679679
auto VFS = [] {
680-
auto BypassSandbox = sys::sandbox::scopedDisable();
680+
[[maybe_unused]] auto BypassSandbox = sys::sandbox::scopedDisable();
681681
return vfs::getRealFileSystem();
682682
}();
683683

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@
126126
* in non assert builds */
127127
#cmakedefine01 LLVM_UNREACHABLE_OPTIMIZE
128128

129+
/* Define if building LLVM with LLVM_ENABLE_IO_SANDBOX */
130+
#cmakedefine01 LLVM_ENABLE_IO_SANDBOX
131+
129132
/* Define to 1 if you have the DIA SDK installed, and to 0 if you don't. */
130133
#cmakedefine01 LLVM_ENABLE_DIA_SDK
131134

llvm/include/llvm/Support/IOSandbox.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ inline void violationIfEnabled() {
2929
#else
3030

3131
namespace llvm::sys::sandbox {
32-
inline int scopedEnable() {}
33-
inline int scopedDisable() {}
32+
inline int scopedEnable() { return 0; }
33+
inline int scopedDisable() { return 0; }
3434
inline void violationIfEnabled() {}
3535
} // namespace llvm::sys::sandbox
3636

0 commit comments

Comments
 (0)