Skip to content

Commit da38562

Browse files
committed
snapshot of cl/607768069
1 parent 64541ce commit da38562

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

clif/backend/matcher.cc

+6-10
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@
3939
#include "llvm/Support/Debug.h"
4040
#include "llvm/Support/raw_ostream.h"
4141

42-
#ifndef PYCLIF_LLVM_VERSION_MAJOR
43-
#define PYCLIF_LLVM_VERSION_MAJOR LLVM_VERSION_MAJOR
44-
#endif
45-
4642
#if PYCLIF_LLVM_VERSION_MAJOR > 16
4743
#include "clang/Sema/EnterExpressionEvaluationContext.h"
4844
#endif
@@ -2989,20 +2985,20 @@ const clang::FunctionDecl* ClifMatcher::SpecializeFunctionTemplate(
29892985
}
29902986

29912987
std::string ClifMatcher::TemplateDeductionResult(
2992-
clang::TemplateDeductionResult specialized_result) const {
2988+
PYCLIF_CLANG_TEMPLATEDEDUCTIONRESULT_TYPE specialized_result) const {
29932989
switch (specialized_result) {
2994-
case clang::TemplateDeductionResult::Invalid:
2990+
case PYCLIF_CLANG_TEMPLATEDEDUCTIONRESULT_ENUM(Invalid):
29952991
return "The template function declaration was invalid.";
2996-
case clang::TemplateDeductionResult::InstantiationDepth:
2992+
case PYCLIF_CLANG_TEMPLATEDEDUCTIONRESULT_ENUM(InstantiationDepth):
29972993
return "Template argument deduction exceeded the maximum template "
29982994
"instantiation depth.";
2999-
case clang::TemplateDeductionResult::Incomplete:
2995+
case PYCLIF_CLANG_TEMPLATEDEDUCTIONRESULT_ENUM(Incomplete):
30002996
return "Template argument deduction did not deduce a value for every "
30012997
"template parameter.";
3002-
case clang::TemplateDeductionResult::Inconsistent:
2998+
case PYCLIF_CLANG_TEMPLATEDEDUCTIONRESULT_ENUM(Inconsistent):
30032999
return "Template argument deduction produced inconsistent deduced "
30043000
"values.";
3005-
case clang::TemplateDeductionResult::Underqualified:
3001+
case PYCLIF_CLANG_TEMPLATEDEDUCTIONRESULT_ENUM(Underqualified):
30063002
return "Template argument deduction failed due to inconsistent "
30073003
"cv-qualifiers.";
30083004
default:

clif/backend/matcher.h

+15-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
#include "clif/protos/ast.pb.h"
4949
#include "gtest/gtest_prod.h" // Defines FRIEND_TEST.
5050

51+
#ifndef PYCLIF_LLVM_VERSION_MAJOR
52+
#define PYCLIF_LLVM_VERSION_MAJOR LLVM_VERSION_MAJOR
53+
#endif
54+
5155
namespace clif {
5256

5357
// ############################################################################
@@ -177,6 +181,16 @@ enum TypeMatchFlags : unsigned int {
177181
class ClifError;
178182
class ClifMatcherTest;
179183

184+
#if PYCLIF_LLVM_VERSION_MAJOR >= 19 // llvm/llvm-project#81398
185+
#define PYCLIF_CLANG_TEMPLATEDEDUCTIONRESULT_TYPE clang::TemplateDeductionResult
186+
#define PYCLIF_CLANG_TEMPLATEDEDUCTIONRESULT_ENUM(Name) \
187+
clang::TemplateDeductionResult::Name
188+
#else
189+
#define PYCLIF_CLANG_TEMPLATEDEDUCTIONRESULT_TYPE \
190+
clang::Sema::TemplateDeductionResult
191+
#define PYCLIF_CLANG_TEMPLATEDEDUCTIONRESULT_ENUM(Name) Sema::TDK_##Name
192+
#endif
193+
180194
class ClifMatcher {
181195
friend class ClifMatcherTest;
182196
public:
@@ -402,7 +416,7 @@ class ClifMatcher {
402416

403417
// Transform template type deduction error codes into error messages.
404418
std::string TemplateDeductionResult(
405-
clang::TemplateDeductionResult specialized_result) const;
419+
PYCLIF_CLANG_TEMPLATEDEDUCTIONRESULT_TYPE specialized_result) const;
406420

407421
// Add the class type as the first parameter to a function.
408422
void AdjustForNonClassMethods(protos::FuncDecl* clif_func_decl) const;

0 commit comments

Comments
 (0)