diff --git a/clif/backend/BUILD b/clif/backend/BUILD index dac7d279..a643e48f 100644 --- a/clif/backend/BUILD +++ b/clif/backend/BUILD @@ -62,7 +62,6 @@ cc_library( "//clif/protos:ast_cc_proto", "@com_google_absl//absl/container:btree", "@com_google_absl//absl/log", - "@com_google_absl//absl/strings", "@com_google_googletest//:gtest_prod", "@llvm-project//clang:ast", "@llvm-project//clang:sema", @@ -74,6 +73,7 @@ cc_library( name = "strutil", hdrs = ["strutil.h"], deps = [ + "@com_google_absl//absl/strings", "@llvm-project//llvm:Support", ], ) diff --git a/clif/backend/code_builder.cc b/clif/backend/code_builder.cc index 0f1e92bf..dc80e1cf 100644 --- a/clif/backend/code_builder.cc +++ b/clif/backend/code_builder.cc @@ -79,7 +79,6 @@ #include #include -#include "absl/strings/str_cat.h" #include "clif/backend/strutil.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" @@ -391,7 +390,7 @@ const std::string& CodeBuilder::BuildCode( current_line_.pop_back(); current_file_.pop_back(); } - LLVM_DEBUG(llvm::dbgs() << absl::StrCat(*clif_ast)); + LLVM_DEBUG(llvm::dbgs() << ProtoDebugString(*clif_ast)); LLVM_DEBUG(llvm::dbgs() << code_); return code_; } diff --git a/clif/backend/matcher.cc b/clif/backend/matcher.cc index 31c5fc5b..d790e1ae 100644 --- a/clif/backend/matcher.cc +++ b/clif/backend/matcher.cc @@ -28,7 +28,6 @@ #include "absl/container/btree_map.h" #include "absl/log/log.h" -#include "absl/strings/str_cat.h" #include "clif/backend/strutil.h" #include "clang/AST/Expr.h" #include "clang/AST/Mangle.h" @@ -352,7 +351,7 @@ bool ClifMatcher::CompileMatchAndSet( const std::string& input_file_name, const AST& clif_ast, AST* modified_clif_ast) { - LLVM_DEBUG(llvm::dbgs() << absl::StrCat(clif_ast)); + LLVM_DEBUG(llvm::dbgs() << ProtoDebugString(clif_ast)); *modified_clif_ast = clif_ast; modified_clif_ast->set_clif_matcher_argv0(clif_matcher_argv0_); modified_clif_ast->set_clif_matcher_version_stamp(kMatcherVersionStamp); @@ -407,7 +406,7 @@ std::string ClifMatcher::GetQualTypeClifName(QualType qual_type) const { bool ClifMatcher::MatchAndSetAST(AST* clif_ast) { assert(ast_ != nullptr && "RunCompiler must be called prior to this."); int num_unmatched = MatchAndSetDecls(clif_ast->mutable_decls()); - LLVM_DEBUG(llvm::dbgs() << "Matched proto:\n" << absl::StrCat(*clif_ast)); + LLVM_DEBUG(llvm::dbgs() << "Matched proto:\n" << ProtoDebugString(*clif_ast)); return num_unmatched == 0; } @@ -1173,7 +1172,7 @@ bool ClifMatcher::MatchAndSetEnum(EnumDecl* enum_decl) { clif_name->set_native(result.GetFirst()->getNameAsString()); } } - LLVM_DEBUG(llvm::dbgs() << absl::StrCat(*enum_decl)); + LLVM_DEBUG(llvm::dbgs() << ProtoDebugString(*enum_decl)); return true; } @@ -2737,7 +2736,11 @@ const FunctionDecl* ClifMatcher::MatchAndSetFuncFromCandidates( if (auto method_decl = llvm::dyn_cast(clang_decl)) { func_decl->set_cpp_const_method(method_decl->isConst()); +#if PYCLIF_LLVM_VERSION_MAJOR >= 18 // llvm/llvm-project#78463 func_decl->set_is_pure_virtual(method_decl->isPureVirtual()); +#else + func_decl->set_is_pure_virtual(method_decl->isPure()); +#endif } if (auto named_decl = llvm::dyn_cast(clang_decl)) { diff --git a/clif/backend/strutil.h b/clif/backend/strutil.h index 4e5ccf04..dd6fca05 100644 --- a/clif/backend/strutil.h +++ b/clif/backend/strutil.h @@ -19,6 +19,7 @@ #include #include +#include "absl/strings/str_cat.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringRef.h" @@ -88,6 +89,11 @@ class NamespaceVector { ComponentsVector namespace_vector_; }; +template +std::string ProtoDebugString(const ProtoType& pb) { + return pb.DebugString(); +} + } // namespace clif #endif // CLIF_BACKEND_STRUTIL_H_