Skip to content

Commit

Permalink
Proof-of-concept fixes for breakages caused by internal changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwgk committed Jan 20, 2024
1 parent aea32dc commit e1806d0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
3 changes: 1 addition & 2 deletions clif/backend/code_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
#include <unordered_map>
#include <vector>

#include "absl/strings/str_cat.h"
#include "clif/backend/strutil.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
Expand Down Expand Up @@ -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_;
}
Expand Down
11 changes: 7 additions & 4 deletions clif/backend/matcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -2737,7 +2736,11 @@ const FunctionDecl* ClifMatcher::MatchAndSetFuncFromCandidates(

if (auto method_decl = llvm::dyn_cast<clang::CXXMethodDecl>(clang_decl)) {
func_decl->set_cpp_const_method(method_decl->isConst());
#if PYCLIF_LLVM_VERSION_MAJOR < 18 // The version number is a guess.
func_decl->set_is_pure_virtual(method_decl->isPure());
#else
func_decl->set_is_pure_virtual(method_decl->isPureVirtual());
#endif
}

if (auto named_decl = llvm::dyn_cast<clang::NamedDecl>(clang_decl)) {
Expand Down
6 changes: 6 additions & 0 deletions clif/backend/strutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <string>
#include <vector>

#include "absl/strings/str_cat.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
Expand Down Expand Up @@ -88,6 +89,11 @@ class NamespaceVector {
ComponentsVector namespace_vector_;
};

template <typename ProtoType>
std::string ProtoDebugString(const ProtoType& pb) {
return pb.DebugString();
}

} // namespace clif

#endif // CLIF_BACKEND_STRUTIL_H_

0 comments on commit e1806d0

Please sign in to comment.