1 //===-- ClangUtil.cpp -------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 // A collection of helper methods and data structures for manipulating clang
9 //===----------------------------------------------------------------------===//
11 #include "lldb/Symbol/ClangUtil.h"
12 #include "lldb/Symbol/ClangASTContext.h"
14 using namespace clang;
15 using namespace lldb_private;
17 bool ClangUtil::IsClangType(const CompilerType &ct) {
18 if (llvm::dyn_cast_or_null<ClangASTContext>(ct.GetTypeSystem()) == nullptr)
21 if (!ct.GetOpaqueQualType())
27 QualType ClangUtil::GetQualType(const CompilerType &ct) {
28 // Make sure we have a clang type before making a clang::QualType
32 return QualType::getFromOpaquePtr(ct.GetOpaqueQualType());
35 QualType ClangUtil::GetCanonicalQualType(const CompilerType &ct) {
39 return GetQualType(ct).getCanonicalType();
42 CompilerType ClangUtil::RemoveFastQualifiers(const CompilerType &ct) {
46 QualType qual_type(GetQualType(ct));
47 qual_type.removeLocalFastQualifiers();
48 return CompilerType(ct.GetTypeSystem(), qual_type.getAsOpaquePtr());
51 clang::TagDecl *ClangUtil::GetAsTagDecl(const CompilerType &type) {
52 clang::QualType qual_type = ClangUtil::GetCanonicalQualType(type);
53 if (qual_type.isNull())
56 return qual_type->getAsTagDecl();