-
-
Notifications
You must be signed in to change notification settings - Fork 244
/
DPrint.cpp
77 lines (59 loc) · 2.36 KB
/
DPrint.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/******************************************************************************
*
* C++ Insights, copyright (C) by Andreas Fertig
* Distributed under an MIT license. See LICENSE for details
*
****************************************************************************/
#include "DPrint.h"
#include "InsightsStaticStrings.h"
#include "OutputFormatHelper.h"
#include "clang/AST/AST.h"
#include "clang/AST/ASTContext.h"
#include "llvm/Support/Path.h"
//-----------------------------------------------------------------------------
namespace clang::insights {
static void ToDo(std::string_view name, OutputFormatHelper& outputFormatHelper, std::source_location loc)
{
const auto fileName = [&]() -> std::string_view {
if(llvm::sys::path::is_separator(loc.file_name()[0])) {
return llvm::sys::path::filename(loc.file_name());
}
return loc.file_name();
}();
outputFormatHelper.Append(
"/* INSIGHTS-TODO: "sv, fileName, ":"sv, loc.line(), " stmt: "sv, name, kwSpaceCCommentEnd);
}
//-----------------------------------------------------------------------------
void ToDo(const Stmt* stmt, OutputFormatHelper& outputFormatHelper, std::source_location loc)
{
const std::string_view name = [&]() {
if(stmt and stmt->getStmtClassName()) {
Dump(stmt);
return stmt->getStmtClassName();
}
Error("arg urg: class name is empty\n");
return "";
}();
ToDo(name, outputFormatHelper, loc);
}
//-----------------------------------------------------------------------------
void ToDo(const Decl* stmt, OutputFormatHelper& outputFormatHelper, std::source_location loc)
{
const std::string_view name = [&]() {
if(stmt and stmt->getDeclKindName()) {
Dump(stmt);
return stmt->getDeclKindName();
}
Error("decl urg: class name is empty\n");
return "";
}();
ToDo(name, outputFormatHelper, loc);
}
//-----------------------------------------------------------------------------
void ToDo(const class TemplateArgument& stmt, class OutputFormatHelper& outputFormatHelper, std::source_location loc)
{
const std::string_view name{StrCat("tmplArgKind: ", stmt.getKind())};
ToDo(name, outputFormatHelper, loc);
}
//-----------------------------------------------------------------------------
} // namespace clang::insights