xref: /llvm-project/clang/tools/libclang/CXFile.h (revision 1c64c414ed6a7ba2973f881a380d322adb5767a2)
1fa5788ffSJan Svoboda //===- CXFile.h - Routines for manipulating CXFile --------------*- C++ -*-===//
2fa5788ffSJan Svoboda //
3fa5788ffSJan Svoboda // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4fa5788ffSJan Svoboda // See https://llvm.org/LICENSE.txt for license information.
5fa5788ffSJan Svoboda // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6fa5788ffSJan Svoboda //
7fa5788ffSJan Svoboda //===----------------------------------------------------------------------===//
8fa5788ffSJan Svoboda 
9fa5788ffSJan Svoboda #ifndef LLVM_CLANG_TOOLS_LIBCLANG_CXFILE_H
10fa5788ffSJan Svoboda #define LLVM_CLANG_TOOLS_LIBCLANG_CXFILE_H
11fa5788ffSJan Svoboda 
12fa5788ffSJan Svoboda #include "clang-c/CXFile.h"
13fa5788ffSJan Svoboda #include "clang/Basic/FileEntry.h"
14fa5788ffSJan Svoboda 
15fa5788ffSJan Svoboda namespace clang {
16fa5788ffSJan Svoboda namespace cxfile {
makeCXFile(OptionalFileEntryRef FE)17fa5788ffSJan Svoboda inline CXFile makeCXFile(OptionalFileEntryRef FE) {
18*1c64c414SJan Svoboda   return CXFile(FE ? const_cast<FileEntryRef::MapEntry *>(&FE->getMapEntry())
19*1c64c414SJan Svoboda                    : nullptr);
20fa5788ffSJan Svoboda }
21fa5788ffSJan Svoboda 
getFileEntryRef(CXFile File)22fa5788ffSJan Svoboda inline OptionalFileEntryRef getFileEntryRef(CXFile File) {
23fa5788ffSJan Svoboda   if (!File)
24fa5788ffSJan Svoboda     return std::nullopt;
25fa5788ffSJan Svoboda   return FileEntryRef(*reinterpret_cast<const FileEntryRef::MapEntry *>(File));
26fa5788ffSJan Svoboda }
27fa5788ffSJan Svoboda } // namespace cxfile
28fa5788ffSJan Svoboda } // namespace clang
29fa5788ffSJan Svoboda 
30fa5788ffSJan Svoboda #endif
31