clang 20.0.0git
AbstractBasicReader.h
Go to the documentation of this file.
1//==--- AbstractBasiceReader.h - Abstract basic value deserialization -----===//
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_AST_ABSTRACTBASICREADER_H
10#define LLVM_CLANG_AST_ABSTRACTBASICREADER_H
11
13#include <optional>
14
15namespace clang {
16namespace serialization {
17
18template <class T>
19inline T makeNullableFromOptional(const std::optional<T> &value) {
20 return (value ? *value : T());
21}
22
23template <class T> inline T *makePointerFromOptional(std::optional<T *> value) {
24 return value.value_or(nullptr);
25}
26
27// PropertyReader is a class concept that requires the following method:
28// BasicReader find(llvm::StringRef propertyName);
29// where BasicReader is some class conforming to the BasicReader concept.
30// An abstract AST-node reader is created with a PropertyReader and