Skip to content

[clang][dataflow] Expose fields, globals, and functions referenced. #88534

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 175 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
175 commits
Select commit Hold shift + click to select a range
869ddaf
[clang][dataflow] Expose fields, globals, and functions referenced.
bazuzi Apr 12, 2024
0f39599
[MLIR][Bufferization] Choose default memory space in tensor copy inse…
Groverkss Apr 12, 2024
8be627c
[SystemZ] Add missing (dis-)assembly tests. (#88498)
dominik-steenken Apr 12, 2024
6167e36
[SystemZ] Add custom handling of legal vectors with reduce-add. (#88495)
dominik-steenken Apr 12, 2024
cefb452
NFC: Make clang resource headers an interface library (#88317)
etcwilde Apr 12, 2024
d7c4b93
[analyzer] Support `PointerType` in `getCXXRecordDecl` for `Container…
shenjunjiekoda Apr 12, 2024
9c1c669
[NFC][ValueTracking] Fix Wunused-variable
rupprecht Apr 12, 2024
c812b95
[clang-tidy] Simplify RenamerClangTidyCheck API (#88268)
revane Apr 12, 2024
91ab88c
[clang][CodeGen][OpenMP] Fix casting of atomic update of ptr types (#…
mikerice1969 Apr 12, 2024
812632a
[clang-format] Fix a regression in ContinuationIndenter (#88414)
owenca Apr 12, 2024
27c5fae
Add IIT_V6 to support 6-element vectors in intrinsics. (#88196)
rampitec Apr 12, 2024
d9a8129
[SelectionDAG] Verify SPLAT_VECTOR nodes when they are created. (#88305)
topperc Apr 12, 2024
a97eb78
[libc++] P3029R1: Better `mdspan`'s CTAD (#87873)
Apr 12, 2024
d40143a
[clang][deps] NFCI: Extract `FilenameForLookup` into new function
jansvoboda11 Apr 12, 2024
3fc9cc6
[llvm][vfs] NFCI: Remove `const` from `VFS::getRealPath()`
jansvoboda11 Apr 12, 2024
22071ca
[clang][deps] Create separate unittest directory
jansvoboda11 Apr 12, 2024
3ccf32f
[clang][deps] Cache `VFS::getRealPath()` (#68645)
jansvoboda11 Apr 12, 2024
731a285
ANDROID: x86_64: Set default max-page-size to 16kB (#87413)
Kalesh-Singh Apr 12, 2024
21c0604
[lldb] Fix test build failure
jansvoboda11 Apr 12, 2024
329c146
[xray] Apply default visibility to __xray_CustomEvent/__xray_TypedEvent
MaskRay Apr 12, 2024
f7aa539
Reapply "Fix error in unrecognized register name handling for "SBFram…
jimingham Apr 12, 2024
f2d6c71
[memprof] Clean up writer traits (NFC) (#88549)
kazutakahirata Apr 12, 2024
6ce6656
[C99] Claim conformance for _Complex support (#88161)
AaronBallman Apr 12, 2024
0f84c75
[NFC][Clang] Fix static analyzer concern (#88179)
elizabethandrews Apr 12, 2024
0bc3c28
[GlobalIsel] Import vscale (#88240)
tschuett Apr 12, 2024
a06b494
[clang] Remove unused variable in test
jansvoboda11 Apr 12, 2024
a99e24d
Add txtpb to the list of supported TextProto extensions (#88355)
jingw Apr 12, 2024
62039e2
[LLVM][OpenMP] Add "nowait" clause as valid for "workshare" (#88426)
kparzysz Apr 12, 2024
1179abe
Reapply "[libc][math][c23] Add remaining linux/* entrypoints for {,u}…
overmighty Apr 12, 2024
1c846a1
[OpenMP] Fix re-locking hang found in issue 86684 (#88539)
jpeyton52 Apr 12, 2024
e2efbc3
Reland "[compiler-rt] Allow running tests without installing first"
arichardson Apr 12, 2024
ae16ecf
[llvm][vfs] Make vfs::FileSystem::exists() virtual NFC (#88575)
artemcm Apr 12, 2024
3d59c80
[Support] Fix the issue where the character being saved in Unicode ca…
harrisonGPU Apr 12, 2024
0212676
[SLP][NFC]Make TTIRef capture argument instead of outer declaration.
alexey-bataev Apr 12, 2024
8d1148b
[Passes] Run SimpleLoopUnswitch after introducing invariant branches.…
fhahn Apr 12, 2024
8d2e3ba
IRVerifier: Allow GlobalValue as llvm.threadlocal.address operand (#8…
MatzeB Apr 12, 2024
985aa52
[OpenACC] Implement 'if' clause for Compute Constructs (#88411)
erichkeane Apr 12, 2024
8a264af
[flang][cuda] Fix crash in semantic (#88577)
clementval Apr 12, 2024
dc06bb9
Fix typos (#88565)
ViToni Apr 12, 2024
97ef724
[libc][docs] use docgen to generate stdbit rst docs (#88540)
Flandini Apr 12, 2024
03bc223
[NFC] Remove unused type alias in OpenACC
erichkeane Apr 12, 2024
26837b2
[NFC][OpenACC] Rename visitor functions to omit redundant OpenACC
erichkeane Apr 12, 2024
e34cbf4
[NFC] Clang-format previous OpenACC Patch
erichkeane Apr 12, 2024
31107c0
[clang][deps] Overload `Filesystem::exists` in `DependencyScanningFil…
artemcm Apr 12, 2024
150fc02
Fix build failure from a472e6473e69
erichkeane Apr 12, 2024
6dc28ed
[CMake][Release] Disable PGO (#88465)
tstellar Apr 12, 2024
3f61cbb
AMDGPU: Undo atomicrmw add/sub/xor 0 -> atomicrmw or canonicalization…
arsenm Apr 12, 2024
6d5ff3b
[test] Improve tests for alias/ifunc attributes
MaskRay Apr 12, 2024
04a9f9e
[DSE] Fix non-determinism due to address reuse (#84943)
nikic Apr 13, 2024
544918e
[unused-includes][ADT] Don't include DJB.h as it's not used. NFC. (#8…
vsapsai Apr 13, 2024
dd43cfd
[test] alias-unused.cpp: set triple to Linux
MaskRay Apr 13, 2024
33f748b
[ELF] Relocations: Avoid MIPS check for ELFCLASS64 with if constexpr.…
MaskRay Apr 13, 2024
3e824c0
[M68k][clang] Enable frame pointer optimization by default (#87264)
tclin914 Apr 13, 2024
0d4c2eb
[clang] Introduce `SemaCUDA` (#88559)
Endilll Apr 13, 2024
9b47056
[clang] Implement `__is_pointer_interconvertible_base_of()` (#88473)
Endilll Apr 13, 2024
6ebc82b
[InstallAPI] Replace std::string -> StringRef
cyndyishida Apr 13, 2024
824c6ac
[clang][NFC] Replace `dr` with `cwg` in DR test suite
Endilll Apr 13, 2024
8d19b9e
[modules] allow use of ptrauth module from no_undeclared_includes sys…
ian-twilightcoder Apr 13, 2024
671eb36
[clang][NFC] Tidy up extension warnings about `_Static_assert`
Endilll Apr 13, 2024
1ab29af
[mlir][spirv] Add op decoration NoContraction (#88578)
Hsiangkai Apr 13, 2024
8020bd6
[ORC] Replace more KV loop variables with structured bindings.
lhames Apr 13, 2024
85f15c4
[X86][BF16] Improve vectorization of BF16 (#88486)
phoebewang Apr 13, 2024
208f595
[CVP] Use at-use info in `processBinOp` (#88523)
dtcxzyw Apr 13, 2024
eea9280
[SLP] Initial vectorization of non-power-of-2 ops. (#77790)
fhahn Apr 13, 2024
3f6827a
[tzdb] Replace shared_mutex with mutex. (#87929)
EricWF Apr 13, 2024
2ab4ab4
[libc++][spaceship][NFC] P0905R1: Symmetry for spaceship - mark as im…
H-G-Hristov Apr 13, 2024
745eab5
[lldb][libc++] Adds local_t clock data formatters. (#88178)
mordante Apr 13, 2024
9d52992
[lldb] Fixes comment typos.
mordante Apr 13, 2024
f049c7b
[clang] Add missing documentation entry for `__is_pointer_interconver…
Endilll Apr 13, 2024
0cb025d
[SLP] Use StoreTy to compute min VF.
fhahn Apr 13, 2024
c884d5c
[libc++][CMake] Removes LIBCXX_ENABLE_CLANG_TIDY. (#85794)
mordante Apr 13, 2024
d42438d
[NewPM] Set diagnostic handler in `MachineModuleAnalysis` (#88229)
paperchalice Apr 13, 2024
bda3cb9
[MergeFunc] Handle ConstantRange attributes (#88584)
andjo403 Apr 13, 2024
0e28c2a
[libc++] Marks a variable const. (#88562)
mordante Apr 13, 2024
0bff8a1
[libc++] Undeprecate POSIX STREAM macros. (#88296)
mordante Apr 13, 2024
ecfd36a
[clang][NFC] Add a test for CWG2254 to `is_pointer_interconvertible_b…
Endilll Apr 13, 2024
75b1a9f
[libc++][TZDZ] Validates the database version.
mordante Apr 13, 2024
67e97d1
[libc++][NFC] Move basic ASan annotation functions into a utility hea…
philnik777 Apr 13, 2024
ff2fea9
[libc++][TZDB] Removes test_indian_kerguelen test.
mordante Apr 13, 2024
8ecebf5
[clang-tidy] Export fixes from check_clang_tidy.py (#88186)
revane Apr 13, 2024
9962d1a
[GVN] lazily update dominator tree when merge unconditional branches …
Enna1 Apr 14, 2024
7fafac0
[LegalizeTypes][RISCV] Support scalable vectors in SplitVecRes_BITCAS…
topperc Apr 14, 2024
73ee36c
[clang][docs] fix whitespace in AttrDocs.td (#88631)
chrisnc Apr 14, 2024
b25e2a8
[Clang] Reduce the size of Decl and classes derived from it (#87361)
philnik777 Apr 14, 2024
a20a5e6
[clang][NFC] Factor out VLA checks in type traits (#88646)
Endilll Apr 14, 2024
a09c2df
Revert "[Clang] Reduce the size of Decl and classes derived from it" …
philnik777 Apr 14, 2024
5877972
[Clang] [C++26] Implement P2573R2: `= delete("should have a reason");…
Sirraide Apr 14, 2024
4c540c2
[mlir][complex] Fastmath flag support for complex.tanh (#88571)
Lewuathe Apr 14, 2024
f076e83
[AArch64] Improve cost of non-zero lane splats
davemgreen Apr 14, 2024
3422325
[libc++] Deprecated `shared_ptr` Atomic Access APIs as per P0718R2 & …
H-G-Hristov Apr 14, 2024
2f9cb64
[clang] Fix -Wunused-variable in SemaCast.cpp (NFC)
DamonFool Apr 14, 2024
5b8a36c
[mlir] Add lib to tests for shared build (#88574)
jpienaar Apr 14, 2024
972bd05
[clang] Fix name conflict with `sys/mac.h` on AIX (#88644)
Endilll Apr 14, 2024
1b41cb9
[libc++][RFC] Only include what is required by-version in the umbrell…
philnik777 Apr 14, 2024
38cbb82
CompilerRT: Normalize COMPILER_RT_DEFAULT_TARGET_TRIPLE (#88407)
wzssyqa Apr 14, 2024
a48ff71
Revert "CompilerRT: Normalize COMPILER_RT_DEFAULT_TARGET_TRIPLE" (#88…
wzssyqa Apr 14, 2024
40c56b5
[TextAPI] Apply NFC code fixups (#88639)
cyndyishida Apr 14, 2024
f9cab3a
[Docs] Update python dependencies for documentation (#87877)
marcauberer Apr 14, 2024
0e1d186
[mlir][python] add to CODEOWNERS (#88561)
makslevental Apr 14, 2024
072ef0a
Include cmath to fix build error on mac os 10.14 (#88665)
Zentrik Apr 14, 2024
ca7908c
[Driver,test] Make Android runtime tests resisent to #87866 change
MaskRay Apr 15, 2024
c84dd32
[Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin
MaskRay Apr 15, 2024
c49aefb
[ADT] In FoldingSet calulation for APInt add bit width to avoid crash…
andjo403 Apr 15, 2024
22e206e
[LoongArch] Return true from shouldConsiderGEPOffsetSplit (#88371)
wangleiat Apr 15, 2024
76afa33
[CodeGen] Let `CodeGenPassBuilder` know concrete target machine (#88614)
paperchalice Apr 15, 2024
bf555e2
[NFC] add myself as the code owner of the PowerPC target
Apr 15, 2024
9a67cde
[InstCombine] Relax shamt assertion in fsh fold
nikic Apr 15, 2024
5f8e8c0
[MLIR][LLVM] Fix recursive DI type export memory leak (#88122)
zyx-billy Apr 15, 2024
bb09408
[SimplifyCFG] Fix crash when there is unreachable large index (#88616)
vfdff Apr 15, 2024
6a38688
[ValueTracking] Add tests for `computeKnownBits` of `llvm.vector.redu…
goldsteinn Apr 10, 2024
8d1a827
[ValueTracking] Implement `computeKnownBits` for `llvm.vector.reduce.…
goldsteinn Apr 10, 2024
74ce58a
[ValueTracking] Add tests for `computeKnownBits` of `llvm.vector.redu…
goldsteinn Apr 10, 2024
f5fea48
[ValueTracking] Implement `computeKnownBits` for `llvm.vector.reduce.…
goldsteinn Apr 10, 2024
30ac0f0
[ValueTracking] Add tests for `isKnownNonZero` of `llvm.vector.reduce…
goldsteinn Apr 11, 2024
233ba77
[ValueTracking] Implement `isKnownNonZero` for `llvm.vector.reduce.or`
goldsteinn Apr 11, 2024
dcb1041
[C++20] [Modules] Introduce -fexperimental-modules-reduced-bmi (#85050)
ChuanqiXu9 Apr 15, 2024
510af4a
[InstCombine] Add test for isKnownNonZero() undef miscompile (NFC)
nikic Apr 15, 2024
18756b8
[ValueTracking] Don't accept undef in isKnownNonZero()
nikic Apr 15, 2024
3d08b60
[SDAG] Apply or-disjoint in SelectionDAG::isBaseWithConstantOffset (#…
fengfeng09 Apr 15, 2024
bf56f13
[mi-sched] Suppress register pressure with i64. (#88256)
lcvon007 Apr 15, 2024
0687f96
[clang][bazel] Fix BUILD after f811d7b50957b801788d7b171ddeb25b1fda415a.
chsigg Apr 15, 2024
359282e
Revert "Reapply "[Clang][Sema] Fix crash when 'this' is used in a dep…
metaflow Apr 15, 2024
2735554
[ARM] Don't include IRBuilder.h in ARMISelLowering.h (NFC)
nikic Apr 15, 2024
c500c2f
[VectorCombine] Add some tests for converting shuffles to identities.…
davemgreen Apr 15, 2024
a5bca19
[llvm-objcopy] Add --compress-sections
MaskRay Apr 15, 2024
063d0ef
[BOLT] Use offset deduplication for cold fragments
aaupov Apr 15, 2024
42e0de5
[SPIR-V] Update type inference and instruction selection (#88254)
VyacheslavLevytskyy Apr 15, 2024
2b7ae10
[LoongArch] Pre-commit test for #88694. NFC
wangleiat Apr 15, 2024
a2ee055
llvm-readobj/ARM: activate big-endian attribute printing (#87806)
artagnon Apr 15, 2024
715835b
[InstCombine] Simplify switch with selects (#84143)
dtcxzyw Apr 15, 2024
2c951eb
[AArch64][GlobalISel] Extend scalar lrint legalization. (#88360)
davemgreen Apr 15, 2024
84ba679
[SelectionDAG] Propagate Disjoint flag. (#88370)
fengfeng09 Apr 15, 2024
a819f53
[GlobalISel] Fix fewerElementsVectorPhi to insert after G_PHIs (#87927)
dfszabo Apr 15, 2024
6ade675
Revert "[C++20] [Modules] Don't import non-inline function bodies eve…
ChuanqiXu9 Apr 15, 2024
0e87303
[flang] Rename AddDebugFoundation to AddDebugInfo (NFC) (#88526)
abidh Apr 15, 2024
ec23e71
Fix rsqrt inaccuracies. (#88691)
jreiffers Apr 15, 2024
072bda6
[MLIR][OpenMP] Introduce the LoopWrapperInterface (#87232)
skatrak Apr 15, 2024
e92fc5b
Support for i8/i16 for bitreverse using GFNI. (#88625)
shamithoke Apr 15, 2024
428f6c2
Revert "Fix rsqrt inaccuracies." (#88705)
jreiffers Apr 15, 2024
30a0991
[ARM][Thumb2] Mark BTI-clearing instructions as scheduling region bou…
vhscampos Apr 15, 2024
dab94d6
[LoongArch] Fix incorrect logic in isLegalAddressingMode() (#88694)
wangleiat Apr 15, 2024
4288c56
Fix rsqrt inaccuracies. (#88707)
jreiffers Apr 15, 2024
f681b15
[mlir][ODS] Make `prop-dict` behave closer to `attr-dict` (#88659)
zero9178 Apr 15, 2024
1b826af
Reapply "[TBAA] Add verifier for tbaa.struct metadata (#86709)"
juliannagele Apr 15, 2024
8ce2801
[VPlan] Add test for dump of recipe not inserted in VPlan. (NFC)
fhahn Apr 15, 2024
698be8c
[X86] Add isCompletePermute helper for single input shuffles where we…
RKSimon Apr 15, 2024
bf26558
[VPlan] Extend recipe printing tests with underlying IR values. (NFC)
fhahn Apr 15, 2024
e2d7bef
ValueTracking: Treat poison more aggressively in computeKnownFPClass …
arsenm Apr 15, 2024
c2fd266
Fix typo in computeKnownBits_AVGFLOORU_AVGFLOORS_AVGCEILU_AVGCEILS.
RKSimon Apr 15, 2024
7683310
[X86] Remove unused function (NFC)
DamonFool Apr 15, 2024
1fd71ea
Fix complex tanh overflows. (#88708)
jreiffers Apr 15, 2024
2dce277
[LLVM][SVE][CodeGen] Fix incorrect isel for signed saturating instruc…
paulwalker-arm Apr 15, 2024
9b584e1
[VPlan] Version VPValue names in VPSlotTracker. (#81411)
fhahn Apr 15, 2024
5de4259
[clang analysis] ExprMutationAnalyzer avoid infinite recursion for re…
HerrCai0907 Apr 15, 2024
7595b63
[LLVM][CodeGen][AArch64] Remove bogus lowering of sve_while{gt/ge/hi/…
paulwalker-arm Apr 15, 2024
c555ebc
[DebugInfo][RemoveDIs] Fix error from not tracking seen debug labels …
SLTozer Apr 15, 2024
62eff79
[X86] Remove scaleVectorShuffleBlendMask and use APIntOps::ScaleBitMa…
RKSimon Apr 15, 2024
e443593
[LLVM][SelectionDAG] Allow verification of target ISD nodes. (#88121)
paulwalker-arm Apr 15, 2024
b5c10a7
[RISCV] Split single width convert to FP pseudos by SEW
michaelmaitland Apr 12, 2024
90732b0
[RISCV] Split Widening convert to FP pseudos by SEW
michaelmaitland Apr 12, 2024
b4eba7a
[RISCV] Split narrowing convert to FP pseudos by SEW
michaelmaitland Apr 12, 2024
a722bdc
[RISCV] Split PseudoVFMIN, PseudoVFMAX PseudoVFSGNJ, PseudoVFSGNJN, a…
michaelmaitland Apr 10, 2024
1aa73c7
[Flang][OpenMP] Accept the reduction modifier (#86492)
kiranchandramohan Apr 15, 2024
7f657fd
[BOLT][NFC] Refactor relocation printing (#88180)
urnathan Apr 15, 2024
6de1689
[HLSL][SPIRV] Add any intrinsic lowering (#88325)
farzonl Apr 15, 2024
83738f9
[NFC][LLVM][CodeGen] Move LiveDebugVariables.h into llvm/include/llvm…
BeMg Apr 15, 2024
dd59294
[AArch64][SME] Create new pass to remove COALESCER_BARRIER early. (#8…
sdesmalen-arm Apr 15, 2024
68028dd
[BOLT][NFC] Remove unused BinaryData::hasNameRegex (#88618)
aaupov Apr 15, 2024
896c7b3
[libc++][PSTL] Introduce cpu traits (#88134)
ldionne Apr 15, 2024
3fd2199
[SystemZ] Bugfix in getDemandedSrcElements(). (#88623)
JonPsson1 Apr 15, 2024
f062048
[clang-tidy][NFC] Fix `linuxkernel-must-check-errs` documentation fil…
whisperity Apr 15, 2024
8c6231b
[libc++] Add a utility to check whether a range is valid (#87665)
ldionne Apr 15, 2024
e52ab44
[clang][dataflow] Update comments and names for referenced decls.
bazuzi Apr 15, 2024
4c95b3d
[clang][dataflow] Move free functions out of DAContext.
bazuzi Apr 15, 2024
708f854
Merge branch 'llvm:main' into fields
bazuzi Apr 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions clang/include/clang/Analysis/FlowSensitive/ASTOps.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
//===-- ASTOps.h -------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// Operations on AST nodes that are used in flow-sensitive analysis.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_ASTOPS_H
#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_ASTOPS_H

#include "clang/AST/Decl.h"
#include "clang/AST/Expr.h"
#include "clang/AST/Type.h"
#include "clang/Analysis/FlowSensitive/StorageLocation.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SetVector.h"

namespace clang {
namespace dataflow {
/// Skip past nodes that the CFG does not emit. These nodes are invisible to
/// flow-sensitive analysis, and should be ignored as they will effectively not
/// exist.
///
/// * `ParenExpr` - The CFG takes the operator precedence into account, but
/// otherwise omits the node afterwards.
///
/// * `ExprWithCleanups` - The CFG will generate the appropriate calls to
/// destructors and then omit the node.
///
const Expr &ignoreCFGOmittedNodes(const Expr &E);
const Stmt &ignoreCFGOmittedNodes(const Stmt &S);

/// A set of `FieldDecl *`. Use `SmallSetVector` to guarantee deterministic
/// iteration order.
using FieldSet = llvm::SmallSetVector<const FieldDecl *, 4>;

/// Returns the set of all fields in the type.
FieldSet getObjectFields(QualType Type);

/// Returns whether `Fields` and `FieldLocs` contain the same fields.
bool containsSameFields(const FieldSet &Fields,
const RecordStorageLocation::FieldToLoc &FieldLocs);

/// Returns the fields of a `RecordDecl` that are initialized by an
/// `InitListExpr`, in the order in which they appear in
/// `InitListExpr::inits()`.
/// `Init->getType()` must be a record type.
std::vector<const FieldDecl *>
getFieldsForInitListExpr(const InitListExpr *InitList);

// A collection of several types of declarations, all referenced from the same
// function.
struct ReferencedDecls {
// Fields includes non-static data members.
FieldSet Fields;
// Globals includes all variables with global storage, notably including
// static data members and static variables declared within a function.
llvm::DenseSet<const VarDecl *> Globals;
// Functions includes free functions and member functions which are
// referenced, but not necessarily called.
llvm::DenseSet<const FunctionDecl *> Functions;
};

/// Collects and returns fields, global variables and functions that are
/// declared in or referenced from `FD`.
ReferencedDecls getReferencedDecls(const FunctionDecl &FD);
} // namespace dataflow
} // namespace clang

#endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_ASTOPS_H
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "clang/AST/Decl.h"
#include "clang/AST/Expr.h"
#include "clang/AST/TypeOrdering.h"
#include "clang/Analysis/FlowSensitive/ASTOps.h"
#include "clang/Analysis/FlowSensitive/AdornedCFG.h"
#include "clang/Analysis/FlowSensitive/Arena.h"
#include "clang/Analysis/FlowSensitive/Solver.h"
Expand All @@ -30,38 +31,11 @@
#include <cassert>
#include <memory>
#include <optional>
#include <type_traits>
#include <utility>
#include <vector>

namespace clang {
namespace dataflow {
class Logger;

/// Skip past nodes that the CFG does not emit. These nodes are invisible to
/// flow-sensitive analysis, and should be ignored as they will effectively not
/// exist.
///
/// * `ParenExpr` - The CFG takes the operator precedence into account, but
/// otherwise omits the node afterwards.
///
/// * `ExprWithCleanups` - The CFG will generate the appropriate calls to
/// destructors and then omit the node.
///
const Expr &ignoreCFGOmittedNodes(const Expr &E);
const Stmt &ignoreCFGOmittedNodes(const Stmt &S);

/// A set of `FieldDecl *`. Use `SmallSetVector` to guarantee deterministic
/// iteration order.
using FieldSet = llvm::SmallSetVector<const FieldDecl *, 4>;

/// Returns the set of all fields in the type.
FieldSet getObjectFields(QualType Type);

/// Returns whether `Fields` and `FieldLocs` contain the same fields.
bool containsSameFields(const FieldSet &Fields,
const RecordStorageLocation::FieldToLoc &FieldLocs);

struct ContextSensitiveOptions {
/// The maximum depth to analyze. A value of zero is equivalent to disabling
/// context-sensitive analysis entirely.
Expand Down
36 changes: 0 additions & 36 deletions clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -775,42 +775,6 @@ RecordStorageLocation *getImplicitObjectLocation(const CXXMemberCallExpr &MCE,
RecordStorageLocation *getBaseObjectLocation(const MemberExpr &ME,
const Environment &Env);

/// Returns the fields of a `RecordDecl` that are initialized by an
/// `InitListExpr`, in the order in which they appear in
/// `InitListExpr::inits()`.
/// `Init->getType()` must be a record type.
std::vector<const FieldDecl *>
getFieldsForInitListExpr(const InitListExpr *InitList);

/// Helper class for initialization of a record with an `InitListExpr`.
/// `InitListExpr::inits()` contains the initializers for both the base classes
/// and the fields of the record; this helper class separates these out into two
/// different lists. In addition, it deals with special cases associated with
/// unions.
class RecordInitListHelper {
public:
// `InitList` must have record type.
RecordInitListHelper(const InitListExpr *InitList);

// Base classes with their associated initializer expressions.
ArrayRef<std::pair<const CXXBaseSpecifier *, Expr *>> base_inits() const {
return BaseInits;
}

// Fields with their associated initializer expressions.
ArrayRef<std::pair<const FieldDecl *, Expr *>> field_inits() const {
return FieldInits;
}

private:
SmallVector<std::pair<const CXXBaseSpecifier *, Expr *>> BaseInits;
SmallVector<std::pair<const FieldDecl *, Expr *>> FieldInits;

// We potentially synthesize an `ImplicitValueInitExpr` for unions. It's a
// member variable because we store a pointer to it in `FieldInits`.
std::optional<ImplicitValueInitExpr> ImplicitValueInitForUnion;
};

/// Associates a new `RecordValue` with `Loc` and returns the new value.
RecordValue &refreshRecordValue(RecordStorageLocation &Loc, Environment &Env);

Expand Down
29 changes: 29 additions & 0 deletions clang/include/clang/Analysis/FlowSensitive/RecordOps.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,35 @@ inline bool recordsEqual(const RecordStorageLocation &Loc1,
return recordsEqual(Loc1, Env, Loc2, Env);
}

/// Helper class for initialization of a record with an `InitListExpr`.
/// `InitListExpr::inits()` contains the initializers for both the base classes
/// and the fields of the record; this helper class separates these out into two
/// different lists. In addition, it deals with special cases associated with
/// unions.
class RecordInitListHelper {
public:
// `InitList` must have record type.
RecordInitListHelper(const InitListExpr *InitList);

// Base classes with their associated initializer expressions.
ArrayRef<std::pair<const CXXBaseSpecifier *, Expr *>> base_inits() const {
return BaseInits;
}

// Fields with their associated initializer expressions.
ArrayRef<std::pair<const FieldDecl *, Expr *>> field_inits() const {
return FieldInits;
}

private:
SmallVector<std::pair<const CXXBaseSpecifier *, Expr *>> BaseInits;
SmallVector<std::pair<const FieldDecl *, Expr *>> FieldInits;

// We potentially synthesize an `ImplicitValueInitExpr` for unions. It's a
// member variable because we store a pointer to it in `FieldInits`.
std::optional<ImplicitValueInitExpr> ImplicitValueInitForUnion;
};

} // namespace dataflow
} // namespace clang

Expand Down
Loading