[llvm-branch-commits] [libcxx] [libc++] Clang-tidy operator& hijacker. (PR #128366)

Mark de Wever via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Mar 14 10:40:03 PDT 2025


================
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 "clang-tidy/ClangTidyCheck.h"
+#include "clang-tidy/ClangTidyModuleRegistry.h"
+#include "clang/Tooling/FixIt.h"
+
+#include "robust_against_operator_ampersand.hpp"
+
+// This clang-tidy check ensures that we don't use operator& on dependant
+// types. If the type is user supplied it may call the type's operator&.
+// Instead use std::addressof.
----------------
mordante wrote:

I disagree. The code should documented what the intention is.

As for the coding guidelines; it already has this information [documented](https://libcxx.llvm.org/CodingGuidelines.html#don-t-use-argument-dependent-lookup-unless-required-by-the-standard).

(Note testing for `operator,` in the same part of the documentation is on my todo list.)

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


More information about the llvm-branch-commits mailing list