diff --git a/clif/backend/matcher.cc b/clif/backend/matcher.cc index 0add125c..a0300fe3 100644 --- a/clif/backend/matcher.cc +++ b/clif/backend/matcher.cc @@ -39,10 +39,6 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" -#ifndef PYCLIF_LLVM_VERSION_MAJOR -#define PYCLIF_LLVM_VERSION_MAJOR LLVM_VERSION_MAJOR -#endif - #if PYCLIF_LLVM_VERSION_MAJOR > 16 #include "clang/Sema/EnterExpressionEvaluationContext.h" #endif @@ -2989,20 +2985,20 @@ const clang::FunctionDecl* ClifMatcher::SpecializeFunctionTemplate( } std::string ClifMatcher::TemplateDeductionResult( - clang::TemplateDeductionResult specialized_result) const { + PYCLIF_CLANG_TEMPLATEDEDUCTIONRESULT_TYPE specialized_result) const { switch (specialized_result) { - case clang::TemplateDeductionResult::Invalid: + case PYCLIF_CLANG_TEMPLATEDEDUCTIONRESULT_ENUM(Invalid): return "The template function declaration was invalid."; - case clang::TemplateDeductionResult::InstantiationDepth: + case PYCLIF_CLANG_TEMPLATEDEDUCTIONRESULT_ENUM(InstantiationDepth): return "Template argument deduction exceeded the maximum template " "instantiation depth."; - case clang::TemplateDeductionResult::Incomplete: + case PYCLIF_CLANG_TEMPLATEDEDUCTIONRESULT_ENUM(Incomplete): return "Template argument deduction did not deduce a value for every " "template parameter."; - case clang::TemplateDeductionResult::Inconsistent: + case PYCLIF_CLANG_TEMPLATEDEDUCTIONRESULT_ENUM(Inconsistent): return "Template argument deduction produced inconsistent deduced " "values."; - case clang::TemplateDeductionResult::Underqualified: + case PYCLIF_CLANG_TEMPLATEDEDUCTIONRESULT_ENUM(Underqualified): return "Template argument deduction failed due to inconsistent " "cv-qualifiers."; default: diff --git a/clif/backend/matcher.h b/clif/backend/matcher.h index e30b2a5a..802f8a9a 100644 --- a/clif/backend/matcher.h +++ b/clif/backend/matcher.h @@ -48,6 +48,10 @@ #include "clif/protos/ast.pb.h" #include "gtest/gtest_prod.h" // Defines FRIEND_TEST. +#ifndef PYCLIF_LLVM_VERSION_MAJOR +#define PYCLIF_LLVM_VERSION_MAJOR LLVM_VERSION_MAJOR +#endif + namespace clif { // ############################################################################ @@ -177,6 +181,16 @@ enum TypeMatchFlags : unsigned int { class ClifError; class ClifMatcherTest; +#if PYCLIF_LLVM_VERSION_MAJOR >= 19 // llvm/llvm-project#81398 +#define PYCLIF_CLANG_TEMPLATEDEDUCTIONRESULT_TYPE clang::TemplateDeductionResult +#define PYCLIF_CLANG_TEMPLATEDEDUCTIONRESULT_ENUM(Name) \ + clang::TemplateDeductionResult::Name +#else +#define PYCLIF_CLANG_TEMPLATEDEDUCTIONRESULT_TYPE \ + clang::Sema::TemplateDeductionResult +#define PYCLIF_CLANG_TEMPLATEDEDUCTIONRESULT_ENUM(Name) Sema::TDK_##Name +#endif + class ClifMatcher { friend class ClifMatcherTest; public: @@ -402,7 +416,7 @@ class ClifMatcher { // Transform template type deduction error codes into error messages. std::string TemplateDeductionResult( - clang::TemplateDeductionResult specialized_result) const; + PYCLIF_CLANG_TEMPLATEDEDUCTIONRESULT_TYPE specialized_result) const; // Add the class type as the first parameter to a function. void AdjustForNonClassMethods(protos::FuncDecl* clif_func_decl) const;