Skip to content

[MLIR][LLVM] Add debug output to the LLVM inliner. #12

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

Open
wants to merge 208 commits into
base: move-llvm-inliner
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
208 commits
Select commit Hold shift + click to select a range
883dbb9
Revert "[MemProf] Context disambiguation cloning pass [patch 1a/3]"
nikic Mar 22, 2023
553bff0
[gn build] Port 883dbb9c86be
llvmgnsyncbot Mar 22, 2023
65a0d66
Fix accessing of aligned arrays in offloaded target regions
doru1004 Feb 22, 2023
299f3ac
Regenerate checks for bswap.ll, NFC
junaire Mar 22, 2023
ada0356
[X86] Extend all_of(icmp_eq()) / any_of(icmp_ne()) -> scalar integer …
RKSimon Mar 22, 2023
71dc3de
[ARM] Improve min/max vector reductions on Arm
calebzulawski Mar 22, 2023
06f1623
[RISCV][NFC] Make interleaved access test more vectorizable
lukel97 Mar 20, 2023
6589046
[AArch64] Add asm aliases for MOV, LDR, STR with predicate-as-counter
CarolineConcatto Mar 22, 2023
0528087
[NFC][WebAssembly] Autogenerate test expectations for tailcall.ll
tlively Mar 22, 2023
3f23c7f
[InstSimplify] Actually use NewOps for calls in simplifyInstructionWi…
aeubanks Mar 22, 2023
d868135
[libc++] Qualifies ptrdiff_t and max_align_t.
mordante Mar 21, 2023
dd0bbae
[WebAssembly] Fix epilogue insertion for indirect tail calls
tlively Mar 22, 2023
8eb464f
[DebugInfo] Allow parsing line tables aligned to 4 or 8-byte boundaries
MacDue Mar 22, 2023
83e420c
[Constant] Inline ConstantInt::getSigned
topperc Mar 22, 2023
9e3ca79
[mlir][tosa] Canonicalize concatenate->slice sequence
lhutton1 Mar 22, 2023
164b046
[RISCV] Convert segment registers to VR registers in RISCVMCInstLower.
topperc Mar 22, 2023
a67e989
[RISCV] Add FallbackRegAltNameIndex to ABIRegAltName.
topperc Mar 22, 2023
700cd99
Restore "[MemProf] Context disambiguation cloning pass [patch 1a/3]"
teresajohnson Mar 22, 2023
96449fa
[gn build] Port 700cd99061ed
llvmgnsyncbot Mar 22, 2023
77044a4
[CMake] Build runtimes for riscv64-unknown-fuchsia
petrhosek Mar 22, 2023
84de019
[RISCV] Remove AnyReg RegisterClass used by .insn instructions. Use c…
topperc Mar 22, 2023
c4125a3
Revert "Remove the LINK_COMPONENTS entry from lldb-instr CMakery"
aheejin Mar 2, 2023
24e3102
[TSan] Avoid deadlock between ReportRace() and dlopen() interceptor
Mar 21, 2023
16b7cf2
SymbolFile: ensure that we have a value before invoking `getBitWidth`
compnerd Mar 21, 2023
ead9644
[clang-format] Annotate noexcept, explicit specifiers as containing e…
rymiel Mar 22, 2023
984354f
[lldb] Update some uses of Python2 API in typemaps.
slackito Mar 21, 2023
38d69df
[Driver][test] Fix avr-ld.c for -DCLANG_DEFAULT_LINKER=lld after D145646
MaskRay Mar 22, 2023
eac8e25
[CodeGen] Fix type of MachineRegisterInfo::RegAllocHints. NFC.
jayfoad Mar 22, 2023
7e5c48b
[clang-tidy][NFC] Move avoid-underscore-in-googletest-name to google …
carlosgalvezp Mar 22, 2023
6afcc54
[SCEV] Infer no-self-wrap via constant ranges
preames Mar 22, 2023
e655d8a
[libc++] Granularize __mutex_base
philnik777 Mar 9, 2023
0766c1b
[LFTR] Simplify integer case for genLoopLimit [nfc-ish]
preames Mar 22, 2023
0862231
Precommit tests for D146327
jrbyrnes Mar 22, 2023
587b371
[gn build] Port e655d8a54880
llvmgnsyncbot Mar 22, 2023
cf8dc9d
[JITLink] Introduce target flags for Symbol and prepare ObjectLinking…
weliveindetail Mar 22, 2023
77ed831
[test] Add tools/llvm-dwarfdump/ARM/lit.local.cfg after D143513
MaskRay Mar 22, 2023
3d334df
[libc++] Remove availability markup for std::format
ldionne Mar 16, 2023
0433abc
[docs][scudo] Add information about M_PURGE_ALL.
cferris1000 Mar 17, 2023
22293a3
Revert "[flang] Feature list plugin" due to failing build
EthanLuisMcDonough Mar 22, 2023
473e9ad
[MSAN] Update vector load/store tests to use proper attribute
preames Mar 22, 2023
e731867
[JITLink] Deterministic JITDylib symbol table dumps
weliveindetail Mar 22, 2023
d59a43f
[libc++] Qualifies intptr_t and uintptr_t.
mordante Mar 22, 2023
71a5958
[libc++] Remove __mutex_base header
philnik777 Mar 22, 2023
4d18d97
[lldb] Fix dwim-print error message for missing expr
kastiglione Mar 9, 2023
fb8d894
[scudo] Early exit from the case can't do page release.
ChiaHungDuan Mar 22, 2023
fe27495
[MemProf] Context disambiguation cloning pass [patch 1b/3]
teresajohnson Dec 29, 2022
201fdef
libclang: Pass Clang install directory to driver via argv[0].
pcc Mar 21, 2023
e7596a9
[-Wunsafe-buffer-usage] Add Fixable for simple pointer dereference
Mar 22, 2023
909e5ce
[mlir][arith] Add `uitofp` support to WIE
kuhar Mar 22, 2023
abfc358
[mlir][arith] Add `sitofp` support to WIE
kuhar Mar 22, 2023
c81f14e
[mlir][arith] Fix typos in WIE. NFC.
kuhar Mar 22, 2023
0c0387c
[NVPTX] Port GenericToNVVM to the new PM.
PavelKopyl Mar 16, 2023
fd47ab0
Add "REQUIRES: asserts" to test that uses --debug-only flag
amykhuang Mar 22, 2023
d859275
[mlir] Fix typo for unknown operation
Lewuathe Mar 23, 2023
9855fe4
[RISCV][NFC] Add more tests for SLP vectorization (binops on load/store)
benshi001 Mar 14, 2023
ae63b1a
[libc] Adjust NVPTX startup code
jhuber6 Mar 23, 2023
3d7383d
[mlir][affine] Prevent vectorizer test from crash without any map
Lewuathe Mar 23, 2023
89a1af7
[mlir][tosa] TosaToLinalg: Lower TOSA.Cast via RoundEven according to…
mgehre-amd Mar 23, 2023
25557aa
Recommit [Modules] Remove unnecessary check when generating name look…
ChuanqiXu9 Mar 23, 2023
45a0433
[-Wunsafe-buffer-usage] Add [[fallthrough]] after D143206
MaskRay Mar 23, 2023
1c420cd
Precommit test for #61120
junaire Mar 23, 2023
b3e12be
[TLI] Fold ~X >/< ~Y --> Y >/< X
junaire Mar 23, 2023
8d93cbe
[InstCombine] Precommit tests
kazutakahirata Mar 23, 2023
0d19e58
[InstCombine] Precommit a test
kazutakahirata Mar 23, 2023
4524db7
[ARM] Use isNullConstant (NFC)
kazutakahirata Mar 23, 2023
7bb6d1b
[llvm] Skip getAPIntValue (NFC)
kazutakahirata Mar 23, 2023
fd29a4d
[Pseudo Probe] Use the name from debug info to compute GUID in probe …
wlei-llvm Mar 22, 2023
c2df1d8
[libfuzzer] add test of cov file-id in control file
yingcong-wu Mar 23, 2023
021edda
[TableGen] Simplify CodeGenHwModes constructor. NFC
topperc Mar 23, 2023
b325604
[TableGen] Change push_back back to emplace_back.
topperc Mar 23, 2023
f9f4767
[InstCombine] Precommit tests
kazutakahirata Mar 23, 2023
a35f9c6
[mlir][llvm] Add poison constant.
Mar 23, 2023
c5d22f4
[clang][Sema][NFC] Make local variable const
tbaederr Mar 23, 2023
79df1a7
[mlir][llvm] Switch rountrip tests to opaque pointers.
gysit Mar 23, 2023
467cf15
[NFC] Fix typo lld::wasm in comment
HerrCai0907 Mar 23, 2023
5acd29e
[clang][dataflow] Fix crash when RHS of `&&` or `||` calls `noreturn`…
martinboehme Mar 23, 2023
b08d35f
[clang-tidy] Ignore DISABLED_ in test suite name in google-avoid-unde…
carlosgalvezp Mar 22, 2023
5b0055a
[mlir][Analysis][NFC] Split FlatAffineValueConstraints into multiple …
matthias-springer Mar 23, 2023
e50f131
[MLIR][Affine] Fix bug and MSAN issue in affine loop utils
bondhugula Mar 23, 2023
47bff1c
[mlir][Analysis][NFC] Make BoundType a top-level enum
matthias-springer Mar 23, 2023
0691bcb
[clang][Interp][NFC] Add tests for __fp16
tbaederr Mar 20, 2023
49dcd08
[XCOFF] support the ref directive for object generation.
EsmeYi Mar 23, 2023
8c10256
clang-tidy: Detect use-after-move in CXXCtorInitializer
Mar 14, 2023
814177e
Revert "[clang][Interp][NFC] Add tests for __fp16"
tbaederr Mar 23, 2023
25466ef
[gn] Port e655d8a54880 more
nico Mar 23, 2023
61b0a49
[llvm][ARM] Refactor isMnemonicVPTPredicable
DavidSpickett Mar 22, 2023
4f17d75
[X86] LowerVectorAllZero - early out if the type size is not pow2. NFC.
RKSimon Mar 23, 2023
7a5b957
[clang-format] NFC Format.h and ClangFormatStyleOptions.rst are out o…
mydeveloperday Mar 23, 2023
7c92820
Revert "[clang-format] NFC Format.h and ClangFormatStyleOptions.rst a…
mydeveloperday Mar 23, 2023
26d954b
[AsmParser] Avoid instantiating LLVMContext if not needed. Try 2.
Mar 23, 2023
d257517
Bump RV32E version to 2.0
mtvec Mar 23, 2023
c2de8ff
[JITLink] Initial AArch32 backend
weliveindetail Mar 23, 2023
b767784
[clang-tidy][NFC] Fix broken link in Release Notes
carlosgalvezp Mar 23, 2023
61f33de
[mlir][Vector] Make sure that vector.contract preserves extra attribu…
apaszke Mar 23, 2023
8d16c68
[RISCV] Increase default vectorizer LMUL to 2
lukel97 Feb 10, 2023
48f97e5
[FlowSensitive] Log analysis progress for debugging purposes
sam-mccall Feb 24, 2023
002c4b7
[clangd] Extend CollectMainFileMacros.
hokein Mar 17, 2023
4dc72d4
[mlir][Tensor] Add a FoldTensorSubsetOps pass and patterns
nicolasvasilache Mar 21, 2023
da44224
[RISCV][test] Fix broken unit test after d25751779ba
asb Mar 23, 2023
80db8b0
[gn build] Port 48f97e575137
llvmgnsyncbot Mar 23, 2023
20725d3
[gn build] Port c2de8ff92753
llvmgnsyncbot Mar 23, 2023
f44c7de
[Local] Use most generic range if K does not dominate J or K doesn't …
Mar 23, 2023
67d828f
[Object][NFC] Factor out computeHeadersSize.
cjacek Mar 23, 2023
257dc54
[Object][NFC] Don't insert string table into object members vector.
cjacek Mar 23, 2023
4fcbf38
[llvm-lib] Use COFF archive format in llvm-lib (other archive tools d…
cjacek Mar 23, 2023
a598803
[lld] Fill .text section gaps with INT3 only on x86 targets.
cjacek Mar 23, 2023
0cbfd68
[mlir] Fix call of overloaded ‘dropResults(<brace-enclosed initialize…
qcolombet Mar 23, 2023
c2c9de4
[gn] port a282ea4898efe
nico Mar 23, 2023
18d5688
Revert "libclang: Pass Clang install directory to driver via argv[0]."
AaronBallman Mar 23, 2023
43fcfdb
[IncludeCleaner][clangd] Mark umbrella headers as users of private
kadircet Mar 20, 2023
6aa7cc0
[X86] LowerVectorAllZero - add 512-bit support with AVX512 vptestnmd+…
RKSimon Mar 23, 2023
c39dd7c
[RISCV][MC] Add support for RV64E
mtvec Mar 23, 2023
3d65cd4
[llvm-objdump] Fix help message for --print-imm-hex
kongy Mar 23, 2023
7fef15e
Revert rG6aa7cc037f2f95c237c1d82c523f8857fa3a10c3 - "[X86] LowerVecto…
RKSimon Mar 23, 2023
c6e9823
[C++20][Modules] Introduce an implementation module.
iains Jun 3, 2022
e54cdd0
[RISCV][clang][test] Fix missed test
mtvec Mar 23, 2023
d0e2a42
[RISCV][test] Fix another missed test change from RV64E patch
mtvec Mar 23, 2023
4738c5f
[X86] LowerVectorAllZero - early out for masked v2i64 cases without P…
RKSimon Mar 23, 2023
3f2dbcc
[Bazel] Rework `//llvm:llvm-tblgen` and `//llvm/unittests:tablegen_te…
chapuni Mar 22, 2023
a7c574d
[MLIR][LLVM] Move the LLVM inliner interface into a separate file.
definelicht Mar 23, 2023
8482b23
[ADT] add ConcurrentHashtable class.
avl-llvm Mar 22, 2023
320969f
[X86] LowerVectorAllZero - add 512-bit support with AVX512 vptestnmd+…
RKSimon Mar 23, 2023
8c7c1f1
Silence unused variable warning in NDEBUG builds
d0k Mar 23, 2023
fd4aeba
Revert "[ADT] add ConcurrentHashtable class."
avl-llvm Mar 23, 2023
4f9929a
[AIX][CodeGen] Storage Locations for Constant Pointers
Mar 23, 2023
5193c4a
[lldb][AArch64] Fix run-qemu.sh when only MTE is enabled.
DavidSpickett Mar 23, 2023
3ab7912
[OpenMP] Add notifyDataUnmapped back in disassociatePtr
ye-luo Mar 23, 2023
0eabf59
Enable constexpr class members that are device-mapped to not be optim…
doru1004 Mar 21, 2023
c7a3284
[AggressiveInstCombine] Pre-Commit test for D144445 (NFC)
khei4 Mar 9, 2023
434b0ba
[AggressiveInstCombine] folding load for constant global patterened a…
khei4 Mar 9, 2023
5bcb4c4
[MSAN] Support load and stores of scalable vector types
preames Mar 23, 2023
82c83d7
[Clang] Fix evaluation of parameters of lambda call operator attributes
cor3ntin Mar 21, 2023
6194446
[AArch64] Add Missing Custom Target Operands
lenary Mar 22, 2023
f570bd8
[HWASAN] Disable unexpected_format_specifier_test because HWASAN does…
kstoimenov Mar 22, 2023
5eb9acf
[HWASAN] Instrument scalable load/store without crashing
preames Mar 23, 2023
fd1850b
Test commit to see if write access works
mtvec Mar 23, 2023
85faee6
[OpenMP][OMPIRBuilder] Make OffloadEntriesInfoManager a member of Ope…
jsjodin Mar 21, 2023
c640a14
[lldb] Explicitly set libcxx paths when USE_SYSTEM_STDLIB is provided
felipepiovezan Mar 23, 2023
2cfd06b
[BoundsChecking] Don't crash on scalable vector sizes
preames Mar 23, 2023
16b6826
[MergeFuncs] Add tests for D144682 (NFC)
dingxiangfei2009 Mar 23, 2023
ec294d2
[X86] LowerVectorAllZero - lower to CMP(MOVMSK(NOT(X)),0) instead of …
RKSimon Mar 23, 2023
dc2f2d2
[MemProf] Use stable_sort to avoid non-determinism
teresajohnson Mar 23, 2023
2bececb
[clangd] Add provider info on symbol hover.
VitaNuo Feb 28, 2023
9c8bdbc
[libc] Implement memory fences on NVPTX
jhuber6 Mar 23, 2023
5525087
[NFC][AArch64] Sort Hints in armv8.3a-signed-pointer.s test
lenary Mar 23, 2023
e33f8ac
[libc] Fix inline assembly for nvptx quick_exit
jhuber6 Mar 23, 2023
2f5fdbf
[MergeFunc] Don't assume constant metadata operands
nikic Mar 23, 2023
4c5dee7
[flang] Lowering fir.dispatch in the polymorphic op pass
Renaud-K Mar 21, 2023
7739be7
[ArgPromotion] Remove dead code produced by removing dead arguments
jrbyrnes Mar 15, 2023
de939c6
[libc] enable printf using system FILE
michaelrj-google Mar 13, 2023
7d11a59
[libc] Fix some math conversion warnings
abrachet Mar 23, 2023
5f883cd
[docs] Document -fomit-frame-pointer
MaskRay Mar 23, 2023
40e5d21
[clangd] Fix indentation in HoverTests.cpp
VitaNuo Mar 23, 2023
40aaa27
[libc++][ranges] P2711R1 Making multi-param constructors of views exp…
Zingam Mar 22, 2023
101cfe1
[libcxx] Fix build bustage with threads disabled
glandium Mar 23, 2023
6a2a5f0
[CodeGenPrepare] Don't give up if unable to sink first arg to a cold …
momchil-velikov Mar 23, 2023
c70e360
[clang-format] Allow trailing return types in macros
rymiel Mar 23, 2023
8088f5b
[support] Fix PrintNumber Test on AIX
ilovepi Mar 23, 2023
cc8a34b
[X86] Refactor movmsk(icmp_eq(and(x,c1),0)) -> movmsk(not(shl(x,c2)))…
RKSimon Mar 23, 2023
5c9a262
[CodeGenPrepare][NFC] Pre-commit test for memory use count fix
momchil-velikov Mar 23, 2023
73bec2b
[mlir][Vector] Retire one old filter-based test
nicolasvasilache Mar 23, 2023
637048f
[TSan][Darwin] Test fix external-swift-debugging.cpp
Mar 23, 2023
2bc4c3e
[mlir][Vector] NFC - Reorganize vector patterns
nicolasvasilache Mar 23, 2023
a86cc83
[libc] Move fma and fmaf into generic dir
abrachet Mar 23, 2023
30e8916
[X86] combineVectorSizedSetCCEquality - update arguments to use indiv…
RKSimon Mar 23, 2023
e036139
[scudo] Add a Timer class to assist performance measurement
ChiaHungDuan Mar 23, 2023
d10110a
[StackProtector] attribute __stack_chk_fail as NoReturn
nickdesaulniers Mar 23, 2023
0c5cee7
[lldb-server] Use Platform plugin corresponding to the host
bulbazord Mar 22, 2023
4b398ec
[HWASAN] Fix decorate_proc_maps to work with HWASAN
kstoimenov Mar 23, 2023
1d30afd
[PATCH] Enable targeting riscv64-linux-android
colincross Mar 23, 2023
156d966
Remove mips target triple for Android
hiraditya Mar 21, 2023
f23dcb2
Revert "[JITLink] Initial AArch32 backend"
gulfemsavrun Mar 23, 2023
d557384
[LLDB] Fix for D139955 Summary:
ayermolo Mar 23, 2023
088da8a
[lldb][NFC] makeArrayRef -> ArrayRef
aeubanks Mar 23, 2023
805f51f
Remove Android-mips related tests
hiraditya Mar 23, 2023
1c91733
Fix highlighting issue with _complex and initialization list with mor…
chaitanyav Mar 23, 2023
3111784
[lld][WebAssembly] Initial support for stub libraries
sbc100 Dec 7, 2022
af54d1e
[NVPTX] Set the atomic inling threshold when targeting NVPTX directly
jhuber6 Mar 23, 2023
d11e49f
[libc][NFC] Fix misspelled variable name in cmake message
jhuber6 Mar 23, 2023
9ddc03a
[OpenMP] Fix test after updating NVPTX atomic inlines
jhuber6 Mar 23, 2023
53a9175
[llvm] Handle duplicate call bases when applying branch funneling
PiJoules Mar 23, 2023
2e9bcad
Revert "[scudo] Add a Timer class to assist performance measurement"
ChiaHungDuan Mar 23, 2023
ec2333d
[JITLink] Add a jitlink::Section::empty operation.
lhames Mar 23, 2023
3974865
[llvm][TextAPI] Handle implicitly upgraded deployment versions
cyndyishida Mar 23, 2023
c13ccf1
[clang][ExtractAPI]Fix Declaration fragments for instancetype in the …
chaitanyav Mar 23, 2023
999643f
[WebAssembly] Tidy up DebugValueManager (NFC)
aheejin Mar 23, 2023
bb0ecb7
[Driver][test] Remove remnant mips*-linux-android tests after 805f51f…
MaskRay Mar 23, 2023
ccc2f36
Android.rules: remove mips* rules
MaskRay Mar 23, 2023
399f313
[Driver] Remove remnant mips64el-linux-android code after D146565
MaskRay Mar 23, 2023
07ef7b1
[Builtins] Add __builtin_assume_separate_storage
bcardosolopes Mar 23, 2023
c828030
[mlir][linalg] Refactor convolution to img2col conversion to use gath…
qedawkins Feb 23, 2023
24847a9
[LegalizeTypes][RISCV] Add a special case for (add X, -1) to ExpandIn…
ChunyuLiao Mar 24, 2023
ccd96b3
[builtins][test] Fix divmodti4_test.c on Windows
aeubanks Mar 24, 2023
24657a9
[NFC] Fix Windows builds that use MSVC 14.x
jurahul Mar 23, 2023
5f48b86
[SelectionDAG] Use isOneConstant (NFC)
kazutakahirata Mar 24, 2023
231fa27
[InstCombine] Generate better code for std::bit_ceil
kazutakahirata Mar 24, 2023
4950104
[NFC][X86]remove trailing space in X86InstrArithmetic.td
XinWang10 Mar 24, 2023
3ca6e69
Precommit tests for #60690
junaire Mar 24, 2023
cea9383
[InstCombine] Try to recognize bswap pattern when calling funnel shifts
junaire Mar 24, 2023
1167414
[LoongArch] Enable LoopDataPrefetch pass
XiaodongLoong Mar 24, 2023
d8efbcf
[AArch64] Add tests for umax(x, 1u)
kazutakahirata Mar 24, 2023
cc86e6b
[BugFix] Fix VSELECT ISel fail
xiangzh1 Mar 21, 2023
abddb83
[lldb] Fix type of --apply-fixits (NFC)
kastiglione Mar 24, 2023
1e4325f
[X86] Precommit a test
kazutakahirata Mar 24, 2023
d30bc9e
[Driver] Change multilib selection algorithm
mplatings Mar 14, 2023
f957b8f
[clang-tidy][NFC] Improve naming convention in google-readability-avo…
carlosgalvezp Mar 23, 2023
b0cd5b2
[mlir][llvm] Switch remaining LLVM dialect tests to opaque pointers.
gysit Mar 24, 2023
3486f5f
[MLIR][LLVM] Add debug output to the LLVM inliner.
definelicht Mar 22, 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
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion bolt/test/X86/section-end-sym.s
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Check that BOLT doesn't consider end-of-section symbols (e.g., _etext) as
## functions.

# REQUIRES: system-linux
# REQUIRES: system-linux, asserts

# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o
# RUN: ld.lld %t.o -o %t.exe -q
Expand Down
82 changes: 54 additions & 28 deletions clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ class UseAfterMoveFinder {
public:
UseAfterMoveFinder(ASTContext *TheContext);

// Within the given function body, finds the first use of 'MovedVariable' that
// Within the given code block, finds the first use of 'MovedVariable' that
// occurs after 'MovingCall' (the expression that performs the move). If a
// use-after-move is found, writes information about it to 'TheUseAfterMove'.
// Returns whether a use-after-move was found.
bool find(Stmt *FunctionBody, const Expr *MovingCall,
bool find(Stmt *CodeBlock, const Expr *MovingCall,
const ValueDecl *MovedVariable, UseAfterMove *TheUseAfterMove);

private:
Expand Down Expand Up @@ -104,7 +104,7 @@ static StatementMatcher inDecltypeOrTemplateArg() {
UseAfterMoveFinder::UseAfterMoveFinder(ASTContext *TheContext)
: Context(TheContext) {}

bool UseAfterMoveFinder::find(Stmt *FunctionBody, const Expr *MovingCall,
bool UseAfterMoveFinder::find(Stmt *CodeBlock, const Expr *MovingCall,
const ValueDecl *MovedVariable,
UseAfterMove *TheUseAfterMove) {
// Generate the CFG manually instead of through an AnalysisDeclContext because
Expand All @@ -118,12 +118,11 @@ bool UseAfterMoveFinder::find(Stmt *FunctionBody, const Expr *MovingCall,
Options.AddImplicitDtors = true;
Options.AddTemporaryDtors = true;
std::unique_ptr<CFG> TheCFG =
CFG::buildCFG(nullptr, FunctionBody, Context, Options);
CFG::buildCFG(nullptr, CodeBlock, Context, Options);
if (!TheCFG)
return false;

Sequence =
std::make_unique<ExprSequence>(TheCFG.get(), FunctionBody, Context);
Sequence = std::make_unique<ExprSequence>(TheCFG.get(), CodeBlock, Context);
BlockMap = std::make_unique<StmtToBlockMap>(TheCFG.get(), Context);
Visited.clear();

Expand Down Expand Up @@ -398,20 +397,28 @@ static void emitDiagnostic(const Expr *MovingCall, const DeclRefExpr *MoveArg,
}

void UseAfterMoveCheck::registerMatchers(MatchFinder *Finder) {
// try_emplace is a common maybe-moving function that returns a
// bool to tell callers whether it moved. Ignore std::move inside
// try_emplace to avoid false positives as we don't track uses of
// the bool.
auto TryEmplaceMatcher =
cxxMemberCallExpr(callee(cxxMethodDecl(hasName("try_emplace"))));
auto CallMoveMatcher =
callExpr(callee(functionDecl(hasName("::std::move"))), argumentCountIs(1),
callExpr(argumentCountIs(1), callee(functionDecl(hasName("::std::move"))),
hasArgument(0, declRefExpr().bind("arg")),
unless(inDecltypeOrTemplateArg()),
unless(hasParent(TryEmplaceMatcher)), expr().bind("call-move"),
anyOf(hasAncestor(compoundStmt(
hasParent(lambdaExpr().bind("containing-lambda")))),
hasAncestor(functionDecl().bind("containing-func"))),
unless(inDecltypeOrTemplateArg()),
// try_emplace is a common maybe-moving function that returns a
// bool to tell callers whether it moved. Ignore std::move inside
// try_emplace to avoid false positives as we don't track uses of
// the bool.
unless(hasParent(cxxMemberCallExpr(
callee(cxxMethodDecl(hasName("try_emplace")))))))
.bind("call-move");
hasAncestor(functionDecl(anyOf(
cxxConstructorDecl(
hasAnyConstructorInitializer(withInitializer(
expr(anyOf(equalsBoundNode("call-move"),
hasDescendant(expr(
equalsBoundNode("call-move")))))
.bind("containing-ctor-init"))))
.bind("containing-ctor"),
functionDecl().bind("containing-func"))))));

Finder->addMatcher(
traverse(
Expand All @@ -434,6 +441,10 @@ void UseAfterMoveCheck::registerMatchers(MatchFinder *Finder) {
}

void UseAfterMoveCheck::check(const MatchFinder::MatchResult &Result) {
const auto *ContainingCtor =
Result.Nodes.getNodeAs<CXXConstructorDecl>("containing-ctor");
const auto *ContainingCtorInit =
Result.Nodes.getNodeAs<Expr>("containing-ctor-init");
const auto *ContainingLambda =
Result.Nodes.getNodeAs<LambdaExpr>("containing-lambda");
const auto *ContainingFunc =
Expand All @@ -445,23 +456,38 @@ void UseAfterMoveCheck::check(const MatchFinder::MatchResult &Result) {
if (!MovingCall || !MovingCall->getExprLoc().isValid())
MovingCall = CallMove;

Stmt *FunctionBody = nullptr;
if (ContainingLambda)
FunctionBody = ContainingLambda->getBody();
else if (ContainingFunc)
FunctionBody = ContainingFunc->getBody();
else
return;

// Ignore the std::move if the variable that was passed to it isn't a local
// variable.
if (!Arg->getDecl()->getDeclContext()->isFunctionOrMethod())
return;

UseAfterMoveFinder Finder(Result.Context);
UseAfterMove Use;
if (Finder.find(FunctionBody, MovingCall, Arg->getDecl(), &Use))
emitDiagnostic(MovingCall, Arg, Use, this, Result.Context);
// Collect all code blocks that could use the arg after move.
llvm::SmallVector<Stmt *> CodeBlocks{};
if (ContainingCtor) {
CodeBlocks.push_back(ContainingCtor->getBody());
if (ContainingCtorInit) {
// Collect the constructor initializer expressions.
bool BeforeMove{true};
for (CXXCtorInitializer *Init : ContainingCtor->inits()) {
if (BeforeMove && Init->getInit()->IgnoreImplicit() ==
ContainingCtorInit->IgnoreImplicit())
BeforeMove = false;
if (!BeforeMove)
CodeBlocks.push_back(Init->getInit());
}
}
} else if (ContainingLambda) {
CodeBlocks.push_back(ContainingLambda->getBody());
} else if (ContainingFunc) {
CodeBlocks.push_back(ContainingFunc->getBody());
}

for (Stmt *CodeBlock : CodeBlocks) {
UseAfterMoveFinder Finder(Result.Context);
UseAfterMove Use;
if (Finder.find(CodeBlock, MovingCall, Arg->getDecl(), &Use))
emitDiagnostic(MovingCall, Arg, Use, this, Result.Context);
}
}

} // namespace clang::tidy::bugprone
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,19 @@ class AvoidUnderscoreInGoogletestNameCallback : public PPCallbacks {
if (!isGoogletestTestMacro(MacroName) || !Args ||
Args->getNumMacroArguments() < 2)
return;
const Token *TestCaseNameToken = Args->getUnexpArgument(0);
const Token *TestSuiteNameToken = Args->getUnexpArgument(0);
const Token *TestNameToken = Args->getUnexpArgument(1);
if (!TestCaseNameToken || !TestNameToken)
if (!TestSuiteNameToken || !TestNameToken)
return;
std::string TestCaseName = PP->getSpelling(*TestCaseNameToken);
if (TestCaseName.find('_') != std::string::npos)
Check->diag(TestCaseNameToken->getLocation(),
"avoid using \"_\" in test case name \"%0\" according to "
std::string TestSuiteNameMaybeDisabled =
PP->getSpelling(*TestSuiteNameToken);
StringRef TestSuiteName = TestSuiteNameMaybeDisabled;
TestSuiteName.consume_front(KDisabledTestPrefix);
if (TestSuiteName.contains('_'))
Check->diag(TestSuiteNameToken->getLocation(),
"avoid using \"_\" in test suite name \"%0\" according to "
"Googletest FAQ")
<< TestCaseName;
<< TestSuiteName;

std::string TestNameMaybeDisabled = PP->getSpelling(*TestNameToken);
StringRef TestName = TestNameMaybeDisabled;
Expand Down
66 changes: 63 additions & 3 deletions clang-tools-extra/clangd/CollectMacros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
#include "CollectMacros.h"
#include "AST.h"
#include "clang/Basic/SourceLocation.h"
#include "llvm/ADT/STLExtras.h"

namespace clang {
namespace clangd {

void CollectMainFileMacros::add(const Token &MacroNameTok, const MacroInfo *MI,
bool IsDefinition) {
bool IsDefinition, bool InIfCondition) {
if (!InMainFile)
return;
auto Loc = MacroNameTok.getLocation();
Expand All @@ -26,9 +27,49 @@ void CollectMainFileMacros::add(const Token &MacroNameTok, const MacroInfo *MI,
auto Range = halfOpenToRange(
SM, CharSourceRange::getCharRange(Loc, MacroNameTok.getEndLoc()));
if (auto SID = getSymbolID(Name, MI, SM))
Out.MacroRefs[SID].push_back({Range, IsDefinition});
Out.MacroRefs[SID].push_back({Range, IsDefinition, InIfCondition});
else
Out.UnknownMacros.push_back({Range, IsDefinition});
Out.UnknownMacros.push_back({Range, IsDefinition, InIfCondition});
}

void CollectMainFileMacros::FileChanged(SourceLocation Loc, FileChangeReason,
SrcMgr::CharacteristicKind, FileID) {
InMainFile = isInsideMainFile(Loc, SM);
}
void CollectMainFileMacros::MacroExpands(const Token &MacroName,
const MacroDefinition &MD,
SourceRange Range,
const MacroArgs *Args) {
add(MacroName, MD.getMacroInfo());
}
void CollectMainFileMacros::MacroUndefined(const clang::Token &MacroName,
const clang::MacroDefinition &MD,
const clang::MacroDirective *Undef) {
add(MacroName, MD.getMacroInfo());
}
void CollectMainFileMacros::Ifdef(SourceLocation Loc, const Token &MacroName,
const MacroDefinition &MD) {
add(MacroName, MD.getMacroInfo(), /*IsDefinition=*/false,
/*InConditionalDirective=*/true);
}
void CollectMainFileMacros::Ifndef(SourceLocation Loc, const Token &MacroName,
const MacroDefinition &MD) {
add(MacroName, MD.getMacroInfo(), /*IsDefinition=*/false,
/*InConditionalDirective=*/true);
}
void CollectMainFileMacros::Defined(const Token &MacroName,
const MacroDefinition &MD,
SourceRange Range) {
add(MacroName, MD.getMacroInfo(), /*IsDefinition=*/false,
/*InConditionalDirective=*/true);
}
void CollectMainFileMacros::SourceRangeSkipped(SourceRange R,
SourceLocation EndifLoc) {
if (!InMainFile)
return;
Position Begin = sourceLocToPosition(SM, R.getBegin());
Position End = sourceLocToPosition(SM, R.getEnd());
Out.SkippedRanges.push_back(Range{Begin, End});
}

class CollectPragmaMarks : public PPCallbacks {
Expand Down Expand Up @@ -58,5 +99,24 @@ collectPragmaMarksCallback(const SourceManager &SM,
return std::make_unique<CollectPragmaMarks>(SM, Out);
}

void CollectMainFileMacros::MacroDefined(const Token &MacroName,
const MacroDirective *MD) {

if (!InMainFile)
return;
const auto *MI = MD->getMacroInfo();
add(MacroName, MD->getMacroInfo(), true);
if (MI)
for (const auto &Tok : MI->tokens()) {
auto *II = Tok.getIdentifierInfo();
// Could this token be a reference to a macro? (Not param to this macro).
if (!II || !II->hadMacroDefinition() ||
llvm::is_contained(MI->params(), II))
continue;
if (const MacroInfo *MI = PP.getMacroInfo(II))
add(Tok, MI);
}
}

} // namespace clangd
} // namespace clang
50 changes: 17 additions & 33 deletions clang-tools-extra/clangd/CollectMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "SourceCode.h"
#include "index/SymbolID.h"
#include "clang/Lex/PPCallbacks.h"
#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/DenseMap.h"
#include <string>

Expand All @@ -24,6 +25,8 @@ struct MacroOccurrence {
// SourceManager from preamble is not available when we build the AST.
Range Rng;
bool IsDefinition;
// True if the occurence is used in a conditional directive, e.g. #ifdef MACRO
bool InConditionalDirective;
};

struct MainFileMacros {
Expand All @@ -43,56 +46,37 @@ struct MainFileMacros {
/// - collect macros after the preamble of the main file (in ParsedAST.cpp)
class CollectMainFileMacros : public PPCallbacks {
public:
explicit CollectMainFileMacros(const SourceManager &SM, MainFileMacros &Out)
: SM(SM), Out(Out) {}
explicit CollectMainFileMacros(const Preprocessor &PP, MainFileMacros &Out)
: SM(PP.getSourceManager()), PP(PP), Out(Out) {}

void FileChanged(SourceLocation Loc, FileChangeReason,
SrcMgr::CharacteristicKind, FileID) override {
InMainFile = isInsideMainFile(Loc, SM);
}
SrcMgr::CharacteristicKind, FileID) override;

void MacroDefined(const Token &MacroName, const MacroDirective *MD) override {
add(MacroName, MD->getMacroInfo(), /*IsDefinition=*/true);
}
void MacroDefined(const Token &MacroName, const MacroDirective *MD) override;

void MacroExpands(const Token &MacroName, const MacroDefinition &MD,
SourceRange Range, const MacroArgs *Args) override {
add(MacroName, MD.getMacroInfo());
}
SourceRange Range, const MacroArgs *Args) override;

void MacroUndefined(const clang::Token &MacroName,
const clang::MacroDefinition &MD,
const clang::MacroDirective *Undef) override {
add(MacroName, MD.getMacroInfo());
}
const clang::MacroDirective *Undef) override;

// FIXME: handle C++23 #elifdef, #elifndef
void Ifdef(SourceLocation Loc, const Token &MacroName,
const MacroDefinition &MD) override {
add(MacroName, MD.getMacroInfo());
}

const MacroDefinition &MD) override;
void Ifndef(SourceLocation Loc, const Token &MacroName,
const MacroDefinition &MD) override {
add(MacroName, MD.getMacroInfo());
}
const MacroDefinition &MD) override;

void Defined(const Token &MacroName, const MacroDefinition &MD,
SourceRange Range) override {
add(MacroName, MD.getMacroInfo());
}

void SourceRangeSkipped(SourceRange R, SourceLocation EndifLoc) override {
if (!InMainFile)
return;
Position Begin = sourceLocToPosition(SM, R.getBegin());
Position End = sourceLocToPosition(SM, R.getEnd());
Out.SkippedRanges.push_back(Range{Begin, End});
}
SourceRange Range) override;

void SourceRangeSkipped(SourceRange R, SourceLocation EndifLoc) override;

private:
void add(const Token &MacroNameTok, const MacroInfo *MI,
bool IsDefinition = false);
bool IsDefinition = false, bool InConditionalDirective = false);
const SourceManager &SM;
const Preprocessor &PP;
bool InMainFile = true;
MainFileMacros &Out;
};
Expand Down
Loading