| 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 AccessPath::dump(llvm::raw_ostream &OS) const { |
| 14 | switch (K) { |
| 15 | case Kind::ValueDecl: |
| 16 | if (const clang::ValueDecl *VD = getAsValueDecl()) |
| 17 | OS << VD->getNameAsString(); |
| 18 | break; |
| 19 | case Kind::MaterializeTemporary: |
| 20 | if (const clang::MaterializeTemporaryExpr *MTE = |
| 21 | getAsMaterializeTemporaryExpr()) |
| 22 | OS << "MaterializeTemporaryExpr at "<< MTE; |
| 23 | break; |
| 24 | case Kind::PlaceholderParam: |
| 25 | if (const auto *PVD = getAsPlaceholderParam()) |
| 26 | OS << "$"<< PVD->getNameAsString(); |
| 27 | break; |
| 28 | case Kind::PlaceholderThis: |
| 29 | OS << "$this"; |
| 30 | break; |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | void Loan::dump(llvm::raw_ostream &OS) const { |
| 35 | OS << getID() << " (Path: "; |
| 36 | Path.dump(OS); |
| 37 | OS << ")"; |
| 38 | } |
| 39 | } // namespace clang::lifetimes::internal |
| 40 |