clang 24.0.0git
Reflection.h
Go to the documentation of this file.
1//===--- Reflection.h - Kind of reflection operands ---*- 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// This file declares the kinds of reflection operands.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_AST_REFLECTION_H
14#define LLVM_CLANG_AST_REFLECTION_H
15
16#include "clang/AST/TypeBase.h"
17#include "llvm/Support/raw_ostream.h"
18
19namespace clang {
20
21// TODO(Reflection): Add support for Template, Namespace and DeclRefExpr.
22enum class ReflectionKind { Null, Type };
23
24inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
25 ReflectionKind Kind) {
26 switch (Kind) {
28 OS << "type";
29 break;
31 OS << "null";
32 break;
33 }
34
35 return OS;
36}
37
38/// [expr.reflect] p5, if a reflect-expression R matches the form
39/// ^^reflection-name it is interpreted as such; the identifier is looked up
40/// and the representation of R is determined as follows:
41/// - if lookup finds a type alias A, R represents the type the underlying
42/// entity of A if A was introduced by the declaration of a template
43/// parameter; otherwise, R represents A.
44
45/// [expr.reflect] p6, Given reflect-expression R of the form ^^type-id,
46/// if type-id is neither a placeholder type nor
47/// in the form of nested-name-specifier_opt template_opt simple-template-id
48/// then R represents the type denoted by the type-id
49
50// In particular, this means that e.g. '^^const Alias' is reflection of
51// a type, not an alias. For example:
52//
53// using foo = const int;
54// ^^int // Type
55// ^^const int // Type
56// ^^foo // Alias
57// ^^const foo // Type
59 return QT.getLocalQualifiers() == Qualifiers{};
60}
61
62} // namespace clang
63
64#endif
C Language Family Type Representation.
A (possibly-)qualified type.
Definition TypeBase.h:938
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Definition TypeBase.h:8478
The collection of all-type qualifiers we support.
Definition TypeBase.h:332
The base class of the type hierarchy.
Definition TypeBase.h:1879
Top level wrappers for InstallAPI frontend operations.
ReflectionKind
Definition Reflection.h:22
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)
Insertion operator for diagnostics.
bool isTypeAliasAsReflectionName(QualType QT)
[expr.reflect] p5, if a reflect-expression R matches the form ^^reflection-name it is interpreted as ...
Definition Reflection.h:58