[clang] [llvm] [DLCov 2/5] Implement DebugLoc coverage tracking (PR #107279)

J. Ryan Stinnett via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 23 10:09:47 PDT 2024


================
@@ -22,6 +23,67 @@ namespace llvm {
   class LLVMContext;
   class raw_ostream;
   class DILocation;
+  class Function;
+
+#if ENABLE_DEBUGLOC_COVERAGE_TRACKING
+  // Used to represent different "kinds" of DebugLoc, expressing that a DebugLoc
+  // is either ordinary, containing a valid DILocation, or otherwise describing
+  // the reason why the DebugLoc does not contain a valid DILocation.
+  enum class DebugLocKind : uint8_t {
+    // DebugLoc is expected to contain a valid DILocation.
+    Normal,
+    // DebugLoc intentionally does not have a valid DILocation; may be for a
+    // compiler-generated instruction, or an explicitly dropped location.
+    LineZero,
----------------
jryans wrote:

Hmm, I'd really prefer the name of this case to clearly state the "intentional" aspect. Perhaps `IntentionallyZero`...?

Another approach might be to have separate enum values for the different reasons, e.g. `CompilerGenerated`, `ExplicitlyDropped`, and whatever the others might be. Stating these cases very clearly, not just in comments, but also via enum value would appear to be a very valuable capturing of intent to me. (However, maybe it is too much trouble to do so...? Please say that if so.)

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


More information about the cfe-commits mailing list