Adapt to various Clang 18 trunk enum rework
<a9070f22a2
> "[clang][NFC] Refactor `CXXConstructExpr::ConstructionKind`", <c23aaa4103
> "[clang][NFC] Refactor `CharacterLiteral::CharacterKind`", <3e6ce58701
> "[clang][NFC] Refactor `StringLiteral::StringKind`", <edd690b02e
> "[clang][NFC] Refactor `TagTypeKind` (#71160)" Change-Id: Ice802f6d662494781ad22fcf11ea5006de918254 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158983 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
parent
0c54c09aeb
commit
c9cedde7c0
@ -16,6 +16,8 @@
|
||||
#include <clang/AST/Type.h>
|
||||
#include <clang/Basic/OperatorKinds.h>
|
||||
|
||||
#include "compat.hxx"
|
||||
|
||||
namespace loplugin {
|
||||
|
||||
class ContextCheck;
|
||||
@ -188,7 +190,7 @@ ContextCheck TypeCheck::Class(llvm::StringRef id)
|
||||
if (!type_.isNull()) {
|
||||
auto const t = type_->getAs<clang::RecordType>();
|
||||
if (t != nullptr) {
|
||||
return detail::checkRecordDecl(t->getDecl(), clang::TTK_Class, id);
|
||||
return detail::checkRecordDecl(t->getDecl(), compat::TagTypeKind::Class, id);
|
||||
}
|
||||
}
|
||||
return ContextCheck();
|
||||
@ -199,7 +201,7 @@ ContextCheck TypeCheck::Struct(llvm::StringRef id) const
|
||||
if (!type_.isNull()) {
|
||||
auto const t = type_->getAs<clang::RecordType>();
|
||||
if (t != nullptr) {
|
||||
return detail::checkRecordDecl(t->getDecl(), clang::TTK_Struct, id);
|
||||
return detail::checkRecordDecl(t->getDecl(), compat::TagTypeKind::Struct, id);
|
||||
}
|
||||
}
|
||||
return ContextCheck();
|
||||
@ -231,12 +233,12 @@ ContextCheck TypeCheck::Typedef(llvm::StringRef id) const
|
||||
|
||||
ContextCheck DeclCheck::Class(llvm::StringRef id) const
|
||||
{
|
||||
return detail::checkRecordDecl(decl_, clang::TTK_Class, id);
|
||||
return detail::checkRecordDecl(decl_, compat::TagTypeKind::Class, id);
|
||||
}
|
||||
|
||||
ContextCheck DeclCheck::Struct(llvm::StringRef id) const
|
||||
{
|
||||
return detail::checkRecordDecl(decl_, clang::TTK_Struct, id);
|
||||
return detail::checkRecordDecl(decl_, compat::TagTypeKind::Struct, id);
|
||||
}
|
||||
|
||||
ContextCheck DeclCheck::ClassOrStruct(llvm::StringRef id) const
|
||||
@ -250,7 +252,7 @@ ContextCheck DeclCheck::ClassOrStruct(llvm::StringRef id) const
|
||||
|
||||
ContextCheck DeclCheck::Union(llvm::StringRef id) const
|
||||
{
|
||||
return detail::checkRecordDecl(decl_, clang::TTK_Union, id);
|
||||
return detail::checkRecordDecl(decl_, compat::TagTypeKind::Union, id);
|
||||
}
|
||||
|
||||
ContextCheck DeclCheck::Function(llvm::StringRef id) const
|
||||
@ -294,13 +296,13 @@ ContextCheck ContextCheck::Namespace(llvm::StringRef id) const
|
||||
ContextCheck ContextCheck::Class(llvm::StringRef id) const
|
||||
{
|
||||
return detail::checkRecordDecl(
|
||||
llvm::dyn_cast_or_null<clang::Decl>(context_), clang::TTK_Class, id);
|
||||
llvm::dyn_cast_or_null<clang::Decl>(context_), compat::TagTypeKind::Class, id);
|
||||
}
|
||||
|
||||
ContextCheck ContextCheck::Struct(llvm::StringRef id) const
|
||||
{
|
||||
return detail::checkRecordDecl(
|
||||
llvm::dyn_cast_or_null<clang::Decl>(context_), clang::TTK_Struct, id);
|
||||
llvm::dyn_cast_or_null<clang::Decl>(context_), compat::TagTypeKind::Struct, id);
|
||||
}
|
||||
|
||||
bool isExtraWarnUnusedType(clang::QualType type);
|
||||
|
@ -82,6 +82,24 @@ constexpr clang::ExprValueKind VK_PRValue = clang::VK_PRValue;
|
||||
constexpr clang::ExprValueKind VK_PRValue = clang::VK_RValue;
|
||||
#endif
|
||||
|
||||
namespace CXXConstructionKind
|
||||
{
|
||||
#if CLANG_VERSION >= 180000
|
||||
constexpr clang::CXXConstructionKind Complete = clang::CXXConstructionKind::Complete;
|
||||
#else
|
||||
constexpr clang::CXXConstructExpr::ConstructionKind Complete = clang::CXXConstructExpr::CK_Complete;
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace CharacterLiteralKind
|
||||
{
|
||||
#if CLANG_VERSION >= 180000
|
||||
constexpr clang::CharacterLiteralKind Ascii = clang::CharacterLiteralKind::Ascii;
|
||||
#else
|
||||
constexpr clang::CharacterLiteral::CharacterKind Ascii = clang::CharacterLiteral::Ascii;
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace ElaboratedTypeKeyword
|
||||
{
|
||||
#if CLANG_VERSION >= 180000
|
||||
@ -102,6 +120,28 @@ constexpr clang::Linkage Module = clang::ModuleLinkage;
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace StringLiteralKind
|
||||
{
|
||||
#if CLANG_VERSION >= 180000
|
||||
constexpr clang::StringLiteralKind UTF8 = clang::StringLiteralKind::UTF8;
|
||||
#else
|
||||
constexpr clang::StringLiteral::StringKind UTF8 = clang::StringLiteral::UTF8;
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace TagTypeKind
|
||||
{
|
||||
#if CLANG_VERSION >= 180000
|
||||
constexpr clang::TagTypeKind Class = clang::TagTypeKind::Class;
|
||||
constexpr clang::TagTypeKind Struct = clang::TagTypeKind::Struct;
|
||||
constexpr clang::TagTypeKind Union = clang::TagTypeKind::Union;
|
||||
#else
|
||||
constexpr clang::TagTypeKind Class = clang::TTK_Class;
|
||||
constexpr clang::TagTypeKind Struct = clang::TTK_Struct;
|
||||
constexpr clang::TagTypeKind Union = clang::TTK_Union;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline bool EvaluateAsInt(clang::Expr const * expr, llvm::APSInt& intRes, const clang::ASTContext& ctx) {
|
||||
clang::Expr::EvalResult res;
|
||||
bool b = expr->EvaluateAsInt(res, ctx);
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include "config_clang.h"
|
||||
#include "compat.hxx"
|
||||
#include "plugin.hxx"
|
||||
#include <fstream>
|
||||
|
||||
@ -129,7 +130,7 @@ bool MergeClasses::VisitCXXConstructExpr( const CXXConstructExpr* pCXXConstructE
|
||||
return true;
|
||||
}
|
||||
// ignore calls when a sub-class is constructing its superclass
|
||||
if (pCXXConstructExpr->getConstructionKind() != CXXConstructExpr::ConstructionKind::CK_Complete) {
|
||||
if (pCXXConstructExpr->getConstructionKind() != compat::CXXConstructionKind::Complete) {
|
||||
return true;
|
||||
}
|
||||
const CXXConstructorDecl* pCXXConstructorDecl = pCXXConstructExpr->getConstructor();
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#ifndef LO_CLANG_SHARED_PLUGINS
|
||||
|
||||
#include "compat.hxx"
|
||||
#include "plugin.hxx"
|
||||
|
||||
namespace {
|
||||
@ -33,7 +34,7 @@ void PrivateBase::run() {
|
||||
|
||||
bool PrivateBase::VisitCXXRecordDecl(CXXRecordDecl const * decl) {
|
||||
if (ignoreLocation(decl) || !decl->isThisDeclarationADefinition()
|
||||
|| decl->getTagKind() != TTK_Class)
|
||||
|| decl->getTagKind() != compat::TagTypeKind::Class)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -609,7 +609,7 @@ bool RedundantCast::VisitCXXReinterpretCastExpr(
|
||||
{
|
||||
if (loplugin::TypeCheck(sub->getType()).Pointer().Const().Char()) {
|
||||
if (auto const lit = dyn_cast<clang::StringLiteral>(expr->getSubExprAsWritten())) {
|
||||
if (lit->getKind() == clang::StringLiteral::UTF8) {
|
||||
if (lit->getKind() == compat::StringLiteralKind::UTF8) {
|
||||
// Don't warn about
|
||||
//
|
||||
// redundant_cast<char const *>(u8"...")
|
||||
|
@ -9,13 +9,14 @@
|
||||
#ifndef LO_CLANG_SHARED_PLUGINS
|
||||
|
||||
#include "check.hxx"
|
||||
#include "compat.hxx"
|
||||
#include "plugin.hxx"
|
||||
|
||||
namespace {
|
||||
|
||||
bool isAsciiCharacterLiteral(Expr const * expr) {
|
||||
if (auto const e = dyn_cast<CharacterLiteral>(expr)) {
|
||||
return e->getKind() == CharacterLiteral::Ascii;
|
||||
return e->getKind() == compat::CharacterLiteralKind::Ascii;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include "plugin.hxx"
|
||||
#include "check.hxx"
|
||||
#include "compat.hxx"
|
||||
#include "config_clang.h"
|
||||
#include "clang/AST/CXXInheritance.h"
|
||||
|
||||
@ -849,7 +850,7 @@ bool VCLWidgets::VisitCXXConstructExpr( const CXXConstructExpr* constructExpr )
|
||||
if (ignoreLocation(constructExpr)) {
|
||||
return true;
|
||||
}
|
||||
if (constructExpr->getConstructionKind() != CXXConstructExpr::CK_Complete) {
|
||||
if (constructExpr->getConstructionKind() != compat::CXXConstructionKind::Complete) {
|
||||
return true;
|
||||
}
|
||||
const CXXConstructorDecl* pConstructorDecl = constructExpr->getConstructor();
|
||||
|
Loading…
x
Reference in New Issue
Block a user