forked from andreasfertig/cppinsights
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DPrint.cpp
67 lines (51 loc) · 1.94 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
/******************************************************************************
*
* C++ Insights, copyright (C) by Andreas Fertig
* Distributed under an MIT license. See LICENSE for details
*
****************************************************************************/
#include "DPrint.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, const char* file, const int line)
{
const auto fileName = [&]() {
if(llvm::sys::path::is_separator(file[0])) {
return llvm::sys::path::filename(file).data();
}
return file;
}();
outputFormatHelper.Append("/* INSIGHTS-TODO: ", fileName, ":", line, " stmt: ", name, " */");
}
//-----------------------------------------------------------------------------
void ToDo(const Stmt* stmt, OutputFormatHelper& outputFormatHelper, const char* file, const int line)
{
const char* name = [&]() {
if(stmt && 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, const char* file, const int line)
{
const char* name = [&]() {
if(stmt && stmt->getDeclKindName()) {
Dump(stmt);
return stmt->getDeclKindName();
}
Error("decl urg: class name is empty\n");
return "";
}();
ToDo(name, outputFormatHelper, file, line);
}
//-----------------------------------------------------------------------------
} // namespace clang::insights