| 1 | //===- CXFile.h - Routines for manipulating CXFile --------------*- 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 | #ifndef LLVM_CLANG_TOOLS_LIBCLANG_CXFILE_H |
| 10 | #define LLVM_CLANG_TOOLS_LIBCLANG_CXFILE_H |
| 11 | |
| 12 | #include "clang-c/CXFile.h" |
| 13 | #include "clang/Basic/FileEntry.h" |
| 14 | |
| 15 | namespace clang { |
| 16 | namespace cxfile { |
| 17 | inline CXFile makeCXFile(OptionalFileEntryRef FE) { |
| 18 | return CXFile(FE ? const_cast<FileEntryRef::MapEntry *>(&FE->getMapEntry()) |
| 19 | : nullptr); |
| 20 | } |
| 21 | |
| 22 | inline OptionalFileEntryRef getFileEntryRef(CXFile File) { |
| 23 | if (!File) |
| 24 | return std::nullopt; |
| 25 | return FileEntryRef(*reinterpret_cast<const FileEntryRef::MapEntry *>(File)); |
| 26 | } |
| 27 | } // namespace cxfile |
| 28 | } // namespace clang |
| 29 | |
| 30 | #endif |
| 31 |