================
@@ -0,0 +1,186 @@
+//===- AssignmentQuery.cpp - C++ Lifetime Safety Checker --------*- C++ 
-*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the LifetimeChecker, which detects use-after-free
+// errors by checking if live origins hold loans that have expired.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Analysis/Analyses/LifetimeSafety/AssignmentQuery.h"
+#include <optional>
+
+namespace {
+using namespace clang;
+using namespace clang::lifetimes;
+using namespace clang::lifetimes::internal;
+
+/// Locate the rightmost sub expression of the RHS, given that the LHS is
+/// already known. To ensure printability, we invoke `Explorc->isValid()`.
+///
+/// Typically, we select the rightmost subexpression, as it can be further
+/// decomposed and parsed recursively.
+///
+/// Since we are traversing assignments in reverse order, this function used
+/// to determines whether `TargetExpr` meets the requirements of the RHS.
+/// A match here triggers a subsequent attempt to match the LHS.
+/// Because the function is not re-invoked until the LHS is matched,
+/// it generally precludes the possibility of matching multiple
+/// subexpressions within the same RHS.
+const Expr *getRootSrcExpr(const Expr *TargetExpr) {
+  assert(TargetExpr);
+  const Expr *SExpr = TargetExpr->IgnoreParenCasts();
+
----------------
NeKon69 wrote:

Hmmm yeah that makes sense. Then I think it would be good if we could separate 
variable names in diagnostics (where we do what you currently do in your code) 
and the diagnostic locations (where I think preserving every expression would 
make more sense).

https://github.com/llvm/llvm-project/pull/196075
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to