Added template insantiation relation
This commit is contained in:
@@ -19,6 +19,9 @@
|
||||
|
||||
#include "cx/type.h"
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
namespace clanguml {
|
||||
namespace cx {
|
||||
|
||||
@@ -214,6 +217,11 @@ public:
|
||||
return clang_Cursor_getTemplateArgumentValue(m_cursor, i);
|
||||
}
|
||||
|
||||
cursor specialized_cursor_template() const
|
||||
{
|
||||
return clang_getSpecializedCursorTemplate(m_cursor);
|
||||
}
|
||||
|
||||
std::string usr() const { return to_string(clang_getCursorUSR(m_cursor)); }
|
||||
|
||||
const CXCursor &get() const { return m_cursor; }
|
||||
|
||||
42
src/cx/type.cc
Normal file
42
src/cx/type.cc
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* src/cx/type.cc
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "type.h"
|
||||
#include "cursor.h"
|
||||
|
||||
namespace clanguml {
|
||||
namespace cx {
|
||||
|
||||
cursor type::type_declaration() const
|
||||
{
|
||||
return {clang_getTypeDeclaration(m_type)};
|
||||
}
|
||||
|
||||
std::string type::instantiation_template() const
|
||||
{
|
||||
assert(is_template_instantiation());
|
||||
|
||||
auto s = spelling();
|
||||
auto it = s.find('<');
|
||||
auto template_base_name = s.substr(0, it);
|
||||
|
||||
auto cur = type_declaration();
|
||||
|
||||
return cur.fully_qualified();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,8 @@ namespace cx {
|
||||
|
||||
using util::to_string;
|
||||
|
||||
class cursor;
|
||||
|
||||
class type {
|
||||
public:
|
||||
type(CXType &&t)
|
||||
@@ -50,6 +52,8 @@ public:
|
||||
|
||||
type canonical() const { return {clang_getCanonicalType(m_type)}; }
|
||||
|
||||
bool is_unexposed() const { return kind() == CXType_Unexposed; }
|
||||
|
||||
bool is_const_qualified() const
|
||||
{
|
||||
return clang_isConstQualifiedType(m_type);
|
||||
@@ -72,12 +76,7 @@ public:
|
||||
|
||||
type pointee_type() const { return {clang_getPointeeType(m_type)}; }
|
||||
|
||||
/*
|
||||
*cursor type_declaration() const
|
||||
*{
|
||||
* return {clang_getTypeDeclaration(m_type)};
|
||||
*}
|
||||
*/
|
||||
cursor type_declaration() const;
|
||||
|
||||
/*
|
||||
*std::string type_kind_spelling() const
|
||||
@@ -151,7 +150,7 @@ public:
|
||||
bool is_relationship() const
|
||||
{
|
||||
return is_pointer() || is_record() || is_reference() || !is_pod() ||
|
||||
is_array() ||
|
||||
is_array() || is_template() ||
|
||||
(spelling().find("std::array") ==
|
||||
0 /* There must be a better way... */);
|
||||
}
|
||||
@@ -204,6 +203,15 @@ public:
|
||||
return clang_Type_getCXXRefQualifier(m_type);
|
||||
}
|
||||
|
||||
bool is_template_instantiation() const
|
||||
{
|
||||
auto s = spelling();
|
||||
auto it = s.find('<');
|
||||
return it != std::string::npos;
|
||||
}
|
||||
|
||||
std::string instantiation_template() const;
|
||||
|
||||
/**
|
||||
* @brief Remove all qualifiers from field declaration.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user