Skip to content
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

[libc++] Set feature-test macro __cpp_lib_atomic_float (#127559) #1

Closed
wants to merge 221 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
221 commits
Select commit Hold shift + click to select a range
2207e3e
[libc++] Set feature-test macro `__cpp_lib_atomic_float` (#127559)
frederick-vs-ja Feb 19, 2025
b2659ca
[InstCombine] Propagate flags in `foldSelectICmpAndBinOp` (#127437)
dtcxzyw Feb 19, 2025
da47a80
[PGO][test] Specify exact match for check labels (#117376)
ken-matsui Feb 19, 2025
b100c50
[lld][WebAssembly] Fix warnings in test. NFC (#127714)
sbc100 Feb 19, 2025
f6d74af
[clang][X86] Only define __CET__ macro for X86 targets (#127616)
mylai-mtk Feb 19, 2025
715edd7
[HLSL] Allow arrays to copy-initialize (#127557)
llvm-beanz Feb 19, 2025
6662fe3
[X86] Add missing vNbf16 handling in X86CallingConv.td file (#127102)
mikolaj-pirog Feb 19, 2025
aed9f11
[AMDGPU] Handle lowering addrspace casts from LDS to FLAT address in …
skc7 Feb 19, 2025
22d65d8
AMDGPU: Teach isOperandLegal about SALU literal restrictions (#127626)
arsenm Feb 19, 2025
27e6561
[Sparc] Use MCRegister. NFC
topperc Feb 19, 2025
8187caf
[NFC][AMDGPU] Pre-commit a test case of checking register coalescer o…
shiltian Feb 19, 2025
6c39ee7
[Driver][MSVC] Pass profile file to lld-link via -lto-sample-profile …
tianleliu Feb 19, 2025
8b284dc
[mlir] Fix FunctionOpInterface impl for external func (#124693)
ZenithalHourlyRate Feb 19, 2025
960b80c
[ELF] Improve INPUT_SECTION_FLAGS test
MaskRay Feb 19, 2025
a44284c
[AMDGPU] Add `isAsCheapAsAMove` for `v_pk_mov_b32` (#127632)
shiltian Feb 19, 2025
fb39445
[RISCV][VLOPT] Add vfsqrt/vfrsqrt7 instruction to isSupportInstr (#12…
LiqinWeng Feb 19, 2025
1c02c8f
[clang] fix use after free in clang/tools/c-index-test/c-index-test.c…
metaflow Feb 19, 2025
6b67aac
[mlir:python] Improve `mlir_(attribute|type|value)_subclass` for `nan…
ingomueller-net Feb 19, 2025
8f41d28
[c-index-test] Fix warnings
kazutakahirata Feb 19, 2025
c4f8da9
[MLIR][emitc]: Remove unused functions (NFC)
mgehre-amd Feb 19, 2025
9072ba7
[libc] Add strftime_l (#127708)
petrhosek Feb 19, 2025
850062c
[AA] Consider extractvalue and extractelement as escape sources (#127…
nikic Feb 19, 2025
a2b4d4e
Revert "[libc] Add strftime_l" (#127766)
petrhosek Feb 19, 2025
b9a1e58
[RISCVISel] Compute leading zeros for RISCVISD::VCPOP_VL node (#127705)
vbe-sc Feb 19, 2025
99aea21
[Flang][OpenMP] Skip threadprivate HostAssoc symbols for default priv…
Thirumalai-Shaktivel Feb 19, 2025
a2f9ae1
[AMDGPU] Replace gfx940 and gfx941 with gfx942 in offload and libclc …
ritter-x2a Feb 19, 2025
55fb793
[AMDGPU] Add missing gfx architectures to AddFlangOffloadRuntime.cmak…
ritter-x2a Feb 19, 2025
d4cb75e
[mlir][bufferization] Module bufferization: Delete obsolete code (#12…
matthias-springer Feb 19, 2025
8900e41
[AMDGPU][MLIR] Replace gfx940 and gfx941 with gfx942 in MLIR (#125836)
ritter-x2a Feb 19, 2025
f3f4afe
[X86] matchUnaryShuffle - add support for matching 512-bit extension …
RKSimon Feb 19, 2025
029c8e7
[AMDGPU][clang] Replace gfx940 and gfx941 with gfx942 in clang (#126762)
ritter-x2a Feb 19, 2025
4af8c53
[BitcodeReader] Use `poison` instead of `undef` to represent unsuppor…
pedroclobo Feb 19, 2025
cc53913
[CodeGen] Use __extendhfsf2 and __truncsfhf2 by default (#126880)
nikic Feb 19, 2025
8615f9a
[AMDGPU] Replace gfx940 and gfx941 with gfx942 in llvm (#126763)
ritter-x2a Feb 19, 2025
1760289
[clang][bytecode] Fix three-way unordered non-pointer comparisions (#…
tbaederr Feb 19, 2025
2260d59
[AMDGPU] Remove FeatureForceStoreSC0SC1 (#126878)
ritter-x2a Feb 19, 2025
db59708
[AMDGPU][docs] Replace gfx940 and gfx941 with gfx942 in llvm/docs (#1…
ritter-x2a Feb 19, 2025
0607f94
[X86] getFauxShuffleMask - add support for vXi64/vXf64 concat_vectors…
RKSimon Feb 19, 2025
c442b39
[AMDGPU][docs][NFC] Replace gfx940 with gfx942 in the gfx940 ISA doc …
ritter-x2a Feb 19, 2025
160da73
[Flang] Check if two ArrayConstructor's are Equal (#121181)
Thirumalai-Shaktivel Feb 19, 2025
7781e10
[clang] Lower non-builtin sincos[f|l] calls to llvm.sincos.* when -fn…
MacDue Feb 19, 2025
1509b46
[libclc] Improve nextafter behaviour around zero (#127469)
frasercrmck Feb 19, 2025
3c938d0
[MLIR][Affine] Fix affine.parallel op verifier (#127611)
bondhugula Feb 19, 2025
0de2cca
[flang][OpenMP]Improve support for DECLARE REDUCTION (#127088)
Leporacanthicus Feb 19, 2025
404f94a
[AArch64] Add optional extensions enabled on Grace (#127620)
ElvinaYakubova Feb 19, 2025
fadbc33
[lldb] Add LineTable::{upper,lower}_bound (#127519)
labath Feb 19, 2025
c0a763d
[NFC][MLIR] Make file-local cl::opt global variables static (#126714)
DanielAugusto191 Feb 19, 2025
0f472e9
AMDGPU: Avoid double attribute lookup for register count attributes (…
arsenm Feb 19, 2025
73d0679
[libclc] Clean up directory search procedure (#127783)
frasercrmck Feb 19, 2025
3ce2e4d
[NVPTX] Add tcgen05.cp/shift intrinsics (#127669)
durga4github Feb 19, 2025
c6a907a
[mlir][dlti] Fix query keys preallocation (#127786)
adam-smnk Feb 19, 2025
2c8b124
[libc++] Guard include of <features.h> with __has_include (#127691)
ldionne Feb 19, 2025
43e83b9
[clang][bytecode] Fix allocating primitive arrays of unknown bound (#…
tbaederr Feb 19, 2025
7f69a39
[libc++] Deprecate and remove member types of `hash` in `<variant>` (…
frederick-vs-ja Feb 19, 2025
1ac0db4
[NFC] using isUndef() instead of getOpcode() == ISD::UNDEF (#127713)
diggerlin Feb 19, 2025
01d0793
[LAA] Make Ptr argument optional in isNoWrap. (#127410)
fhahn Feb 19, 2025
760ec2c
[MLIR][Linalg] Introduce Python API for linalg.batch_matmul Ops. (#12…
shahidact Feb 19, 2025
aa9e519
Revert "[PowerPC] Deprecate uses of ISD::ADDC/ISD::ADDE/ISD::SUBC/ISD…
daltenty Feb 19, 2025
d804c83
[clang] Lower modf builtin using `llvm.modf` intrinsic (#126750)
MacDue Feb 19, 2025
2b340c1
flang: Fix build with latest libc++ (#127362)
tstellar Feb 19, 2025
d6c6bde
[flang] Implement !DIR$ UNROLL_AND_JAM [N] (#125046)
JDPailleux Feb 19, 2025
0b63dfb
[MLIR][NFC] Use base alias for constructor inheritance (#127756)
chelini Feb 19, 2025
fb5a87e
[libclc][NFC] Reformat ep_log.cl
frasercrmck Feb 19, 2025
26a8399
[clang][Sema] Fix initialization of `NonTypeTemplateParmDecl`... (#12…
alejandro-alvarez-sonarsource Feb 19, 2025
4624087
[llvm-dwarfdump] Print number of out-of-line functions described by D…
jalopezg-git Feb 19, 2025
826af17
[libc] add `LLVM_LIBC_CAST` macro. (#127319)
c8ef Feb 19, 2025
80ccf01
[Clang] Do not try to transform invalid bindings (#125658)
cor3ntin Feb 19, 2025
888c099
[Clang] Add release note for #127623 (#127815)
Sirraide Feb 19, 2025
3e61c1a
[libc++] Avoid code duplication in strings operator+ overloads (#126048)
philnik777 Feb 19, 2025
2f2295c
[Analysis] Avoid repeated hash lookups (NFC) (#127743)
kazutakahirata Feb 19, 2025
c23256e
[AsmPrinter] Avoid repeated hash lookups (NFC) (#127744)
kazutakahirata Feb 19, 2025
af922cf
[CodeGen] Avoid repeated hash lookups (NFC) (#127745)
kazutakahirata Feb 19, 2025
1bb72f0
[Object] Avoid repeated hash lookups (NFC) (#127746)
kazutakahirata Feb 19, 2025
bb75a96
[Support] Avoid repeated hash lookups (NFC) (#127747)
kazutakahirata Feb 19, 2025
fc5849d
[X86] Avoid repeated hash lookups (NFC) (#127748)
kazutakahirata Feb 19, 2025
9743b99
[libclc] Explicitly qualify private address spaces (#127823)
frasercrmck Feb 19, 2025
65998ab
[lldb] Make GetOutputStreamSP and GetErrorStreamSP protected (#127682)
JDevlieghere Feb 19, 2025
e2ba1b6
Revert "Reapply [CaptureTracking][FunctionAttrs] Add support for Capt…
nico Feb 19, 2025
70e693c
[lldb] Gardening in StreamAsynchronousIO (NFC) (#127717)
JDevlieghere Feb 19, 2025
ab3d793
[libc++] Optimize ranges::move{,_backward} for vector<bool>::iterator…
winner245 Feb 19, 2025
210036a
[AMDGPU][True16][CodeGen] true16 codegen pattern for fma (#127240)
broxigarchen Feb 19, 2025
e7bf54d
[flang] AliasAnalysis: Handle fir.load on hlfir.designate (#127107)
jdenny-ornl Feb 19, 2025
fda0e63
[clang] handle fp options in __builtin_convertvector (#125522)
ficol Feb 19, 2025
ddf2408
[AMDGPU] Remove unused variables. NFC
d0k Feb 19, 2025
75ea7ae
[CIR] Add additional frontend actions (#127249)
andykaylor Feb 19, 2025
8fc03e4
[InstCombine] avoid extra instructions in foldSelectICmpAnd (#127398)
andjo403 Feb 19, 2025
0ffe270
[ELF,test] Remove unneeded -o /dev/null
MaskRay Feb 19, 2025
8ecd788
Remove header file spuriously added by 9905728e2fb4ebe9b7518dfd73a057…
TIFitis Feb 19, 2025
aa847ce
[InstCombine] handle trunc to i1 in foldSelectICmpAndBinOp (#127390)
andjo403 Feb 19, 2025
e1d1bb9
[ELF,test] Clean up aarch64-relocs.s
MaskRay Feb 19, 2025
3e8db13
[SLP][NFC]Replace undefs by zeroinitializer
alexey-bataev Feb 19, 2025
ad87d5f
[libc++][test] Refactor tests for std::{copy, move, fill} algorithms …
winner245 Feb 19, 2025
5450954
Include test folder in the Clang Static Analyzer team mentions (#127810)
Xazax-hun Feb 19, 2025
a96444a
[VPlan] Remove dead exit block handling code in HCFGBuilder.
fhahn Feb 19, 2025
d1889cf
[X86] combineX86ShuffleChain - provide list of combined shuffle nodes…
RKSimon Feb 19, 2025
ccd3def
[clangd] Avoid round-trip from SourceLocation to clangd::Range and ba…
HighCommander4 Feb 19, 2025
1d829f6
[mlir][tosa] Align check variables naming to use capitals (#127830)
GeorgeARM Feb 19, 2025
9ebb618
[Clang] [Sema] Combine fallout warnings to just one warning (#127546)
foxtran Feb 19, 2025
2bf473b
[GlobalOpt] Don't query TTI on a llvm.memcpy declaration. (#127760)
topperc Feb 19, 2025
a6f48ed
[MC] Remove MCRegister::isStackSlot. (#127755)
topperc Feb 19, 2025
d57479c
[mlir][tosa] Update SelectOp's input names to match TOSA specificatio…
Jerry-Ge Feb 19, 2025
1841bcd
[clangd] Update XRefs to support overridden ObjC methods (#127109)
DavidGoldman Feb 19, 2025
8337d01
[MLIR] Fix doc build (NFC)
joker-eph Feb 19, 2025
36eaf0d
AMDGPU: Don't canonicalize fminnum/fmaxnum if targets support IEEE fm…
changpeng Feb 19, 2025
85e23fe
[Modules] Add `clang/Lex/HLSLRootSignatureTokenKinds.def` to clang's …
qiongsiwu Feb 19, 2025
1c762c2
[HLSL] Implement the 'and' HLSL function (#127098)
Icohedron Feb 19, 2025
5caefe2
[MLIR][LLVMIR] Add support for asin acos atan intrinsics op (#127317)
FantasqueX Feb 19, 2025
c3ebbfd
[RISCV] Add a pass to remove ADDI by reassociating to fold into load/…
topperc Feb 19, 2025
b1f882f
[OpenMP][NFC] Remove unused clock function types and globals (#127684)
jpeyton52 Feb 19, 2025
851177c
[OpenMP][NFC] Remove unused __kmp_dispatch_lock global (#127686)
jpeyton52 Feb 19, 2025
dca7306
[clang][perf-training] Support excluding LLVM build from PGO training…
petrhosek Feb 19, 2025
4a411eb
[MLIR] Fix rewrite of ops with vector operands to LLVM on GPU (#127844)
bjacob Feb 19, 2025
1987f93
[SandboxIR] OpaqueValue (#127699)
vporpo Feb 19, 2025
37d0f20
Revert "[RISCV] Add a pass to remove ADDI by reassociating to fold in…
topperc Feb 19, 2025
c9ff839
[mlir][Linalg] Fix linalg.generic iteration domain collapse for dynam…
Groverkss Feb 19, 2025
26e3750
Recommit "[RISCV] Add a pass to remove ADDI by reassociating to fold …
topperc Feb 19, 2025
84eacd3
[gn build] Port 26e375046dbd
llvmgnsyncbot Feb 19, 2025
c833746
[DSE] Make iter order deterministic in removePartiallyOverlappedStore…
bjope Feb 19, 2025
1761066
[GlobalOpt] Remove Function* argument from tryWidenGlobalArrayAndDest…
topperc Feb 19, 2025
1a6ed4d
[mlir][Vector] Deprecate vector.extractelement/vector.insertelement (…
Groverkss Feb 19, 2025
92b0752
[MemProf] Support cloning through recursive cycles (#127429)
teresajohnson Feb 19, 2025
3836559
[InstCombine] Test for regession with trunc in foldSelectICmpAnd
andjo403 Feb 19, 2025
c0c42c8
[SandboxIR][NFC] Change order of ifs in Context::getOrCreateValueInte…
vporpo Feb 19, 2025
5f8b256
Check the type of Objective-C++ instance variables in WebKit member v…
rniwa Feb 19, 2025
526b34a
adding rootsignature to obj2yaml
Jan 13, 2025
e84a8e1
adding test
Jan 13, 2025
f25fd64
removing old test
Jan 13, 2025
16552f0
remove useless includes
Jan 13, 2025
a6eb4c0
addressing comments
Jan 14, 2025
7d080b3
updating test
Jan 14, 2025
504527b
removing useless header
Jan 15, 2025
2425672
fix formating
Jan 15, 2025
08c17bb
renaming test
Jan 15, 2025
395a536
addressing pr comments
Jan 16, 2025
f93dff9
adding str to ROOT_ELEMENT_FLAG
Jan 16, 2025
1c1edb8
formating
Jan 17, 2025
5bef775
refactoring to follow llvm standards
Jan 18, 2025
628545a
addressing comments
Jan 27, 2025
c5c2ab6
clean up
Jan 27, 2025
b9db72c
remove version
Jan 30, 2025
f4af043
fix pr
Jan 30, 2025
496b922
adding dxil-dis test
Jan 31, 2025
422578f
adding compatibility test
Jan 31, 2025
b1423eb
addressing test concerns
Feb 3, 2025
b6262b6
clean up
Feb 3, 2025
16d0e8e
addressing comments
Feb 4, 2025
0a9e468
adding fail test
Feb 4, 2025
8295031
adding comment
Feb 4, 2025
c8e1e38
adding few more tests
Feb 4, 2025
434b862
format
Feb 4, 2025
2bfc5ad
cleanup
Feb 5, 2025
479422d
adding metadata extraction
Jan 15, 2025
f61ee77
moving root signature to it's own pass
Jan 16, 2025
499d879
formating
Jan 16, 2025
c4af535
removing useless imports
Jan 16, 2025
819fa0d
fixing pr changes
Jan 16, 2025
d347a87
adding some asserts
Jan 16, 2025
d8824ed
format
Jan 16, 2025
25c0384
fixing assert
Jan 18, 2025
5eb0ad2
cleaning
Jan 27, 2025
559427d
clean up
Jan 29, 2025
8ca5b2a
addressing comments
Jan 30, 2025
d52cd2c
removing version
Jan 30, 2025
5930dcb
fix test
Jan 30, 2025
fc72988
addressing PR Comments
Jan 31, 2025
2d1ee0d
fix test
Feb 3, 2025
92a85fe
filtering root signatures not associated with entry function
Feb 4, 2025
979ee91
separating parsing and validation
Feb 4, 2025
d089674
improve error handling
Feb 6, 2025
980e7d9
clean up
Feb 6, 2025
04667f3
clean up
Feb 6, 2025
8ec40aa
formating
Feb 6, 2025
b0ac6be
addressing comments and fix tests
Feb 7, 2025
6a36503
formating
Feb 7, 2025
f7d2c12
addressing pr comments
Feb 10, 2025
d6c98ed
addressing PR comments
Feb 11, 2025
36746f5
addressing pr comments
Feb 11, 2025
b5208e8
removing copies from root signature use in dx container globals
Feb 11, 2025
1fd6568
adding more tests
Feb 12, 2025
cde4634
maybe fix test?
Feb 12, 2025
4410e7b
try fix format
Feb 12, 2025
cbdb114
removing test
Feb 12, 2025
667ee17
adding llvm unreachable and testing test
Feb 12, 2025
d0dae8b
stopping compilation if root signature error were emitted
Feb 12, 2025
b1b28f8
making sure Error tests fail
Feb 12, 2025
0efd8cc
adding root constants
Feb 12, 2025
11256d8
refactoring root signature analysis to return a map instead
Feb 12, 2025
3c5046e
addressing pr comments
Feb 12, 2025
5d4505c
clean up
Feb 12, 2025
3117530
addressing pr comments
Feb 13, 2025
0af845c
implementing find interface for RootSignatureAnalysisWrapper
Feb 13, 2025
bf49a3a
adding test for null function
Feb 13, 2025
78826a5
fix root signature test error
Feb 14, 2025
4e689e9
fix other functions are checked
Feb 14, 2025
b0d0180
adding missing continue
Feb 14, 2025
3c6894f
adding few more tests
Feb 14, 2025
08f6ddc
adding yaml2obj support
Feb 15, 2025
b232967
adding support for obj2yaml and initial tests
Feb 18, 2025
1026a8e
multiple parameters support and more testing
Feb 19, 2025
00175bf
clean up
Feb 19, 2025
9ed2adc
fixing formating
Feb 19, 2025
e8252ba
reapply rebase fix
Feb 19, 2025
4de5c29
clean up
Feb 20, 2025
fe13b61
addressing pr comments
Feb 22, 2025
767b7d0
first working version
Feb 22, 2025
8434dc2
formating
Feb 22, 2025
d391727
moving the offset logic to it's own class
Feb 24, 2025
68c7513
refactoring to remove use of map and string
Feb 24, 2025
23069ab
addressing comments
Feb 25, 2025
d14471b
using buffer_ostream
Feb 25, 2025
216341c
remove getsize
Feb 25, 2025
85f012c
clean up
Feb 25, 2025
1e2bcf5
clean up
Feb 25, 2025
0e277d9
clean up
Feb 25, 2025
5cd0044
clean up
Feb 25, 2025
7a7c34d
addressing pr comments
Feb 25, 2025
d3fafab
clean up
Feb 25, 2025
15d1a8c
Merge branch 'refactor/improve-offset-calculation' into users/joaosaf…
Feb 25, 2025
7485640
clean up
Feb 26, 2025
17abc82
moving initializer arround
Feb 26, 2025
4b177e2
addressing pr comments
Feb 26, 2025
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
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .github/new-prs-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ clang:static analyzer:
- clang/tools/scan-build/**
- clang/utils/analyzer/**
- clang/docs/analyzer/**
- clang/test/Analysis/**

pgo:
- llvm/lib/Transforms/Instrumentation/CGProfile.cpp
Expand Down
9 changes: 6 additions & 3 deletions clang-tools-extra/clangd/CollectMacros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
namespace clang {
namespace clangd {

Range MacroOccurrence::toRange(const SourceManager &SM) const {
CharSourceRange MacroOccurrence::toSourceRange(const SourceManager &SM) const {
auto MainFile = SM.getMainFileID();
return halfOpenToRange(
SM, syntax::FileRange(MainFile, StartOffset, EndOffset).toCharRange(SM));
return syntax::FileRange(MainFile, StartOffset, EndOffset).toCharRange(SM);
}

Range MacroOccurrence::toRange(const SourceManager &SM) const {
return halfOpenToRange(SM, toSourceRange(SM));
}

void CollectMainFileMacros::add(const Token &MacroNameTok, const MacroInfo *MI,
Expand Down
1 change: 1 addition & 0 deletions clang-tools-extra/clangd/CollectMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct MacroOccurrence {
// True if the occurence is used in a conditional directive, e.g. #ifdef MACRO
bool InConditionalDirective;

CharSourceRange toSourceRange(const SourceManager &SM) const;
Range toRange(const SourceManager &SM) const;
};

Expand Down
56 changes: 56 additions & 0 deletions clang-tools-extra/clangd/XRefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,15 @@ void enhanceLocatedSymbolsFromIndex(llvm::MutableArrayRef<LocatedSymbol> Result,
});
}

bool objcMethodIsTouched(const SourceManager &SM, const ObjCMethodDecl *OMD,
SourceLocation Loc) {
unsigned NumSels = OMD->getNumSelectorLocs();
for (unsigned I = 0; I < NumSels; ++I)
if (SM.getSpellingLoc(OMD->getSelectorLoc(I)) == Loc)
return true;
return false;
}

// Decls are more complicated.
// The AST contains at least a declaration, maybe a definition.
// These are up-to-date, and so generally preferred over index results.
Expand Down Expand Up @@ -430,6 +439,26 @@ locateASTReferent(SourceLocation CurLoc, const syntax::Token *TouchedIdentifier,
continue;
}
}
// Special case: - (void)^method {} should jump to overrides, but the decl
// shouldn't, only the definition. Note that an Objective-C method can
// override a parent class or protocol.
//
// FIXME: Support jumping from a protocol decl to overrides on go-to
// definition.
if (const auto *OMD = llvm::dyn_cast<ObjCMethodDecl>(D)) {
if (OMD->isThisDeclarationADefinition() && TouchedIdentifier &&
objcMethodIsTouched(SM, OMD, TouchedIdentifier->location())) {
llvm::SmallVector<const ObjCMethodDecl *, 4> Overrides;
OMD->getOverriddenMethods(Overrides);
if (!Overrides.empty()) {
for (const auto *Override : Overrides)
AddResultDecl(Override);
LocateASTReferentMetric.record(1, "objc-overriden-method");
}
AddResultDecl(OMD);
continue;
}
}

// Special case: the cursor is on an alias, prefer other results.
// This targets "using ns::^Foo", where the target is more interesting.
Expand Down Expand Up @@ -1283,6 +1312,12 @@ std::vector<LocatedSymbol> findImplementations(ParsedAST &AST, Position Pos,
} else if (const auto *RD = dyn_cast<CXXRecordDecl>(ND)) {
IDs.insert(getSymbolID(RD));
QueryKind = RelationKind::BaseOf;
} else if (const auto *OMD = dyn_cast<ObjCMethodDecl>(ND)) {
IDs.insert(getSymbolID(OMD));
QueryKind = RelationKind::OverriddenBy;
} else if (const auto *ID = dyn_cast<ObjCInterfaceDecl>(ND)) {
IDs.insert(getSymbolID(ID));
QueryKind = RelationKind::BaseOf;
}
}
return findImplementors(std::move(IDs), QueryKind, Index, AST.tuPath());
Expand All @@ -1302,6 +1337,21 @@ void getOverriddenMethods(const CXXMethodDecl *CMD,
}
}

// Recursively finds all the overridden methods of `OMD` in complete type
// hierarchy.
void getOverriddenMethods(const ObjCMethodDecl *OMD,
llvm::DenseSet<SymbolID> &OverriddenMethods) {
if (!OMD)
return;
llvm::SmallVector<const ObjCMethodDecl *, 4> Overrides;
OMD->getOverriddenMethods(Overrides);
for (const ObjCMethodDecl *Base : Overrides) {
if (auto ID = getSymbolID(Base))
OverriddenMethods.insert(ID);
getOverriddenMethods(Base, OverriddenMethods);
}
}

std::optional<std::string>
stringifyContainerForMainFileRef(const Decl *Container) {
// FIXME We might also want to display the signature here
Expand Down Expand Up @@ -1438,6 +1488,12 @@ ReferencesResult findReferences(ParsedAST &AST, Position Pos, uint32_t Limit,
getOverriddenMethods(CMD, OverriddenMethods);
}
}
// Special case: Objective-C methods can override a parent class or
// protocol, we should be sure to report references to those.
if (const auto *OMD = llvm::dyn_cast<ObjCMethodDecl>(ND)) {
OverriddenBy.Subjects.insert(getSymbolID(OMD));
getOverriddenMethods(OMD, OverriddenMethods);
}
}
}

Expand Down
7 changes: 3 additions & 4 deletions clang-tools-extra/clangd/index/SymbolCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,8 @@ void SymbolCollector::handleMacros(const MainFileMacros &MacroRefsToIndex) {
// Add macro references.
for (const auto &IDToRefs : MacroRefsToIndex.MacroRefs) {
for (const auto &MacroRef : IDToRefs.second) {
const auto &Range = MacroRef.toRange(SM);
const auto &SR = MacroRef.toSourceRange(SM);
auto Range = halfOpenToRange(SM, SR);
bool IsDefinition = MacroRef.IsDefinition;
Ref R;
R.Location.Start.setLine(Range.start.line);
Expand All @@ -726,9 +727,7 @@ void SymbolCollector::handleMacros(const MainFileMacros &MacroRefsToIndex) {
if (IsDefinition) {
Symbol S;
S.ID = IDToRefs.first;
auto StartLoc = cantFail(sourceLocationInMainFile(SM, Range.start));
auto EndLoc = cantFail(sourceLocationInMainFile(SM, Range.end));
S.Name = toSourceCode(SM, SourceRange(StartLoc, EndLoc));
S.Name = toSourceCode(SM, SR.getAsRange());
S.SymInfo.Kind = index::SymbolKind::Macro;
S.SymInfo.SubKind = index::SymbolSubKind::None;
S.SymInfo.Properties = index::SymbolPropertySet();
Expand Down
36 changes: 36 additions & 0 deletions clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,42 @@ TEST_F(SymbolCollectorTest, OverrideRelationsMultipleInheritance) {
OverriddenBy(CBar, DBar), OverriddenBy(CBaz, DBaz)));
}

TEST_F(SymbolCollectorTest, ObjCOverrideRelationsSimpleInheritance) {
std::string Header = R"cpp(
@interface A
- (void)foo;
@end
@interface B : A
- (void)foo; // A::foo
- (void)bar;
@end
@interface C : B
- (void)bar; // B::bar
@end
@interface D : C
- (void)foo; // B::foo
- (void)bar; // C::bar
@end
)cpp";
runSymbolCollector(Header, /*Main=*/"",
{"-xobjective-c++", "-Wno-objc-root-class"});
const Symbol &AFoo = findSymbol(Symbols, "A::foo");
const Symbol &BFoo = findSymbol(Symbols, "B::foo");
const Symbol &DFoo = findSymbol(Symbols, "D::foo");

const Symbol &BBar = findSymbol(Symbols, "B::bar");
const Symbol &CBar = findSymbol(Symbols, "C::bar");
const Symbol &DBar = findSymbol(Symbols, "D::bar");

std::vector<Relation> Result;
for (const Relation &R : Relations)
if (R.Predicate == RelationKind::OverriddenBy)
Result.push_back(R);
EXPECT_THAT(Result, UnorderedElementsAre(
OverriddenBy(AFoo, BFoo), OverriddenBy(BBar, CBar),
OverriddenBy(BFoo, DFoo), OverriddenBy(CBar, DBar)));
}

TEST_F(SymbolCollectorTest, CountReferences) {
const std::string Header = R"(
class W;
Expand Down
155 changes: 155 additions & 0 deletions clang-tools-extra/clangd/unittests/XRefsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,85 @@ TEST(LocateSymbol, FindOverrides) {
sym("foo", Code.range("2"), std::nullopt)));
}

TEST(LocateSymbol, FindOverridesFromDefObjC) {
auto Code = Annotations(R"objc(
@protocol Fooey
- (void)foo;
@end
@interface Base
- (void)foo;
@end
@interface Foo : Base<Fooey>
- (void)$1[[foo]];
@end

@interface Bar : Foo
- (void)$2[[foo]];
@end
@implementation Bar
- (void)$3[[fo^o]] {}
@end
)objc");
TestTU TU = TestTU::withCode(Code.code());
TU.ExtraArgs.push_back("-xobjective-c++");
auto AST = TU.build();
EXPECT_THAT(
locateSymbolAt(AST, Code.point(), TU.index().get()),
UnorderedElementsAre(sym("foo", Code.range("1"), std::nullopt),
sym("foo", Code.range("2"), Code.range("3"))));
}

TEST(LocateSymbol, NoOverridesFromDeclObjC) {
auto Code = Annotations(R"objc(
@protocol Fooey
- (void)foo;
@end
@interface Base
- (void)foo;
@end
@interface Foo : Base<Fooey>
- (void)foo;
@end

@interface Bar : Foo
- (void)$2[[fo^o]];
@end
@implementation Bar
- (void)$3[[foo]] {}
@end
)objc");
TestTU TU = TestTU::withCode(Code.code());
TU.ExtraArgs.push_back("-xobjective-c++");
auto AST = TU.build();
EXPECT_THAT(
locateSymbolAt(AST, Code.point(), TU.index().get()),
UnorderedElementsAre(sym("foo", Code.range("2"), Code.range("3"))));
}

TEST(LocateSymbol, ObjCNoOverridesOnUsage) {
auto Code = Annotations(R"objc(
@interface Foo
- (void)foo;
@end

@interface Bar : Foo
- (void)$1[[foo]];
@end
@implementation Bar
- (void)$2[[foo]] {}
@end
void doSomething(Bar *bar) {
[bar fo^o];
}
)objc");
TestTU TU = TestTU::withCode(Code.code());
TU.ExtraArgs.push_back("-xobjective-c++");
auto AST = TU.build();
EXPECT_THAT(
locateSymbolAt(AST, Code.point(), TU.index().get()),
UnorderedElementsAre(sym("foo", Code.range("1"), Code.range("2"))));
}

TEST(LocateSymbol, WithIndexPreferredLocation) {
Annotations SymbolHeader(R"cpp(
class $p[[Proto]] {};
Expand Down Expand Up @@ -1834,6 +1913,41 @@ TEST(FindImplementations, Inheritance) {
}
}

TEST(FindImplementations, InheritanceObjC) {
llvm::StringRef Test = R"objc(
@interface $base^Base
- (void)fo$foo^o;
@end
@protocol Protocol
- (void)$protocol^protocol;
@end
@interface $ChildDecl[[Child]] : Base <Protocol>
- (void)concrete;
- (void)$fooDecl[[foo]];
@end
@implementation $ChildDef[[Child]]
- (void)concrete {}
- (void)$fooDef[[foo]] {}
- (void)$protocolDef[[protocol]] {}
@end
)objc";

Annotations Code(Test);
auto TU = TestTU::withCode(Code.code());
TU.ExtraArgs.push_back("-xobjective-c++");
auto AST = TU.build();
auto Index = TU.index();
EXPECT_THAT(findImplementations(AST, Code.point("base"), Index.get()),
UnorderedElementsAre(sym("Child", Code.range("ChildDecl"),
Code.range("ChildDef"))));
EXPECT_THAT(findImplementations(AST, Code.point("foo"), Index.get()),
UnorderedElementsAre(
sym("foo", Code.range("fooDecl"), Code.range("fooDef"))));
EXPECT_THAT(findImplementations(AST, Code.point("protocol"), Index.get()),
UnorderedElementsAre(sym("protocol", Code.range("protocolDef"),
Code.range("protocolDef"))));
}

TEST(FindImplementations, CaptureDefinition) {
llvm::StringRef Test = R"cpp(
struct Base {
Expand Down Expand Up @@ -1963,6 +2077,7 @@ void checkFindRefs(llvm::StringRef Test, bool UseIndex = false) {
Annotations T(Test);
auto TU = TestTU::withCode(T.code());
TU.ExtraArgs.push_back("-std=c++20");
TU.ExtraArgs.push_back("-xobjective-c++");

auto AST = TU.build();
std::vector<Matcher<ReferencesResult::Reference>> ExpectedLocations;
Expand Down Expand Up @@ -2260,6 +2375,25 @@ TEST(FindReferences, IncludeOverrides) {
checkFindRefs(Test, /*UseIndex=*/true);
}

TEST(FindReferences, IncludeOverridesObjC) {
llvm::StringRef Test =
R"objc(
@interface Base
- (void)$decl(Base)[[f^unc]];
@end
@interface Derived : Base
- (void)$overridedecl(Derived::func)[[func]];
@end
@implementation Derived
- (void)$overridedef[[func]] {}
@end
void test(Derived *derived, Base *base) {
[derived func]; // No references to the overrides.
[base $(test)[[func]]];
})objc";
checkFindRefs(Test, /*UseIndex=*/true);
}

TEST(FindReferences, RefsToBaseMethod) {
llvm::StringRef Test =
R"cpp(
Expand All @@ -2284,6 +2418,27 @@ TEST(FindReferences, RefsToBaseMethod) {
checkFindRefs(Test, /*UseIndex=*/true);
}

TEST(FindReferences, RefsToBaseMethodObjC) {
llvm::StringRef Test =
R"objc(
@interface BaseBase
- (void)$(BaseBase)[[func]];
@end
@interface Base : BaseBase
- (void)$(Base)[[func]];
@end
@interface Derived : Base
- (void)$decl(Derived)[[fu^nc]];
@end
void test(BaseBase *bb, Base *b, Derived *d) {
// refs to overridden methods in complete type hierarchy are reported.
[bb $(test)[[func]]];
[b $(test)[[func]]];
[d $(test)[[fu^nc]]];
})objc";
checkFindRefs(Test, /*UseIndex=*/true);
}

TEST(FindReferences, MainFileReferencesOnly) {
llvm::StringRef Test =
R"cpp(
Expand Down
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ Bug Fixes to C++ Support
- Clang is now better at keeping track of friend function template instance contexts. (#GH55509)
- The initialization kind of elements of structured bindings
direct-list-initialized from an array is corrected to direct-initialization.
- Clang no longer crashes when a coroutine is declared ``[[noreturn]]``. (#GH127327)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Loading
Loading