r366544 - [sanitizers] Use covering ObjectFormatType switches

Hubert Tong via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 19 01:46:18 PDT 2019

Author: hubert.reinterpretcast
Date: Fri Jul 19 01:46:18 2019
New Revision: 366544

URL: http://llvm.org/viewvc/llvm-project?rev=366544&view=rev
[sanitizers] Use covering ObjectFormatType switches

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.

Reviewers: sfertile, jasonliu, daltenty

Reviewed By: sfertile

Subscribers: hiraditya, aheejin, sunfish, llvm-commits, cfe-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D64222


Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=366544&r1=366543&r2=366544&view=diff
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Jul 19 01:46:18 2019
@@ -231,9 +231,13 @@ static bool asanUseGlobalsGC(const Tripl
     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,

More information about the cfe-commits mailing list