| 1 | //===- Loans.cpp - Loan Implementation --------------------------*- C++ -*-===// |
|---|---|
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "clang/Analysis/Analyses/LifetimeSafety/Loans.h" |
| 10 | |
| 11 | namespace clang::lifetimes::internal { |
| 12 | |
| 13 | void PathLoan::dump(llvm::raw_ostream &OS) const { |
| 14 | OS << getID() << " (Path: "; |
| 15 | if (const clang::ValueDecl *VD = Path.getAsValueDecl()) |
| 16 | OS << VD->getNameAsString(); |
| 17 | else if (const clang::MaterializeTemporaryExpr *MTE = |
| 18 | Path.getAsMaterializeTemporaryExpr()) |
| 19 | // No nice "name" for the temporary, so deferring to LLVM default |
| 20 | OS << "MaterializeTemporaryExpr at "<< MTE; |
| 21 | else |
| 22 | llvm_unreachable("access path is not one of any supported types"); |
| 23 | OS << ")"; |
| 24 | } |
| 25 | |
| 26 | void PlaceholderLoan::dump(llvm::raw_ostream &OS) const { |
| 27 | OS << getID() << " (Placeholder loan)"; |
| 28 | } |
| 29 | |
| 30 | } // namespace clang::lifetimes::internal |
| 31 |