[clang] Check for mutability better (PR #127843)
Hans Wennborg via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 20 12:46:36 PST 2025
================
@@ -13440,6 +13440,23 @@ bool Sema::GloballyUniqueObjectMightBeAccidentallyDuplicated(
return true;
}
+// Determine whether the object seems mutable for the purpose of diagnosing
+// possible unique object duplication, i.e. non-const-qualified, and
+// not an always-constant type like a function.
+// Not perfect: doesn't account for mutable members, for example, or
+// elements of container types.
+// For nested pointers, any individual level being non-const is sufficient.
+bool looksMutable(QualType T, const ASTContext &Ctx) {
----------------
zmodem wrote:
nit: make it `static` since it's local to this file
https://github.com/llvm/llvm-project/pull/127843
More information about the cfe-commits
mailing list