Skip to content

Commit 692e38c

Browse files
committed
[[maybe_unused]], proper CMake flag setup
1 parent a3307cd commit 692e38c

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
@@ -1414,7 +1414,7 @@ void clang::emitBackendOutput(CompilerInstance &CI, CodeGenOptions &CGOpts,
14141414
std::unique_ptr<llvm::Module> EmptyModule;
14151415
if (!CGOpts.ThinLTOIndexFile.empty()) {
14161416
// FIXME(sandboxing): Figure out how to support distributed indexing.
1417-
auto BypassSandbox = sys::sandbox::scopedDisable();
1417+
[[maybe_unused]] auto BypassSandbox = sys::sandbox::scopedDisable();
14181418
// If we are performing a ThinLTO importing compile, load the function index
14191419
// into memory and pass it into runThinLTOBackend, which will run the
14201420
// 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
@@ -428,7 +428,7 @@ int CC1Command::Execute(ArrayRef<std::optional<StringRef>> Redirects,
428428

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

433433
llvm::CrashRecoveryContext CRC;
434434
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
llvm::sys::fs::file_status Status;
125125
if (llvm::sys::fs::status(ModuleFilename, Status) != std::error_code{})
126126
return 0;

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
@@ -427,7 +427,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
427427

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

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

676676
auto VFS = [] {
677-
auto BypassSandbox = sys::sandbox::scopedDisable();
677+
[[maybe_unused]] auto BypassSandbox = sys::sandbox::scopedDisable();
678678
return vfs::getRealFileSystem();
679679
}();
680680

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)