forked from andreasfertig/cppinsights
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDPrint.cpp
68 lines (52 loc) · 2.02 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
/******************************************************************************
*
* 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(const char* name, OutputFormatHelper& outputFormatHelper, std::string_view file, const int line)
{
const auto fileName = [&]() {
if(llvm::sys::path::is_separator(file[0])) {
return std::string_view{llvm::sys::path::filename(file)};
}
return file;
}();
outputFormatHelper.Append("/* INSIGHTS-TODO: "sv, fileName, ":"sv, line, " stmt: "sv, name, kwSpaceCCommentEnd);
}
//-----------------------------------------------------------------------------
void ToDo(const Stmt* stmt, OutputFormatHelper& outputFormatHelper, std::string_view file, const int line)
{
const char* name = [&]() {
if(stmt and stmt->getStmtClassName()) {
Dump(stmt);
return stmt->getStmtClassName();
}
Error("arg urg: class name is empty\n");
return "";
}();
ToDo(name, outputFormatHelper, file, line);
}
//-----------------------------------------------------------------------------
void ToDo(const Decl* stmt, OutputFormatHelper& outputFormatHelper, std::string_view file, const int line)
{
const char* name = [&]() {
if(stmt and stmt->getDeclKindName()) {
Dump(stmt);
return stmt->getDeclKindName();
}
Error("decl urg: class name is empty\n");
return "";
}();
ToDo(name, outputFormatHelper, file, line);
}
//-----------------------------------------------------------------------------
} // namespace clang::insights