Skip to content

[SelectionDAG] [NFC] Add pre-commit test for PR66701. #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 108 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
014c41d
[LLDB] Attempt to fix DumpDataExtractorTest
Sep 18, 2023
929662b
Revert "[analyzer] Fix crash analyzing _BitInt() in evalIntegralCast …
bjope Sep 18, 2023
6b7c402
Ignore out-of-bounds printf() format string in ASan test (#66695)
hctim Sep 18, 2023
266630c
[LLDB] Attempt to fix DumpDataExtractorTest
Sep 18, 2023
cacdb90
[Clang] Fix a crash in the diagnostic emission of invalid immediate c…
cor3ntin Sep 18, 2023
4176ce6
[mlir][sparse] fix logical error when generating sort_coo. (#66690)
PeimingLiu Sep 18, 2023
272bd6f
[WPD][LLD] Add option to validate RTTI is enabled on all native types…
modiking Jul 14, 2023
9a04bc4
[AArch64] Move LDR_PXI from isStoreToStackSlot to isLoadFromStackSlot…
weiguozhi Sep 18, 2023
58288c6
[driver] Search for compatible Android runtime directories
smeenai Sep 1, 2023
915ebb0
[driver] Address missed feedback from https://reviews.llvm.org/D158476
smeenai Sep 18, 2023
928564c
[RISCV] Combine a gather to a larger element type (#66694)
preames Sep 18, 2023
b2ef297
[NFC][hwasan] Remove default argument
vitalybuka Sep 19, 2023
cbd4750
[mlir][mlprogram] Add `mlprogram-pipeline-globals` optimization pass
rsuderman Sep 18, 2023
0fb6da8
[NFC][hwasan] Create *Report classes (#66682)
vitalybuka Sep 18, 2023
d39d86d
[NFC][hwasan] Use unnamed namespace and static (#66682)
vitalybuka Sep 18, 2023
75fdf2e
[NFC][hwasan] Move Report classes together (#66682)
vitalybuka Sep 18, 2023
170a25a
[mlir][TilingInterface] Make the tiling set tile sizes function use `…
MaheshRavishankar Sep 19, 2023
9094b3b
[NFC][hwasan] Extract BaseReport (#66682)
vitalybuka Sep 18, 2023
810bca5
[NFC][hwasan] Move PrintAddressDescription (#66682)
vitalybuka Sep 18, 2023
0a0c7e8
[mlir][tensor] Bufferize tensor.reshape with non-identity layouts (#6…
sabauma Sep 19, 2023
542f91f
[NFC][hwasan] Store thread id in SavedStackAllocations (#66682)
vitalybuka Sep 18, 2023
48caa07
[LAA] Analyze pointers forked by a phi (#65834)
vfdff Sep 19, 2023
8519d4f
[NFC][hwasan] Add access_size into base report (#66682)
vitalybuka Sep 18, 2023
13deda4
[NFC][hwasan] Remove default argument
vitalybuka Sep 18, 2023
d307d20
[NFC][hwasan] Make PrintAddressDescription method of BaseReport (#66682)
vitalybuka Sep 18, 2023
a668c0f
[LoopPredication] Fix division by zero in case of zero branch weights…
danilaml Sep 19, 2023
dc810e8
[NFC][hwasan] Collect heap related data early (#66682)
vitalybuka Sep 18, 2023
7db4a6f
[bazel] Port cbd475040f8952cfc55b9e13dd5ce6c4f6434cd3 (mlir/lib/Diale…
MaskRay Sep 19, 2023
c724ac9
[clang] Fix null dereference on return in lambda attribute statement …
pfusik Sep 19, 2023
3692267
[lldb] Add 'modify' type watchpoints, make it default (#66308)
jasonmolenda Sep 19, 2023
4b7a08f
[gn build] Port 3692267ca8f9
llvmgnsyncbot Sep 19, 2023
5445359
[RISCV][MC]Add support for Binary MCExpr
Yunzezhu94 Aug 25, 2023
6af39d9
[RISCV][NFC] Simplify the sp-offset reduction by spimm of CM.PUSH/POP…
yetingk Sep 19, 2023
31ebe98
[mlir][c] Expose AsmState. (#66693)
jpienaar Sep 19, 2023
4ea883c
[InstCombine] Add pre-commit tests for PR66606. NFC.
dtcxzyw Sep 19, 2023
6a1cf54
[BOLT][YAML] Only read first profile per function
aaupov Sep 19, 2023
3017545
[RISCV] Fix inline asm error for block address (#66640)
wangpc-pp Sep 19, 2023
acfb99d
[libc] Specify path for making include/ subdirs (#66589)
kaladron Sep 19, 2023
33df617
[mlir] Quality of life improvements to python API types. (#66723)
stellaraccident Sep 19, 2023
345f532
[ELF][test] Improve relocations referencing STT_SECTION tests for -r
MaskRay Sep 19, 2023
af935cf
[CodeLayout] Fix X1_Y_X2 and Y_X2_X1 testing for jumps from Y (#66592)
MaskRay Sep 19, 2023
44532a9
Revert "[lldb] Add 'modify' type watchpoints, make it default (#66308)"
jasonmolenda Sep 19, 2023
7ac1f60
[llvm-libgcc][CMake] Refactor llvm-libgcc (#65455)
ur4t Sep 19, 2023
69ae904
[gn build] Port 44532a9dd4a0
llvmgnsyncbot Sep 19, 2023
b9a6b28
[mlir][bazel] Small adjustment to https://github.com/llvm/llvm-projec…
chsigg Sep 19, 2023
1328a85
AMDGPU: Fix handling of -0 in round lowering (#65761)
arsenm Sep 19, 2023
3583d40
[NFC][NewGVN] Update assume_dominating_icmp.ll (#66711)
kmitropoulou Sep 19, 2023
1d7b59c
[clang][dataflow] Fix two null pointer dereferences in `getMemberForA…
martinboehme Sep 19, 2023
45bb45f
[llvm] Move CallInst::CreateMalloc to IRBuilderBase::CreateMalloc
kwk Aug 23, 2023
6923a31
[mlir][IR] Change `MutableArrayRange` to enumerate `OpOperand &` (#66…
matthias-springer Sep 19, 2023
ca723f2
[lldb][Docs] Document our major differences from the LLVM style (#66345)
DavidSpickett Sep 19, 2023
da57ced
[examples] Remove unused variable 'BB' in BrainF.cpp (NFC)
DamonFool Sep 19, 2023
ec7baca
[SPIR-V] Remove -opaque-pointers=0 from LITs, fixes for opaque pointe…
michalpaszkowski Sep 7, 2023
59c3dca
[AArch64] Remove copy instruction between uaddlv with v4i16/v8i16 and…
jaykang10 Sep 19, 2023
9568601
[lldb] Correct expected output for variable on 32 bit platforms
DavidSpickett Sep 19, 2023
159e94a
[mlir][linalg][transform] Add some debug output to vectorization. (NF…
ingomueller-net Sep 19, 2023
86ddbdd
[mlir][linalg][transform][python] Allow no args in MaskedVectorize. (…
ingomueller-net Sep 19, 2023
2616c27
[SPIR-V] Preserve pointer address space for load/gep instructions
michalpaszkowski Sep 19, 2023
91f46ec
[lldb][AArch64] Document how to control the SVE/SSVE tests
DavidSpickett Sep 19, 2023
c809051
[NFC] Preparatory work for D153131 (#66750)
legrosbuffle Sep 19, 2023
97495d3
[analyzer] TaintPropagation checker strlen() should not propagate (#6…
dkrupp Sep 19, 2023
ad4a513
[clang][CFG] Cleanup functions
tbaederr Aug 8, 2023
5bd1b93
Move CallInst::CreateFree to IRBuilderBase
kwk Aug 29, 2023
1d305f9
[AMDGPU] Fix line endings in a test
jayfoad Sep 19, 2023
e0919b1
[CodeGen] Renumber slot indexes before register allocation (#66334)
jayfoad Sep 13, 2023
d99d9d8
[lldb][AArch64] Add SME's Array Storage (ZA) register
DavidSpickett Sep 12, 2023
a0768b8
[lldb][AArch64] Add SME streaming vector length pseduo register
DavidSpickett Sep 12, 2023
73c2cb5
[RISCV] Merge RV32/RV64 CHECK lines in strided vp load/store tests. NFC
lukel97 Sep 19, 2023
a2a1dbb
[mlir] avoid crash in transform.sequence verifier (#66756)
ftynse Sep 19, 2023
71c83fb
[LLD] Improve the lit tests added by 272bd6f9cc86bf6b4dd6bd51e85c46db…
hokein Sep 19, 2023
61d819d
[RISCV] Add tests for memory constraint A
wangpc-pp Sep 19, 2023
46b961f
[lldb][AArch64] Implement resizing of SME's ZA register
DavidSpickett Sep 12, 2023
e96adfd
[lldb][AArch64] Add testing for SME's ZA and SVG registers
DavidSpickett Sep 12, 2023
f502ab7
[InstCombine] Add test for #62450 (NFC)
nikic Sep 19, 2023
c41b4b6
[InstCombine] Make flag drop during select equiv fold more generic
nikic Sep 19, 2023
6d1c6ec
[IR] `SingleBlock::push_back` operations to the back of the block (#6…
victor-eds Sep 19, 2023
a292e7e
Fix math-errno issue (#66381)
zahiraam Sep 19, 2023
9120e85
[Dexter] Associate parser errors with correct file (#66765)
Sep 19, 2023
571df01
[OpenMP][MLIR] Refactor and extend current map support by adding MapI…
agozillon Sep 19, 2023
8fde6f4
[Flang][OpenMP] Add lowering from PFT to new MapEntry and Bounds oper…
agozillon Sep 19, 2023
eaa0d28
[Flang][MLIR][OpenMP] Update OMPEarlyOutlining to support Bounds, Map…
agozillon Sep 19, 2023
b05d436
[MLIR][OpenMP] Alterations to LLVM-IR lowering of OpenMP Dialect due …
agozillon Sep 19, 2023
e15d72a
[FuncSpec] Adjust the names of specializations and promoted stack values
labrinea Sep 19, 2023
4abe3f1
[SPIRV] Fix bug in emitting GLSL ext inst names
sudonatalie Aug 30, 2023
00ecef9
[bazel] Port for 571df0132daa903ed2c5ad5776e4d264b823de40
hokein Sep 19, 2023
5f476b8
[flang] Add comdats to functions with linkonce linkage (#66516)
DavidTruby Sep 19, 2023
cf8e189
[clang][TSA] Thread safety cleanup functions
tbaederr Sep 6, 2023
116f7a2
[SPIRV] Test basic float and int types (#66282)
sudonatalie Sep 19, 2023
a21d4ab
[mlgo] Fix tests post PR #66334
mtrofin Sep 19, 2023
e25cd08
[libunwind][AIX] Fix up TOC register if unw_getcontext is called from…
xingxue-ibm Sep 19, 2023
8f8f449
[RISCV] Recognize veyron-v1 processor in clang driver. (#66703)
mgudim Sep 19, 2023
188d5c7
[RISCV] Add a combine to form masked.store from unit strided store
preames Sep 18, 2023
ddf7cc2
[SROA] Remove unnecessary IsStorePastEnd handling (NFCI)
nikic Sep 19, 2023
11bb5e5
In ExprRequirement building, treat OverloadExpr as dependent (#66683)
erichkeane Sep 19, 2023
d69293c
[mlir][SCF] `ForOp`: Remove `getIterArgNumberForOpOperand` (#66629)
matthias-springer Sep 19, 2023
9b5ef2b
[mlir][Interfaces] `LoopLikeOpInterface`: Support ops with multiple r…
matthias-springer Sep 19, 2023
469f6b9
[DAGCombiner] Combine vp.strided.load with unit stride to vp.load (#6…
lukel97 Sep 19, 2023
22d0bd8
[DAGCombiner] Combine vp.strided.store with unit stride to vp.store (…
lukel97 Sep 19, 2023
44e997a
[TwoAddressInstruction] Use isPlainlyKilled in processTiedPairs (#65976)
jayfoad Sep 19, 2023
82676d4
[RISCV] Fix bad isel predicate handling for Ztso. (#66739)
topperc Sep 19, 2023
84c899b
[libc][math] Extract non-MPFR math tests into libc-math-smoke-tests.
lntue Sep 7, 2023
1495d51
[lit] Drop "Script:", make -v and -a imply -vv
jdenny-ornl Sep 19, 2023
f223022
[lit] Improve test output from lit's internal shell
jdenny-ornl Sep 19, 2023
fba457d
[lit] Echo full RUN lines in case of external shells (#66408)
jdenny-ornl Sep 19, 2023
93fde2e
[RISCV] Add a pass to rewrite rd to x0 for non-computational instrs w…
dtcxzyw Sep 19, 2023
bdb5c9c
[mlir][spirv][gpu] Convert remaining wmma ops to KHR coop matrix (#66…
kuhar Sep 19, 2023
c6472f5
[mlir][sparse] More allocate -> empty tensor migration (#66720)
aartbik Sep 19, 2023
57dca34
[SelectionDAG] [NFC] Add pre-commit test for PR66701.
srpande Sep 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 12 additions & 2 deletions bolt/lib/Profile/YAMLProfileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,19 @@ Error YAMLProfileReader::preprocessProfile(BinaryContext &BC) {
buildNameMaps(BC);

// Preliminary assign function execution count.
for (auto [YamlBF, BF] : llvm::zip_equal(YamlBP.Functions, ProfileBFs))
if (BF)
for (auto [YamlBF, BF] : llvm::zip_equal(YamlBP.Functions, ProfileBFs)) {
if (!BF)
continue;
if (!BF->hasProfile()) {
BF->setExecutionCount(YamlBF.ExecCount);
} else {
if (opts::Verbosity >= 1) {
errs() << "BOLT-WARNING: dropping duplicate profile for " << YamlBF.Name
<< '\n';
}
BF = nullptr;
}
}

return Error::success();
}
Expand Down
53 changes: 53 additions & 0 deletions bolt/test/X86/yaml-multiple-profiles.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This test ensures that a YAML profile with multiple profiles matching the same
# function is handled gracefully.

# REQUIRES: system-linux
# RUN: split-file %s %t
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %t/main.s -o %t.o
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -nostdlib
# RUN: llvm-bolt %t.exe -o /dev/null --data %t/profile.yaml \
# RUN: --profile-ignore-hash -v=1 2>&1 | FileCheck %s
# CHECK: BOLT-WARNING: dropping duplicate profile for main_alias(*2)
#--- main.s
.globl main_alias
.type main_alias, %function
main_alias:
.globl main
.type main, %function
main:
.cfi_startproc
cmpl $0x0, %eax
retq
.cfi_endproc
.size main, .-main
.size main_alias, .-main_alias
#--- profile.yaml
---
header:
profile-version: 1
binary-name: 'yaml-multiple-profiles.test.tmp.exe'
binary-build-id: '<unknown>'
profile-flags: [ lbr ]
profile-origin: branch profile reader
profile-events: ''
dfs-order: false
functions:
- name: 'main(*2)'
fid: 1
hash: 0x50BBA3441D436491
exec: 1
nblocks: 1
blocks:
- bid: 0
insns: 2
hash: 0x4D4D8FAF7D4C0000
- name: 'main_alias(*2)'
fid: 1
hash: 0x50BBA3441D436491
exec: 1
nblocks: 1
blocks:
- bid: 0
insns: 2
hash: 0x4D4D8FAF7D4C0000
...
35 changes: 35 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,17 @@ Bug Fixes to C++ Support
definition the specialization was instantiated from.
(`#26057 <https://github.com/llvm/llvm-project/issues/26057>`_`)

- Fix a crash when a default member initializer of a base aggregate
makes an invalid call to an immediate function.
(`#66324 <https://github.com/llvm/llvm-project/issues/66324>`_)

- Fix crash for a lambda attribute with a statement expression
that contains a `return`.
(`#48527 <https://github.com/llvm/llvm-project/issues/48527>`_)

- Clang now no longer asserts when an UnresolvedLookupExpr is used as an
expression requirement. (`#66612 https://github.com/llvm/llvm-project/issues/66612`)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed an import failure of recursive friend class template.
Expand Down Expand Up @@ -337,6 +348,23 @@ X86 Support
Arm and AArch64 Support
^^^^^^^^^^^^^^^^^^^^^^^

Android Support
^^^^^^^^^^^^^^^

- Android target triples are usually suffixed with a version. Clang searches for
target-specific runtime and standard libraries in directories named after the
target (e.g. if you're building with ``--target=aarch64-none-linux-android21``,
Clang will look for ``lib/aarch64-none-linux-android21`` under its resource
directory to find runtime libraries). If an exact match isn't found, Clang
would previously fall back to a directory without any version (which would be
``lib/aarch64-none-linux-android`` in our example). Clang will now look for
directories for lower versions and use the newest version it finds instead,
e.g. if you have ``lib/aarch64-none-linux-android21`` and
``lib/aarch64-none-linux-android29``, ``-target aarch64-none-linux-android23``
will use the former and ``-target aarch64-none-linux-android30`` will use the
latter. Falling back to a versionless directory will now emit a warning, and
the fallback will be removed in Clang 19.

Windows Support
^^^^^^^^^^^^^^^
- Fixed an assertion failure that occurred due to a failure to propagate
Expand Down Expand Up @@ -425,6 +453,13 @@ Static Analyzer
bitwise shift operators produce undefined behavior (because some operand is
negative or too large).

- The ``alpha.security.taint.TaintPropagation`` checker no longer propagates
taint on ``strlen`` and ``strnlen`` calls, unless these are marked
explicitly propagators in the user-provided taint configuration file.
This removal empirically reduces the number of false positive reports.
Read the PR for the details.
(`#66086 <https://github.com/llvm/llvm-project/pull/66086>`_)

.. _release-notes-sanitizers:

Sanitizers
Expand Down
4 changes: 2 additions & 2 deletions clang/docs/analyzer/checkers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2599,8 +2599,8 @@ Default propagations rules:
``memcpy``, ``memmem``, ``memmove``, ``mbtowc``, ``pread``, ``qsort``,
``qsort_r``, ``rawmemchr``, ``read``, ``recv``, ``recvfrom``, ``rindex``,
``strcasestr``, ``strchr``, ``strchrnul``, ``strcasecmp``, ``strcmp``,
``strcspn``, ``strlen``, ``strncasecmp``, ``strncmp``, ``strndup``,
``strndupa``, ``strnlen``, ``strpbrk``, ``strrchr``, ``strsep``, ``strspn``,
``strcspn``, ``strncasecmp``, ``strncmp``, ``strndup``,
``strndupa``, ``strpbrk``, ``strrchr``, ``strsep``, ``strspn``,
``strstr``, ``strtol``, ``strtoll``, ``strtoul``, ``strtoull``, ``tolower``,
``toupper``, ``ttyname``, ``ttyname_r``, ``wctomb``, ``wcwidth``

Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ class SExprBuilder {
unsigned NumArgs = 0;

// Function arguments
const Expr *const *FunArgs = nullptr;
llvm::PointerUnion<const Expr *const *, til::SExpr *> FunArgs = nullptr;

// is Self referred to with -> or .?
bool SelfArrow = false;
Expand Down
38 changes: 35 additions & 3 deletions clang/include/clang/Analysis/CFG.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
#ifndef LLVM_CLANG_ANALYSIS_CFG_H
#define LLVM_CLANG_ANALYSIS_CFG_H

#include "clang/Analysis/Support/BumpVector.h"
#include "clang/Analysis/ConstructionContext.h"
#include "clang/AST/Attr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExprObjC.h"
#include "clang/Analysis/ConstructionContext.h"
#include "clang/Analysis/Support/BumpVector.h"
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/GraphTraits.h"
Expand Down Expand Up @@ -74,7 +75,8 @@ class CFGElement {
MemberDtor,
TemporaryDtor,
DTOR_BEGIN = AutomaticObjectDtor,
DTOR_END = TemporaryDtor
DTOR_END = TemporaryDtor,
CleanupFunction,
};

protected:
Expand Down Expand Up @@ -383,6 +385,32 @@ class CFGImplicitDtor : public CFGElement {
}
};

class CFGCleanupFunction final : public CFGElement {
public:
CFGCleanupFunction() = default;
CFGCleanupFunction(const VarDecl *VD)
: CFGElement(Kind::CleanupFunction, VD) {
assert(VD->hasAttr<CleanupAttr>());
}

const VarDecl *getVarDecl() const {
return static_cast<VarDecl *>(Data1.getPointer());
}

/// Returns the function to be called when cleaning up the var decl.
const FunctionDecl *getFunctionDecl() const {
const CleanupAttr *A = getVarDecl()->getAttr<CleanupAttr>();
return A->getFunctionDecl();
}

private:
friend class CFGElement;

static bool isKind(const CFGElement E) {
return E.getKind() == Kind::CleanupFunction;
}
};

/// Represents C++ object destructor implicitly generated for automatic object
/// or temporary bound to const reference at the point of leaving its local
/// scope.
Expand Down Expand Up @@ -1142,6 +1170,10 @@ class CFGBlock {
Elements.push_back(CFGAutomaticObjDtor(VD, S), C);
}

void appendCleanupFunction(const VarDecl *VD, BumpVectorContext &C) {
Elements.push_back(CFGCleanupFunction(VD), C);
}

void appendLifetimeEnds(VarDecl *VD, Stmt *S, BumpVectorContext &C) {
Elements.push_back(CFGLifetimeEnds(VD, S), C);
}
Expand Down
6 changes: 6 additions & 0 deletions clang/include/clang/Basic/DiagnosticDriverKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -749,4 +749,10 @@ def warn_drv_missing_multilib : Warning<
InGroup<DiagGroup<"missing-multilib">>;
def note_drv_available_multilibs : Note<
"available multilibs are:%0">;

def warn_android_unversioned_fallback : Warning<
"Using unversioned Android target directory %0 for target %1. Unversioned"
" directories will not be used in Clang 19. Provide a versioned directory"
" for the target version or lower instead.">,
InGroup<DiagGroup<"android-unversioned-fallback">>;
}
3 changes: 3 additions & 0 deletions clang/include/clang/Driver/ToolChain.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ class ToolChain {
EffectiveTriple = std::move(ET);
}

std::optional<std::string>
getFallbackAndroidTargetPath(StringRef BaseDir) const;

mutable std::optional<CXXStdlibType> cxxStdlibType;
mutable std::optional<RuntimeLibType> runtimeLibType;
mutable std::optional<UnwindLibType> unwindLibType;
Expand Down
40 changes: 29 additions & 11 deletions clang/lib/Analysis/CFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,10 @@ class CFGBuilder {
B->appendAutomaticObjDtor(VD, S, cfg->getBumpVectorContext());
}

void appendCleanupFunction(CFGBlock *B, VarDecl *VD) {
B->appendCleanupFunction(VD, cfg->getBumpVectorContext());
}

void appendLifetimeEnds(CFGBlock *B, VarDecl *VD, Stmt *S) {
B->appendLifetimeEnds(VD, S, cfg->getBumpVectorContext());
}
Expand Down Expand Up @@ -1346,7 +1350,8 @@ class CFGBuilder {
return {};
}

bool hasTrivialDestructor(VarDecl *VD);
bool hasTrivialDestructor(const VarDecl *VD) const;
bool needsAutomaticDestruction(const VarDecl *VD) const;
};

} // namespace
Expand Down Expand Up @@ -1861,14 +1866,14 @@ void CFGBuilder::addAutomaticObjDestruction(LocalScope::const_iterator B,
if (B == E)
return;

SmallVector<VarDecl *, 10> DeclsNonTrivial;
DeclsNonTrivial.reserve(B.distance(E));
SmallVector<VarDecl *, 10> DeclsNeedDestruction;
DeclsNeedDestruction.reserve(B.distance(E));

for (VarDecl* D : llvm::make_range(B, E))
if (!hasTrivialDestructor(D))
DeclsNonTrivial.push_back(D);
if (needsAutomaticDestruction(D))
DeclsNeedDestruction.push_back(D);

for (VarDecl *VD : llvm::reverse(DeclsNonTrivial)) {
for (VarDecl *VD : llvm::reverse(DeclsNeedDestruction)) {
if (BuildOpts.AddImplicitDtors) {
// If this destructor is marked as a no-return destructor, we need to
// create a new block for the destructor which does not have as a
Expand All @@ -1879,7 +1884,8 @@ void CFGBuilder::addAutomaticObjDestruction(LocalScope::const_iterator B,
Ty = getReferenceInitTemporaryType(VD->getInit());
Ty = Context->getBaseElementType(Ty);

if (Ty->getAsCXXRecordDecl()->isAnyDestructorNoReturn())
const CXXRecordDecl *CRD = Ty->getAsCXXRecordDecl();
if (CRD && CRD->isAnyDestructorNoReturn())
Block = createNoReturnBlock();
}

Expand All @@ -1890,8 +1896,10 @@ void CFGBuilder::addAutomaticObjDestruction(LocalScope::const_iterator B,
// objects, we end lifetime with scope end.
if (BuildOpts.AddLifetime)
appendLifetimeEnds(Block, VD, S);
if (BuildOpts.AddImplicitDtors)
if (BuildOpts.AddImplicitDtors && !hasTrivialDestructor(VD))
appendAutomaticObjDtor(Block, VD, S);
if (VD->hasAttr<CleanupAttr>())
appendCleanupFunction(Block, VD);
}
}

Expand Down Expand Up @@ -1922,7 +1930,7 @@ void CFGBuilder::addScopeExitHandling(LocalScope::const_iterator B,
// is destroyed, for automatic variables, this happens when the end of the
// scope is added.
for (VarDecl* D : llvm::make_range(B, E))
if (hasTrivialDestructor(D))
if (!needsAutomaticDestruction(D))
DeclsTrivial.push_back(D);

if (DeclsTrivial.empty())
Expand Down Expand Up @@ -2095,7 +2103,11 @@ LocalScope* CFGBuilder::addLocalScopeForDeclStmt(DeclStmt *DS,
return Scope;
}

bool CFGBuilder::hasTrivialDestructor(VarDecl *VD) {
bool CFGBuilder::needsAutomaticDestruction(const VarDecl *VD) const {
return !hasTrivialDestructor(VD) || VD->hasAttr<CleanupAttr>();
}

bool CFGBuilder::hasTrivialDestructor(const VarDecl *VD) const {
// Check for const references bound to temporary. Set type to pointee.
QualType QT = VD->getType();
if (QT->isReferenceType()) {
Expand Down Expand Up @@ -2149,7 +2161,7 @@ LocalScope* CFGBuilder::addLocalScopeForVarDecl(VarDecl *VD,
return Scope;

if (!BuildOpts.AddLifetime && !BuildOpts.AddScopes &&
hasTrivialDestructor(VD)) {
!needsAutomaticDestruction(VD)) {
assert(BuildOpts.AddImplicitDtors);
return Scope;
}
Expand Down Expand Up @@ -5287,6 +5299,7 @@ CFGImplicitDtor::getDestructorDecl(ASTContext &astContext) const {
case CFGElement::CXXRecordTypedCall:
case CFGElement::ScopeBegin:
case CFGElement::ScopeEnd:
case CFGElement::CleanupFunction:
llvm_unreachable("getDestructorDecl should only be used with "
"ImplicitDtors");
case CFGElement::AutomaticObjectDtor: {
Expand Down Expand Up @@ -5830,6 +5843,11 @@ static void print_elem(raw_ostream &OS, StmtPrinterHelper &Helper,
break;
}

case CFGElement::Kind::CleanupFunction:
OS << "CleanupFunction ("
<< E.castAs<CFGCleanupFunction>().getFunctionDecl()->getName() << ")\n";
break;

case CFGElement::Kind::LifetimeEnds:
Helper.handleDecl(E.castAs<CFGLifetimeEnds>().getVarDecl(), OS);
OS << " (Lifetime ends)\n";
Expand Down
5 changes: 4 additions & 1 deletion clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,14 @@ static void insertIfFunction(const Decl &D,
}

static MemberExpr *getMemberForAccessor(const CXXMemberCallExpr &C) {
if (!C.getMethodDecl())
return nullptr;
auto *Body = dyn_cast_or_null<CompoundStmt>(C.getMethodDecl()->getBody());
if (!Body || Body->size() != 1)
return nullptr;
if (auto *RS = dyn_cast<ReturnStmt>(*Body->body_begin()))
return dyn_cast<MemberExpr>(RS->getRetValue()->IgnoreParenImpCasts());
if (auto *Return = RS->getRetValue())
return dyn_cast<MemberExpr>(Return->IgnoreParenImpCasts());
return nullptr;
}

Expand Down
1 change: 1 addition & 0 deletions clang/lib/Analysis/PathDiagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ getLocationForCaller(const StackFrameContext *SFC,
}
case CFGElement::ScopeBegin:
case CFGElement::ScopeEnd:
case CFGElement::CleanupFunction:
llvm_unreachable("not yet implemented!");
case CFGElement::LifetimeEnds:
case CFGElement::LoopExit:
Expand Down
Loading