clang
24.0.0git
lib
StaticAnalyzer
Checkers
WebKit
DiagOutputUtils.h
Go to the documentation of this file.
1
//=======- DiagOutputUtils.h -------------------------------------*- C++ -*-==//
2
//
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
6
//
7
//===----------------------------------------------------------------------===//
8
9
#ifndef LLVM_CLANG_ANALYZER_WEBKIT_DIAGPRINTUTILS_H
10
#define LLVM_CLANG_ANALYZER_WEBKIT_DIAGPRINTUTILS_H
11
12
#include "
ASTUtils.h
"
13
#include "
clang/AST/ASTContext.h
"
14
#include "
clang/AST/Decl.h
"
15
#include "
clang/AST/DeclCXX.h
"
16
#include "
clang/AST/DeclObjC.h
"
17
#include "llvm/Support/raw_ostream.h"
18
19
namespace
clang
{
20
21
template
<
typename
NamedDeclDerivedT>
22
void
printQuotedQualifiedName
(llvm::raw_ostream &Os,
23
const
NamedDeclDerivedT &D) {
24
Os <<
"'"
;
25
D->getNameForDiagnostic(Os, D->getASTContext().getPrintingPolicy(),
26
/*Qualified=*/
true
);
27
Os <<
"'"
;
28
}
29
30
template
<
typename
NamedDeclDerivedT>
31
void
printQuotedName
(llvm::raw_ostream &Os,
const
NamedDeclDerivedT &D) {
32
Os <<
"'"
;
33
D->getNameForDiagnostic(Os, D->getASTContext().getPrintingPolicy(),
34
/*Qualified=*/
false
);
35
Os <<
"'"
;
36
}
37
38
inline
void
printTypeName
(llvm::raw_ostream &Os,
const
QualType
QT) {
39
auto
*
Type
= QT.
getTypePtr
();
40
assert(
Type
);
41
if
(
auto
*CXXRD =
Type
->
getPointeeCXXRecordDecl
()) {
42
printQuotedQualifiedName
(Os, CXXRD);
43
return
;
44
}
45
if
(
auto
*ObjCDecl =
getObjCDeclFromObjCPtr
(
Type
)) {
46
printQuotedQualifiedName
(Os, ObjCDecl);
47
return
;
48
}
49
if
(!
Type
->
isPointerOrReferenceType
()) {
50
if
(
auto
*RD =
Type
->
getAsRecordDecl
())
51
printQuotedQualifiedName
(Os, RD);
52
}
53
}
54
55
}
// namespace clang
56
57
#endif
ASTContext.h
Defines the clang::ASTContext interface.
ASTUtils.h
DeclCXX.h
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
DeclObjC.h
Decl.h
clang::QualType
A (possibly-)qualified type.
Definition
TypeBase.h:937
clang::QualType::getTypePtr
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition
TypeBase.h:8447
clang::Type
The base class of the type hierarchy.
Definition
TypeBase.h:1875
clang::Type::getAsRecordDecl
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
Definition
Type.h:41
clang::Type::getPointeeCXXRecordDecl
const CXXRecordDecl * getPointeeCXXRecordDecl() const
If this is a pointer or reference to a RecordType, return the CXXRecordDecl that the type refers to.
Definition
Type.cpp:1958
clang::Type::isPointerOrReferenceType
bool isPointerOrReferenceType() const
Definition
TypeBase.h:8688
clang
The JSON file list parser is used to communicate input to InstallAPI.
Definition
CalledOnceCheck.h:17
clang::printQuotedQualifiedName
void printQuotedQualifiedName(llvm::raw_ostream &Os, const NamedDeclDerivedT &D)
Definition
DiagOutputUtils.h:22
clang::printQuotedName
void printQuotedName(llvm::raw_ostream &Os, const NamedDeclDerivedT &D)
Definition
DiagOutputUtils.h:31
clang::printTypeName
void printTypeName(llvm::raw_ostream &Os, const QualType QT)
Definition
DiagOutputUtils.h:38
clang::getObjCDeclFromObjCPtr
ObjCInterfaceDecl * getObjCDeclFromObjCPtr(const Type *TypePtr)
Definition
ASTUtils.cpp:391
Generated on
for clang by
1.14.0