LLDB mainline
FortranTypes.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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/// \file
10/// This file defines the classes that describe the Fortran types.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLDB_SOURCE_PLUGINS_TYPESYSTEM_FORTRAN_FORTRANTYPES_H
15#define LLDB_SOURCE_PLUGINS_TYPESYSTEM_FORTRAN_FORTRANTYPES_H
16
21
22#include "llvm/ADT/ArrayRef.h"
23#include "llvm/ADT/FoldingSet.h"
24#include "llvm/ADT/SmallVector.h"
25
26namespace lldb_private {
27namespace plugin {
28namespace fortran {
29
30/// A simplified internal representation of a Fortran type.
31class FortranType : public llvm::FoldingSetNode {
32 // LLVM RTTI support
33 static char ID;
34
35public:
36 // llvm casting support
37 virtual bool isA(const void *ClassID) const { return ClassID == &ID; }
38
39 static bool classof(const FortranType *ft) { return ft->isA(&ID); }
40
50
51 FortranType(int32_t kind, uint64_t bitsize, const ConstString &name)
52 : m_kind(kind), m_bitsize(bitsize), m_type_name(name) {}
53 virtual ~FortranType();
54
55 int GetKind() const { return m_kind; }
56 uint64_t GetBitSize() const { return m_bitsize; }
57 ConstString GetName() const { return m_type_name; }
58
59 void Profile(llvm::FoldingSetNodeID &ID) const {
61 }
62
63 static void Profile(llvm::FoldingSetNodeID &ID, int32_t kind,
64 uint64_t bitsize) {
65 ID.AddInteger(kind);
66 ID.AddInteger(bitsize);
67 }
68
69private:
70 int32_t m_kind;
71 uint64_t m_bitsize;
73};
74
76 // LLVM RTTI support
77 static char ID;
78
79public:
80 // llvm casting support
81 bool isA(const void *ClassID) const override {
82 return ClassID == &ID || FortranType::isA(ClassID);
83 }
84
85 static bool classof(const FortranType *ft) { return ft->isA(&ID); }
86
88 const llvm::SmallVectorImpl<CompilerType> &param_types,
90 CompilerType return_type);
91
92 llvm::ArrayRef<CompilerType> GetParamTypes() const { return m_param_types; }
93 size_t GetNumParams() const { return m_param_types.size(); }
96
97 void Profile(llvm::FoldingSetNodeID &id) const {
99 }
100
101 static void Profile(llvm::FoldingSetNodeID &id, ConstString func_name,
102 llvm::ArrayRef<CompilerType> param_types,
103 CompilerType return_type) {
104 id.AddString(func_name.GetStringRef());
105 id.AddInteger(param_types.size());
106
107 if (return_type.IsValid())
108 id.AddPointer(return_type.GetOpaqueQualType());
109
110 for (const CompilerType &param : param_types)
111 id.AddPointer(param.GetOpaqueQualType());
112 }
113
114 static FortranFunction *GetFunctionType(void *type);
115
116private:
117 llvm::SmallVector<CompilerType, 4> m_param_types;
120};
121
122} // namespace fortran
123} // namespace plugin
124} // namespace lldb_private
125
126#endif // LLDB_SOURCE_PLUGINS_TYPESYSTEM_FORTRAN_FORTRANTYPES_H
Generic representation of a type in a programming language.
lldb::opaque_compiler_type_t GetOpaqueQualType() const
A uniqued constant string class.
Definition ConstString.h:40
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
static FortranFunction * GetFunctionType(void *type)
static bool classof(const FortranType *ft)
void Profile(llvm::FoldingSetNodeID &id) const
static void Profile(llvm::FoldingSetNodeID &id, ConstString func_name, llvm::ArrayRef< CompilerType > param_types, CompilerType return_type)
llvm::ArrayRef< CompilerType > GetParamTypes() const
FortranFunction(ConstString func_name, const llvm::SmallVectorImpl< CompilerType > &param_types, const llvm::SmallVectorImpl< llvm::StringRef > &param_names, CompilerType return_type)
bool isA(const void *ClassID) const override
llvm::SmallVector< CompilerType, 4 > m_param_types
void Profile(llvm::FoldingSetNodeID &ID) const
static void Profile(llvm::FoldingSetNodeID &ID, int32_t kind, uint64_t bitsize)
virtual bool isA(const void *ClassID) const
FortranType(int32_t kind, uint64_t bitsize, const ConstString &name)
static bool classof(const FortranType *ft)
A class that represents a running process on the host machine.