[clang] [llvm] [Instrumentor] A configurable instrumentation pass plugin (PR #151551)

Asher Mancinelli via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 5 09:43:42 PDT 2025


Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/151551 at github.com>


================
@@ -0,0 +1,86 @@
+//===- tools/plugins-shlib/ReferencePlugin.cpp ----------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "Instrumentor.h"
+
+#include "llvm/Passes/PassBuilder.h"
+#include "llvm/Passes/PassPlugin.h"
+
+#include <algorithm>
+#include <cstdlib>
+#include <optional>
+#include <string>
+
+using namespace llvm;
+
+static std::optional<std::string> getEnv(const std::string &Var) {
+  const char *Val = std::getenv(Var.c_str());
+  if (!Val)
+    return std::nullopt;
+  return std::string(Val);
+}
----------------
ashermancinelli wrote:

If we are already using command-line options elsewhere in the instrumentation pass, why not use them here instead of environment variables?

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


More information about the llvm-commits mailing list