-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathClangUtils.cpp
More file actions
30 lines (26 loc) · 902 Bytes
/
ClangUtils.cpp
File metadata and controls
30 lines (26 loc) · 902 Bytes
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
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2012-2021. All rights reserved.
*/
#include "ClangUtils.h"
#include <clang/AST/Decl.h>
namespace ClangUtils {
static bool isIncompleteTagDecl(clang::QualType type) {
if (!type.isNull()) {
if (auto const *tagDecl = type->getAsTagDecl()) {
return tagDecl->getDefinition() == nullptr;
}
}
return false;
}
bool isPointerToIncomplete(clang::QualType type) {
clang::QualType canonicalType = type.getCanonicalType();
if (auto const *pType = canonicalType.getTypePtrOrNull()) {
auto pointeeType = pType->getPointeeType();
if (!pointeeType.isNull()) {
return isIncompleteTagDecl(pointeeType) ||
isIncompleteTagDecl(pointeeType->getPointeeType());
}
}
return false;
}
}