Skip to content

Commit

Permalink
snapshot of cl/607768069
Browse files Browse the repository at this point in the history
  • Loading branch information
rwgk committed Feb 16, 2024
1 parent 64541ce commit da38562
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
16 changes: 6 additions & 10 deletions clif/backend/matcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
16 changes: 15 additions & 1 deletion clif/backend/matcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

// ############################################################################
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit da38562

Please sign in to comment.