Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
70 changes: 35 additions & 35 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
env:
CMAKE_VERSION: 3.29.0
NINJA_VERSION: 1.11.1
LLVM_VERSION: 20.1.0
LLVM_VERSION: 21.1.0
NINJA_STATUS: "[%f/%t %o/sec] "

jobs:
Expand All @@ -32,7 +32,7 @@ jobs:
name: "Linux Clang - Format check",
os: ubuntu-22.04,
build_type: Release,
cformat_name: 'clang-format-20'
cformat_name: 'clang-format-21'
}

steps:
Expand All @@ -45,7 +45,7 @@ jobs:
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 20
sudo ./llvm.sh 21
sudo apt-get install ${{ matrix.config.cformat_name }}

- name: clang-format check
Expand All @@ -68,11 +68,11 @@ jobs:
config:
# AppleClang
- {
name: "Clang 20 / LLVM 20 @ macOS Release",
name: "Clang 21 / LLVM 21 @ macOS Release",
os: macos-14,
build_type: Release,
cxx: "clang++",
llvm_version: "20.1.0",
llvm_version: "21.1.0",
llvm_config: "llvm-config",
coverage: "No",
static: "No",
Expand All @@ -87,11 +87,11 @@ jobs:

# AppleClang
- {
name: "Clang 20 / LLVM 20 @ macOS Debug",
name: "Clang 21 / LLVM 21 @ macOS Debug",
os: macos-14,
build_type: Release,
cxx: "clang++",
llvm_version: "20.1.0",
llvm_version: "21.1.0",
llvm_config: "llvm-config",
coverage: "No",
static: "No",
Expand All @@ -106,11 +106,11 @@ jobs:

# AppleClang
- {
name: "Clang 20 / LLVM 20 @ macOS Coverage & Debug",
name: "Clang 21 / LLVM 21 @ macOS Coverage & Debug",
os: macos-14,
build_type: Release,
cxx: "clang++",
llvm_version: "20.1.0",
llvm_version: "21.1.0",
llvm_config: "llvm-config",
coverage: "Yes",
static: "No",
Expand All @@ -124,11 +124,11 @@ jobs:

# # MSVC 2019
# - {
# name: "MSVC 2022 / LLVM 20 @ Windows Release",
# name: "MSVC 2022 / LLVM 21 @ Windows Release",
# os: windows-2022,
# build_type: Release,
# cxx: "cl",
# llvm_version: "20.1.0",
# llvm_version: "21.1.0",
# llvm_config: "current/bin/llvm-config.exe",
# static: "Yes",
# debug: "No",
Expand All @@ -143,11 +143,11 @@ jobs:

# # MSVC 2019
# - {
# name: "MSVC 2022 / LLVM 20 @ Windows Debug",
# name: "MSVC 2022 / LLVM 21 @ Windows Debug",
# os: windows-2022,
# build_type: Release,
# cxx: "cl",
# llvm_version: "20.1.0",
# llvm_version: "21.1.0",
# llvm_config: "current/bin/llvm-config.exe",
# static: "Yes",
# debug: "Yes",
Expand All @@ -161,11 +161,11 @@ jobs:

# # MSVC 2019
# - {
# name: "MSVC 2022 / LLVM 20 @ Windows Code Coverage & Debug",
# name: "MSVC 2022 / LLVM 21 @ Windows Code Coverage & Debug",
# os: windows-2022,
# build_type: Release,
# cxx: "clang-cl.exe",
# llvm_version: "20.1.0",
# llvm_version: "21.1.0",
# llvm_config: "current/bin/llvm-config.exe",
# coverage: "Yes",
# static: "Yes",
Expand Down Expand Up @@ -462,13 +462,13 @@ jobs:
- ubuntu-22.04-arm

config:
# GCC 14 / LLVM 20
# GCC 16 / LLVM 21
- {
name: "GCC 14 / LLVM 20 @ Ubuntu Release",
name: "GCC 16 / LLVM 21 @ Ubuntu Release",
build_type: Release,
cxx: "g++-14",
llvm_version: "20.1.0",
llvm_config: "/usr/bin/llvm-config-20",
cxx: "g++-16",
llvm_version: "21.1.0",
llvm_config: "/usr/bin/llvm-config-21",
coverage: "No",
static: "Yes",
debug: "No",
Expand All @@ -481,13 +481,13 @@ jobs:
docs: "Yes",
}

# GCC 14 / LLVM 20
# GCC 16 / LLVM 21
- {
name: "GCC 14 / LLVM 20 @ Ubuntu Code Coverage & Debug",
name: "GCC 16 / LLVM 21 @ Ubuntu Code Coverage & Debug",
build_type: Release,
cxx: "g++-14",
llvm_version: "20.1.0",
llvm_config: "/usr/bin/llvm-config-20",
cxx: "g++-16",
llvm_version: "21.1.0",
llvm_config: "/usr/bin/llvm-config-21",
coverage: "Yes",
static: "No",
debug: "Yes",
Expand All @@ -498,13 +498,13 @@ jobs:
archive_name: "insights-ubuntu",
}

# GCC 14 / LLVM 20
# GCC 16 / LLVM 21
- {
name: "GCC 14 / LLVM 20 @ Ubuntu Code Coverage (libc++)",
name: "GCC 16 / LLVM 21 @ Ubuntu Code Coverage (libc++)",
build_type: Release,
cxx: "g++-14",
llvm_version: "20.1.0",
llvm_config: "/usr/bin/llvm-config-20",
cxx: "g++-16",
llvm_version: "21.1.0",
llvm_config: "/usr/bin/llvm-config-21",
coverage: "Yes",
static: "No",
debug: "Yes",
Expand Down Expand Up @@ -630,13 +630,13 @@ jobs:
- amd64

config:
# GCC 14 / LLVM 20
# GCC 16 / LLVM 21
- {
name: "GCC 14 / LLVM 20 @ Ubuntu Release",
name: "GCC 16 / LLVM 21 @ Ubuntu Release",
build_type: Release,
cxx: "g++-14",
llvm_version: "20.1.0",
llvm_config: "/usr/bin/llvm-config-20",
cxx: "g++-16",
llvm_version: "21.1.0",
llvm_config: "/usr/bin/llvm-config-21",
coverage: "No",
static: "Yes",
debug: "No",
Expand Down
11 changes: 10 additions & 1 deletion ASTHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,12 @@ FunctionBase(std::string_view name, QualType returnType, const params_vector& pa
false,
false,
ConstexprSpecKind::Unspecified,
nullptr);
#if IS_CLANG_NEWER_THAN(20)
AssociatedConstraint {}
#else
nullptr
#endif
);
fdd->setImplicit(true);

SmallVector<ParmVarDecl*, 8> paramVarDecls{};
Expand Down Expand Up @@ -695,7 +700,11 @@ CXXNewExpr* New(ArrayRef<Expr*> placementArgs, const Expr* expr, QualType t)
false,
nullptr,
nullptr,
#if IS_CLANG_NEWER_THAN(20)
ImplicitAllocationParameters{AlignedAllocationMode::Yes},
#else
true,
#endif
false,
placementArgs,
SourceRange{},
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ option(INSIGHTS_STATIC "Use static linking" Off)

set(INSIGHTS_LLVM_CONFIG "llvm-config" CACHE STRING "LLVM config executable to use")

set(INSIGHTS_MIN_LLVM_MAJOR_VERSION 20)
set(INSIGHTS_MIN_LLVM_MAJOR_VERSION 21)
set(INSIGHTS_MIN_LLVM_VERSION ${INSIGHTS_MIN_LLVM_MAJOR_VERSION}.0)

if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
Expand Down
61 changes: 45 additions & 16 deletions CodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ namespace ranges = std::ranges;
//-----------------------------------------------------------------------------
namespace clang::insights {

#define BUILD_OPT_AND(name, param) std::function name = [](param t) -> MyOptional<param>
#define BUILD_OPT_AND_O(name, param, ret) std::function name = [](param t) -> MyOptional<ret>
#define BUILD_OPT_AND(name, param) std::function name = [](param t)->MyOptional<param>
#define BUILD_OPT_AND_O(name, param, ret) std::function name = [](param t)->MyOptional<ret>

BUILD_OPT_AND(IsPointer, QualType)
{
Expand Down Expand Up @@ -1412,7 +1412,6 @@ void CodeGenerator::InsertArg(const VarDecl* stmt)
// }

} else {
mProcessingVarDecl = false;
BackupAndRestore _{mProcessingVarDecl, true};

if(MyOptional<const InitListExpr*> initList{dyn_cast_or_null<InitListExpr>(init)};
Expand Down Expand Up @@ -2398,18 +2397,20 @@ void CodeGenerator::InsertArg(const ImplicitCastExpr* stmt)
} else {
auto castName{GetCastName(castKind)};
const QualType castDestType{[&] {
const auto type{stmt->getType()};
auto type{stmt->getType()};

// In case of a dependent type the canonical type doesn't know the parameters name.
if(not type->isDependentType()) {
type = type.getCanonicalType();
}

// In at least the case a structured bindings the compiler adds xvalue casts but the && is missing to
// make it valid C++.
if(VK_XValue == stmt->getValueKind()) {
return GetGlobalAST().getRValueReferenceType(type.getCanonicalType());
} else if(type->isDependentType()) { // In case of a dependent type the canonical type doesn't know the
// parameters name.
return type;
return GetGlobalAST().getRValueReferenceType(type);
}

return type.getCanonicalType();
return type;
}()};

FormatCast(castName, castDestType, subExpr, castKind);
Expand Down Expand Up @@ -3178,16 +3179,21 @@ void CodeGenerator::InsertArg(const TypeAliasDecl* stmt)
mOutputFormatHelper.Append(stream.str());

InsertTemplateArgs(*templateSpecializationType);
} else if(auto* dependentTemplateSpecializationType =
underlyingType->getAs<DependentTemplateSpecializationType>()) {

mOutputFormatHelper.Append(GetElaboratedTypeKeyword(dependentTemplateSpecializationType->getKeyword()));
} else if(auto* depSpecType = underlyingType->getAs<DependentTemplateSpecializationType>()) {
mOutputFormatHelper.Append(GetElaboratedTypeKeyword(depSpecType->getKeyword()));

InsertNamespace(dependentTemplateSpecializationType->getQualifier());
#if IS_CLANG_NEWER_THAN(20)
InsertNamespace(depSpecType->getDependentTemplateName().getQualifier());

mOutputFormatHelper.Append(kwTemplateSpace, dependentTemplateSpecializationType->getIdentifier()->getName());
mOutputFormatHelper.Append(kwTemplateSpace, GetName(depSpecType->getDependentTemplateName()));
#else
InsertNamespace(depSpecType->getQualifier());

mOutputFormatHelper.Append(kwTemplateSpace, depSpecType->getIdentifier()->getName());
#endif

InsertTemplateArgs(*dependentTemplateSpecializationType);
InsertTemplateArgs(*depSpecType);

} else {
mOutputFormatHelper.Append(GetName(underlyingType));
Expand Down Expand Up @@ -3802,6 +3808,11 @@ void CodeGenerator::InsertAttribute(const Attr& attr)
// skip this custom clang attribute
RETURN_IF(attr::NoInline == attr.getKind());

#if IS_CLANG_NEWER_THAN(20)
// skip this custom clang attribute
RETURN_IF(attr::InferredNoReturn == attr.getKind());
#endif

// Clang's printPretty misses the parameter pack ellipsis. Hence treat this special case here.
if(const auto* alignedAttr = dyn_cast_or_null<AlignedAttr>(&attr)) {
auto insert = [&](const QualType type, const TemplateTypeParmType* tmplTypeParam) {
Expand Down Expand Up @@ -4460,7 +4471,7 @@ void CodeGenerator::InsertArg(const CXXStdInitializerListExpr* stmt)
auto internalListName =
MakeLineColumnName(GetGlobalAST().getSourceManager(), stmt->getBeginLoc(), BuildInternalVarName("list"sv));

ofm.Append(modifiers, GetTypeNameAsParameter(subExpr->getType(), internalListName));
ofm.Append(modifiers, GetTypeNameAsParameter(subExpr->getType().getCanonicalType(), internalListName));
CodeGeneratorVariant codeGenerator{ofm};
codeGenerator->InsertArg(subExpr);
ofm.AppendSemiNewLine();
Expand Down Expand Up @@ -4637,11 +4648,19 @@ void CodeGenerator::InsertTemplateArg(const TemplateArgument& arg)
if(const auto* tmplDecl = arg.getAsTemplateOrTemplatePattern().getAsTemplateDecl()) {
mOutputFormatHelper.Append(GetName(*tmplDecl, QualifiedName::Yes));

#if IS_CLANG_NEWER_THAN(20)
} else if(const auto* depName = arg.getAsTemplateOrTemplatePattern().getAsDependentTemplateName();
depName->getName().getIdentifier()) {
InsertNamespace(depName->getQualifier());

mOutputFormatHelper.Append(kwTemplateSpace, GetName(*depName));
#else
} else if(const auto* depName = arg.getAsTemplateOrTemplatePattern().getAsDependentTemplateName();
depName->isIdentifier()) {
InsertNamespace(depName->getQualifier());

mOutputFormatHelper.Append(kwTemplateSpace, depName->getIdentifier()->getName());
#endif
} else {
ToDo(arg, mOutputFormatHelper);
}
Expand Down Expand Up @@ -4834,7 +4853,17 @@ void CodeGenerator::InsertConceptConstraint(const TemplateParameterList& tmplDec
void CodeGenerator::InsertConceptConstraint(const FunctionDecl* tmplDecl)
{
SmallVector<const Expr*, 5> constraints{};

#if IS_CLANG_NEWER_THAN(20)
SmallVector<AssociatedConstraint, 5> assocConstraints{};
tmplDecl->getAssociatedConstraints(assocConstraints);

for(auto& e : assocConstraints) {
constraints.push_back(e.ConstraintExpr);
}
#else
tmplDecl->getAssociatedConstraints(constraints);
#endif

InsertConceptConstraint(constraints, InsertInline::Yes);
}
Expand Down
Loading
Loading