ROSE 2.23.0
Loading...
Searching...
No Matches
CppHierarchyAnalysis.h
1#ifndef ROSE_Source_Analysis_CppHierarchyAnalysis_H
2#define ROSE_Source_Analysis_CppHierarchyAnalysis_H 1
3
4#include <RoseFirst.h>
5
6#include <cstdint>
7#include <functional>
8#include <string>
9#include <tuple>
10#include <unordered_map>
11#include <utility>
12#include <vector>
13
14#include <Rose/Common/Analysis/ClassHierarchyAnalysis.h>
15#include <Rose/Source/Analysis/CppCompatibility.h>
16#include <Rose/Source/Analysis/CppSpecialMemberAnalysis.h>
17
18class SgProject;
23class SgFunctionType;
24class SgType;
25
27{
30{
31 public:
32
35 using base::base;
36
39 std::unordered_map<Rose::Common::Analysis::ClassKeyType, SpecialMemberFunctionContainer>;
40
43 const CppCompatibility&
44 compatibilityBridge() const override;
45
50 rootId(const SgProject* root) const;
51
57
62 classId(const SgClassDefinition* cls) const;
63
69
75
81
87
93
99
105
111
116 typeId(const SgType* ty) const;
117
121 SgType*
123
127 std::string
128 nameOf(const SgClassDefinition* cls) const;
129
133 std::string
134 nameOf(const SgFunctionDeclaration* fun) const;
135
139 std::string
140 nameOf(const SgInitializedName* var) const;
141
145 SpecialMemberFunctionContainer&
147
151 const SpecialMemberFunctionContainer&
153
156 std::uint32_t languageStandard() const { return langVersion; }
157
160 void languageStandard(std::uint32_t v) { langVersion = v; }
161
163 static constexpr std::uint32_t Cxx98 = 199711L;
164
166 static constexpr std::uint32_t Cxx11 = 201103L;
167
169 static constexpr std::uint32_t Cxx14 = 201402L;
170
172 static constexpr std::uint32_t Cxx17 = 201703L;
173
175 static constexpr std::uint32_t Cxx20 = 202002L;
176
178 static constexpr std::uint32_t Cxx23 = 202302L;
179
181 static constexpr std::uint32_t Cxx26 = 202600L;
182
183
184 private:
185 static CppCompatibility compat;
186
187 SpecialMemberFunctionMap allSpecialMemberFunctions;
188 std::uint32_t langVersion = Cxx98;
189};
190
195
199
207 SpecialMemberFunctionPredicate pred);
208
209/*
215bool hasSpecialFunction(const Rose::Common::Analysis::ClassAnalysis& all,
216 Rose::Common::Analysis::ClassKeyType clazz,
217 SpecialMemberFunctionPredicate pred);
218*/
219
227
234 bool normalizedSignature = false);
235
236} // namespace Rose::Source::Analysis
237
238#endif
holds data about all classes in a program
ClassAnalysisBase base
Base map type used for storage.
stores the results of virtual function analysis by Id
Implements the Common compatibility interface for C++ ROSE AST nodes.
Binds Rose::Common::Analysis::ClassAnalysis to C++ ROSE AST nodes and stores C++-specific metadata.
static constexpr std::uint32_t Cxx26
Draft C++26 language standard identifier.
std::unordered_map< Rose::Common::Analysis::ClassKeyType, SpecialMemberFunctionContainer > SpecialMemberFunctionMap
Map from class keys to their detected special member functions.
static constexpr std::uint32_t Cxx14
C++14 language standard identifier.
const SpecialMemberFunctionContainer & specialMemberFunctions(Rose::Common::Analysis::ClassKeyType clazz) const
Returns special member function metadata for clazz.
static constexpr std::uint32_t Cxx23
C++23 language standard identifier.
const CppCompatibility & compatibilityBridge() const override
Returns the C++ compatibility bridge.
SgProject * root(Rose::Common::Analysis::ASTRootType key) const
Converts an abstract analysis key back to a ROSE project root pointer.
Rose::Common::Analysis::FunctionTypeKeyType functionTypeId(const SgFunctionType *ty) const
Converts a ROSE function type pointer to an abstract function type key.
std::string nameOf(const SgClassDefinition *cls) const
Returns a printable source name for a ROSE class definition.
Rose::Common::Analysis::VariableKeyType variableId(SgInitializedName *var) const
Converts a ROSE initialized-name pointer to an abstract variable key.
static constexpr std::uint32_t Cxx20
C++20 language standard identifier.
static constexpr std::uint32_t Cxx17
C++17 language standard identifier.
SgInitializedName * variableDeclaration(Rose::Common::Analysis::VariableKeyType key) const
Converts an abstract variable key back to a ROSE initialized-name pointer.
std::string nameOf(const SgFunctionDeclaration *fun) const
Returns a printable source name for a ROSE function declaration.
SgFunctionType * functionType(Rose::Common::Analysis::FunctionTypeKeyType key) const
Converts an abstract function type key back to a ROSE function type pointer.
SgFunctionDeclaration * functionDeclaration(Rose::Common::Analysis::FunctionKeyType key) const
Converts an abstract function key back to a ROSE function declaration pointer.
SpecialMemberFunctionContainer & specialMemberFunctions(Rose::Common::Analysis::ClassKeyType clazz)
Returns mutable special member function metadata for clazz.
static constexpr std::uint32_t Cxx98
C++98 language standard identifier.
void languageStandard(std::uint32_t v)
Sets the version identifier of the language standard.
SgClassDefinition * classDefinition(Rose::Common::Analysis::ClassKeyType key) const
Converts an abstract class key back to a ROSE class definition pointer.
Rose::Common::Analysis::ClassKeyType classId(const SgClassDefinition *cls) const
Converts a ROSE class definition pointer to an abstract analysis key.
Rose::Common::Analysis::FunctionKeyType functionId(const SgFunctionDeclaration *fun) const
Converts a ROSE function declaration pointer to an abstract analysis key.
Rose::Common::Analysis::VariableKeyType variableId(SgVariableDeclaration *var) const
Converts a ROSE variable declaration pointer to an abstract variable key.
SgType * type(Rose::Common::Analysis::TypeKeyType key) const
Converts an abstract type key back to a ROSE type pointer.
std::uint32_t languageStandard() const
returns the version identifier of the language standard.
std::string nameOf(const SgInitializedName *var) const
Returns a printable source name for a ROSE initialized name (field).
static constexpr std::uint32_t Cxx11
C++11 language standard identifier.
Rose::Common::Analysis::TypeKeyType typeId(const SgType *ty) const
Converts a ROSE type pointer to an abstract type key.
Rose::Common::Analysis::ASTRootType rootId(const SgProject *root) const
Converts a ROSE project root pointer to an abstract analysis key.
This class represents the concept of a class definition in C++.
This class represents the concept of a function declaration statement.
This class represents a type for all functions.
This class represents the notion of a declared variable.
This class represents a source project, with a list of SgFile objects and global information about th...
This class represents the base class for all types.
This class represents the concept of a C or C++ variable declaration.
Capabilities related to the analysis of source-code.
void analyzeSpecialMemberFunctions(CppHierarchyAnalysis &all)
Detects and records C++ special member functions for all classes in all.
CppHierarchyAnalysis analyzeCppClasses(const SgProject *)
Builds a C++ class hierarchy analysis by traversing the AST rooted at root.
bool hasSpecialFunction(const CppHierarchyAnalysis &all, Rose::Common::Analysis::ClassKeyType clazz, SpecialMemberFunctionPredicate pred)
Returns true when class clazz in all has a special member matching pred.
CppHierarchyAnalysis analyzeCppClassesFromMemoryPool()
Builds a C++ class hierarchy analysis from the ROSE memory pool.
Rose::Common::Analysis::VirtualFunctionAnalysis analyzeCppVirtualFunctions(const Rose::Common::Analysis::ClassAnalysis &classes, bool normalizedSignature=false)
Computes virtual function override relationships for C++ classes.
Strongly typed wrapper around an abstract pointer-sized analysis key.