[PATCH] D64222: [sanitizers] Use covering ObjectFormatType switches
Hubert Tong via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 4 15:07:38 PDT 2019
hubert.reinterpretcast created this revision.
hubert.reinterpretcast added reviewers: sfertile, jasonliu, daltenty.
Herald added subscribers: sunfish, aheejin, hiraditya.
Herald added projects: clang, LLVM.
This patch removes the `default` case from some switches on `llvm::Triple::ObjectFormatType`, and cases for the missing enumerators (`UnknownObjectFormat`, `Wasm`, and `XCOFF`) are then added.
For `UnknownObjectFormat`, the effect of the action for the `default` case is maintained; otherwise, where `llvm_unreachable` is called, `report_fatal_error` is used instead.
Where the `default` case returns a default value, `report_fatal_error` is used for XCOFF as a placeholder. For `Wasm`, the effect of the action for the `default` case in maintained.
The code is structured to avoid strongly implying that the `Wasm` case is present for any reason other than to make the switch cover all `ObjectFormatType` enumerator values.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D64222
Files:
clang/lib/CodeGen/BackendUtil.cpp
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1919,7 +1919,12 @@
case Triple::COFF: return ".ASAN$GL";
case Triple::ELF: return "asan_globals";
case Triple::MachO: return "__DATA,__asan_globals,regular";
- default: break;
+ case Triple::Wasm:
+ case Triple::XCOFF:
+ report_fatal_error(
+ "ModuleAddressSanitizer not implemented for object file format.");
+ case Triple::UnknownObjectFormat:
+ break;
}
llvm_unreachable("unsupported object format");
}
Index: clang/lib/CodeGen/BackendUtil.cpp
===================================================================
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -231,9 +231,13 @@
return true;
case Triple::ELF:
return CGOpts.DataSections && !CGOpts.DisableIntegratedAS;
- default:
- return false;
+ case Triple::XCOFF:
+ llvm::report_fatal_error("ASan not implemented for XCOFF.");
+ case Triple::Wasm:
+ case Triple::UnknownObjectFormat:
+ break;
}
+ return false;
}
static void addAddressSanitizerPasses(const PassManagerBuilder &Builder,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64222.208085.patch
Type: text/x-patch
Size: 1301 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190704/27fdd41b/attachment.bin>
More information about the cfe-commits
mailing list