mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-16 01:58:11 +00:00
Improve debugability of clang decls (#7945)
Add `Dump` functions for `ClangDecl`/`ClangDeclSignature`, and add `MakeClangDeclId`/`MakeClangDeclSignatureId` and add those to `lldbinit.py`. Also change the label for `ClangDeclId` and `ClangDeclSignatureId` to not have an "_id" suffix, to make them consistent with other ID types.
This commit is contained in:
1 parent
9887d23b3f
commit
04443a9a14
7 files changed
+64
-13
No files matched your search
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "clang/AST/DeclBase.h"
|
||||
#include "common/raw_string_ostream.h"
|
||||
#include "toolchain/sem_ir/ids.h"
|
||||
#include "toolchain/sem_ir/inst.h"
|
||||
@@ -213,6 +214,31 @@ LLVM_DUMP_METHOD auto Dump(const File& file,
|
||||
return out.TakeStr();
|
||||
}
|
||||
|
||||
LLVM_DUMP_METHOD auto Dump(const File& file, ClangDeclId clang_decl_id)
|
||||
-> std::string {
|
||||
RawStringOstream out;
|
||||
out << clang_decl_id;
|
||||
if (clang_decl_id.has_value()) {
|
||||
const auto& clang_decl = file.clang_decls().Get(clang_decl_id);
|
||||
out << ": " << clang_decl << "\ndecl:\n";
|
||||
clang_decl.decl()->dump(out);
|
||||
}
|
||||
return out.TakeStr();
|
||||
}
|
||||
|
||||
LLVM_DUMP_METHOD auto Dump(const File& file,
|
||||
ClangDeclSignatureId clang_decl_signature_id)
|
||||
-> std::string {
|
||||
RawStringOstream out;
|
||||
out << clang_decl_signature_id;
|
||||
if (clang_decl_signature_id.has_value()) {
|
||||
const auto& clang_decl_signature =
|
||||
file.clang_decl_signatures().Get(clang_decl_signature_id);
|
||||
out << ": " << clang_decl_signature;
|
||||
}
|
||||
return out.TakeStr();
|
||||
}
|
||||
|
||||
LLVM_DUMP_METHOD auto Dump(const File& file, ClassId class_id) -> std::string {
|
||||
RawStringOstream out;
|
||||
out << class_id;
|
||||
@@ -647,6 +673,13 @@ LLVM_DUMP_METHOD static auto MakeGeneratedFunctionId(int id)
|
||||
-> GeneratedFunctionId {
|
||||
return GeneratedFunctionId(id);
|
||||
}
|
||||
LLVM_DUMP_METHOD static auto MakeClangDeclId(int id) -> ClangDeclId {
|
||||
return ClangDeclId(id);
|
||||
}
|
||||
LLVM_DUMP_METHOD static auto MakeClangDeclSignatureId(int id)
|
||||
-> ClangDeclSignatureId {
|
||||
return ClangDeclSignatureId(id);
|
||||
}
|
||||
LLVM_DUMP_METHOD static auto MakeClassId(int id) -> ClassId {
|
||||
return ClassId(id);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user