[compiler-rt] [UBSan] Wrap Location variants in anonymous union (PR #168866)

via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 20 04:17:20 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Benjamin Stott (BStott6)

<details>
<summary>Changes</summary>

(Addresses the FIXME)

---
Full diff: https://github.com/llvm/llvm-project/pull/168866.diff


1 Files Affected:

- (modified) compiler-rt/lib/ubsan/ubsan_diag.h (+5-4) 


``````````diff
diff --git a/compiler-rt/lib/ubsan/ubsan_diag.h b/compiler-rt/lib/ubsan/ubsan_diag.h
index c836647c98f3c..d37bc309fdd0a 100644
--- a/compiler-rt/lib/ubsan/ubsan_diag.h
+++ b/compiler-rt/lib/ubsan/ubsan_diag.h
@@ -37,10 +37,11 @@ class Location {
 
 private:
   LocationKind Kind;
-  // FIXME: In C++11, wrap these in an anonymous union.
-  SourceLocation SourceLoc;
-  MemoryLocation MemoryLoc;
-  const SymbolizedStack *SymbolizedLoc;  // Not owned.
+  union {
+    SourceLocation SourceLoc;
+    MemoryLocation MemoryLoc;
+    const SymbolizedStack *SymbolizedLoc; // Not owned.
+  };
 
 public:
   Location() : Kind(LK_Null) {}

``````````

</details>


https://github.com/llvm/llvm-project/pull/168866


More information about the llvm-commits mailing list