forked from andreasfertig/cppinsights
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InsightsHelpers.cpp
678 lines (554 loc) · 24.2 KB
/
InsightsHelpers.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
/******************************************************************************
*
* C++ Insights, copyright (C) by Andreas Fertig
* Distributed under an MIT license. See LICENSE for details
*
****************************************************************************/
#include "InsightsHelpers.h"
#include "ClangCompat.h"
#include "CodeGenerator.h"
#include "DPrint.h"
#include "InsightsStaticStrings.h"
#include "OutputFormatHelper.h"
//-----------------------------------------------------------------------------
namespace clang::insights {
static const struct CppInsightsPrintingPolicy : PrintingPolicy
{
CppInsightsPrintingPolicy()
: PrintingPolicy{LangOptions{}}
{
adjustForCPlusPlus();
SuppressUnwrittenScope = true;
Alignof = true;
ConstantsAsWritten = true;
AnonymousTagLocations = false; // does remove filename and line for from lambdas in parameters
}
} InsightsPrintingPolicy{}; // NOLINT
//-----------------------------------------------------------------------------
static const std::string GetAsCPPStyleString(const QualType& t)
{
return t.getAsString(InsightsPrintingPolicy);
}
//-----------------------------------------------------------------------------
std::string BuildInternalVarName(const std::string& varName)
{
return StrCat("__", varName);
}
//-----------------------------------------------------------------------------
std::string BuildInternalVarName(const std::string& varName, const SourceLocation& loc, const SourceManager& sm)
{
const auto lineNo = sm.getSpellingLineNumber(loc);
return StrCat(BuildInternalVarName(varName), lineNo);
}
//-----------------------------------------------------------------------------
static const LangOptions& GetLangOpts(const ast_matchers::MatchFinder::MatchResult& result)
{
return result.Context->getLangOpts();
}
//-----------------------------------------------------------------------------
SourceLocation FindLocationAfterSemi(const SourceLocation loc,
const ast_matchers::MatchFinder::MatchResult& result,
RequireSemi requireSemi)
{
auto findLocation = [&](const tok::TokenKind tKind) {
return clang::Lexer::findLocationAfterToken(loc, tKind, GetSM(result), GetLangOpts(result), false);
};
if(const auto locEnd{findLocation(tok::semi)}; locEnd.isValid()) {
return locEnd;
} else if(RequireSemi::Yes == requireSemi) {
// if we do not find a ; then it can possibly be a brace init like this:
// auto x {23};
// Try to find the right curly which seems to also contain the semi.
if(const auto locEnd2{findLocation(tok::r_brace)}; locEnd2.isValid()) {
return locEnd2;
}
}
return loc;
}
//-----------------------------------------------------------------------------
SourceRange GetSourceRangeAfterSemi(const SourceRange range,
const ast_matchers::MatchFinder::MatchResult& result,
RequireSemi requireSemi)
{
const SourceLocation locEnd = FindLocationAfterSemi(range.getEnd(), result, requireSemi);
return {range.getBegin(), locEnd};
}
//-----------------------------------------------------------------------------
void InsertBefore(std::string& source, const std::string& find, const std::string& replace)
{
const std::string::size_type i = source.find(find, 0);
if(std::string::npos != i) {
source.insert(i, replace);
}
}
//-----------------------------------------------------------------------------
static void InsertAfter(std::string& source, const std::string& find, const std::string& replace)
{
const std::string::size_type i = source.find(find, 0);
if(std::string::npos != i) {
source.insert(i + find.length(), replace);
}
}
//-----------------------------------------------------------------------------
std::string GetLambdaName(const CXXRecordDecl& lambda)
{
static const std::string lambdaPrefix{"__lambda_"};
const auto& sm = GetSM(lambda);
const auto locBegin = GetBeginLoc(lambda);
const auto lineNo = sm.getSpellingLineNumber(locBegin);
const auto columnNo = sm.getSpellingColumnNumber(locBegin);
return StrCat(lambdaPrefix, lineNo, "_", columnNo);
}
//-----------------------------------------------------------------------------
std::string BuildRetTypeName(const Decl& decl)
{
static const std::string retTypePrefix{"retType_"};
const auto& sm = GetSM(decl);
const auto locBegin = GetBeginLoc(decl);
const auto lineNo = sm.getSpellingLineNumber(locBegin);
const auto columnNo = sm.getSpellingColumnNumber(locBegin);
return StrCat(retTypePrefix, lineNo, "_", columnNo);
}
//-----------------------------------------------------------------------------
const QualType GetDesugarType(const QualType& QT)
{
if(QT.getTypePtrOrNull()) {
if(auto autoType = QT->getAs<clang::AutoType>()) {
if(autoType->isSugared()) {
return autoType->getDeducedType();
}
} else if(auto declType = QT->getAs<clang::DecltypeType>()) {
return declType->desugar();
}
}
return QT;
}
//-----------------------------------------------------------------------------
const std::string EvaluateAsFloat(const FloatingLiteral& expr)
{
SmallString<16> str{};
expr.getValue().toString(str);
if(std::string::npos == str.find('.')) {
/* in case it is a number like 10.0 toString() seems to leave out the .0. However, as this distinguished
* between an integer and a floating point literal we need that dot. */
str.append(".0");
}
return str.str();
}
//-----------------------------------------------------------------------------
static const VarDecl* GetVarDeclFromDeclRefExpr(const DeclRefExpr& declRefExpr)
{
const auto* valueDecl = declRefExpr.getDecl();
return dyn_cast_or_null<VarDecl>(valueDecl);
}
//-----------------------------------------------------------------------------
std::string GetNameAsWritten(const QualType& t)
{
SplitQualType splitted = t.split();
return QualType::getAsString(splitted, InsightsPrintingPolicy);
}
//-----------------------------------------------------------------------------
namespace details {
static std::string GetQualifiedName(const NamedDecl& decl)
{
std::string name;
llvm::raw_string_ostream stream(name);
decl.printQualifiedName(stream, InsightsPrintingPolicy);
return stream.str();
}
//-----------------------------------------------------------------------------
static std::string GetScope(const DeclContext* declCtx)
{
std::string name{};
if(!declCtx->isTranslationUnit() && !declCtx->isFunctionOrMethod()) {
while(declCtx->isInlineNamespace()) {
declCtx = declCtx->getParent();
}
if(declCtx->isNamespace() || declCtx->getParent()->isTranslationUnit()) {
if(const auto* namespaceDecl = dyn_cast_or_null<NamespaceDecl>(declCtx)) {
name = GetQualifiedName(*namespaceDecl);
name.append("::");
}
}
}
return name;
}
//-----------------------------------------------------------------------------
static std::string GetNameInternal(const QualType& t, const Unqualified unqualified)
{
if(const auto* memberPointerType = t->getAs<MemberPointerType>()) {
if(const auto* recordType2 = dyn_cast_or_null<RecordType>(memberPointerType->getClass())) {
if(const auto* decl = recordType2->getDecl()) {
if(const auto* cxxRecordDecl = dyn_cast_or_null<CXXRecordDecl>(decl)) {
if(cxxRecordDecl->isLambda()) {
std::string result{GetAsCPPStyleString(t)};
static const std::string clangLambdaName{"(lambda)::*"};
if(auto pos = result.find(clangLambdaName); std::string::npos != pos) {
std::string lambdaName = GetLambdaName(*cxxRecordDecl);
lambdaName += "::*";
result.replace(pos, clangLambdaName.length(), lambdaName);
return result;
}
}
}
}
}
}
if(t.getTypePtrOrNull()) {
std::string refOrPointer{};
const RecordType* recordType = [&]() -> const RecordType* {
const auto& ct = t.getCanonicalType();
const auto* ctp = ct.getTypePtrOrNull();
if(const auto* sta = dyn_cast_or_null<RValueReferenceType>(ctp)) {
refOrPointer = "&&";
return dyn_cast_or_null<RecordType>(sta->getPointeeTypeAsWritten().getTypePtrOrNull());
} else if(const auto* ref = dyn_cast_or_null<ReferenceType>(ctp)) {
refOrPointer = "&";
return dyn_cast_or_null<RecordType>(ref->getPointeeTypeAsWritten().getTypePtrOrNull());
} else if(const auto* ptr = dyn_cast_or_null<PointerType>(ctp)) {
refOrPointer = "*";
return dyn_cast_or_null<RecordType>(ptr->getPointeeType().getTypePtrOrNull());
}
return dyn_cast_or_null<RecordType>(ctp);
}();
if(recordType) {
if(const auto* decl = recordType->getDecl()) {
const std::string cvqStr{[&]() {
if(const auto* refType = dyn_cast_or_null<ReferenceType>(t.getTypePtrOrNull())) {
return refType->getPointeeTypeAsWritten().getLocalQualifiers().getAsString();
}
return t.getCanonicalType().getLocalQualifiers().getAsString();
}()};
if(const auto* tt = dyn_cast_or_null<ClassTemplateSpecializationDecl>(decl)) {
if(const auto* x = t.getBaseTypeIdentifier()) {
OutputFormatHelper ofm{};
if((Unqualified::No == unqualified) && !cvqStr.empty()) {
ofm.Append(cvqStr, " ");
}
ofm.Append(GetScope(decl->getDeclContext()), x->getName());
CodeGenerator codeGenerator{ofm};
codeGenerator.InsertTemplateArgs(*tt);
if(!refOrPointer.empty()) {
ofm.Append(" ", refOrPointer);
}
return ofm.GetString();
}
} else if(const auto* cxxRecordDecl = dyn_cast_or_null<CXXRecordDecl>(decl)) {
if(cxxRecordDecl->isLambda()) {
std::string result{cvqStr};
if(!cvqStr.empty()) {
result += ' ';
}
result += GetLambdaName(*cxxRecordDecl);
if(!refOrPointer.empty()) {
result += ' ';
result += refOrPointer;
}
return result;
}
}
}
}
}
if(Unqualified::Yes == unqualified) {
return GetAsCPPStyleString(t.getUnqualifiedType());
}
return GetAsCPPStyleString(t);
}
//-----------------------------------------------------------------------------
static bool IsDecltypeType(const QualType& t)
{
if(t.getTypePtrOrNull()) {
if(isa<clang::DecltypeType>(t)) {
return true;
}
}
return false;
}
//-----------------------------------------------------------------------------
static std::string GetName(const QualType& t, const Unqualified unqualified = Unqualified::No)
{
const auto t2 = GetDesugarType(t);
const auto* at = t2->getContainedAutoType();
if(at && at->isSugared()) {
const auto dt = at->getDeducedType();
// treat LValueReference special at this point. This means we are coming from auto&& and it decayed to an
// l-value reference.
if(dt->isLValueReferenceType()) {
return GetNameInternal(dt, unqualified);
}
} else if(IsDecltypeType(t)) { // Handle decltype(var)
return GetNameInternal(t2, unqualified);
}
return GetNameInternal(t, unqualified);
}
} // namespace details
//-----------------------------------------------------------------------------
std::string GetName(const QualType& t, const Unqualified unqualified)
{
return details::GetName(t, unqualified);
}
//-----------------------------------------------------------------------------
template<typename QT, typename SUB_T>
static bool HasTypeWithSubType(const QualType& t)
{
if(const auto* lref = dyn_cast_or_null<QT>(t.getTypePtrOrNull())) {
const auto subType = GetDesugarType(lref->getPointeeType());
const auto& ct = subType.getCanonicalType();
const auto* plainSubType = ct.getTypePtrOrNull();
return isa<SUB_T>(plainSubType);
}
return false;
}
//-----------------------------------------------------------------------------
std::string GetTypeNameAsParameter(const QualType& t, const std::string& varName, const Unqualified unqualified)
{
const bool isFunctionPointer = HasTypeWithSubType<ReferenceType, FunctionProtoType>(t);
const bool isArrayRef = HasTypeWithSubType<ReferenceType, ArrayType>(t);
// Special case for Issue81, auto returns an array-ref and to catch auto deducing an array (Issue106)
const bool isAutoType = dyn_cast_or_null<AutoType>(t.getTypePtrOrNull());
const auto pointerToArrayBaseType = isAutoType ? t->getContainedAutoType()->getDeducedType() : t;
const bool isPointerToArray = HasTypeWithSubType<PointerType, ArrayType>(pointerToArrayBaseType);
std::string typeName = details::GetName(t, unqualified);
// Sometimes we get char const[2]. If we directly insert the typename we end up with char const__var[2] which is not
// a valid type name. Hence check for this condition and, if necessary, insert a space before __var.
auto getSpaceOrEmpty = [&](const std::string& needle) -> std::string {
if(not Contains(typeName, needle)) {
return " ";
}
return "";
};
if(t->isArrayType() && !t->isLValueReferenceType()) {
std::string space = getSpaceOrEmpty(" [");
InsertBefore(typeName, "[", StrCat(space, varName));
} else if(isArrayRef) {
const bool isRValueRef{HasTypeWithSubType<RValueReferenceType, ArrayType>(t)};
const std::string contains{isRValueRef ? "(&&" : "(&"};
if(Contains(typeName, contains)) {
InsertAfter(typeName, contains, varName);
} else {
const std::string insertBefore{isRValueRef ? "&&[" : "&["};
InsertBefore(typeName, insertBefore, "(");
InsertAfter(typeName, contains, StrCat(varName, ")"));
}
} else if(isFunctionPointer) {
const bool isRValueRef{HasTypeWithSubType<RValueReferenceType, FunctionProtoType>(t)};
const std::string contains{isRValueRef ? "(&&" : "(&"};
if(Contains(typeName, contains)) {
InsertAfter(typeName, contains, varName);
} else {
typeName += StrCat(" ", varName);
}
} else if(isPointerToArray) {
if(Contains(typeName, "(*")) {
InsertAfter(typeName, "(*", varName);
} else if(Contains(typeName, "*")) {
InsertBefore(typeName, "*", "(");
InsertAfter(typeName, "*", StrCat(varName, ")"));
} else {
typeName += StrCat(" ", varName);
}
} else if(t->isFunctionPointerType()) {
InsertAfter(typeName, "(*", varName);
} else if(!t->isArrayType() && !varName.empty()) {
typeName += StrCat(" ", varName);
}
return typeName;
}
//-----------------------------------------------------------------------------
static bool IsTrivialStaticClassVarDecl(const DeclRefExpr& declRefExpr)
{
if(const VarDecl* vd = GetVarDeclFromDeclRefExpr(declRefExpr)) {
return IsTrivialStaticClassVarDecl(*vd);
}
return false;
}
//-----------------------------------------------------------------------------
bool IsTrivialStaticClassVarDecl(const VarDecl& varDecl)
{
if(varDecl.isStaticLocal()) {
if(const auto* cxxRecordDecl = varDecl.getType()->getAsCXXRecordDecl()) {
if(cxxRecordDecl->hasNonTrivialDestructor() || cxxRecordDecl->hasNonTrivialDefaultConstructor()) {
return true;
}
}
}
return false;
}
//-----------------------------------------------------------------------------
static const SubstTemplateTypeParmType* GetSubstTemplateTypeParmType(const Type* t)
{
if(const auto* substTemplateTypeParmType = dyn_cast_or_null<SubstTemplateTypeParmType>(t)) {
return substTemplateTypeParmType;
} else if(const auto& pointeeType = t->getPointeeType(); not pointeeType.isNull()) {
return GetSubstTemplateTypeParmType(pointeeType.getTypePtrOrNull());
}
return nullptr;
}
//-----------------------------------------------------------------------------
/*
* \brief Get a usable name from a template parameter pack.
*
* A template parameter pack, args, as in:
* \code
template<typename F, typename ...Types>
auto forward(F f, Types &&...args) {
f(args...);
}
forward(f,1, 2,3);
* \endcode
*
* gets expanded by clang as
* \code
f(args, args, args);
* \endcode
*
* which would obviously not compile. For clang AST dump it is the right thing. For C++ Insights where the resulting
* code should be compilable it is not. What this function does is, figure out whether it is a pack expansion and if so,
* make the parameters unique, such that \c args becomes \c __args1 to \c __args3.
*
* The expected type for \c T currently is \c ValueDecl or \c VarDecl.
*/
template<typename T>
static std::string GetTemplateParameterPackArgumentName(std::string& name, const T* decl)
{
if(const auto* parmVarDecl = dyn_cast_or_null<ParmVarDecl>(decl)) {
if(const auto& originalType = parmVarDecl->getOriginalType(); not originalType.isNull()) {
if(const auto* substTemplateTypeParmType = GetSubstTemplateTypeParmType(originalType.getTypePtrOrNull())) {
if(substTemplateTypeParmType->getReplacedParameter()->isParameterPack()) {
name = StrCat(BuildInternalVarName(name), parmVarDecl->getFunctionScopeIndex());
}
}
}
}
return name;
}
//-----------------------------------------------------------------------------
std::string GetName(const DeclRefExpr& declRefExpr)
{
std::string name{};
const auto* declRefDecl = declRefExpr.getDecl();
const auto* declCtx = declRefDecl->getDeclContext();
const bool isFriend{(declRefDecl->getFriendObjectKind() != Decl::FOK_None)};
const bool hasNamespace{(declCtx && (declCtx->isNamespace() || declCtx->isInlineNamespace()) &&
!declCtx->isTransparentContext() && !isFriend)};
// get the namespace as well
if(hasNamespace) {
name = details::GetScope(declCtx);
} else if(declRefExpr.hasQualifier()) {
name = details::GetQualifiedName(*declRefDecl);
}
if(hasNamespace || !declRefExpr.hasQualifier()) {
std::string plainName{GetPlainName(declRefExpr)};
// try to handle the special case of a function local static with class type and non trivial destructor. In
// this case, as we teared that variable apart, we need to adjust the variable named and add a reinterpret
// cast
if(IsTrivialStaticClassVarDecl(declRefExpr)) {
if(const VarDecl* vd = GetVarDeclFromDeclRefExpr(declRefExpr)) {
if(const auto* cxxRecordDecl = vd->getType()->getAsCXXRecordDecl()) {
plainName = StrCat(
"*reinterpret_cast<", GetName(*cxxRecordDecl), "*>(", BuildInternalVarName(plainName), ")");
}
}
}
name.append(plainName);
}
return GetTemplateParameterPackArgumentName(name, declRefDecl);
}
//-----------------------------------------------------------------------------
/*
* Go deep in a Stmt if necessary and look to all childs for a DeclRefExpr.
*/
static const DeclRefExpr* FindDeclRef(const Stmt* stmt)
{
if(const auto* dref = dyn_cast_or_null<DeclRefExpr>(stmt)) {
return dref;
} else if(const auto* arrayInitExpr = dyn_cast_or_null<ArrayInitLoopExpr>(stmt)) {
const auto* srcExpr = arrayInitExpr->getCommonExpr()->getSourceExpr();
if(const auto* arrayDeclRefExpr = dyn_cast_or_null<DeclRefExpr>(srcExpr)) {
return arrayDeclRefExpr;
}
} else if(const auto func = dyn_cast_or_null<CXXFunctionalCastExpr>(stmt)) {
// TODO(stmt, "");
}
if(stmt) {
for(const auto* child : stmt->children()) {
if(const auto* childRef = FindDeclRef(child)) {
return childRef;
}
}
}
return nullptr;
}
//-----------------------------------------------------------------------------
std::string GetName(const VarDecl& VD)
{
// Handle a special case of DecompositionDecl. A DecompositionDecl does not have a name. Hence we make one up from
// the original name of the variable that is decomposed plus line number where the decomposition was written.
if(const auto* decompositionDeclStmt = dyn_cast_or_null<DecompositionDecl>(&VD)) {
const auto baseVarName{[&]() {
if(const auto* declName = FindDeclRef(decompositionDeclStmt->getInit())) {
std::string name = GetPlainName(*declName);
const std::string operatorName{"operator"};
if(Contains(name, operatorName)) {
return operatorName;
}
return name;
}
// We approached an unnamed decl. This happens for example like this: auto& [x, y] = Point{};
return std::string{};
}()};
return {BuildInternalVarName(baseVarName, GetBeginLoc(decompositionDeclStmt), GetSM(*decompositionDeclStmt))};
}
std::string name{VD.getNameAsString()};
return GetTemplateParameterPackArgumentName(name, &VD);
}
//-----------------------------------------------------------------------------
static bool EvaluateAsBoolenCondition(const Expr& expr, const Decl& decl)
{
bool r{false};
expr.EvaluateAsBooleanCondition(r, decl.getASTContext());
return r;
}
//-----------------------------------------------------------------------------
const std::string GetNoExcept(const FunctionDecl& decl)
{
const auto* func = decl.getType()->castAs<FunctionProtoType>();
if(func && func->hasNoexceptExceptionSpec()) {
std::string ret{kwSpaceNoexcept};
if(const auto* expr = func->getNoexceptExpr()) {
const auto value = [&] {
if(const auto* boolExpr = dyn_cast_or_null<CXXBoolLiteralExpr>(expr)) {
return boolExpr->getValue();
} else if(const auto* bExpr = dyn_cast_or_null<BinaryOperator>(expr)) {
return EvaluateAsBoolenCondition(*bExpr, decl);
} else if(const auto* cExpr = dyn_cast_or_null<ConstantExpr>(expr)) {
return EvaluateAsBoolenCondition(*cExpr, decl);
}
Error(expr, "INSIGHTS: Unexpected noexcept expr\n");
return false;
}();
ret += "(";
if(value) {
ret += "true";
} else {
ret += "false";
}
ret += ")";
}
return ret;
}
return {};
}
//-----------------------------------------------------------------------------
const char* GetConst(const FunctionDecl& decl)
{
if(const auto* methodDecl = dyn_cast_or_null<CXXMethodDecl>(&decl)) {
if(methodDecl->isConst()) {
return kwSpaceConst;
}
}
return "";
}
//-----------------------------------------------------------------------------
} // namespace clang::insights