Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
7c3d396
refactor: move common_type_printer<mimicpp::util::SourceLocation> spe…
DNKpp Apr 11, 2026
bd24da0
test: add case for incomplete types
DNKpp Apr 11, 2026
d5fac68
refactor: replace type_info type-name deduction approach with source-…
DNKpp Apr 11, 2026
8e34ccc
refactor: printing::type::type_name returns a std::string_view instea…
DNKpp Apr 11, 2026
87bc8e3
test: correct some type-name printing related test-cases
DNKpp Apr 11, 2026
683989b
fix: util::StaticString stores its underlying string null-terminated
DNKpp Apr 12, 2026
65b0481
refactor: add separate type-name-print-tests test-suite
DNKpp Apr 12, 2026
6af7440
refactor: transfer several special-type cases to the new type-name-pr…
DNKpp Apr 12, 2026
c2ffa6e
fix: remove alias for "<lambda()>"
DNKpp Apr 12, 2026
6c1563a
fix: add `mutable` to the keyword list
DNKpp Apr 12, 2026
366fa02
refactor: transfer prettify_function related test to FunctionTypePost…
DNKpp Apr 13, 2026
34c0707
chore: add index getter to lexing::keyword and lexing::operator_or_pu…
DNKpp Apr 20, 2026
499693b
test: add exhaustive builtin-type tests for new parser generation
DNKpp Apr 20, 2026
cf8a71f
feat: add new parser generation sketchup
DNKpp Apr 20, 2026
ee50b3b
refactor: extract parser state types into type/Parser2State.hpp
DNKpp Apr 20, 2026
d364211
feat: add support for qualified and/or template types
DNKpp Apr 21, 2026
c4a08ca
chore: switch from right aligned AlignArrayOfStructures formatting op…
DNKpp Apr 21, 2026
03e5956
feat: add support for simple pointer and reference declarations
DNKpp Apr 21, 2026
1b705a8
chore: leadingQualification member is actually the full qualification…
DNKpp Apr 21, 2026
4b4d88d
deps: upgrade catch2 to v3.14.0
DNKpp Apr 21, 2026
5af2306
feat: add WIP lexing::literal support
DNKpp Apr 21, 2026
0c0b1dc
feat: parser gen2 supports array declarations
DNKpp Apr 21, 2026
3765658
feat: parser gen2 supports parameterless function declarations
DNKpp May 1, 2026
de92ac9
feat: parser gen2 supports function declarations with arbitrary params
DNKpp May 1, 2026
75509fc
refactor: merge ParametersAndQualifiers and FunctionDeclarator
DNKpp May 2, 2026
255648e
test: add case for function-pointers
DNKpp May 2, 2026
74cf331
feat: parser gen2 supports member-function-pointers
DNKpp May 2, 2026
5e4e044
fix: correct transaction handling in parse_type_specifier_seq
DNKpp May 2, 2026
9d2ff57
feat: parser gen2 supports nested function-ids
DNKpp May 2, 2026
bea61f5
feat: parser gen2 supports placeholder identifiers
DNKpp May 2, 2026
9634c14
refactor: enhance nested-id handling
DNKpp May 2, 2026
20b7e40
refactor: add explicit state::Identifier
DNKpp May 3, 2026
c6cb35c
refactor: merge UnqualifiedId and NestedId but keep separate productions
DNKpp May 3, 2026
6cfc57a
refactor: replace previous parser implementation with gen2
DNKpp May 3, 2026
61dc358
fix: disambiguate cxx23_backport_printer for tuple-likes in cases whe…
DNKpp May 4, 2026
ea462b2
chore: add util::Overloaded helper type
DNKpp May 4, 2026
774f1e1
feat: add support for operator functions
DNKpp May 4, 2026
8da1290
cleanup: remove obsolete previous parser implementation
DNKpp May 4, 2026
08c1c5f
chore: adapt type-name-print-tests to gen2 parser
DNKpp May 4, 2026
72ef785
feat: do not print redundant `int` when `long` or `short` spec is app…
DNKpp May 4, 2026
b040609
feat: print content of constant expressions
DNKpp May 4, 2026
82d96ab
cleanup: remove unused SimpleTemplateId
DNKpp May 4, 2026
7be533f
feat: parser gen2 supports conversion-functions
DNKpp May 5, 2026
0a1e837
chore: temporarily disable broken mutable lambda parsing test
DNKpp May 5, 2026
9ebc200
refactor: rename NameLexer.hpp to Lexer.hpp
DNKpp May 5, 2026
6d82bc1
fix: re-enable prettify_function
DNKpp May 5, 2026
b0f8c0f
docs: update documentation string
DNKpp May 5, 2026
102d7d9
fix: filter certain scope identifiers
DNKpp May 5, 2026
3030fa7
chore: transform last tests from TypePostProcessing.cpp to type-name-…
DNKpp May 5, 2026
975389f
fix: correctly handle synthetic-ids with nested open-close token-ranges
DNKpp May 5, 2026
dd55513
fix: please clang by using correct lambda capture
DNKpp May 5, 2026
d14b7fe
fix: parse_type_specifier_seq does validate the current token and ter…
DNKpp May 5, 2026
68ceee2
fix: correct priority of operator-function-id vs conversion-function-…
DNKpp May 5, 2026
04b70f8
fix: add a synthetic-identifier alias for `(anonymous-namespace)`
DNKpp May 5, 2026
b3205f0
fix: print terminating `::` only if scopes are not empty
DNKpp May 5, 2026
3d59227
test: relax certain test-cases to please clang
DNKpp May 5, 2026
c5f6f1d
fix: unify lambda-id printing for clang
DNKpp May 5, 2026
84aa264
fix: unify unnamed-type printing for clang
DNKpp May 5, 2026
d3e70fd
feat: add util::CopyableBox
DNKpp May 6, 2026
2f3001d
refactor: implement RecursiveState as sub-class of util::CopyableBox
DNKpp May 6, 2026
9dbe92d
refactor: rename RecursiveState to Recursive
DNKpp May 6, 2026
20013c2
chore: run type-name-print-tests only if MIMICPP_CONFIG_EXPERIMENTAL_…
DNKpp May 6, 2026
5df7ca4
feat: re-implement type::prettify_function
DNKpp May 9, 2026
ac9acea
fix: always enable RESOURCE_LOCK for compile-error test-suite
DNKpp May 14, 2026
7385a96
fix: add MIMICPP_DETAIL_CONSTEXPR_PRETTY_TYPES to circumvent non-cons…
DNKpp May 14, 2026
97fff63
fix: add manual deduction guide for Overloaded template to please old…
DNKpp May 14, 2026
5c1f793
fix: please older gcc versions
DNKpp May 14, 2026
32d472d
fix: correctly transfer parsed function-declarator
DNKpp May 14, 2026
c96b355
fix: make test-case name unique
DNKpp May 14, 2026
ff7eb40
test: adjust certain cases to please gcc-11
DNKpp May 14, 2026
8c16fcc
fix: simplify certain syntax to avoid parsing errors on older clang v…
DNKpp May 14, 2026
0010155
fix: enhance constexpr friendlyness
aunovis-koepke May 15, 2026
e241ea9
fix: simplify `type::detail::raw_type_name` implementation
aunovis-koepke May 15, 2026
a78d4c6
feat: handle optional class- and enum-keys
aunovis-koepke May 15, 2026
15b90d6
feat: handle msvc style anon-ns identifier
aunovis-koepke May 15, 2026
b766c76
feat: handle msvc-style unnamed-type identifiers
aunovis-koepke May 15, 2026
a048d26
feat: handle msvc call-convention
aunovis-koepke May 15, 2026
7a36054
refactor: add special state::LambdaFunctionId type
aunovis-koepke May 15, 2026
a694ed8
feat: handle msvc's `<unnamed-tag>` symbol
aunovis-koepke May 15, 2026
eb04520
feat: handle msvc's __int64 keyword
aunovis-koepke May 15, 2026
50f38b6
fix: do not accept terse-operators is first scope element
aunovis-koepke May 15, 2026
5672331
fix: correct destructor printing on msvc
aunovis-koepke May 15, 2026
8345298
fix: correctly specify MIMICPP_DETAIL_CONSTEXPR_PRETTY_TYPES
DNKpp May 15, 2026
7d9d134
fix: correctly identify lambdas on clang
DNKpp May 15, 2026
a308e76
fix: only accept type-keys as immediate prefix of qualified-ids
DNKpp May 15, 2026
0b081a4
fix: move MIMICPP_DETAIL_HAS_SOURCE_LOCATION definition to config/Con…
DNKpp May 15, 2026
22300e2
fix: correctly detect mutable lambdas
DNKpp May 15, 2026
b8886cd
fix: make mutable lambda case more permissive to please msvc
aunovis-koepke May 15, 2026
23c3872
docs: update type-name related documentation
DNKpp May 15, 2026
dd44173
fix: make certain cases slightly more permissive to please clang-21
DNKpp May 15, 2026
384ac2a
test: add dedicated test for template comparison operators
DNKpp May 15, 2026
be63b75
fix: nested operator-function-ids are not required to contain functio…
DNKpp May 19, 2026
ba917ce
test: add negative tests for unparsable type declarations
DNKpp May 19, 2026
632c8d3
chore: exclude several unreachable branches from coverage
DNKpp May 19, 2026
3dfad90
test: add test-cases for CopyableBox
DNKpp May 19, 2026
eef141e
test: add cases for printing array types
DNKpp May 19, 2026
3647f61
chore: exclude constant-evaluated code from coverage analysis
DNKpp May 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ KeepEmptyLines:
# Alignment

AlignAfterOpenBracket: AlwaysBreak
AlignArrayOfStructures: Right
AlignArrayOfStructures: Left
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignConsecutiveAssignments: None
Expand Down
3 changes: 2 additions & 1 deletion include/mimic++/Utilities.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Dominic (DNKpp) Koepke 2024 - 2025.
// Copyright Dominic (DNKpp) Koepke 2024-2026.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -11,6 +11,7 @@
#include "mimic++/utilities/C++23Backports.hpp"
#include "mimic++/utilities/C++26Backports.hpp"
#include "mimic++/utilities/Concepts.hpp"
#include "mimic++/utilities/CopyableBox.hpp"
#include "mimic++/utilities/PassKey.hpp"
#include "mimic++/utilities/PriorityTag.hpp"
#include "mimic++/utilities/SourceLocation.hpp"
Expand Down
17 changes: 16 additions & 1 deletion include/mimic++/config/Config.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Dominic (DNKpp) Koepke 2024 - 2025.
// Copyright Dominic (DNKpp) Koepke 2024-2026.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
Expand Down Expand Up @@ -69,11 +69,26 @@
#define MIMICPP_DETAIL_CONSTEXPR_VECTOR inline
#endif

// Requires constexpr vector and constexpr optional
// clang-format off
// Prevent number from getting decorated with '.
#if 201907L <= __cpp_lib_constexpr_vector \
&& 202106L <= __cpp_lib_optional
// clang-format on
#define MIMICPP_DETAIL_CONSTEXPR_PRETTY_TYPES constexpr
#else
#define MIMICPP_DETAIL_CONSTEXPR_PRETTY_TYPES inline
#endif

// gcc 10 requires a workaround, due to some ambiguities.
// see: https://github.com/DNKpp/mimicpp/issues/151
#if MIMICPP_DETAIL_IS_GCC \
&& __GNUC__ <= 10
#define MIMICPP_DETAIL_STD_GET_WORKAROUND 1
#endif

#ifdef __cpp_lib_source_location
#define MIMICPP_DETAIL_HAS_SOURCE_LOCATION 1
#endif

#endif
9 changes: 5 additions & 4 deletions include/mimic++/printing/TypePrinter.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Dominic (DNKpp) Koepke 2024 - 2025.
// Copyright Dominic (DNKpp) Koepke 2024-2026.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -7,10 +7,11 @@
#define MIMICPP_PRINTING_TYPE_PRINTER_HPP

#include "mimic++/printing/type/CommonTypes.hpp"
#include "mimic++/printing/type/NameLexer.hpp"
#include "mimic++/printing/type/NameParser.hpp"
#include "mimic++/printing/type/NamePrintVisitor.hpp"
#include "mimic++/printing/type/Lexer.hpp"
#include "mimic++/printing/type/Parser.hpp"
#include "mimic++/printing/type/ParserState.hpp"
#include "mimic++/printing/type/PrintType.hpp"
#include "mimic++/printing/type/PrintVisitor.hpp"
#include "mimic++/printing/type/Signature.hpp"
#include "mimic++/printing/type/Templated.hpp"

Expand Down
1 change: 1 addition & 0 deletions include/mimic++/printing/state/C++23Backports.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ namespace mimicpp::printing::detail::state
};

template <tuple_like T>
requires(!std::ranges::forward_range<T>)
struct cxx23_backport_printer<T>
{
template <print_iterator OutIter>
Expand Down
17 changes: 16 additions & 1 deletion include/mimic++/printing/state/CommonTypes.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Dominic (DNKpp) Koepke 2024 - 2026.
// Copyright Dominic (DNKpp) Koepke 2024-2026.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -19,6 +19,7 @@
#include "mimic++/printing/type/PrintType.hpp"
#include "mimic++/utilities/C++20Compatibility.hpp"
#include "mimic++/utilities/C++23Backports.hpp" // unreachable
#include "mimic++/utilities/SourceLocation.hpp"

#ifndef MIMICPP_DETAIL_IS_MODULE
#include <algorithm>
Expand Down Expand Up @@ -70,6 +71,20 @@ struct mimicpp::printing::detail::state::common_type_printer<std::source_locatio

namespace mimicpp::printing::detail::state
{
template <>
struct common_type_printer<util::SourceLocation>
{
template <print_iterator OutIter>
static constexpr OutIter print(OutIter out, util::SourceLocation const& loc)
{
return detail::print_source_location(
std::move(out),
loc.file_name(),
loc.line(),
loc.function_name());
}
};

template <>
struct common_type_printer<std::nullopt_t>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright Dominic (DNKpp) Koepke 2024 - 2025.
// Copyright Dominic (DNKpp) Koepke 2024-2026.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)

#ifndef MIMICPP_PRINTING_TYPE_NAME_LEXER_HPP
#define MIMICPP_PRINTING_TYPE_NAME_LEXER_HPP
#ifndef MIMICPP_PRINTING_TYPE_LEXER_HPP
#define MIMICPP_PRINTING_TYPE_LEXER_HPP

#pragma once

Expand All @@ -24,23 +24,33 @@

namespace mimicpp::printing::type::lexing
{
// This is a constexpr friendly version of `std::isspace`.
// see: https://en.cppreference.com/w/cpp/string/byte/isspace
inline auto constexpr is_space = [](char const c) noexcept {
return static_cast<bool>(
std::isspace(static_cast<unsigned char>(c)));
switch (c)
{
case ' ': [[fallthrough]];
case '\f': [[fallthrough]];
case '\n': [[fallthrough]];
case '\r': [[fallthrough]];
case '\t': [[fallthrough]];
case '\v': return true;

default: return false;
}
};

// This is a constexpr friendly version of `std::isdigit`.
// see: https://en.cppreference.com/w/cpp/string/byte/isdigit
inline auto constexpr is_digit = [](char const c) noexcept {
return static_cast<bool>(
std::isdigit(static_cast<unsigned char>(c)));
return '0' <= c && c <= '9';
};

namespace texts
{
// just list the noteworthy ones here
inline std::array constexpr visibilityKeywords = std::to_array<StringViewT>({"public", "protected", "private"});
inline std::array constexpr specKeywords = std::to_array<StringViewT>({"const", "constexpr", "volatile", "noexcept", "static"});
inline std::array constexpr specKeywords = std::to_array<StringViewT>({"const", "constexpr", "volatile", "noexcept", "static", "mutable"});
inline std::array constexpr contextKeywords = std::to_array<StringViewT>({"operator", "struct", "class", "enum"});
inline std::array constexpr typeKeywords = std::to_array<StringViewT>(
// The `__int64` keyword is used by msvc as an alias for `long long`.
Expand All @@ -57,8 +67,10 @@ namespace mimicpp::printing::type::lexing
inline std::array constexpr bitArithmetic = std::to_array<StringViewT>({"~", "&", "|", "^", "<<", ">>"});
inline std::array constexpr logical = std::to_array<StringViewT>({"!", "&&", "||"});
inline std::array constexpr access = std::to_array<StringViewT>({".", ".*", "->", "->*"});
inline std::array constexpr specialAngles = std::to_array<StringViewT>({"<:", ":>", "<%", "%>"});
inline std::array constexpr rest = std::to_array<StringViewT>({"::", ";", ",", ":", "...", "?"});

// These operators exist, but are in fact alternative versions and will probably never encountered.
// inline std::array constexpr specialAngles = std::to_array<StringViewT>({"<:", ":>", "<%", "%>"});
}

[[nodiscard]]
Expand Down Expand Up @@ -91,7 +103,6 @@ namespace mimicpp::printing::type::lexing
texts::bitArithmetic,
texts::logical,
texts::access,
texts::specialAngles,
texts::rest);
std::ranges::sort(collection);
MIMICPP_ASSERT(collection.cend() == std::ranges::unique(collection).begin(), "Fix your input!");
Expand Down Expand Up @@ -132,6 +143,12 @@ namespace mimicpp::printing::type::lexing
return textCollection[m_KeywordIndex];
}

[[nodiscard]]
constexpr std::ptrdiff_t index() const noexcept
{
return m_KeywordIndex;
}

[[nodiscard]]
bool operator==(keyword const&) const = default;

Expand Down Expand Up @@ -166,6 +183,12 @@ namespace mimicpp::printing::type::lexing
return textCollection[m_TextIndex];
}

[[nodiscard]]
constexpr std::ptrdiff_t index() const noexcept
{
return m_TextIndex;
}

[[nodiscard]]
bool operator==(operator_or_punctuator const&) const = default;

Expand All @@ -181,6 +204,14 @@ namespace mimicpp::printing::type::lexing
bool operator==(identifier const&) const = default;
};

struct literal
{
StringViewT content;

[[nodiscard]]
bool operator==(literal const&) const = default;
};

struct end
{
[[nodiscard]]
Expand All @@ -192,7 +223,8 @@ namespace mimicpp::printing::type::lexing
space,
keyword,
operator_or_punctuator,
identifier>;
identifier,
literal>;

struct token
{
Expand Down Expand Up @@ -261,6 +293,13 @@ namespace mimicpp::printing::type::lexing
return next_as_op_or_punctuator(options);
}

if (std::optional literal = try_next_as_literal())
{
return token{
.content = literal->content,
.classification = *std::move(literal)};
}

StringViewT const content = next_as_identifier();
// As we do not perform any prefix-checks, we need to check now whether the token actually denotes a keyword.
if (auto const iter = util::binary_find(keyword::textCollection, content);
Expand Down Expand Up @@ -359,6 +398,35 @@ namespace mimicpp::printing::type::lexing

return content;
}

// This function currently implements just a very basic integer-literal detection.
// see: https://eel.is/c++draft/lex.literal.kinds#nt:literal
[[nodiscard]]
constexpr std::optional<literal> try_next_as_literal() noexcept
{
MIMICPP_ASSERT(!m_Text.empty(), "Empty text.");

if (is_digit(m_Text.front()))
{
if ('0' == m_Text.front()
&& 2u <= m_Text.size())
{
// Todo: one of
// https://eel.is/c++draft/lex.icon#nt:binary-literal
// https://eel.is/c++draft/lex.icon#nt:octal-literal
// https://eel.is/c++draft/lex.icon#nt:hexadecimal-prefix
}

// Todo: this is just a very naive approach.
auto const last = std::ranges::find_if_not(m_Text.cbegin() + 1, m_Text.cend(), is_digit);
StringViewT const content{m_Text.cbegin(), last};
m_Text = {last, m_Text.cend()};

return literal{.content = content};
}

return std::nullopt;
}
};
}

Expand Down
Loading
Loading