clang 19.0.0git
NodeIntrospection.h
Go to the documentation of this file.
1//===- NodeIntrospection.h ------------------------------------*- 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 contains the implementation of the NodeIntrospection.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_TOOLING_NODEINTROSPECTION_H
14#define LLVM_CLANG_TOOLING_NODEINTROSPECTION_H
15
18#include "llvm/ADT/IntrusiveRefCntPtr.h"
19#include <set>
20
21namespace clang {
22
23class Stmt;
24class Decl;
25class CXXCtorInitializer;
26class NestedNameSpecifierLoc;
27class TemplateArgumentLoc;
28class CXXBaseSpecifier;
29struct DeclarationNameInfo;
30
31namespace tooling {
32
33class LocationCall;
35
36class LocationCall : public llvm::ThreadSafeRefCountedBase<LocationCall> {
37public:
41 : m_flags(flags), m_on(std::move(on)), m_name(std::move(name)) {}
42
43 LocationCall *on() const { return m_on.get(); }
44 StringRef name() const { return m_name; }
45 bool returnsPointer() const { return m_flags & ReturnsPointer; }
46 bool isCast() const { return m_flags & IsCast; }
47
48private:
49 LocationCallFlags m_flags;
51 std::string m_name;
52};
53
55public:
56 static void print(const LocationCall &Call, llvm::raw_ostream &OS);
57 static std::string format(const LocationCall &Call);
58};
59
60namespace internal {
62 bool operator()(std::pair<SourceRange, SharedLocationCall> const &LHS,
63 std::pair<SourceRange, SharedLocationCall> const &RHS) const;
64 bool
65 operator()(std::pair<SourceLocation, SharedLocationCall> const &LHS,
66 std::pair<SourceLocation, SharedLocationCall> const &RHS) const;
67};
68
69} // namespace internal
70
71// Note that this container stores unique results in a deterministic, but
72// the location calls are in an unspecified order. Clients which desire
73// a particular order for the location calls, such as alphabetical,
74// should sort results after retrieval, because the order is dependent
75// on how the LocationCalls are formatted.
76template <typename T, typename U>
77using UniqueMultiMap = std::set<std::pair<T, U>, internal::RangeLessThan>;
78
81
85};
86
87namespace NodeIntrospection {
98} // namespace NodeIntrospection
99} // namespace tooling
100} // namespace clang
101#endif
DynTypedNode Node
Represents a base class of a C++ class.
Definition: DeclCXX.h:146
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2297
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:85
A dynamically typed AST node container.
A C++ nested-name-specifier augmented with source location information.
Stmt - This represents one statement.
Definition: Stmt.h:84
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:524
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:59
static void print(const LocationCall &Call, llvm::raw_ostream &OS)
static std::string format(const LocationCall &Call)
LocationCall * on() const
LocationCall(SharedLocationCall on, std::string name, LocationCallFlags flags=NoFlags)
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
NodeLocationAccessors GetLocations(clang::Stmt const *Object)
UniqueMultiMap< SourceLocation, SharedLocationCall > SourceLocationMap
std::set< std::pair< T, U >, internal::RangeLessThan > UniqueMultiMap
UniqueMultiMap< SourceRange, SharedLocationCall > SourceRangeMap
The JSON file list parser is used to communicate input to InstallAPI.
Definition: Format.h:5394
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
bool operator()(std::pair< SourceRange, SharedLocationCall > const &LHS, std::pair< SourceRange, SharedLocationCall > const &RHS) const