clang
24.0.0git
lib
CodeGenUtils
ClassUtils.cpp
Go to the documentation of this file.
1
//===--- ClassUtils.cpp - Shared C++ class emission queries ---------------===//
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
#include "
clang/CodeGenUtils/ClassUtils.h
"
10
#include "
clang/AST/EvaluatedExprVisitor.h
"
11
12
namespace
clang::CodeGenUtils
{
13
namespace
{
14
/// A visitor which checks whether an initializer uses 'this' in a
15
/// way which requires the vtable to be properly set.
16
struct
DynamicThisUseChecker
17
: ConstEvaluatedExprVisitor<DynamicThisUseChecker> {
18
using
super = ConstEvaluatedExprVisitor<DynamicThisUseChecker>;
19
20
bool
UsesThis =
false
;
21
22
DynamicThisUseChecker(
const
ASTContext &
C
) : super(
C
) {}
23
24
// Black-list all explicit and implicit references to 'this'.
25
//
26
// Do we need to worry about external references to 'this' derived
27
// from arbitrary code? If so, then anything which runs arbitrary
28
// external code might potentially access the vtable.
29
void
VisitCXXThisExpr(
const
CXXThisExpr *E) { UsesThis =
true
; }
30
};
31
}
// namespace
32
33
bool
baseInitializerUsesThis
(
ASTContext
&Ctx,
const
Expr
*
Init
) {
34
DynamicThisUseChecker Checker(Ctx);
35
Checker.Visit(
Init
);
36
return
Checker.UsesThis;
37
}
38
39
}
// namespace clang::CodeGenUtils
ClassUtils.h
EvaluatedExprVisitor.h
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition
ASTContext.h:239
clang::Expr
This represents one expression.
Definition
Expr.h:113
clang::CodeGenUtils
Definition
CallUtils.h:21
clang::CodeGenUtils::baseInitializerUsesThis
bool baseInitializerUsesThis(ASTContext &Ctx, const Expr *Init)
Check whether Init uses 'this' in a way which requires the vtable to be properly set.
Definition
ClassUtils.cpp:33
clang::OpenACCDirectiveKind::Init
@ Init
Definition
OpenACCKinds.h:59
clang::LinkageSpecLanguageIDs::C
@ C
Definition
DeclCXX.h:3036
Generated on
for clang by
1.14.0