214 Commits

Author SHA1 Message Date
  Maksim Levental 164217cc33
Merge branch 'main' into users/makslevental/mlirpythonsupport 1 day ago
  Hristo Hristov 9975cb166e
[libc++][expected] Applied `[[nodiscard]]` (#170245) 1 day ago
  Alexey Samsonov 8f93365b19
[tsan] Export __cxa_guard_ interceptors from TSan runtime. (#171921) 1 day ago
  Asher Mancinelli 4b267d5caa
[MLIR][MemRef] Emit error on atomic generic result op defined outside the region (#172190) 1 day ago
  Simon Pilgrim dd33690686
[X86] combineVectorSizedSetCCEquality - convert to mayFoldIntoVector helper (#172215) 1 day ago
  Sergei Druzhkov e82edd28f6
[lldb-dap] Migrate locations request to structured types (#171099) 1 day ago
  nerix 9de41eef6e
[LLDB][NativePDB] Create typedefs in structs (#169248) 1 day ago
  Alex Bradbury 8a53c01b67 [XRay][test] Mark fdr-mode.cpp test as unsupported for RISC-V 1 day ago
  Simon Pilgrim 8d7c3fa6e4
[X86] combineVectorSizedSetCCEquality - ensure the load is a normal load (#172212) 1 day ago
  David Green 1a1c5df7f9
[ARM] Introduce intrinsics for MVE fp-converts under strict-fp. (#170686) 1 day ago
  David Green b97d24796c
[ARM] Introduce intrinsics for MVE vcmp under strict-fp. (#169798) 1 day ago
  David Green 1b93f8b48f
[ARM] Introduce intrinsics for MVE vrnd under strict-fp. (#169797) 1 day ago
  Alexis Engelke 66d92d4cfb [LLVM][Examples] Disable broken JIT + plugin tests (AIX, Sparc) 1 day ago
  Artur Bermond Torres 755a693299
[DAG] SDPatternMatch - Replace runtime data structures with lengths known at compile time (#172064) 1 day ago
  Ivan Butygin f785ca0d72
[mlir][nvgpu] Move memref memspace attributes conversion to single place (#172156) 1 day ago
  Hui 8680feb913
[libc++] Use native wait in std::barrier instead of sleep loop (#171041) 1 day ago
  Hristo Hristov 86dc131997
[libc++][flat_multiset] Applied `[[nodiscard]]` (#169984) 1 day ago
  Hristo Hristov 61f4cc7cd2
[libc++][flat_multimap] Applied `[[nodiscard]]` (#169986) 1 day ago
  Mythreya Kuricheti d78e431917
[clangd] Add option to fuzzy-match macros in code-complete (#169880) 1 day ago
  Dominicentek 4a1b6966ac
[clangd] Add a (currently hidden) --strong-workspace-mode flag (#172160) 1 day ago
  David Green 7db97696a2 [ARM][AArch64] Replace ".f16(bfloat" with ".bf16(bfloat" in intrinsics. NFC 1 day ago
  mitchell 72574b8195
[clang-tidy] Add `IgnoreMacro` option to `bugprone-chained-comparison` (#171975) 1 day ago
  Phoebe Wang f0557d8eb7
Revert "[X86][APX] Add pattern for zext(X86setcc ..) -> SETZUCCr (#170806)" (#172192) 1 day ago
  Mingjie Xu 1ea9f44f29
[IR] Optimize PHINode::removeIncomingValueIf() using two-pointer (#171961) 2 days ago
  int-zjt fd95803a35
[LoopRotate] Simplify PHINode::removeIncomingValue usage (NFC) (#171958) 2 days ago
  Mingjie Xu 1156629f4f
[ARM][MVE] Avoid `PHINode::removeIncomingValue()` with `PHINode::setIncomingValue()` and `PHINode::setIncomingBlock()` (NFC) (#171960) 2 days ago
  Mingjie Xu 681dbf9941
[WinEH] Use removeIncomingValueIf() in UpdatePHIOnClonedBlock() (NFC) (#171962) 2 days ago
  Rolf Morel b33354f272
[MLIR][Python][Transform] Print diagnostics also upon success (#172188) 2 days ago
  Victor Chernyakin 49ad1e9ea2
[clang-tidy][NFC] Remove obsolete FIXME comment (#172120) 2 days ago
  Matt Arsenault 16727674e0
AArch64: Use AArch64InstrInfo instead of base class in frame lowering (#172183) 2 days ago
  Florian Hahn a99a982440
[LV] Add test coverage for remark for unprofitable RT checks. 2 days ago
  Craig Topper 0cdc1b6dd4
[SelectionDAG] Support integer types with multiple registers in ComputePHILiveOutRegInfo. (#172081) 2 days ago
  Jonas Devlieghere 61db1ff8c5
[lldb] Add unit tests for NonNullSharedPtr (#172173) 2 days ago
  Ziqing Luo a630642585
[-Wunsafe-buffer-usage] Check isValueDependent before EvaluateAsBooleanCondition (#172091) 2 days ago
  Maksim Panchenko 3c2f81820c
[BOLT] Introduce BinaryFunctionListType. NFC (#172128) 2 days ago
  Hui 1e15dbe311
[libc++] Implement adjacent_view (#165089) 2 days ago
  Matt Arsenault b2d9356719
DAG: Make more use of the LibcallImpl overload of getExternalSymbol (#172171) 2 days ago
  Sirraide a5625ed128
[Clang] [NFC] Add an accessor for `ASTUnit::CodeGenOpts` (#172164) 2 days ago
  Jakub Kuderski 2490bb7e4b
[ADT] Only call reserve on empty containers in append_values (#172109) 2 days ago
  Ramil Sattarov a523ee6e7a
llvm/cmake/config.guess: add support for e2k (Elbrus-2000) (#162460) 2 days ago
  Orlando Cazalet-Hyams fa1dceb67f
[DebugInfo][DWARF] Allow memory locations in DW_AT_call_target expressions (#171183) 2 days ago
  Tom Stellard f721a3965c
[GitHub][CI] Drop manual build of universal-ctags from abi container (#172096) 2 days ago
  Simon Pilgrim 96891b73a9
[X86] EltsFromConsecutiveLoads - attempt to match consecutive truncated loads (#172051) 2 days ago
  Alexis Engelke 249acb6f87 [LLVM][Examples] Disable tests on AIX 2 days ago
  Haojian Wu 0c698f6ea8 [bazel] Port for e0379b8f91 2 days ago
  Amr Hesham c3a084933f
[CIR] Add support for the ArrayTypeTraitExpr (#171710) 2 days ago
  Luke Lau 4ea8157773 Revert "[VPlan] Remove legacy costing inside VPBlendRecipe::computeCost (#171846)" 2 days ago
  Amr Hesham 95e4dc62b1
[CIR] Add support for the RequiresExpr (#171818) 2 days ago
  xiaoyang-sde fa79e0a400
[libc++][ranges] implement `ranges::elements_of` (#91414) 2 days ago
  Matt Arsenault d8b03f282a
DAG: Use the LibcallImpl to get calling conv in ExpandDivRemLibCall (#172152) 2 days ago
  Florian Hahn 3afa68fb0e
[Flang] Rename modfile75.f90 to modfile81.f90. (NFC) 2 days ago
  actink 09197e4633
[Docs] Fix typo: missing closing parenthesis in __attribute__ (#172148) 2 days ago
  Tomohiro Kashiwada 0b64dc96df
[LLVM][Examples][Cygwin] Exclude examples that are not built from test dependencies (#172145) 2 days ago
  Ian Butterworth bea172c08b
[AArch64][GlobalISel] Fix incorrect codegen for FPR16/FPR8 to GPR copies (#171499) 2 days ago
  Longsheng Mou ad8d9e1428
[mlir][gpu] Use `arith` dialect to lower gpu.global_id (#171614) 2 days ago
  Alexis Engelke 9f5c96318d
[LLVM][Example] More test feature fixes for s390 and RISC-V 2 days ago
  Guray Ozen eeaf435859
[MLIR][Remarks] Improve the doc (#171128) 2 days ago
  Alexis Engelke b5019c2de4
[LLVM][Examples] Fix test requirements 2 days ago
  Hristo Hristov d52d761c23
[libc++][complex] Applied `[[nodiscard]]` (#171027) 2 days ago
  Alexis Engelke c81d44942e
[LLVM][CMake] Build examples for llvm-test-depends 2 days ago
  LLVM GN Syncbot e7c652bf9e [gn build] Port e0379b8f91 2 days ago
  Lang Hames 7ccf968d0b
[orc-rt] Add build options for EH and RTTI, and a config.h header. (#172129) 2 days ago
  Lang Hames b6c7a27c12
[orc-rt] Refactor ErrorHandlerTraits to use CallableTraitsHelper. (#172126) 2 days ago
  Craig Topper 9483353ba2
[SelectionDAG] Remove single quote around GET_ROUNDING in doxygen comment in ISDOPcode.h. NFC (#172114) 2 days ago
  Bala_Bhuvan_Varma e0379b8f91
[clang-tidy] Moved Multiple Inheritence check from fuchsia to misc module (#171565) 3 days ago
  Connector Switch 62ee2cf0f4
[libc] Add `IN6_IS_ADDR_{LINK, SITE}LOCAL` (#168207) 3 days ago
  Hristo Hristov b3bc005832
[libc++][map] Applied `[[nodiscard]]` (#169971) 3 days ago
  Jeffrey Byrnes e45241a4fe
[AMDGPU] Hoist s_set_vgpr_msb past SALU program state instructions (#172108) 3 days ago
  Jonas Devlieghere 9878bac3a8
Revert "[lldb] Still echo the command if we print the error." (#172110) 3 days ago
  Med Ismail Bennani 7927597860 Revert "[lldb/test] Enable debug info for TestFrameProviderCircularDependency.py" 3 days ago
  Michael Jones b50f6f24fe
[libc] Properly fix printf long double subnormals (#172103) 3 days ago
  Naveen Seth Hanig ad2fca7513
[clang][DependencyScanning] Move driver-command logic for by-name scanning into DependencyScanningTool (#171238) 3 days ago
  Jonas Devlieghere eb501b211a
[lldb] Still echo the command if we print the error. (#171931) 3 days ago
  Susan Tan (ス-ザン タン) 47b4c6a7d7
[acc][test] add tests for RegionBranchOpInterface for acc regions (#172073) 3 days ago
  Peter Klausler cf4be781be
[flang][runtime] Debug PRINT *, "HI" on GPU (#172087) 3 days ago
  Peter Klausler 6a41acef89
[flang] Initializers for proc pointers in module files (#170349) 3 days ago
  Ryosuke Niwa 6f1e3c3968
[alpha.webkit.UncountedLocalVarsChecker] Ignore a VarDecl in "if" with trivial "then" (#171764) 3 days ago
  Ryosuke Niwa e23e5705e6
[webkit.UncountedLambdaCapturesChecker] Ignore a lambda which gets called immediately (#162977) 3 days ago
  Med Ismail Bennani 13b4eb9452 [lldb/test] Enable debug info for TestFrameProviderCircularDependency.py 3 days ago
  Maksim Levental 536163650e
[mlir][LLVM] refactor FailOnUnsupportedFP (#172054) 3 days ago
  Arthur Eubanks 560fe76506
[docs] Point to `git bisect --first-parent` (#171728) 3 days ago
  Nicolai Hähnle 54ae1222ef
VectorCombine: Fold chains of shuffles fed by length-changing shuffles (#168819) 3 days ago
  Florian Hahn e6e3f94b5c
[VPlan] Re-add clarifying comment regarding part to extract. (NFC) 3 days ago
  Florian Hahn 333ee931df
[LV] Update stale comment after 4e05d702f0. (NFC) 3 days ago
  Louis Dionne 20c67c75ec [libc++] Produce summary reports in compare-benchmarks 2 months ago
  Florian Hahn 0171e881b5
[VPlan] Strip stray whitespace when printing VPWidenIntOrFpInduction. 3 days ago
  Syadus Sefat f3c16454b4
[Reland][AMDGPU][GlobalISel] Add register bank legalization for buffer_load byte and short (#172065) 3 days ago
  adams381 f195d5278f
[CIR] Support wide string literals in CIR codegen (#171541) 3 days ago
  Farzon Lotfi 0d53746eaa
[HLSL][Matrix] Add support for ICK_HLSL_Matrix_Splat to add splat cast of scalars (#170885) 3 days ago
  Ryosuke Niwa 1307b77de3
Delete unused code in WebKit checkers (#171768) 3 days ago
  Aiden Grossman a6c211dfa9
[bazel] Port d107b3c82a (#172077) 3 days ago
  Alireza Torabian 9bc38df587
[LoopFusion] Simplifying the legality checks (#171889) 3 days ago
  Seraphimt 0603d4af1d
Fix misprint in computeKnownFPClass in GISelValueTracking.cpp (#171566) 3 days ago
  ArielCPU d901485655
[Mips] Add compact branch patterns for MipsR6 (#171131) 3 days ago
  Erick Velez c9ad896dd7
[clang-doc] Add functions to namespace template (#171938) 3 days ago
  Ryosuke Niwa 5f6a5e02cd
[alpha.webkit.ForwardDeclChecker] Add a missing nullptr check (#171740) 3 days ago
  Zhewen Yu d107b3c82a
[MLIR][AMDGPU] Implement reifyDimOfResult for FatRawBufferCastOp (#171839) 3 days ago
  Alex MacLean a94920cdd5
[NVPTX] Fixup and refactor brx.idx support (#171933) 3 days ago
  Maksim Levental 8d5ade8feb
[mlir] enable APFloatWrappers on MacOS (#172070) 3 days ago
  Erick Velez 8f264586d7
[clang-doc] Add class template to HTML (#171937) 3 days ago
  KRM7 e0e5b6e1f7
[GISel][Inlineasm] Support inlineasm i/s constraint for symbols (#170094) 3 days ago
  ayank227 76c3eed673
[AArch64][GlobalISel] Fix vector lrint/llrint fallbacks (#170814) 3 days ago
  Med Ismail Bennani 53972216d1
[lldb] Add arm32/thumb register layout to Scripted{Frame,Thread} (#172005) 3 days ago
  Erick Velez ed42c81bd6
[clang-doc] Add JSON output to existing template tests (#171936) 3 days ago
  Seraphimt 112a6126ef
Fixes non-functional changes found static analyzer (#171197) 3 days ago
  Aiden Grossman 68535970ab [Delinearization] Fix unused variable from 5cdb757 3 days ago
  Aiden Grossman a0e7476be5
[bazel] Port 568ce76c6e (#172059) 3 days ago
  Amr Hesham 858fa0e1ed
[CIR][NFC] Fix the mms-bitfields test file (#172060) 3 days ago
  Craig Topper ef21740781
[LoopPeel] Check for onlyAccessesInaccessibleMemory instead of llvm.assume in peelToTurnInvariantLoadsDereferenceable. (#171910) 3 days ago
  Ryotaro Kasuga 5cdb757cc3
[Delinearization] Remove `isKnownNonNegative` (#171817) 3 days ago
  Amr Hesham 366f3ac144
[CIR] Add support for the ConceptSpecializationExpr (#171824) 3 days ago
  Michael Buch 26ff166637
[lldb][ClangExpressionParser] Emit more accurate language note for Objective-C++ fallback (#172047) 3 days ago
  Aiden Grossman b8816a4e83 Revert "[AMDGPU][GlobalISel] Add register bank legalization for buffer_load byte and short (#167798)" 3 days ago
  Alexander Johnston 4ca2caeab6
[HLSL] Implement ddx/ddy_fine intrinsics (#168874) 3 days ago
  Charles Zablit 8515ddaa2b
[lldb] fix failing diagnostics test when Unicode is supported (#172038) 3 days ago
  jeanPerier c14c256170
[flang][TBAA] fix unsafe optional deref after #170908 (#172033) 3 days ago
  Dan Klishch 1760effa33
[clang] Implement gcc_struct attribute on Itanium targets (#71148) 3 days ago
  Amr Hesham 44aec0e768
[CIR] Add support for TypeTraitExpr with bool result (#171687) 3 days ago
  Durgadoss R 9dc6f18a3e
[MLIR][NVVM] Fix results-check for mbarrier Op (#171657) 3 days ago
  Matt Arsenault 2af693bbec
AMDGPU: Fix selection failure on bf16 inverse sqrt (#172044) 3 days ago
  Louis Dionne 4ffd373e38
[runtimes] Remove dependencies on cxx_experimental for test-suite installs (#171678) 3 days ago
  Simon Pilgrim b880428bf0
[X86] Cleanup check prefixes for any/zero_extend_vector_inreg_of_broadcast_from_memory.ll tests (#172043) 3 days ago
  Amr Hesham dbd0122cf5
[CIR] Add support the ChooseExpr for scalar (#171882) 3 days ago
  Syadus Sefat 4dbd16bb62
[AMDGPU][GlobalISel] Add register bank legalization for buffer_load byte and short (#167798) 3 days ago
  Mircea Trofin ff3dcd06a9
[GlobalOpt][profcheck] Mark as `unknown` the branch weights of global shrunk to boolean (#171530) 3 days ago
  Mehdi Amini 0570cab7c1 [MLIR] Apply clang-tidy fixes for misc-use-internal-linkage in IndexingUtils.cpp (NFC) 3 months ago
  Michael Buch d7cbc7f9e4
[lldb][InstrumentationRuntime] Run sanitizer utility expressions as C (#172019) 3 days ago
  Felipe de Azevedo Piovezan 66f2b6625e
[lldb][nfc] Change ProcessGDBRemote::ParseMultiMemReadPacket signature (#172020) 3 days ago
  Matt Arsenault 44c0469e5f
ValueTracking: Handle amdgcn.rsq intrinsic in computeKnownFPClass (#171837) 3 days ago
  Juan Manuel Martinez Caamaño 55c0e2e20f
[AMDGPU] Add missing cases for V_INDIRECT_REG_{READ/WRITE}_GPR_IDX and V/S_INDIRECT_REG_WRITE_MOVREL (#171835) 3 days ago
  David Stone ec1bf9c562
Use `llvm::SmallVector` instead of `OwningArrayRef` in `VTableLayout`. (#168768) 3 days ago
  Ravil Dorozhinskii 3ae5f2782e
[ROCDL] Added LDS barrier ops to ROCDL (gfx1250) (#171810) 3 days ago
  Matthew Devereau 7a43921af8
[AArch64][SVE] Fix -msve-vector-bits=256 fixed width vector crash (#171776) 3 days ago
  Charles Zablit 7345233fb6
[lldb] improve the heuristics for checking if a terminal supports Unicode (#171832) 3 days ago
  Simon Pilgrim 95e6d23f24
[X86] combineHorizOpWithShuffle - ensure we handle undef elements from widened shuffle (#172014) 3 days ago
  Asher Mancinelli 568ce76c6e
[MLIR][LLVM] Add pass to update ops with default visibility (#171727) 3 days ago
  Muhammad Bassiouni 3a04e01f34
[libc][wctype][codegen] Add generation script for conversion data (#170868) 3 days ago
  Tarun Prabhu 7d21334127
[flang][NFC] Strip trailing whitespace from tests (12 of 14) 3 days ago
  nerix 6f44be6f3e
[LLDB][NativePDB] Use original struct name when searching for constants (#166845) 3 days ago
  LLVM GN Syncbot 42defcd39c [gn build] Port 48d942c715 3 days ago
  Erick Ochoa Lopez 5ebb928532
[mlir][amdgpu] Adds make_dma_gather_base (#171857) 3 days ago
  Krzysztof Parzyszek 1451f3d9b0
[flang][OpenMP] Use StylizedInstance in converted clauses (#171907) 3 days ago
  Nico Weber 099985fded [gn] port 3d1f04425a 3 days ago
  Nico Weber ffac200e71 [gn] port 4e9e7c5816 3 days ago
  Erich Keane 1dbff71312
[OpenACC][CIR] 'bind' lowering with identifier (#171749) 3 days ago
  Jacek Caban eb98089a26
[llvm-objcopy] Allow -p on COFF targets (#171237) 3 days ago
  Nico Weber 234c41413f [gn] "port" 8e999e3d78 (LLVM_ENABLE_IO_SANDBOX) 3 days ago
  Nico Weber 66601d8734 [gn] port 4c6aa8fd8a (clang/Analysis/Scalable) 3 days ago
  Felipe de Azevedo Piovezan 7d151cf170
[LLDB][NFC] Remove redundant target/process checks in SBFrame (#153258) 3 days ago
  Pankaj Dwivedi e151434b0f
[AMDGPU][InsertWaitCnts][NFC] Merge VMEM_ACCESS and VMEM_READ_ACCESS into a single event type (#171973) 3 days ago
  Matt Arsenault 87b3bf5b66
ValueTracking: Add baseline test for fpclass handling of amdgcn.rsq (#171836) 3 days ago
  Kirill Vedernikov 07eb9fa43f
[MLIR][NVVM] Support for dense and sparse MMA with block scaling (#170566) 3 days ago
  Victor Chernyakin df7b90b9db
[clang-tidy][NFC] Refactor `bugprone-branch-clone` (#171849) 3 days ago
  Ryutaro Okada 04b197599e
[MLIR] [Vector] Fix canonicalization for vector.scatter with tensor output (#168824) 3 days ago
  Mikołaj Piróg 81a75b1af9
[X86] Remove rest of AMX-TRANSPOSE (#171906) 3 days ago
  Matt Arsenault 6e47d4ef45
Reapply "InstCombine: Fold ldexp with constant exponent to fmul" (#171895) (#171977) 3 days ago
  Matt Arsenault 975bda005e
InstCombine: Add more ldexp by constant tests (#171976) 3 days ago
  Victor Chernyakin f9a3076180
[clang-tidy] Fix some false negatives in `readability-redundant-typename` (#171947) 3 days ago
  Paul Walker 54744bc0a6
[LLVM][AArch64] Add "u" variants of sve.[s,u]hsub intrinsics (#170894) 3 days ago
  jeanPerier ad62c049b6
[flang] add includes to AbstractConverter.h after #171501 (#171987) 3 days ago
  Jasmine Tang 80ec43d455
[CIR] Implement builtin reduce fadd/fmul/fmax/fmin (#171633) 3 days ago
  Benjamin Maxwell c18d9eabd4
[AArch64] Generalize bfdotq_lane patterns to work for f32/i32 duplanes (#171146) 3 days ago
  Kunwar Grover e4733424bc
[mlir][Vector] Improve vector.transferx store-to-load-forwarding (#171840) 3 days ago
  Haojian Wu 0deee8ca98 Fix a typo in the Modules.rst doc. 3 days ago
  Wenju He b123b7059f
[NFC] Fix build error: multi-line comment in opencl-c.h (#171953) 3 days ago
  jeanPerier 9c5744cbc8
[flang] add missing headers in ConvertVariable.h after #171501 (#171983) 3 days ago
  Michael Buch 04ce013d7c
Reapply "[llvm][lit] Add option to run only the failed tests" (#171588) 3 days ago
  Nikita Popov 123d4d9b85 [AMGGPUInstCombine] Use getSigned() for frexp exponent 4 days ago
  Nikita Popov 89c37fee25 [WPD] Use getSigned() for offset 4 days ago
  Nikita Popov 1d7bfb752f [SafeStack] Use getSigned() for negative value 4 days ago
  lonely eagle 917e458b96
[mlir] Cleanup the addLegalOp of convert-linalg-to-std pass (NFC) (#171979) 3 days ago
  jeanPerier 2aa345054f
[flang][OpenACC] remap component references in structured constructs (#171501) 3 days ago
  Sergei Druzhkov f0d7d833f5
[lldb-dap] Allow empty memory reference in disassemble arguments (#162517) 3 days ago
  Sam Tebbs 71c3acb18b
[Analysis][AArch64] Add cost model for loop.dependence.{war/raw}.mask (#167551) 3 days ago
  Hristo Hristov 51bd0edb56
[libc++][valarray] Applied `[[nodiscard]]` (#170996) 3 days ago
  Mariya Podchishchaeva d714a6c210
Reland [MS][clang] Add support for vector deleting destructors (#170337) 3 days ago
  ShivaChen a318c50110
[mlir][tosa] Remove NegateOp to SubOp and 48-bit promotion in TosaToLinalg (#170622) 3 days ago
  Sam Tebbs 19e1011df5
[SelectionDAG] Fix unsafe cases for loop.dependence.{war/raw}.mask (#168565) 3 days ago
  jeanPerier fbde1dcfb3
[flang][OpenACC] do not load pointer and allocatables component in data clauses (#171445) 3 days ago
  Pierre van Houtryve 025d0c0d1d
(reland) [AMDGPU][SIInsertWaitCnts] Use RegUnits-based tracking (#162077) (#171779) 3 days ago
  Sjoerd Meijer b492b3523c
[LoopInterchange] Motivating example for interchange. NFC. (#171631) 3 days ago
  Hristo Hristov 3e2a8e2eff
[libc++][multiset] Applied `[[nodiscard]]` (#171654) 3 days ago
  Michael Buch 5bc7b9d462
[llvm][dwarfdump] Print the name (if available) of entities referenced by DW_AT_import (#171859) 3 days ago
  yingopq 64dfc26237
[Mips] Support "$sp" named register (#171793) 3 days ago
  Nikolas Klauser a34a92d9e2
[libc++] Always return bool from bitset::operator[](size_t) const (#169894) 3 days ago
  Nikolas Klauser 4fc5b6d8c4
[libc++] Optimize {std,ranges}::for_each for iterating over __trees (#164405) 3 days ago
  Nikita Popov d0d8359c01
[InstSimplify] Remove redundant icmp+ptrtoint fold (#171807) 3 days ago
  Nikita Popov 294fb60e5b
[SandboxIR] Fix ConstantInt::get() for vector types (#171852) 3 days ago
  Nikita Popov 43a4442fac
[ExpandFp] Fix incorrect ConstantInt construction (#171861) 3 days ago
  mitchell 3383004a95
[clang-tidy] Support comments in WarningsAsErrors (#171816) 3 days ago
  Hristo Hristov c05a3ac915
[libc++][filesystem] Applied `[[nodiscard]]` (#171085) 3 days ago
  Alexander Richardson 7275817739
[TableGen] Improve generated comments for RegClassByHwMode tables 3 days ago
  Craig Topper f0bec9ec46
[RISCV] Use OPERAND_MEMORY as the OperandType for CVrr. NFC (#171967) 3 days ago
  Craig Topper 618b874d84
[RISCV] Add OperandType to tsimm5 used by Xsfvcp. (#171964) 3 days ago
  Hristo Hristov 63ea393f96
[libc++][optional] Applied `[[nodiscard]]` (#170045) 3 days ago
  Himadhith c3e7a1ab8f
[NFC][PowerPC] Optimize vector compares for not equal to non zero vectors (#171635) 3 days ago
  Michael Pratt cdfdb06c91
[TSan] Zero-initialize Trace.local_head 3 days ago
  Yusuke MINATO c7ca7047a7
[flang][docs] Reorganize the table of contents (#171240) 3 days ago
  Hongzheng Chen 1335a05ab8
[MLIR][Python] Fix AffineIfOp insertion point (#171957) 3 days ago
  Hristo Hristov ecaf673850
[libc++][format] Applied `[[nodiscard]]` to more classes (#170808) 4 days ago
  Craig Topper cea9813565
[RISCV] Add an OperandType to VMaskOp. NFC (#171926) 4 days ago
  Craig Topper 8deb4221e2
[RISCV] Use VMV0 instead of VMaskOp in masked vector pseudoinstructions. NFC (#171924) 4 days ago
  Jim Lin 9d5403c892
[RISCV] Fix incorrect chapter number in comments in RISCVSchedSpacemitX60.td. (#171765) 4 days ago
  Hristo Hristov 8378ec44ff
[libc++][set] Applied `[[nodiscard]]` (#169982) 4 days ago
  Younan Zhang 96b6594c90
[Clang] Remove the early-check for anonymous struct in ShouldDeleteSpecialMember (#171799) 4 days ago
  Peter Collingbourne b0d3405578
SROA: Recognize llvm.protected.field.ptr intrinsics. 4 days ago
  Farzon Lotfi 2b1fa68ad0
[HLSL] Add the DXC matrix orientation flags (#171550) 4 days ago
  Aiden Grossman e13998f116
[bazel] Port 8e999e3d78 (#171946) 4 days ago
  Aashcharya Gorakh a1b3586492
[flang][docs] Remove stale inline links to Intel and IBM compiler option 4 days ago
  Nicolai Hähnle e760d0619f
AMDGPU/PromoteAlloca: Refactor into analysis / commit phases (#170512) 4 days ago
  Henrich Lauko b2f36149d8
[CIR] Implement function personality attribute and its lowering (#171001) 4 days ago
  Andy Kaylor d8d87b594e
[CIR] Add support for global member pointer values (#171888) 4 days ago
  Andrew Haberlandt e281800924
Revert: check-builtins target for LLVM_ENABLE_RUNTIMES (#171940) 4 days ago
  Florian Mayer ee22217d1f
[Sanitizer] show configure.log for libz build (#171932) 4 days ago
100 changed files with 1290 additions and 406 deletions
Split View
  1. +2
    -9
      .github/workflows/containers/github-action-ci-tooling/Dockerfile
  2. +9
    -6
      bolt/include/bolt/Core/BinaryContext.h
  3. +2
    -2
      bolt/include/bolt/Core/BinaryFunctionCallGraph.h
  4. +2
    -3
      bolt/include/bolt/Passes/CacheMetrics.h
  5. +7
    -9
      bolt/include/bolt/Passes/LongJmp.h
  6. +3
    -3
      bolt/include/bolt/Profile/YAMLProfileReader.h
  7. +5
    -5
      bolt/lib/Core/BinaryContext.cpp
  8. +2
    -2
      bolt/lib/Core/BinaryEmitter.cpp
  9. +2
    -2
      bolt/lib/Passes/BinaryPasses.cpp
  10. +5
    -5
      bolt/lib/Passes/CacheMetrics.cpp
  11. +3
    -3
      bolt/lib/Passes/IdenticalCodeFolding.cpp
  12. +1
    -1
      bolt/lib/Passes/Inliner.cpp
  13. +8
    -7
      bolt/lib/Passes/LongJmp.cpp
  14. +1
    -1
      bolt/lib/Passes/ProfileQualityStats.cpp
  15. +2
    -2
      bolt/lib/Passes/ReorderFunctions.cpp
  16. +3
    -3
      bolt/lib/Profile/YAMLProfileReader.cpp
  17. +12
    -3
      clang-tools-extra/clang-doc/JSONGenerator.cpp
  18. +3
    -0
      clang-tools-extra/clang-doc/assets/class-template.mustache
  19. +5
    -1
      clang-tools-extra/clang-doc/assets/function-template.mustache
  20. +26
    -0
      clang-tools-extra/clang-doc/assets/namespace-template.mustache
  21. +0
    -4
      clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  22. +14
    -12
      clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  23. +14
    -42
      clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
  24. +12
    -0
      clang-tools-extra/clang-tidy/bugprone/ChainedComparisonCheck.cpp
  25. +5
    -2
      clang-tools-extra/clang-tidy/bugprone/ChainedComparisonCheck.h
  26. +1
    -1
      clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt
  27. +2
    -2
      clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  28. +1
    -0
      clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  29. +3
    -0
      clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  30. +2
    -2
      clang-tools-extra/clang-tidy/misc/MultipleInheritanceCheck.cpp
  31. +6
    -6
      clang-tools-extra/clang-tidy/misc/MultipleInheritanceCheck.h
  32. +30
    -34
      clang-tools-extra/clang-tidy/readability/RedundantTypenameCheck.cpp
  33. +2
    -0
      clang-tools-extra/clangd/ClangdLSPServer.cpp
  34. +1
    -0
      clang-tools-extra/clangd/ClangdServer.cpp
  35. +5
    -0
      clang-tools-extra/clangd/ClangdServer.h
  36. +21
    -5
      clang-tools-extra/clangd/CodeComplete.cpp
  37. +5
    -0
      clang-tools-extra/clangd/CodeComplete.h
  38. +8
    -0
      clang-tools-extra/clangd/Config.h
  39. +16
    -4
      clang-tools-extra/clangd/ConfigCompile.cpp
  40. +6
    -0
      clang-tools-extra/clangd/ConfigFragment.h
  41. +4
    -0
      clang-tools-extra/clangd/ConfigYAML.cpp
  42. +32
    -9
      clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  43. +21
    -5
      clang-tools-extra/clangd/GlobalCompilationDatabase.h
  44. +6
    -2
      clang-tools-extra/clangd/tool/Check.cpp
  45. +12
    -0
      clang-tools-extra/clangd/tool/ClangdMain.cpp
  46. +58
    -0
      clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  47. +14
    -0
      clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
  48. +14
    -0
      clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
  49. +18
    -0
      clang-tools-extra/docs/ReleaseNotes.rst
  50. +8
    -0
      clang-tools-extra/docs/clang-tidy/checks/bugprone/chained-comparison.rst
  51. +3
    -40
      clang-tools-extra/docs/clang-tidy/checks/fuchsia/multiple-inheritance.rst
  52. +2
    -1
      clang-tools-extra/docs/clang-tidy/checks/list.rst
  53. +49
    -0
      clang-tools-extra/docs/clang-tidy/checks/misc/multiple-inheritance.rst
  54. +4
    -1
      clang-tools-extra/test/clang-doc/json/class-requires.cpp
  55. +8
    -2
      clang-tools-extra/test/clang-doc/json/class-specialization.cpp
  56. +4
    -1
      clang-tools-extra/test/clang-doc/json/class-template.cpp
  57. +4
    -1
      clang-tools-extra/test/clang-doc/json/class.cpp
  58. +4
    -1
      clang-tools-extra/test/clang-doc/json/concept.cpp
  59. +8
    -2
      clang-tools-extra/test/clang-doc/json/function-requires.cpp
  60. +4
    -1
      clang-tools-extra/test/clang-doc/json/method-template.cpp
  61. +1
    -0
      clang-tools-extra/test/clang-doc/json/namespace.cpp
  62. +45
    -25
      clang-tools-extra/test/clang-doc/namespace.cpp
  63. +161
    -0
      clang-tools-extra/test/clang-doc/templates.cpp
  64. +37
    -0
      clang-tools-extra/test/clang-tidy/checkers/bugprone/chained-comparison-ignore-macros.cpp
  65. +41
    -0
      clang-tools-extra/test/clang-tidy/checkers/bugprone/chained-comparison.cpp
  66. +8
    -8
      clang-tools-extra/test/clang-tidy/checkers/misc/multiple-inheritance.cpp
  67. +19
    -3
      clang-tools-extra/test/clang-tidy/checkers/readability/redundant-typename.cpp
  68. +5
    -1
      clang-tools-extra/unittests/clang-doc/JSONGeneratorTest.cpp
  69. +31
    -0
      clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
  70. +1
    -1
      clang/docs/Modules.rst
  71. +15
    -0
      clang/docs/ReleaseNotes.rst
  72. +31
    -0
      clang/include/clang/AST/ASTContext.h
  73. +9
    -0
      clang/include/clang/AST/ASTMutationListener.h
  74. +6
    -10
      clang/include/clang/AST/DeclCXX.h
  75. +13
    -25
      clang/include/clang/AST/VTableBuilder.h
  76. +6
    -5
      clang/include/clang/Basic/ABI.h
  77. +7
    -2
      clang/include/clang/Basic/Attr.td
  78. +22
    -1
      clang/include/clang/Basic/AttrDocs.td
  79. +12
    -0
      clang/include/clang/Basic/Builtins.td
  80. +3
    -0
      clang/include/clang/Basic/DiagnosticASTKinds.td
  81. +2
    -0
      clang/include/clang/Basic/DiagnosticDriverKinds.td
  82. +3
    -1
      clang/include/clang/Basic/LangOptions.def
  83. +10
    -0
      clang/include/clang/Basic/LangOptions.h
  84. +5
    -0
      clang/include/clang/Basic/TargetInfo.h
  85. +3
    -2
      clang/include/clang/Basic/arm_mve.td
  86. +32
    -12
      clang/include/clang/Basic/arm_mve_defs.td
  87. +4
    -4
      clang/include/clang/Basic/arm_sve.td
  88. +5
    -0
      clang/include/clang/CIR/Dialect/IR/CIROps.td
  89. +1
    -1
      clang/include/clang/CIR/MissingFeatures.h
  90. +5
    -17
      clang/include/clang/DependencyScanning/DependencyScannerImpl.h
  91. +25
    -21
      clang/include/clang/DependencyScanning/DependencyScanningWorker.h
  92. +5
    -0
      clang/include/clang/Frontend/ASTUnit.h
  93. +9
    -3
      clang/include/clang/Options/Options.td
  94. +3
    -0
      clang/include/clang/Sema/Overload.h
  95. +6
    -1
      clang/include/clang/Sema/Sema.h
  96. +4
    -0
      clang/include/clang/Serialization/ASTWriter.h
  97. +5
    -5
      clang/include/clang/Tooling/DependencyScanningTool.h
  98. +85
    -0
      clang/lib/AST/ASTContext.cpp
  99. +8
    -1
      clang/lib/AST/Decl.cpp
  100. +63
    -10
      clang/lib/AST/DeclCXX.cpp

+ 2
- 9
.github/workflows/containers/github-action-ci-tooling/Dockerfile View File

@@ -109,14 +109,7 @@ RUN apt-get update && \
abi-dumper \
autoconf \
parallel \
pkg-config && \
pkg-config \
universal-ctags && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN git clone https://github.com/universal-ctags/ctags.git && \
cd ctags && \
./autogen.sh && \
./configure && \
sudo make install && \
rm -Rf ../ctags


+ 9
- 6
bolt/include/bolt/Core/BinaryContext.h View File

@@ -65,6 +65,9 @@ namespace bolt {

class BinaryFunction;

using BinaryFunctionListType = std::vector<BinaryFunction *>;
using ConstBinaryFunctionListType = std::vector<const BinaryFunction *>;

/// Information on loadable part of the file.
struct SegmentInfo {
uint64_t Address; /// Address of the segment in memory.
@@ -228,11 +231,11 @@ class BinaryContext {
/// Store all functions in the binary, sorted by original address.
std::map<uint64_t, BinaryFunction> BinaryFunctions;

/// A mutex that is used to control parallel accesses to BinaryFunctions
/// A mutex that is used to control parallel accesses to BinaryFunctions.
mutable llvm::sys::RWMutex BinaryFunctionsMutex;

/// Functions injected by BOLT
std::vector<BinaryFunction *> InjectedBinaryFunctions;
/// Functions injected by BOLT.
BinaryFunctionListType InjectedBinaryFunctions;

/// Jump tables for all functions mapped by address.
std::map<uint64_t, JumpTable *> JumpTables;
@@ -567,13 +570,13 @@ public:
const InstructionListType &Instructions,
const Twine &Name = "");

std::vector<BinaryFunction *> &getInjectedBinaryFunctions() {
BinaryFunctionListType &getInjectedBinaryFunctions() {
return InjectedBinaryFunctions;
}

/// Return vector with all functions, i.e. include functions from the input
/// binary and functions created by BOLT.
std::vector<BinaryFunction *> getAllBinaryFunctions();
BinaryFunctionListType getAllBinaryFunctions();

/// Construct a jump table for \p Function at \p Address or return an existing
/// one at that location.
@@ -1385,7 +1388,7 @@ public:
const uint32_t SrcCUID, unsigned FileIndex);

/// Return functions in output layout order
std::vector<BinaryFunction *> getSortedFunctions();
BinaryFunctionListType getSortedFunctions();

/// Do the best effort to calculate the size of the function by emitting
/// its code, and relaxing branch instructions. By default, branch


+ 2
- 2
bolt/include/bolt/Core/BinaryFunctionCallGraph.h View File

@@ -9,6 +9,7 @@
#ifndef BOLT_PASSES_BINARY_FUNCTION_CALLGRAPH_H
#define BOLT_PASSES_BINARY_FUNCTION_CALLGRAPH_H

#include "bolt/Core/BinaryContext.h"
#include "bolt/Core/CallGraph.h"
#include <deque>
#include <functional>
@@ -18,7 +19,6 @@ namespace llvm {
namespace bolt {

class BinaryFunction;
class BinaryContext;

class BinaryFunctionCallGraph : public CallGraph {
public:
@@ -46,7 +46,7 @@ public:

private:
std::unordered_map<const BinaryFunction *, NodeId> FuncToNodeId;
std::vector<BinaryFunction *> Funcs;
BinaryFunctionListType Funcs;
};

using CgFilterFunction = std::function<bool(const BinaryFunction &BF)>;


+ 2
- 3
bolt/include/bolt/Passes/CacheMetrics.h View File

@@ -13,6 +13,7 @@
#ifndef BOLT_PASSES_CACHEMETRICS_H
#define BOLT_PASSES_CACHEMETRICS_H

#include "bolt/Core/BinaryContext.h"
#include <vector>

namespace llvm {
@@ -20,12 +21,10 @@ namespace llvm {
class raw_ostream;

namespace bolt {
class BinaryFunction;
namespace CacheMetrics {

/// Calculate and print various metrics related to instruction cache performance
void printAll(raw_ostream &OS,
const std::vector<BinaryFunction *> &BinaryFunctions);
void printAll(raw_ostream &OS, const BinaryFunctionListType &BinaryFunctions);

} // namespace CacheMetrics
} // namespace bolt


+ 7
- 9
bolt/include/bolt/Passes/LongJmp.h View File

@@ -82,15 +82,13 @@ class LongJmpPass : public BinaryFunctionPass {
/// purposes, we need to do a size worst-case estimation. Real layout is done
/// by RewriteInstance::mapFileSections()
void tentativeLayout(const BinaryContext &BC,
std::vector<BinaryFunction *> &SortedFunctions);
uint64_t
tentativeLayoutRelocMode(const BinaryContext &BC,
std::vector<BinaryFunction *> &SortedFunctions,
uint64_t DotAddress);
uint64_t
tentativeLayoutRelocColdPart(const BinaryContext &BC,
std::vector<BinaryFunction *> &SortedFunctions,
uint64_t DotAddress);
BinaryFunctionListType &SortedFunctions);
uint64_t tentativeLayoutRelocMode(const BinaryContext &BC,
BinaryFunctionListType &SortedFunctions,
uint64_t DotAddress);
uint64_t tentativeLayoutRelocColdPart(const BinaryContext &BC,
BinaryFunctionListType &SortedFunctions,
uint64_t DotAddress);
void tentativeBBLayout(const BinaryFunction &Func);

/// Update stubs addresses with their exact address after a round of stub


+ 3
- 3
bolt/include/bolt/Profile/YAMLProfileReader.h View File

@@ -68,7 +68,7 @@ public:
}

/// Returns the binary functions with the parameter neighbor hash.
std::optional<std::vector<BinaryFunction *>>
std::optional<BinaryFunctionListType>
getBFsWithNeighborHash(uint64_t NeighborHash) {
auto It = NeighborHashToBFs.find(NeighborHash);
return It == NeighborHashToBFs.end() ? std::nullopt
@@ -93,7 +93,7 @@ public:
DenseMap<BinaryFunction *, std::set<BinaryFunction *>> BFAdjacencyMap;

/// Maps neighbor hashes to binary functions.
DenseMap<uint64_t, std::vector<BinaryFunction *>> NeighborHashToBFs;
DenseMap<uint64_t, BinaryFunctionListType> NeighborHashToBFs;

/// Adjacency map for profile functions in the call graph.
DenseMap<yaml::bolt::BinaryFunctionProfile *,
@@ -187,7 +187,7 @@ private:
StringSet<> ProfileFunctionNames;

/// BinaryFunction pointers indexed by YamlBP functions.
std::vector<BinaryFunction *> ProfileBFs;
BinaryFunctionListType ProfileBFs;

// Pseudo probe function GUID to inline tree node
GUIDInlineTreeMap TopLevelGUIDToInlineTree;


+ 5
- 5
bolt/lib/Core/BinaryContext.cpp View File

@@ -826,7 +826,7 @@ void BinaryContext::populateJumpTables() {
}

void BinaryContext::skipMarkedFragments() {
std::vector<BinaryFunction *> FragmentQueue;
BinaryFunctionListType FragmentQueue;
// Copy the functions to FragmentQueue.
FragmentQueue.assign(FragmentsToSkip.begin(), FragmentsToSkip.end());
auto addToWorklist = [&](BinaryFunction *Function) -> void {
@@ -1715,8 +1715,8 @@ unsigned BinaryContext::addDebugFilenameToUnit(const uint32_t DestCUID,
DestCUID, DstUnit->getVersion()));
}

std::vector<BinaryFunction *> BinaryContext::getSortedFunctions() {
std::vector<BinaryFunction *> SortedFunctions(BinaryFunctions.size());
BinaryFunctionListType BinaryContext::getSortedFunctions() {
BinaryFunctionListType SortedFunctions(BinaryFunctions.size());
llvm::transform(llvm::make_second_range(BinaryFunctions),
SortedFunctions.begin(),
[](BinaryFunction &BF) { return &BF; });
@@ -1725,8 +1725,8 @@ std::vector<BinaryFunction *> BinaryContext::getSortedFunctions() {
return SortedFunctions;
}

std::vector<BinaryFunction *> BinaryContext::getAllBinaryFunctions() {
std::vector<BinaryFunction *> AllFunctions;
BinaryFunctionListType BinaryContext::getAllBinaryFunctions() {
BinaryFunctionListType AllFunctions;
AllFunctions.reserve(BinaryFunctions.size() + InjectedBinaryFunctions.size());
llvm::transform(llvm::make_second_range(BinaryFunctions),
std::back_inserter(AllFunctions),


+ 2
- 2
bolt/lib/Core/BinaryEmitter.cpp View File

@@ -232,7 +232,7 @@ void BinaryEmitter::emitAll(StringRef OrgSecPrefix) {
}

void BinaryEmitter::emitFunctions() {
auto emit = [&](const std::vector<BinaryFunction *> &Functions) {
auto emit = [&](const BinaryFunctionListType &Functions) {
const bool HasProfile = BC.NumProfiledFuncs > 0;
const bool OriginalAllowAutoPadding = Streamer.getAllowAutoPadding();
for (BinaryFunction *Function : Functions) {
@@ -282,7 +282,7 @@ void BinaryEmitter::emitFunctions() {
}

// Emit functions in sorted order.
std::vector<BinaryFunction *> SortedFunctions = BC.getSortedFunctions();
BinaryFunctionListType SortedFunctions = BC.getSortedFunctions();
emit(SortedFunctions);

// Emit functions added by BOLT.


+ 2
- 2
bolt/lib/Passes/BinaryPasses.cpp View File

@@ -1609,7 +1609,7 @@ Error PrintProgramStats::runOnFunctions(BinaryContext &BC) {
}

if (!opts::PrintSortedBy.empty()) {
std::vector<BinaryFunction *> Functions;
BinaryFunctionListType Functions;
std::map<const BinaryFunction *, DynoStats> Stats;

for (auto &BFI : BC.getBinaryFunctions()) {
@@ -1700,7 +1700,7 @@ Error PrintProgramStats::runOnFunctions(BinaryContext &BC) {

// Collect and print information about suboptimal code layout on input.
if (opts::ReportBadLayout) {
std::vector<BinaryFunction *> SuboptimalFuncs;
BinaryFunctionListType SuboptimalFuncs;
for (auto &BFI : BC.getBinaryFunctions()) {
BinaryFunction &BF = BFI.second;
if (!BF.hasValidProfile())


+ 5
- 5
bolt/lib/Passes/CacheMetrics.cpp View File

@@ -30,7 +30,7 @@ constexpr unsigned ITLBEntries = 16;

/// Initialize and return a position map for binary basic blocks
void extractBasicBlockInfo(
const std::vector<BinaryFunction *> &BinaryFunctions,
const BinaryFunctionListType &BinaryFunctions,
std::unordered_map<BinaryBasicBlock *, uint64_t> &BBAddr,
std::unordered_map<BinaryBasicBlock *, uint64_t> &BBSize) {

@@ -54,7 +54,7 @@ void extractBasicBlockInfo(
/// the ordering of basic blocks. The method returns a pair
/// (the number of fallthrough branches, the total number of branches)
std::pair<uint64_t, uint64_t>
calcTSPScore(const std::vector<BinaryFunction *> &BinaryFunctions,
calcTSPScore(const BinaryFunctionListType &BinaryFunctions,
const std::unordered_map<BinaryBasicBlock *, uint64_t> &BBAddr,
const std::unordered_map<BinaryBasicBlock *, uint64_t> &BBSize) {
uint64_t Score = 0;
@@ -95,7 +95,7 @@ using Predecessors = std::vector<std::pair<BinaryFunction *, uint64_t>>;
/// Build a simplified version of the call graph: For every function, keep
/// its callers and the frequencies of the calls
std::unordered_map<const BinaryFunction *, Predecessors>
extractFunctionCalls(const std::vector<BinaryFunction *> &BinaryFunctions) {
extractFunctionCalls(const BinaryFunctionListType &BinaryFunctions) {
std::unordered_map<const BinaryFunction *, Predecessors> Calls;

for (BinaryFunction *SrcFunction : BinaryFunctions) {
@@ -140,7 +140,7 @@ extractFunctionCalls(const std::vector<BinaryFunction *> &BinaryFunctions) {
/// the page. The following procedure detects short and long calls, and
/// estimates the expected number of cache misses for the long ones.
double expectedCacheHitRatio(
const std::vector<BinaryFunction *> &BinaryFunctions,
const BinaryFunctionListType &BinaryFunctions,
const std::unordered_map<BinaryBasicBlock *, uint64_t> &BBAddr,
const std::unordered_map<BinaryBasicBlock *, uint64_t> &BBSize) {
std::unordered_map<const BinaryFunction *, Predecessors> Calls =
@@ -213,7 +213,7 @@ double expectedCacheHitRatio(
} // namespace

void CacheMetrics::printAll(raw_ostream &OS,
const std::vector<BinaryFunction *> &BFs) {
const BinaryFunctionListType &BFs) {
// Stats related to hot-cold code splitting
size_t NumFunctions = 0;
size_t NumProfiledFunctions = 0;


+ 3
- 3
bolt/lib/Passes/IdenticalCodeFolding.cpp View File

@@ -368,8 +368,8 @@ typedef std::unordered_map<BinaryFunction *, std::set<BinaryFunction *>,
KeyHash, KeyCongruent>
CongruentBucketsMap;

typedef std::unordered_map<BinaryFunction *, std::vector<BinaryFunction *>,
KeyHash, KeyEqual>
typedef std::unordered_map<BinaryFunction *, BinaryFunctionListType, KeyHash,
KeyEqual>
IdenticalBucketsMap;

namespace llvm {
@@ -522,7 +522,7 @@ Error IdenticalCodeFolding::runOnFunctions(BinaryContext &BC) {

for (auto &IBI : IdenticalBuckets) {
// Functions identified as identical.
std::vector<BinaryFunction *> &Twins = IBI.second;
BinaryFunctionListType &Twins = IBI.second;
if (Twins.size() < 2)
continue;



+ 1
- 1
bolt/lib/Passes/Inliner.cpp View File

@@ -571,7 +571,7 @@ Error Inliner::runOnFunctions(BinaryContext &BC) {
InliningCandidates.clear();
findInliningCandidates(BC);

std::vector<BinaryFunction *> ConsideredFunctions;
BinaryFunctionListType ConsideredFunctions;
for (auto &BFI : BC.getBinaryFunctions()) {
BinaryFunction &Function = BFI.second;
if (!shouldOptimize(Function))


+ 8
- 7
bolt/lib/Passes/LongJmp.cpp View File

@@ -304,7 +304,7 @@ void LongJmpPass::tentativeBBLayout(const BinaryFunction &Func) {
}

uint64_t LongJmpPass::tentativeLayoutRelocColdPart(
const BinaryContext &BC, std::vector<BinaryFunction *> &SortedFunctions,
const BinaryContext &BC, BinaryFunctionListType &SortedFunctions,
uint64_t DotAddress) {
DotAddress = alignTo(DotAddress, llvm::Align(opts::AlignFunctions));
for (BinaryFunction *Func : SortedFunctions) {
@@ -325,9 +325,10 @@ uint64_t LongJmpPass::tentativeLayoutRelocColdPart(
return DotAddress;
}

uint64_t LongJmpPass::tentativeLayoutRelocMode(
const BinaryContext &BC, std::vector<BinaryFunction *> &SortedFunctions,
uint64_t DotAddress) {
uint64_t
LongJmpPass::tentativeLayoutRelocMode(const BinaryContext &BC,
BinaryFunctionListType &SortedFunctions,
uint64_t DotAddress) {
// Compute hot cold frontier
int64_t LastHotIndex = -1u;
uint32_t CurrentIndex = 0;
@@ -398,8 +399,8 @@ uint64_t LongJmpPass::tentativeLayoutRelocMode(
return DotAddress;
}

void LongJmpPass::tentativeLayout(
const BinaryContext &BC, std::vector<BinaryFunction *> &SortedFunctions) {
void LongJmpPass::tentativeLayout(const BinaryContext &BC,
BinaryFunctionListType &SortedFunctions) {
uint64_t DotAddress = BC.LayoutStartAddress;

if (!BC.HasRelocations) {
@@ -920,7 +921,7 @@ Error LongJmpPass::runOnFunctions(BinaryContext &BC) {
}

BC.outs() << "BOLT-INFO: Starting stub-insertion pass\n";
std::vector<BinaryFunction *> Sorted = BC.getSortedFunctions();
BinaryFunctionListType Sorted = BC.getSortedFunctions();
bool Modified;
uint32_t Iterations = 0;
do {


+ 1
- 1
bolt/lib/Passes/ProfileQualityStats.cpp View File

@@ -37,7 +37,7 @@ static cl::opt<unsigned> PercentileForProfileQualityCheck(
} // namespace opts

namespace {
using FunctionListType = std::vector<const BinaryFunction *>;
using FunctionListType = ConstBinaryFunctionListType;
using function_iterator = FunctionListType::iterator;

// Function number -> vector of flows for BBs in the function


+ 2
- 2
bolt/lib/Passes/ReorderFunctions.cpp View File

@@ -296,7 +296,7 @@ Error ReorderFunctions::runOnFunctions(BinaryContext &BC) {
case RT_NONE:
break;
case RT_EXEC_COUNT: {
std::vector<BinaryFunction *> SortedFunctions(BFs.size());
BinaryFunctionListType SortedFunctions(BFs.size());
llvm::transform(llvm::make_second_range(BFs), SortedFunctions.begin(),
[](BinaryFunction &BF) { return &BF; });
llvm::stable_sort(SortedFunctions,
@@ -471,7 +471,7 @@ Error ReorderFunctions::runOnFunctions(BinaryContext &BC) {
}

if (FuncsFile || LinkSectionsFile) {
std::vector<BinaryFunction *> SortedFunctions(BFs.size());
BinaryFunctionListType SortedFunctions(BFs.size());
llvm::transform(llvm::make_second_range(BFs), SortedFunctions.begin(),
[](BinaryFunction &BF) { return &BF; });



+ 3
- 3
bolt/lib/Profile/YAMLProfileReader.cpp View File

@@ -559,7 +559,7 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) {
auto BFsWithSameHashOpt = CGMatcher.getBFsWithNeighborHash(Hash);
if (!BFsWithSameHashOpt)
continue;
std::vector<BinaryFunction *> BFsWithSameHash = BFsWithSameHashOpt.value();
BinaryFunctionListType BFsWithSameHash = BFsWithSameHashOpt.value();
// Finds the binary function with the longest common prefix to the profiled
// function and matches.
BinaryFunction *ClosestBF = nullptr;
@@ -725,7 +725,7 @@ size_t YAMLProfileReader::matchWithNameSimilarity(BinaryContext &BC) {
NamespaceToProfiledBFSizes[YamlBFNamespace].insert(YamlBF.NumBasicBlocks);
}

StringMap<std::vector<BinaryFunction *>> NamespaceToBFs;
StringMap<BinaryFunctionListType> NamespaceToBFs;

// Maps namespaces to BFs excluding binary functions with no equal sized
// profiled functions belonging to the same namespace.
@@ -760,7 +760,7 @@ size_t YAMLProfileReader::matchWithNameSimilarity(BinaryContext &BC) {
continue;

std::string &YamlBFDemangledName = ProfileBFDemangledNames[I];
std::vector<BinaryFunction *> BFs = It->second;
BinaryFunctionListType BFs = It->second;
unsigned MinEditDistance = UINT_MAX;
BinaryFunction *ClosestNameBF = nullptr;



+ 12
- 3
clang-tools-extra/clang-doc/JSONGenerator.cpp View File

@@ -378,8 +378,15 @@ static void serializeInfo(const ArrayRef<TemplateParamInfo> &Params,
json::Value ParamsArray = Array();
auto &ParamsArrayRef = *ParamsArray.getAsArray();
ParamsArrayRef.reserve(Params.size());
for (const auto &Param : Params)
ParamsArrayRef.push_back(Param.Contents);
for (size_t Idx = 0; Idx < Params.size(); ++Idx) {
json::Value ParamObjVal = Object();
Object &ParamObj = *ParamObjVal.getAsObject();

ParamObj["Param"] = Params[Idx].Contents;
if (Idx == Params.size() - 1)
ParamObj["End"] = true;
ParamsArrayRef.push_back(ParamObjVal);
}
Obj["Parameters"] = ParamsArray;
}

@@ -622,8 +629,10 @@ static void serializeInfo(const NamespaceInfo &I, json::Object &Obj,
serializeInfo(Info, Object, RepositoryUrl);
};

if (!I.Children.Functions.empty())
if (!I.Children.Functions.empty()) {
serializeArray(I.Children.Functions, Obj, "Functions", SerializeInfo);
Obj["HasFunctions"] = true;
}

if (!I.Children.Concepts.empty())
serializeArray(I.Children.Concepts, Obj, "Concepts", SerializeInfo);


+ 3
- 0
clang-tools-extra/clang-doc/assets/class-template.mustache View File

@@ -107,6 +107,9 @@
<div class="resizer" id="resizer"></div>
<div class="content">
<section class="hero section-container">
{{#Template}}
<pre><code class="language-cpp code-clang-doc">template &lt;{{#Parameters}}{{Param}}{{^End}}, {{/End}}{{/Parameters}}&gt;</code></pre>
{{/Template}}
<div class="hero__title">
<h1 class="hero__title-large">{{TagType}} {{Name}}</h1>
<p>Defined at line {{Location.LineNumber}} of file {{Location.Filename}}</p>


+ 5
- 1
clang-tools-extra/clang-doc/assets/function-template.mustache View File

@@ -7,13 +7,17 @@
}}
<div class="delimiter-container">
<div id="{{USR}}">
{{#Template}}
<pre><code class="language-cpp code-clang-doc">template &lt;{{#Parameters}}{{Param}}{{^End}}, {{/End}}{{/Parameters}}&gt;</code></pre>
{{/Template}}
{{! Function Prototype }}
<pre><code class="language-cpp code-clang-doc">{{ReturnType.Name}} {{Name}} ({{#Params}}{{^End}}{{Type}} {{Name}}, {{/End}}{{#End}}{{Type}} {{Name}}{{/End}}{{/Params}})</code></pre>
<pre><code class="language-cpp code-clang-doc">{{ReturnType.Name}} {{Name}}{{#Template}}{{#Specialization}}&lt;{{#Parameters}}{{Param}}{{^End}}, {{/End}}{{/Parameters}}&gt;{{/Specialization}}{{/Template}} ({{#Params}}{{^End}}{{Type}} {{Name}}, {{/End}}{{#End}}{{Type}} {{Name}}{{/End}}{{/Params}})</code></pre>
{{! Function Comments }}
{{#Description}}
<div>
{{>Comments}}
</div>
{{/Description}}
<p>Defined at line {{Location.LineNumber}} of file {{Location.Filename}}</p>
</div>
</div>

+ 26
- 0
clang-tools-extra/clang-doc/assets/namespace-template.mustache View File

@@ -43,6 +43,20 @@
</ul>
</li>
{{/HasRecords}}
{{#HasFunctions}}
<li class="sidebar-section">
<a class="sidebar-item" href="#Functions">Functions</a>
</li>
<li>
<ul>
{{#Functions}}
<li class="sidebar-item-container">
<a class="sidebar-item" href="#{{USR}}">{{Name}}{{#Template}}{{#Specialization}}&lt;{{#Parameters}}{{Param}}{{^End}}, {{/End}}{{/Parameters}}&gt;{{/Specialization}}{{/Template}}</a>
</li>
{{/Functions}}
</ul>
</li>
{{/HasFunctions}}
</ul>
</div>
<div class="resizer" id="resizer"></div>
@@ -71,6 +85,18 @@
</ul>
</section>
{{/HasRecords}}
{{#HasFunctions}}
<section id="Functions" class="section-container">
<h2>Functions</h2>
<ul class="class-container">
{{#Functions}}
<li>
{{>FunctionPartial}}
</li>
{{/Functions}}
</ul>
</section>
{{/HasFunctions}}
</div>
</div>
</main>


+ 0
- 4
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h View File

@@ -91,10 +91,6 @@ public:
ClangTidyContext &operator=(const ClangTidyContext &) = delete;

/// Report any errors detected using this method.
///
/// This is still under heavy development and will likely change towards using
/// tablegen'd diagnostic IDs.
/// FIXME: Figure out a way to manage ID spaces.
DiagnosticBuilder diag(StringRef CheckName, SourceLocation Loc,
StringRef Description,
DiagnosticIDs::Level Level = DiagnosticIDs::Warning);


+ 14
- 12
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp View File

@@ -178,12 +178,13 @@ template <> struct MappingTraits<ClangTidyOptions::CustomCheckValue> {
}
};

struct ChecksVariant {
struct GlobListVariant {
std::optional<std::string> AsString;
std::optional<std::vector<std::string>> AsVector;
};

template <> void yamlize(IO &IO, ChecksVariant &Val, bool, EmptyContext &Ctx) {
template <>
void yamlize(IO &IO, GlobListVariant &Val, bool, EmptyContext &Ctx) {
if (!IO.outputting()) {
// Special case for reading from YAML
// Must support reading from both a string or a list
@@ -200,25 +201,26 @@ template <> void yamlize(IO &IO, ChecksVariant &Val, bool, EmptyContext &Ctx) {
}
}

static void mapChecks(IO &IO, std::optional<std::string> &Checks) {
static void mapGlobList(IO &IO, std::optional<std::string> &GlobList,
StringRef Key) {
if (IO.outputting()) {
// Output always a string
IO.mapOptional("Checks", Checks);
IO.mapOptional(Key, GlobList);
} else {
// Input as either a string or a list
ChecksVariant ChecksAsVariant;
IO.mapOptional("Checks", ChecksAsVariant);
if (ChecksAsVariant.AsString)
Checks = ChecksAsVariant.AsString;
else if (ChecksAsVariant.AsVector)
Checks = llvm::join(*ChecksAsVariant.AsVector, ",");
GlobListVariant GlobListAsVariant;
IO.mapOptional(Key, GlobListAsVariant);
if (GlobListAsVariant.AsString)
GlobList = GlobListAsVariant.AsString;
else if (GlobListAsVariant.AsVector)
GlobList = llvm::join(*GlobListAsVariant.AsVector, ",");
}
}

template <> struct MappingTraits<ClangTidyOptions> {
static void mapping(IO &IO, ClangTidyOptions &Options) {
mapChecks(IO, Options.Checks);
IO.mapOptional("WarningsAsErrors", Options.WarningsAsErrors);
mapGlobList(IO, Options.Checks, "Checks");
mapGlobList(IO, Options.WarningsAsErrors, "WarningsAsErrors");
IO.mapOptional("HeaderFileExtensions", Options.HeaderFileExtensions);
IO.mapOptional("ImplementationFileExtensions",
Options.ImplementationFileExtensions);


+ 14
- 42
clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp View File

@@ -29,21 +29,14 @@ using SwitchBranch = llvm::SmallVector<const Stmt *, 2>;
static bool areSwitchBranchesIdentical(const SwitchBranch &LHS,
const SwitchBranch &RHS,
const ASTContext &Context) {
if (LHS.size() != RHS.size())
return false;

for (size_t I = 0, Size = LHS.size(); I < Size; I++) {
return llvm::equal(LHS, RHS, [&](const Stmt *S1, const Stmt *S2) {
// NOTE: We strip goto labels and annotations in addition to stripping
// the `case X:` or `default:` labels, but it is very unlikely that this
// would cause false positives in real-world code.
if (!tidy::utils::areStatementsIdentical(LHS[I]->stripLabelLikeStatements(),
RHS[I]->stripLabelLikeStatements(),
Context)) {
return false;
}
}

return true;
return tidy::utils::areStatementsIdentical(S1->stripLabelLikeStatements(),
S2->stripLabelLikeStatements(),
Context);
});
}

static bool isFallthroughSwitchBranch(const SwitchBranch &Branch) {
@@ -137,19 +130,10 @@ static bool isIdenticalStmt(const ASTContext &Ctx, const Stmt *Stmt1,
return false;

// If all children of two expressions are identical, return true.
Expr::const_child_iterator I1 = Expr1->child_begin();
Expr::const_child_iterator I2 = Expr2->child_begin();
while (I1 != Expr1->child_end() && I2 != Expr2->child_end()) {
if (!isIdenticalStmt(Ctx, *I1, *I2, IgnoreSideEffects))
return false;
++I1;
++I2;
}
// If there are different number of children in the statements, return
// false.
if (I1 != Expr1->child_end())
return false;
if (I2 != Expr2->child_end())
if (!llvm::equal(Expr1->children(), Expr2->children(),
[&](const Stmt *S1, const Stmt *S2) {
return isIdenticalStmt(Ctx, S1, S2, IgnoreSideEffects);
}))
return false;
}

@@ -246,22 +230,10 @@ static bool isIdenticalStmt(const ASTContext &Ctx, const Stmt *Stmt1,
case Stmt::CompoundStmtClass: {
const auto *CompStmt1 = cast<CompoundStmt>(Stmt1);
const auto *CompStmt2 = cast<CompoundStmt>(Stmt2);

if (CompStmt1->size() != CompStmt2->size())
return false;

if (!llvm::all_of(llvm::zip(CompStmt1->body(), CompStmt2->body()),
[&Ctx, IgnoreSideEffects](
std::tuple<const Stmt *, const Stmt *> StmtPair) {
const Stmt *Stmt0 = std::get<0>(StmtPair);
const Stmt *Stmt1 = std::get<1>(StmtPair);
return isIdenticalStmt(Ctx, Stmt0, Stmt1,
IgnoreSideEffects);
})) {
return false;
}

return true;
return llvm::equal(CompStmt1->body(), CompStmt2->body(),
[&](const Stmt *S1, const Stmt *S2) {
return isIdenticalStmt(Ctx, S1, S2, IgnoreSideEffects);
});
}
case Stmt::CompoundAssignOperatorClass:
case Stmt::BinaryOperatorClass: {
@@ -456,7 +428,7 @@ void BranchCloneCheck::check(const MatchFinder::MatchResult &Result) {

diag(BeginCurrent->front()->getBeginLoc(),
"switch has %0 consecutive identical branches")
<< static_cast<int>(std::distance(BeginCurrent, EndCurrent));
<< std::distance(BeginCurrent, EndCurrent);

SourceLocation EndLoc = (EndCurrent - 1)->back()->getEndLoc();
// If the case statement is generated from a macro, it's SourceLocation


+ 12
- 0
clang-tools-extra/clang-tidy/bugprone/ChainedComparisonCheck.cpp View File

@@ -112,6 +112,15 @@ void ChainedComparisonData::extract(const Expr *Op) {
}
}

ChainedComparisonCheck::ChainedComparisonCheck(StringRef Name,
ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
IgnoreMacros(Options.get("IgnoreMacros", false)) {}

void ChainedComparisonCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
Options.store(Opts, "IgnoreMacros", IgnoreMacros);
}

void ChainedComparisonCheck::registerMatchers(MatchFinder *Finder) {
const auto OperatorMatcher = expr(anyOf(
binaryOperator(isComparisonOperator(),
@@ -128,6 +137,9 @@ void ChainedComparisonCheck::registerMatchers(MatchFinder *Finder) {
void ChainedComparisonCheck::check(const MatchFinder::MatchResult &Result) {
const auto *MatchedOperator = Result.Nodes.getNodeAs<Expr>("op");

if (IgnoreMacros && MatchedOperator->getBeginLoc().isMacroID())
return;

ChainedComparisonData Data(MatchedOperator);
if (Data.Operands.empty())
return;


+ 5
- 2
clang-tools-extra/clang-tidy/bugprone/ChainedComparisonCheck.h View File

@@ -20,13 +20,16 @@ namespace clang::tidy::bugprone {
/// https://clang.llvm.org/extra/clang-tidy/checks/bugprone/chained-comparison.html
class ChainedComparisonCheck : public ClangTidyCheck {
public:
ChainedComparisonCheck(StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context) {}
ChainedComparisonCheck(StringRef Name, ClangTidyContext *Context);
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
std::optional<TraversalKind> getCheckTraversalKind() const override {
return TK_IgnoreUnlessSpelledInSource;
}

private:
const bool IgnoreMacros;
};

} // namespace clang::tidy::bugprone


+ 1
- 1
clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt View File

@@ -7,7 +7,6 @@ add_clang_library(clangTidyFuchsiaModule STATIC
DefaultArgumentsCallsCheck.cpp
DefaultArgumentsDeclarationsCheck.cpp
FuchsiaTidyModule.cpp
MultipleInheritanceCheck.cpp
OverloadedOperatorCheck.cpp
StaticallyConstructedObjectsCheck.cpp
TemporaryObjectsCheck.cpp
@@ -17,6 +16,7 @@ add_clang_library(clangTidyFuchsiaModule STATIC
LINK_LIBS
clangTidy
clangTidyGoogleModule
clangTidyMiscModule
clangTidyUtils

DEPENDS


+ 2
- 2
clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp View File

@@ -10,9 +10,9 @@
#include "../ClangTidyModule.h"
#include "../ClangTidyModuleRegistry.h"
#include "../google/UnnamedNamespaceInHeaderCheck.h"
#include "../misc/MultipleInheritanceCheck.h"
#include "DefaultArgumentsCallsCheck.h"
#include "DefaultArgumentsDeclarationsCheck.h"
#include "MultipleInheritanceCheck.h"
#include "OverloadedOperatorCheck.h"
#include "StaticallyConstructedObjectsCheck.h"
#include "TemporaryObjectsCheck.h"
@@ -34,7 +34,7 @@ public:
"fuchsia-default-arguments-declarations");
CheckFactories.registerCheck<google::build::UnnamedNamespaceInHeaderCheck>(
"fuchsia-header-anon-namespaces");
CheckFactories.registerCheck<MultipleInheritanceCheck>(
CheckFactories.registerCheck<misc::MultipleInheritanceCheck>(
"fuchsia-multiple-inheritance");
CheckFactories.registerCheck<OverloadedOperatorCheck>(
"fuchsia-overloaded-operator");


+ 1
- 0
clang-tools-extra/clang-tidy/misc/CMakeLists.txt View File

@@ -28,6 +28,7 @@ add_clang_library(clangTidyMiscModule STATIC
MisleadingBidirectionalCheck.cpp
MisleadingIdentifierCheck.cpp
MisplacedConstCheck.cpp
MultipleInheritanceCheck.cpp
NewDeleteOverloadsCheck.cpp
NoRecursionCheck.cpp
NonCopyableObjectsCheck.cpp


+ 3
- 0
clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp View File

@@ -18,6 +18,7 @@
#include "MisleadingBidirectionalCheck.h"
#include "MisleadingIdentifierCheck.h"
#include "MisplacedConstCheck.h"
#include "MultipleInheritanceCheck.h"
#include "NewDeleteOverloadsCheck.h"
#include "NoRecursionCheck.h"
#include "NonCopyableObjectsCheck.h"
@@ -57,6 +58,8 @@ public:
CheckFactories.registerCheck<MisleadingIdentifierCheck>(
"misc-misleading-identifier");
CheckFactories.registerCheck<MisplacedConstCheck>("misc-misplaced-const");
CheckFactories.registerCheck<MultipleInheritanceCheck>(
"misc-multiple-inheritance");
CheckFactories.registerCheck<NewDeleteOverloadsCheck>(
"misc-new-delete-overloads");
CheckFactories.registerCheck<NoRecursionCheck>("misc-no-recursion");


clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp → clang-tools-extra/clang-tidy/misc/MultipleInheritanceCheck.cpp View File

@@ -13,7 +13,7 @@
using namespace clang;
using namespace clang::ast_matchers;

namespace clang::tidy::fuchsia {
namespace clang::tidy::misc {

namespace {
AST_MATCHER(CXXRecordDecl, hasBases) {
@@ -74,4 +74,4 @@ void MultipleInheritanceCheck::check(const MatchFinder::MatchResult &Result) {
"pure virtual is discouraged");
}

} // namespace clang::tidy::fuchsia
} // namespace clang::tidy::misc

clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.h → clang-tools-extra/clang-tidy/misc/MultipleInheritanceCheck.h View File

@@ -6,17 +6,17 @@
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_MULTIPLEINHERITANCECHECK_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_MULTIPLEINHERITANCECHECK_H
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MULTIPLEINHERITANCECHECK_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MULTIPLEINHERITANCECHECK_H

#include "../ClangTidyCheck.h"

namespace clang::tidy::fuchsia {
namespace clang::tidy::misc {

/// Multiple implementation inheritance is discouraged.
///
/// For the user-facing documentation see:
/// https://clang.llvm.org/extra/clang-tidy/checks/fuchsia/multiple-inheritance.html
/// https://clang.llvm.org/extra/clang-tidy/checks/misc/multiple-inheritance.html
class MultipleInheritanceCheck : public ClangTidyCheck {
public:
MultipleInheritanceCheck(StringRef Name, ClangTidyContext *Context)
@@ -38,6 +38,6 @@ private:
llvm::DenseMap<const CXXRecordDecl *, bool> InterfaceMap;
};

} // namespace clang::tidy::fuchsia
} // namespace clang::tidy::misc

#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_MULTIPLEINHERITANCECHECK_H
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MULTIPLEINHERITANCECHECK_H

+ 30
- 34
clang-tools-extra/clang-tidy/readability/RedundantTypenameCheck.cpp View File

@@ -18,9 +18,9 @@ using namespace clang::ast_matchers;
namespace clang::tidy::readability {

void RedundantTypenameCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(typeLoc(unless(hasAncestor(decl(isInstantiated()))))
.bind("nonDependentTypeLoc"),
this);
Finder->addMatcher(
typeLoc(unless(hasAncestor(decl(isInstantiated())))).bind("typeLoc"),
this);

if (!getLangOpts().CPlusPlus20)
return;
@@ -44,38 +44,34 @@ void RedundantTypenameCheck::registerMatchers(MatchFinder *Finder) {
}

void RedundantTypenameCheck::check(const MatchFinder::MatchResult &Result) {
const TypeLoc TL = [&] {
if (const auto *TL = Result.Nodes.getNodeAs<TypeLoc>("typeLoc"))
return TL->getType()->isDependentType() ? TypeLoc() : *TL;

auto TL = *Result.Nodes.getNodeAs<TypeLoc>("dependentTypeLoc");
while (const TypeLoc Next = TL.getNextTypeLoc())
TL = Next;
return TL;
}();

if (TL.isNull())
return;

const SourceLocation ElaboratedKeywordLoc = [&] {
if (const auto *NonDependentTypeLoc =
Result.Nodes.getNodeAs<TypeLoc>("nonDependentTypeLoc")) {
if (NonDependentTypeLoc->getType()->isDependentType())
return SourceLocation();

if (const auto TL = NonDependentTypeLoc->getAs<TypedefTypeLoc>())
return TL.getElaboratedKeywordLoc();

if (const auto TL = NonDependentTypeLoc->getAs<TagTypeLoc>())
return TL.getElaboratedKeywordLoc();

if (const auto TL = NonDependentTypeLoc
->getAs<DeducedTemplateSpecializationTypeLoc>())
return TL.getElaboratedKeywordLoc();

if (const auto TL =
NonDependentTypeLoc->getAs<TemplateSpecializationTypeLoc>())
return TL.getElaboratedKeywordLoc();
} else {
TypeLoc InnermostTypeLoc =
*Result.Nodes.getNodeAs<TypeLoc>("dependentTypeLoc");
while (const TypeLoc Next = InnermostTypeLoc.getNextTypeLoc())
InnermostTypeLoc = Next;

if (const auto TL = InnermostTypeLoc.getAs<DependentNameTypeLoc>())
return TL.getElaboratedKeywordLoc();

if (const auto TL =
InnermostTypeLoc.getAs<TemplateSpecializationTypeLoc>())
return TL.getElaboratedKeywordLoc();
}
if (const auto CastTL = TL.getAs<TypedefTypeLoc>())
return CastTL.getElaboratedKeywordLoc();

if (const auto CastTL = TL.getAs<TagTypeLoc>())
return CastTL.getElaboratedKeywordLoc();

if (const auto CastTL = TL.getAs<DeducedTemplateSpecializationTypeLoc>())
return CastTL.getElaboratedKeywordLoc();

if (const auto CastTL = TL.getAs<TemplateSpecializationTypeLoc>())
return CastTL.getElaboratedKeywordLoc();

if (const auto CastTL = TL.getAs<DependentNameTypeLoc>())
return CastTL.getElaboratedKeywordLoc();

return SourceLocation();
}();


+ 2
- 0
clang-tools-extra/clangd/ClangdLSPServer.cpp View File

@@ -554,6 +554,8 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
if (const auto &Dir = Params.initializationOptions.compilationDatabasePath)
CDBOpts.CompileCommandsDir = Dir;
CDBOpts.ContextProvider = Opts.ContextProvider;
if (Opts.StrongWorkspaceMode)
CDBOpts.applyFallbackWorkingDirectory(Opts.WorkspaceRoot);
BaseCDB =
std::make_unique<DirectoryBasedGlobalCompilationDatabase>(CDBOpts);
}


+ 1
- 0
clang-tools-extra/clangd/ClangdServer.cpp View File

@@ -458,6 +458,7 @@ void ClangdServer::codeComplete(PathRef File, Position Pos,
CodeCompleteOpts.InsertIncludes =
Config::current().Completion.HeaderInsertion;
CodeCompleteOpts.CodePatterns = Config::current().Completion.CodePatterns;
CodeCompleteOpts.MacroFilter = Config::current().Completion.MacroFilter;
// FIXME(ibiryukov): even if Preamble is non-null, we may want to check
// both the old and the new version in case only one of them matches.
CodeCompleteResult Result = clangd::codeComplete(


+ 5
- 0
clang-tools-extra/clangd/ClangdServer.h View File

@@ -152,6 +152,11 @@ public:
/// FIXME: If not set, should use the current working directory.
std::optional<std::string> WorkspaceRoot;

/// Sets an alternate mode of operation. Current effects are:
/// - Using the current working directory as the working directory for
/// fallback commands
bool StrongWorkspaceMode = false;

/// The resource directory is used to find internal headers, overriding
/// defaults and -resource-dir compiler flag).
/// If std::nullopt, ClangdServer calls


+ 21
- 5
clang-tools-extra/clangd/CodeComplete.cpp View File

@@ -1435,7 +1435,8 @@ bool semaCodeComplete(std::unique_ptr<CodeCompleteConsumer> Consumer,
Clang->setCodeCompletionConsumer(Consumer.release());

if (Input.Preamble.RequiredModules)
Input.Preamble.RequiredModules->adjustHeaderSearchOptions(Clang->getHeaderSearchOpts());
Input.Preamble.RequiredModules->adjustHeaderSearchOptions(
Clang->getHeaderSearchOpts());

SyntaxOnlyAction Action;
if (!Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0])) {
@@ -2037,13 +2038,28 @@ private:
}

std::optional<float> fuzzyScore(const CompletionCandidate &C) {
// Macros can be very spammy, so we only support prefix completion.
if (((C.SemaResult &&
using MacroFilterPolicy = Config::MacroFilterPolicy;

const auto IsMacroResult =
((C.SemaResult &&
C.SemaResult->Kind == CodeCompletionResult::RK_Macro) ||
(C.IndexResult &&
C.IndexResult->SymInfo.Kind == index::SymbolKind::Macro)) &&
!C.Name.starts_with_insensitive(Filter->pattern()))
C.IndexResult->SymInfo.Kind == index::SymbolKind::Macro));

if (!IsMacroResult)
return Filter->match(C.Name);

// macros with underscores are probably noisy, so don't suggest them
bool RequireExactPrefix =
Opts.MacroFilter == MacroFilterPolicy::ExactPrefix ||
C.Name.starts_with_insensitive("_") ||
C.Name.ends_with_insensitive("_");

if (RequireExactPrefix &&
!C.Name.starts_with_insensitive(Filter->pattern())) {
return std::nullopt;
}

return Filter->match(C.Name);
}



+ 5
- 0
clang-tools-extra/clangd/CodeComplete.h View File

@@ -114,6 +114,11 @@ struct CodeCompleteOptions {
/// Whether to suggest code patterns & snippets or not in completion
Config::CodePatternsPolicy CodePatterns = Config::CodePatternsPolicy::All;

/// Filter macros using an exact prefix, or with a fuzzy match. In both cases,
/// macros with leading or trailing underscores are strictly filtered
Config::MacroFilterPolicy MacroFilter =
Config::MacroFilterPolicy::ExactPrefix;

/// Whether to use the clang parser, or fallback to text-based completion
/// (using identifiers in the current file and symbol indexes).
enum CodeCompletionParse {


+ 8
- 0
clang-tools-extra/clangd/Config.h View File

@@ -157,6 +157,12 @@ struct Config {
None // Suggest none of the code patterns and snippets
};

enum class MacroFilterPolicy {
ExactPrefix, // Suggest macros if the prefix matches exactly
FuzzyMatch, // Fuzzy-match macros if they do not have "_" as prefix or
// suffix
};

/// Configures code completion feature.
struct {
/// Whether code completion includes results that are not visible in current
@@ -168,6 +174,8 @@ struct Config {
HeaderInsertionPolicy HeaderInsertion = HeaderInsertionPolicy::IWYU;
/// Enables code patterns & snippets suggestions
CodePatternsPolicy CodePatterns = CodePatternsPolicy::All;
/// Controls how macros are filtered
MacroFilterPolicy MacroFilter = MacroFilterPolicy::ExactPrefix;
} Completion;

/// Configures hover feature.


+ 16
- 4
clang-tools-extra/clangd/ConfigCompile.cpp View File

@@ -564,10 +564,10 @@ struct FragmentCompiler {
auto Fast = isFastTidyCheck(Str);
if (!Fast.has_value()) {
diag(Warning,
llvm::formatv(
"Latency of clang-tidy check '{0}' is not known. "
"It will only run if ClangTidy.FastCheckFilter is Loose or None",
Str)
llvm::formatv("Latency of clang-tidy check '{0}' is not known. "
"It will only run if ClangTidy.FastCheckFilter is "
"Loose or None",
Str)
.str(),
Arg.Range);
} else if (!*Fast) {
@@ -719,6 +719,18 @@ struct FragmentCompiler {
C.Completion.CodePatterns = *Val;
});
}

if (F.MacroFilter) {
if (auto Val =
compileEnum<Config::MacroFilterPolicy>("MacroFilter",
*F.MacroFilter)
.map("ExactPrefix", Config::MacroFilterPolicy::ExactPrefix)
.map("FuzzyMatch", Config::MacroFilterPolicy::FuzzyMatch)
.value())
Out.Apply.push_back([Val](const Params &, Config &C) {
C.Completion.MacroFilter = *Val;
});
}
}

void compile(Fragment::HoverBlock &&F) {


+ 6
- 0
clang-tools-extra/clangd/ConfigFragment.h View File

@@ -354,6 +354,12 @@ struct Fragment {
/// All => enable all code patterns and snippets suggestion
/// None => disable all code patterns and snippets suggestion
std::optional<Located<std::string>> CodePatterns;
/// How to filter macros before offering them as suggestions
/// Values are Config::MacroFilterPolicy:
/// ExactPrefix: Suggest macros if the prefix matches exactly
/// FuzzyMatch: Fuzzy-match macros if they do not have "_" as prefix or
/// suffix
std::optional<Located<std::string>> MacroFilter;
};
CompletionBlock Completion;



+ 4
- 0
clang-tools-extra/clangd/ConfigYAML.cpp View File

@@ -255,6 +255,10 @@ private:
if (auto CodePatterns = scalarValue(N, "CodePatterns"))
F.CodePatterns = *CodePatterns;
});
Dict.handle("MacroFilter", [&](Node &N) {
if (auto MacroFilter = scalarValue(N, "MacroFilter"))
F.MacroFilter = *MacroFilter;
});
Dict.parse(N);
}



+ 32
- 9
clang-tools-extra/clangd/GlobalCompilationDatabase.cpp View File

@@ -64,7 +64,9 @@ GlobalCompilationDatabase::getFallbackCommand(PathRef File) const {
if (FileExtension.empty() || FileExtension == ".h")
Argv.push_back("-xobjective-c++-header");
Argv.push_back(std::string(File));
tooling::CompileCommand Cmd(llvm::sys::path::parent_path(File),
tooling::CompileCommand Cmd(FallbackWorkingDirectory
? *FallbackWorkingDirectory
: llvm::sys::path::parent_path(File),
llvm::sys::path::filename(File), std::move(Argv),
/*Output=*/"");
Cmd.Heuristic = "clangd fallback";
@@ -349,7 +351,8 @@ bool DirectoryBasedGlobalCompilationDatabase::DirectoryCache::load(

DirectoryBasedGlobalCompilationDatabase::
DirectoryBasedGlobalCompilationDatabase(const Options &Opts)
: Opts(Opts), Broadcaster(std::make_unique<BroadcastThread>(*this)) {
: GlobalCompilationDatabase(Opts.FallbackWorkingDirectory), Opts(Opts),
Broadcaster(std::make_unique<BroadcastThread>(*this)) {
if (!this->Opts.ContextProvider)
this->Opts.ContextProvider = [](llvm::StringRef) {
return Context::current().clone();
@@ -460,6 +463,21 @@ DirectoryBasedGlobalCompilationDatabase::lookupCDB(
return Result;
}

void DirectoryBasedGlobalCompilationDatabase::Options::
applyFallbackWorkingDirectory(
std::optional<std::string> FallbackWorkingDirectory) {
if (FallbackWorkingDirectory)
this->FallbackWorkingDirectory = *FallbackWorkingDirectory;
else {
// Clangd is running in strong workspace mode but the client didn't
// specify a workspace path in the `initialize` request.
// Fallback to current working directory.
SmallString<256> CWD;
llvm::sys::fs::current_path(CWD);
this->FallbackWorkingDirectory = std::string(CWD);
}
}

// The broadcast thread announces files with new compile commands to the world.
// Primarily this is used to enqueue them for background indexing.
//
@@ -759,9 +777,10 @@ DirectoryBasedGlobalCompilationDatabase::getProjectModules(PathRef File) const {

OverlayCDB::OverlayCDB(const GlobalCompilationDatabase *Base,
std::vector<std::string> FallbackFlags,
CommandMangler Mangler)
: DelegatingCDB(Base), Mangler(std::move(Mangler)),
FallbackFlags(std::move(FallbackFlags)) {}
CommandMangler Mangler,
std::optional<std::string> FallbackWorkingDirectory)
: DelegatingCDB(Base, FallbackWorkingDirectory),
Mangler(std::move(Mangler)), FallbackFlags(std::move(FallbackFlags)) {}

std::optional<tooling::CompileCommand>
OverlayCDB::getCompileCommand(PathRef File) const {
@@ -844,16 +863,20 @@ OverlayCDB::getProjectModules(PathRef File) const {
return MDB;
}

DelegatingCDB::DelegatingCDB(const GlobalCompilationDatabase *Base)
: Base(Base) {
DelegatingCDB::DelegatingCDB(
const GlobalCompilationDatabase *Base,
std::optional<std::string> FallbackWorkingDirectory)
: GlobalCompilationDatabase(FallbackWorkingDirectory), Base(Base) {
if (Base)
BaseChanged = Base->watch([this](const std::vector<std::string> Changes) {
OnCommandChanged.broadcast(Changes);
});
}

DelegatingCDB::DelegatingCDB(std::unique_ptr<GlobalCompilationDatabase> Base)
: DelegatingCDB(Base.get()) {
DelegatingCDB::DelegatingCDB(
std::unique_ptr<GlobalCompilationDatabase> Base,
std::optional<std::string> FallbackWorkingDirectory)
: DelegatingCDB(Base.get(), FallbackWorkingDirectory) {
BaseOwner = std::move(Base);
}



+ 21
- 5
clang-tools-extra/clangd/GlobalCompilationDatabase.h View File

@@ -35,6 +35,9 @@ struct ProjectInfo {
/// Provides compilation arguments used for parsing C and C++ files.
class GlobalCompilationDatabase {
public:
GlobalCompilationDatabase(
std::optional<std::string> FallbackWorkingDirectory = std::nullopt)
: FallbackWorkingDirectory(FallbackWorkingDirectory) {}
virtual ~GlobalCompilationDatabase() = default;

/// If there are any known-good commands for building this file, returns one.
@@ -69,14 +72,19 @@ public:
}

protected:
std::optional<std::string> FallbackWorkingDirectory;
mutable CommandChanged OnCommandChanged;
};

// Helper class for implementing GlobalCompilationDatabases that wrap others.
class DelegatingCDB : public GlobalCompilationDatabase {
public:
DelegatingCDB(const GlobalCompilationDatabase *Base);
DelegatingCDB(std::unique_ptr<GlobalCompilationDatabase> Base);
DelegatingCDB(
const GlobalCompilationDatabase *Base,
std::optional<std::string> FallbackWorkingDirectory = std::nullopt);
DelegatingCDB(
std::unique_ptr<GlobalCompilationDatabase> Base,
std::optional<std::string> FallbackWorkingDirectory = std::nullopt);

std::optional<tooling::CompileCommand>
getCompileCommand(PathRef File) const override;
@@ -117,6 +125,12 @@ public:
// Only look for a compilation database in this one fixed directory.
// FIXME: fold this into config/context mechanism.
std::optional<Path> CompileCommandsDir;
// Working directory for fallback commands
// If unset, parent directory of file should be used
std::optional<std::string> FallbackWorkingDirectory;

void applyFallbackWorkingDirectory(
std::optional<std::string> FallbackWorkingDirectory);
};

DirectoryBasedGlobalCompilationDatabase(const Options &Opts);
@@ -194,9 +208,11 @@ public:
// Base may be null, in which case no entries are inherited.
// FallbackFlags are added to the fallback compile command.
// Adjuster is applied to all commands, fallback or not.
OverlayCDB(const GlobalCompilationDatabase *Base,
std::vector<std::string> FallbackFlags = {},
CommandMangler Mangler = nullptr);
OverlayCDB(
const GlobalCompilationDatabase *Base,
std::vector<std::string> FallbackFlags = {},
CommandMangler Mangler = nullptr,
std::optional<std::string> FallbackWorkingDirectory = std::nullopt);

std::optional<tooling::CompileCommand>
getCompileCommand(PathRef File) const override;


+ 6
- 2
clang-tools-extra/clangd/tool/Check.cpp View File

@@ -169,6 +169,8 @@ public:
bool buildCommand(const ThreadsafeFS &TFS) {
log("Loading compilation database...");
DirectoryBasedGlobalCompilationDatabase::Options CDBOpts(TFS);
if (Opts.StrongWorkspaceMode)
CDBOpts.applyFallbackWorkingDirectory(Opts.WorkspaceRoot);
CDBOpts.CompileCommandsDir =
Config::current().CompileFlags.CDBSearch.FixedCDBPath;
BaseCDB =
@@ -178,8 +180,10 @@ public:
getSystemIncludeExtractor(llvm::ArrayRef(Opts.QueryDriverGlobs));
if (Opts.ResourceDir)
Mangler.ResourceDir = *Opts.ResourceDir;

CDB = std::make_unique<OverlayCDB>(
BaseCDB.get(), std::vector<std::string>{}, std::move(Mangler));
BaseCDB.get(), std::vector<std::string>{}, std::move(Mangler),
CDBOpts.FallbackWorkingDirectory);

if (auto TrueCmd = CDB->getCompileCommand(File)) {
Cmd = std::move(*TrueCmd);
@@ -502,7 +506,7 @@ bool check(llvm::StringRef File, const ThreadsafeFS &TFS,
config::DiagnosticCallback Diag) const override {
config::Fragment F;
// If we're timing clang-tidy checks, implicitly disabling the slow ones
// is counterproductive!
// is counterproductive!
if (CheckTidyTime.getNumOccurrences())
F.Diagnostics.ClangTidy.FastCheckFilter.emplace("None");
return {std::move(F).compile(Diag)};


+ 12
- 0
clang-tools-extra/clangd/tool/ClangdMain.cpp View File

@@ -500,6 +500,17 @@ opt<bool> EnableConfig{
init(true),
};

opt<bool> StrongWorkspaceMode{
"strong-workspace-mode",
cat(Features),
desc("An alternate mode of operation for clangd, where the clangd instance "
"is used to edit a single workspace.\n"
"When enabled, fallback commands use the workspace directory as their "
"working directory instead of the parent folder."),
init(false),
Hidden,
};

opt<bool> UseDirtyHeaders{"use-dirty-headers", cat(Misc),
desc("Use files open in the editor when parsing "
"headers instead of reading from the disk"),
@@ -907,6 +918,7 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var
}
if (!ResourceDir.empty())
Opts.ResourceDir = ResourceDir;
Opts.StrongWorkspaceMode = StrongWorkspaceMode;
Opts.BuildDynamicSymbolIndex = true;
#if CLANGD_ENABLE_REMOTE
if (RemoteIndexAddress.empty() != ProjectRoot.empty()) {


+ 58
- 0
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp View File

@@ -4692,6 +4692,64 @@ TEST(CompletionTest, ListExplicitObjectOverloads) {
}
}

TEST(CompletionTest, FuzzyMatchMacro) {
Annotations Code(R"cpp(
#define gl_foo() 42
#define _gl_foo() 42
#define glfbar() 42

int gl_frob();
int _gl_frob();

int main() {
int y = glf$c1^;
int y = _gl$c2^;
}
)cpp");

auto TU = TestTU::withCode(Code.code());

// Exact prefix should match macro or symbol
{
CodeCompleteOptions Opts{};
EXPECT_EQ(Opts.MacroFilter, Config::MacroFilterPolicy::ExactPrefix);

{
auto Results = completions(TU, Code.point("c1"), {}, Opts);
EXPECT_THAT(
Results.Completions,
ElementsAre(named("gl_frob"), named("_gl_frob"), named("glfbar")));
}

{
auto Results = completions(TU, Code.point("c2"), {}, Opts);
EXPECT_THAT(Results.Completions,
ElementsAre(named("_gl_frob"), named("_gl_foo")));
}
}

// but with fuzzy match
{
CodeCompleteOptions Opts{};
Opts.MacroFilter = Config::MacroFilterPolicy::FuzzyMatch;

// don't suggest underscore macros in general,
{
auto Results = completions(TU, Code.point("c1"), {}, Opts);
EXPECT_THAT(Results.Completions,
ElementsAre(named("gl_frob"), named("_gl_frob"),
named("glfbar"), named("gl_foo")));
}

// but do suggest when macro contains exact prefix
{
auto Results = completions(TU, Code.point("c2"), {}, Opts);
EXPECT_THAT(Results.Completions,
ElementsAre(named("_gl_frob"), named("_gl_foo")));
}
}
}

} // namespace
} // namespace clangd
} // namespace clang

+ 14
- 0
clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp View File

@@ -228,6 +228,20 @@ TEST(ParseYAML, CodePatterns) {
EXPECT_THAT(Results[0].Completion.CodePatterns, llvm::ValueIs(val("None")));
}

TEST(ParseYAML, MacroFilter) {
CapturedDiags Diags;
Annotations YAML(R"yaml(
Completion:
MacroFilter: FuzzyMatch
)yaml");
auto Results =
Fragment::parseYAML(YAML.code(), "config.yaml", Diags.callback());
ASSERT_THAT(Diags.Diagnostics, IsEmpty());
ASSERT_EQ(Results.size(), 1u);
EXPECT_THAT(Results[0].Completion.MacroFilter,
llvm::ValueIs(val("FuzzyMatch")));
}

TEST(ParseYAML, Hover) {
CapturedDiags Diags;
Annotations YAML(R"yaml(


+ 14
- 0
clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp View File

@@ -55,6 +55,20 @@ TEST(GlobalCompilationDatabaseTest, FallbackCommand) {
testPath("foo/bar")));
}

TEST(GlobalCompilationDatabaseTest, FallbackWorkingDirectory) {
MockFS TFS;
DirectoryBasedGlobalCompilationDatabase::Options CDBOpts(TFS);
CDBOpts.applyFallbackWorkingDirectory(testPath("foo"));
EXPECT_EQ(CDBOpts.FallbackWorkingDirectory, testPath("foo"));

DirectoryBasedGlobalCompilationDatabase DB(CDBOpts);
auto Cmd = DB.getFallbackCommand(testPath("foo/src/bar.cc"));
EXPECT_EQ(Cmd.Directory, testPath("foo"));
EXPECT_THAT(Cmd.CommandLine,
ElementsAre("clang", testPath("foo/src/bar.cc")));
EXPECT_EQ(Cmd.Output, "");
}

static tooling::CompileCommand cmd(llvm::StringRef File, llvm::StringRef Arg) {
return tooling::CompileCommand(
testRoot(), File, {"clang", std::string(Arg), std::string(File)}, "");


+ 18
- 0
clang-tools-extra/docs/ReleaseNotes.rst View File

@@ -107,6 +107,11 @@ Hover
Code completion
^^^^^^^^^^^^^^^

- Added a new ``MacroFilter`` configuration option to ``Completion`` to
allow fuzzy-matching with the ``FuzzyMatch`` option when suggesting
macros. ``ExactPrefix`` is the default, which retains previous
behavior of suggesting macros which match the prefix exactly.

Code actions
^^^^^^^^^^^^

@@ -196,6 +201,9 @@ Improvements to clang-tidy
moved to the ``fuchsia`` module instead. The ``zircon`` module will be removed
in the 24th release.

- Improved :program:`clang-tidy` configuration parsing by allowing the same list
syntax in `WarningsAsErrors` as in `Checks`.

New checks
^^^^^^^^^^

@@ -328,6 +336,11 @@ New check aliases
<clang-tidy/checks/bugprone/copy-constructor-mutates-argument>`
keeping initial check as an alias to the new one.

- Renamed :doc:`fuchsia-multiple-inheritance <clang-tidy/checks/fuchsia/multiple-inheritance>` to
:doc:`misc-multiple-inheritance
<clang-tidy/checks/misc/multiple-inheritance>`
keeping initial check as an alias to the new one.

- Renamed :doc:`google-readability-casting <clang-tidy/checks/google/readability-casting>` to
:doc:`modernize-avoid-c-style-cast
<clang-tidy/checks/modernize/avoid-c-style-cast>`
@@ -336,6 +349,11 @@ New check aliases
Changes in existing checks
^^^^^^^^^^^^^^^^^^^^^^^^^^

- Improved :doc:`bugprone-chained-comparison
<clang-tidy/checks/bugprone/chained-comparison>` check by adding a
new option `IgnoreMacros` to suppress warnings within macro
expansions.

- Improved :doc:`bugprone-easily-swappable-parameters
<clang-tidy/checks/bugprone/easily-swappable-parameters>` check by
correcting a spelling mistake on its option


+ 8
- 0
clang-tools-extra/docs/clang-tidy/checks/bugprone/chained-comparison.rst View File

@@ -71,3 +71,11 @@ developer's intention more explicit and help avoid misunderstanding.
// This block will be executed
}

Options
-------

.. option:: IgnoreMacros

If `true`, the check will not warn on chained comparisons inside macros.
Default is `false`.


+ 3
- 40
clang-tools-extra/docs/clang-tidy/checks/fuchsia/multiple-inheritance.rst View File

@@ -3,44 +3,7 @@
fuchsia-multiple-inheritance
============================

Warns if a class inherits from multiple classes that are not pure virtual.
The `fuchsia-multiple-inheritance` check is an alias, please See
:doc:`misc-multiple-inheritance <../misc/multiple-inheritance>` for details.

For example, declaring a class that inherits from multiple concrete classes is
disallowed:

.. code-block:: c++

class Base_A {
public:
virtual int foo() { return 0; }
};

class Base_B {
public:
virtual int bar() { return 0; }
};

// Warning
class Bad_Child1 : public Base_A, Base_B {};

A class that inherits from a pure virtual is allowed:

.. code-block:: c++

class Interface_A {
public:
virtual int foo() = 0;
};

class Interface_B {
public:
virtual int bar() = 0;
};

// No warning
class Good_Child1 : public Interface_A, Interface_B {
virtual int foo() override { return 0; }
virtual int bar() override { return 0; }
};

See the features disallowed in Fuchsia at https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/cxx?hl=en
See the features disallowed in Fuchsia at https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/cxx?hl=en

+ 2
- 1
clang-tools-extra/docs/clang-tidy/checks/list.rst View File

@@ -222,7 +222,6 @@ Clang-Tidy Checks
:doc:`darwin-dispatch-once-nonstatic <darwin/dispatch-once-nonstatic>`, "Yes"
:doc:`fuchsia-default-arguments-calls <fuchsia/default-arguments-calls>`,
:doc:`fuchsia-default-arguments-declarations <fuchsia/default-arguments-declarations>`, "Yes"
:doc:`fuchsia-multiple-inheritance <fuchsia/multiple-inheritance>`,
:doc:`fuchsia-overloaded-operator <fuchsia/overloaded-operator>`,
:doc:`fuchsia-statically-constructed-objects <fuchsia/statically-constructed-objects>`,
:doc:`fuchsia-temporary-objects <fuchsia/temporary-objects>`,
@@ -272,6 +271,7 @@ Clang-Tidy Checks
:doc:`misc-misleading-bidirectional <misc/misleading-bidirectional>`,
:doc:`misc-misleading-identifier <misc/misleading-identifier>`,
:doc:`misc-misplaced-const <misc/misplaced-const>`,
:doc:`misc-multiple-inheritance <misc/multiple-inheritance>`,
:doc:`misc-new-delete-overloads <misc/new-delete-overloads>`,
:doc:`misc-no-recursion <misc/no-recursion>`,
:doc:`misc-non-copyable-objects <misc/non-copyable-objects>`,
@@ -584,6 +584,7 @@ Check aliases
:doc:`cppcoreguidelines-non-private-member-variables-in-classes <cppcoreguidelines/non-private-member-variables-in-classes>`, :doc:`misc-non-private-member-variables-in-classes <misc/non-private-member-variables-in-classes>`,
:doc:`cppcoreguidelines-use-default-member-init <cppcoreguidelines/use-default-member-init>`, :doc:`modernize-use-default-member-init <modernize/use-default-member-init>`, "Yes"
:doc:`fuchsia-header-anon-namespaces <fuchsia/header-anon-namespaces>`, :doc:`google-build-namespaces <google/build-namespaces>`,
:doc:`fuchsia-multiple-inheritance <fuchsia/multiple-inheritance>`, :doc:`misc-multiple-inheritance <misc/multiple-inheritance>`,
:doc:`google-readability-braces-around-statements <google/readability-braces-around-statements>`, :doc:`readability-braces-around-statements <readability/braces-around-statements>`, "Yes"
:doc:`google-readability-casting <google/readability-casting>`, :doc:`modernize-avoid-c-style-cast <modernize/avoid-c-style-cast>`,
:doc:`google-readability-function-size <google/readability-function-size>`, :doc:`readability-function-size <readability/function-size>`,


+ 49
- 0
clang-tools-extra/docs/clang-tidy/checks/misc/multiple-inheritance.rst View File

@@ -0,0 +1,49 @@
.. title:: clang-tidy - misc-multiple-inheritance

misc-multiple-inheritance
=========================

Warns if a class inherits from multiple classes that are not pure virtual.

For example, declaring a class that inherits from multiple concrete classes is
disallowed:

.. code-block:: c++

class Base_A {
public:
virtual int foo() { return 0; }
};

class Base_B {
public:
virtual int bar() { return 0; }
};

// Warning
class Bad_Child1 : public Base_A, Base_B {};

A class that inherits from a pure virtual is allowed:

.. code-block:: c++

class Interface_A {
public:
virtual int foo() = 0;
};

class Interface_B {
public:
virtual int bar() = 0;
};

// No warning
class Good_Child1 : public Interface_A, Interface_B {
virtual int foo() override { return 0; }
virtual int bar() override { return 0; }
};

References
----------

See the features disallowed in Fuchsia at https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/cxx?hl=en

+ 4
- 1
clang-tools-extra/test/clang-doc/json/class-requires.cpp View File

@@ -29,7 +29,10 @@ struct MyClass;
// CHECK-NEXT: }
// CHECK-NEXT: ],
// CHECK-NEXT: "Parameters": [
// CHECK-NEXT: "typename T"
// CHECK-NEXT: {
// CHECK-NEXT: "End": true,
// CHECK-NEXT: "typename T"
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK-NEXT: },
// CHECK-NEXT: "USR": "{{[0-9A-F]*}}"

+ 8
- 2
clang-tools-extra/test/clang-doc/json/class-specialization.cpp View File

@@ -16,7 +16,10 @@ template<> struct MyClass<int> {};
// BASE-NEXT: "TagType": "struct",
// BASE-NEXT: "Template": {
// BASE-NEXT: "Parameters": [
// BASE-NEXT: "typename T"
// BASE-NEXT: {
// BASE-NEXT: "End": true,
// BASE-NEXT: "Param": "typename T"
// BASE-NEXT: }
// BASE-NEXT: ]
// BASE-NEXT: },

@@ -30,7 +33,10 @@ template<> struct MyClass<int> {};
// SPECIALIZATION-NEXT: "Template": {
// SPECIALIZATION-NEXT: "Specialization": {
// SPECIALIZATION-NEXT: "Parameters": [
// SPECIALIZATION-NEXT: "int"
// SPECIALIZATION-NEXT: {
// SPECIALIZATION-NEXT: "End": true,
// SPECIALIZATION-NEXT: "Param": "int"
// SPECIALIZATION-NEXT: }
// SPECIALIZATION-NEXT: ],
// SPECIALIZATION-NEXT: "SpecializationOf": "{{[0-9A-F]*}}"
// SPECIALIZATION-NEXT: }


+ 4
- 1
clang-tools-extra/test/clang-doc/json/class-template.cpp View File

@@ -26,5 +26,8 @@ template<typename T> struct MyClass {
// CHECK: "Type": "T"
// CHECK: "Template": {
// CHECK-NEXT: "Parameters": [
// CHECK-NEXT: "typename T"
// CHECK-NEXT: {
// CHECK-NEXT: "End": true,
// CHECK-NEXT: "Param": "typename T"
// CHECK-NEXT: }
// CHECK-NEXT: ]

+ 4
- 1
clang-tools-extra/test/clang-doc/json/class.cpp View File

@@ -108,7 +108,10 @@ private:
// CHECK-NEXT: },
// CHECK-NEXT: "Template": {
// CHECK-NEXT: "Parameters": [
// CHECK-NEXT: "typename T"
// CHECK-NEXT: {
// CHECK-NEXT: "End": true,
// CHECK-NEXT: "Param": "typename T"
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK-NEXT: }
// CHECK-NEXT: },


+ 4
- 1
clang-tools-extra/test/clang-doc/json/concept.cpp View File

@@ -25,7 +25,10 @@ concept Incrementable = requires(T x) {
// CHECK-NEXT: "Name": "Incrementable",
// CHECK-NEXT: "Template": {
// CHECK-NEXT: "Parameters": [
// CHECK-NEXT: "typename T"
// CHECK-NEXT: {
// CHECK-NEXT: "End": true,
// CHECK-NEXT: "Param": "typename T"
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK-NEXT: },
// CHECK-NEXT: "USR": "{{[0-9A-F]*}}"


+ 8
- 2
clang-tools-extra/test/clang-doc/json/function-requires.cpp View File

@@ -43,7 +43,10 @@ template<Incrementable T> Incrementable auto incrementTwo(T t);
// CHECK-NEXT: }
// CHECK-NEXT: ],
// CHECK-NEXT: "Parameters": [
// CHECK-NEXT: "typename T"
// CHECK-NEXT: {
// CHECK-NEXT: "End": true,
// CHECK-NEXT: "Param": "typename T"
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK-NEXT: },
// CHECK-NEXT: "USR": "{{[0-9A-F]*}}"
@@ -79,7 +82,10 @@ template<Incrementable T> Incrementable auto incrementTwo(T t);
// CHECK-NEXT: }
// CHECK-NEXT: ],
// CHECK-NEXT: "Parameters": [
// CHECK-NEXT: "Incrementable T"
// CHECK-NEXT: {
// CHECK-NEXT: "End": true,
// CHECK-NEXT: "Param": "Incrementable T"
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK-NEXT: },
// CHECK-NEXT: "USR": "{{[0-9A-F]*}}"


+ 4
- 1
clang-tools-extra/test/clang-doc/json/method-template.cpp View File

@@ -36,7 +36,10 @@ struct MyClass {
// CHECK-NEXT: },
// CHECK-NEXT: "Template": {
// CHECK-NEXT: "Parameters": [
// CHECK-NEXT: "class T"
// CHECK-NEXT: {
// CHECK-NEXT: "End": true,
// CHECK-NEXT: "Param": "class T"
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK-NEXT: },
// CHECK-NEXT: "USR": "{{[0-9A-F]*}}"

+ 1
- 0
clang-tools-extra/test/clang-doc/json/namespace.cpp View File

@@ -73,6 +73,7 @@ typedef int MyTypedef;
// CHECK-NEXT: }
// CHECK-NEXT: ],
// CHECK-NEXT: "HasEnums": true,
// CHECK-NEXT: "HasFunctions": true,
// CHECK-NEXT: "HasRecords": true,
// CHECK-NEXT: "InfoType": "namespace",
// CHECK-NEXT: "Name": "Global Namespace",


+ 45
- 25
clang-tools-extra/test/clang-doc/namespace.cpp View File

@@ -45,7 +45,7 @@
namespace {
void anonFunction() {}
// MD-ANON-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
// HTML-ANON-INDEX-LINE-NOT: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
// HTML-ANON-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>

class AnonClass {};
// MD-ANON-CLASS-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
@@ -80,7 +80,7 @@ namespace PrimaryNamespace {
// Function in PrimaryNamespace
void functionInPrimaryNamespace() {}
// MD-PRIMARY-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
// HTML-PRIMARY-INDEX-LINE-NOT: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
// HTML-PRIMARY-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>

// Class in PrimaryNamespace
class ClassInPrimaryNamespace {};
@@ -97,7 +97,7 @@ namespace NestedNamespace {
// Function in NestedNamespace
void functionInNestedNamespace() {}
// MD-NESTED-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
// HTML-NESTED-INDEX-LINE-NOT: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
// HTML-NESTED-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>

// Class in NestedNamespace
class ClassInNestedNamespace {};
@@ -128,10 +128,17 @@ class ClassInNestedNamespace {};
// HTML-NESTED-INDEX: </a>
// HTML-NESTED-INDEX: </li>
// HTML-NESTED-INDEX: </ul>
// HTML-NESTED-INDEX-NOT: <h2 id="Functions">Functions</h2>
// HTML-NESTED-INDEX-NOT: <h3 id="{{([0-9A-F]{40})}}">functionInNestedNamespace</h3>
// HTML-NESTED-INDEX-NOT: <p>void functionInNestedNamespace()</p>
// HTML-NESTED-INDEX-NOT: <p> Function in NestedNamespace</p>
// HTML-NESTED-INDEX: <div class="delimiter-container">
// HTML-NESTED-INDEX: <div id="{{([0-9A-F]{40})}}">
// HTML-NESTED-INDEX: <pre><code class="language-cpp code-clang-doc">void functionInNestedNamespace ()</code></pre>
// HTML-NESTED-INDEX: <div>
// HTML-NESTED-INDEX: <div>
// HTML-NESTED-INDEX: <p> Function in NestedNamespace</p>
// HTML-NESTED-INDEX: </div>
// HTML-NESTED-INDEX: </div>
// HTML-NESTED-INDEX: <p>Defined at line 98 of file {{.*}}namespace.cpp</p>
// HTML-NESTED-INDEX: </div>
// HTML-NESTED-INDEX: </div>
} // namespace PrimaryNamespace

// MD-PRIMARY-INDEX: # namespace PrimaryNamespace
@@ -148,25 +155,31 @@ class ClassInNestedNamespace {};
// HTML-PRIMARY-INDEX: <h2>PrimaryNamespace</h2>
// HTML-PRIMARY-INDEX-NOT: <h2 id="Namespaces">Namespaces</h2>
// HTML-PRIMARY-INDEX-NOT: <a href="NestedNamespace{{[\/]}}index.html">NestedNamespace</a>
// HTML-PRIMARY-INDEX <h2>Inner Classes</h2>
// HTML-PRIMARY-INDEX <ul class="class-container">
// HTML-PRIMARY-INDEX <li id="{{([0-9A-F]{40})}}" style="max-height: 40px;">
// HTML-PRIMARY-INDEX <a href="_ZTVN16PrimaryNamespace23ClassInPrimaryNamespaceE.html">
// HTML-PRIMARY-INDEX <pre><code class="language-cpp code-clang-doc">class ClassInPrimaryNamespace</code></pre>
// HTML-PRIMARY-INDEX </a>
// HTML-PRIMARY-INDEX </li>
// HTML-PRIMARY-INDEX </ul>
// HTML-PRIMARY-INDEX-NOT: <h2 id="Functions">Functions</h2>
// HTML-PRIMARY-INDEX-NOT: <h3 id="{{([0-9A-F]{40})}}">functionInPrimaryNamespace</h3>
// HTML-PRIMARY-INDEX-NOT: <p>void functionInPrimaryNamespace()</p>
// HTML-PRIMARY-INDEX-NOT: <p> Function in PrimaryNamespace</p>

// HTML-PRIMARY-INDEX: <h2>Inner Classes</h2>
// HTML-PRIMARY-INDEX: <ul class="class-container">
// HTML-PRIMARY-INDEX: <li id="{{([0-9A-F]{40})}}" style="max-height: 40px;">
// HTML-PRIMARY-INDEX: <a href="_ZTVN16PrimaryNamespace23ClassInPrimaryNamespaceE.html">
// HTML-PRIMARY-INDEX: <pre><code class="language-cpp code-clang-doc">class ClassInPrimaryNamespace</code></pre>
// HTML-PRIMARY-INDEX: </a>
// HTML-PRIMARY-INDEX: </li>
// HTML-PRIMARY-INDEX: </ul>
// HTML-PRIMARY-INDEX: <div class="delimiter-container">
// HTML-PRIMARY-INDEX: <div id="{{([0-9A-F]{40})}}">
// HTML-PRIMARY-INDEX: <pre><code class="language-cpp code-clang-doc">void functionInPrimaryNamespace ()</code></pre>
// HTML-PRIMARY-INDEX: <div>
// HTML-PRIMARY-INDEX: <div>
// HTML-PRIMARY-INDEX: <p> Function in PrimaryNamespace</p>
// HTML-PRIMARY-INDEX: </div>
// HTML-PRIMARY-INDEX: </div>
// HTML-PRIMARY-INDEX: <p>Defined at line 81 of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
// HTML-PRIMARY-INDEX: </div>
// HTML-PRIMARY-INDEX: </div>
// AnotherNamespace
namespace AnotherNamespace {
// Function in AnotherNamespace
void functionInAnotherNamespace() {}
// MD-ANOTHER-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
// HTML-ANOTHER-INDEX-LINE-NOT: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
// HTML-ANOTHER-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>

// Class in AnotherNamespace
class ClassInAnotherNamespace {};
@@ -198,10 +211,17 @@ class ClassInAnotherNamespace {};
// HTML-ANOTHER-INDEX: </a>
// HTML-ANOTHER-INDEX: </li>
// HTML-ANOTHER-INDEX: </ul>
// HTML-ANOTHER-INDEX-NOT: <h2 id="Functions">Functions</h2>
// HTML-ANOTHER-INDEX-NOT: <h3 id="{{([0-9A-F]{40})}}">functionInAnotherNamespace</h3>
// HTML-ANOTHER-INDEX-NOT: <p>void functionInAnotherNamespace()</p>
// HTML-ANOTHER-INDEX-NOT: <p> Function in AnotherNamespace</p>
// HTML-ANOTHER-INDEX: <div class="delimiter-container">
// HTML-ANOTHER-INDEX: <div id="{{([0-9A-F]{40})}}">
// HTML-ANOTHER-INDEX: <pre><code class="language-cpp code-clang-doc">void functionInAnotherNamespace ()</code></pre>
// HTML-ANOTHER-INDEX: <div>
// HTML-ANOTHER-INDEX: <div>
// HTML-ANOTHER-INDEX: <p> Function in AnotherNamespace</p>
// HTML-ANOTHER-INDEX: </div>
// HTML-ANOTHER-INDEX: </div>
// HTML-ANOTHER-INDEX: <p>Defined at line 180 of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
// HTML-ANOTHER-INDEX: </div>
// HTML-ANOTHER-INDEX: </div>

// COM: FIXME: Add namespaces to namespace template
// HTML-GLOBAL-INDEX-NOT: <div id="main-content" class="col-xs-12 col-sm-9 col-md-8 main-content">


+ 161
- 0
clang-tools-extra/test/clang-doc/templates.cpp View File

@@ -7,6 +7,11 @@
// RUN: clang-doc --doxygen --executor=standalone %s -output=%t/docs --format=md
// RUN: cat %t/docs/GlobalNamespace/index.md | FileCheck %s --check-prefix=MD

// RUN: clang-doc --doxygen --executor=standalone %s -output=%t/docs --format=html
// RUN: cat %t/docs/json/GlobalNamespace/index.json | FileCheck %s --check-prefix=JSON
// RUN: cat %t/docs/html/GlobalNamespace/_ZTV5tuple.html | FileCheck %s --check-prefix=HTML-STRUCT
// RUN: cat %t/docs/html/GlobalNamespace/index.html | FileCheck %s --check-prefix=HTML

// YAML: ---
// YAML-NEXT: USR: '{{([0-9A-F]{40})}}'
// YAML-NEXT: ChildRecords:
@@ -44,6 +49,39 @@ void ParamPackFunction(T... args);
// MD: ### ParamPackFunction
// MD: *void ParamPackFunction(T... args)*

// JSON: "Name": "ParamPackFunction",
// JSON-NEXT: "Params": [
// JSON-NEXT: {
// JSON-NEXT: "End": true,
// JSON-NEXT: "Name": "args",
// JSON-NEXT: "Type": "T..."
// JSON-NEXT: }
// JSON-NEXT: ],
// JSON-NEXT: "ReturnType": {
// JSON-NEXT: "IsBuiltIn": true,
// JSON-NEXT: "IsTemplate": false,
// JSON-NEXT: "Name": "void",
// JSON-NEXT: "QualName": "void",
// JSON-NEXT: "USR": "0000000000000000000000000000000000000000"
// JSON-NEXT: },
// JSON-NEXT: "Template": {
// JSON-NEXT: "Parameters": [
// JSON-NEXT: {
// JSON-NEXT: "End": true,
// JSON-NEXT: "Param": "class... T"
// JSON-NEXT: }
// JSON-NEXT: ]
// JSON-NEXT: },

// HTML: <div class="delimiter-container">
// HTML-NEXT: <div id="{{([0-9A-F]{40})}}">
// HTML-NEXT: <pre><code class="language-cpp code-clang-doc">template &lt;class... T&gt;</code></pre>
// HTML-NEXT: <pre><code class="language-cpp code-clang-doc">void ParamPackFunction (T... args)</code></pre>
// COM: FIXME: Omit defined line if not defined, or emit declaration line.
// HTML-NEXT: <p>Defined at line of file </p>
// HTML-NEXT: </div>
// HTML-NEXT: </div>

template <typename T, int U = 1>
void function(T x) {}

@@ -70,6 +108,42 @@ void function(T x) {}
// MD: *void function(T x)*
// MD: *Defined at {{.*}}templates.cpp#[[# @LINE - 23]]*

// JSON: "Name": "function",
// JSON-NEXT: "Params": [
// JSON-NEXT: {
// JSON-NEXT: "End": true,
// JSON-NEXT: "Name": "x",
// JSON-NEXT: "Type": "T"
// JSON-NEXT: }
// JSON-NEXT: ],
// JSON-NEXT: "ReturnType": {
// JSON-NEXT: "IsBuiltIn": true,
// JSON-NEXT: "IsTemplate": false,
// JSON-NEXT: "Name": "void",
// JSON-NEXT: "QualName": "void",
// JSON-NEXT: "USR": "0000000000000000000000000000000000000000"
// JSON-NEXT: },
// JSON-NEXT: "Template": {
// JSON-NEXT: "Parameters": [
// JSON-NEXT: {
// JSON-NEXT: "Param": "typename T"
// JSON-NEXT: },
// JSON-NEXT: {
// JSON-NEXT: "End": true,
// JSON-NEXT: "Param": "int U = 1"
// JSON-NEXT: }
// JSON-NEXT: ]
// JSON-NEXT: }

// HTML: <div class="delimiter-container">
// HTML-NEXT: <div id="{{([0-9A-F]{40})}}">
// HTML-NEXT: <pre><code class="language-cpp code-clang-doc">template &lt;typename T, int U = 1&gt;</code></pre>
// HTML-NEXT: <pre><code class="language-cpp code-clang-doc">void function (T x)</code></pre>
// HTML-NEXT: <p>Defined at line [[# @LINE - 56]] of file {{.*}}templates.cpp</p>
// HTML-NEXT: </div>
// HTML-NEXT: </div>


template <>
void function<bool, 0>(bool x) {}

@@ -98,12 +172,66 @@ void function<bool, 0>(bool x) {}
// MD: *void function(bool x)*
// MD: *Defined at {{.*}}templates.cpp#[[# @LINE - 26]]*

// JSON: "Name": "function",
// JSON-NEXT: "Params": [
// JSON-NEXT: {
// JSON-NEXT: "End": true,
// JSON-NEXT: "Name": "x",
// JSON-NEXT: "Type": "bool"
// JSON-NEXT: }
// JSON-NEXT: ],
// JSON-NEXT: "ReturnType": {
// JSON-NEXT: "IsBuiltIn": true,
// JSON-NEXT: "IsTemplate": false,
// JSON-NEXT: "Name": "void",
// JSON-NEXT: "QualName": "void",
// JSON-NEXT: "USR": "0000000000000000000000000000000000000000"
// JSON-NEXT: },
// JSON-NEXT: "Template": {
// JSON-NEXT: "Specialization": {
// JSON-NEXT: "Parameters": [
// JSON-NEXT: {
// JSON-NEXT: "Param": "bool"
// JSON-NEXT: },
// JSON-NEXT: {
// JSON-NEXT: "End": true,
// JSON-NEXT: "Param": "0"
// JSON-NEXT: }
// JSON-NEXT: ],
// JSON-NEXT: "SpecializationOf": "{{([0-9A-F]{40})}}"
// JSON-NEXT: }
// JSON-NEXT: },

// HTML: <div class="delimiter-container">
// HTML-NEXT: <div id="{{([0-9A-F]{40})}}">
// HTML-NEXT: <pre><code class="language-cpp code-clang-doc">template &lt;&gt;</code></pre>
// HTML-NEXT: <pre><code class="language-cpp code-clang-doc">void function&lt;bool, 0&gt; (bool x)</code></pre>
// HTML-NEXT: <p>Defined at line [[# @LINE - 62]] of file {{.*}}templates.cpp</p>
// HTML-NEXT: </div>
// HTML-NEXT: </div>

/// A Tuple type
///
/// Does Tuple things.
template <typename... Tys>
struct tuple {};

// HTML-STRUCT: <section class="hero section-container">
// HTML-STRUCT-NEXT: <pre><code class="language-cpp code-clang-doc">template &lt;typename... Tys&gt;</code></pre>
// HTML-STRUCT-NEXT: <div class="hero__title">
// HTML-STRUCT-NEXT: <h1 class="hero__title-large">struct tuple</h1>
// HTML-STRUCT-NEXT: <p>Defined at line [[# @LINE - 6]] of file {{.*}}templates.cpp</p>
// HTML-STRUCT-NEXT: <div class="hero__subtitle">
// HTML-STRUCT-NEXT: <div>
// HTML-STRUCT-NEXT: <p> A Tuple type</p>
// HTML-STRUCT-NEXT: </div>
// HTML-STRUCT-NEXT: <div>
// HTML-STRUCT-NEXT: <p> Does Tuple things.</p>
// HTML-STRUCT-NEXT: </div>
// HTML-STRUCT-NEXT: </div>
// HTML-STRUCT-NEXT: </div>
// HTML-STRUCT-NEXT: </section>

/// A function with a tuple parameter
///
/// \param t The input to func_with_tuple_param
@@ -154,3 +282,36 @@ tuple<int, int, bool> func_with_tuple_param(tuple<int, int, bool> t) { return t;
// MD: *Defined at {{.*}}templates.cpp#[[# @LINE - 44]]*
// MD: A function with a tuple parameter
// MD: **t** The input to func_with_tuple_param

// JSON: "Name": "func_with_tuple_param",
// COM: FIXME: Add type info to parameters
// JSON-NEXT: "Params": [
// JSON-NEXT: {
// JSON-NEXT: "End": true,
// JSON-NEXT: "Name": "t",
// JSON-NEXT: "Type": "tuple"
// JSON-NEXT: }
// JSON-NEXT: ],
// JSON-NEXT: "ReturnType": {
// JSON-NEXT: "IsBuiltIn": false,
// JSON-NEXT: "IsTemplate": false,
// JSON-NEXT: "Name": "tuple",
// JSON-NEXT: "QualName": "tuple<int, int, bool>",
// JSON-NEXT: "USR": "{{([0-9A-F]{40})}}"
// JSON-NEXT: },

// HTML: <div class="delimiter-container">
// HTML-NEXT: <div id="{{([0-9A-F]{40})}}">
// HTML-NEXT: <pre><code class="language-cpp code-clang-doc">tuple func_with_tuple_param (tuple t)</code></pre>
// HTML-NEXT: <div>
// HTML-NEXT: <div>
// HTML-NEXT: <p> A function with a tuple parameter</p>
// HTML-NEXT: </div>
// HTML-NEXT: <h3>Parameters</h3>
// HTML-NEXT: <div>
// HTML-NEXT: <b>t</b> The input to func_with_tuple_param
// HTML-NEXT: </div>
// HTML-NEXT: </div>
// HTML-NEXT: <p>Defined at line [[# @LINE - 77]] of file {{.*}}templates.cpp</p>
// HTML-NEXT: </div>
// HTML-NEXT: </div>

+ 37
- 0
clang-tools-extra/test/clang-tidy/checkers/bugprone/chained-comparison-ignore-macros.cpp View File

@@ -0,0 +1,37 @@
// RUN: %check_clang_tidy -std=c++98-or-later --extra-arg=-Wno-error=parentheses %s bugprone-chained-comparison %t -- -config="{CheckOptions: {bugprone-chained-comparison.IgnoreMacros: true}}"

#define CHAINED_COMPARE(a, b, c) (a < b < c)

void macro_test(int x, int y, int z) {
bool result = CHAINED_COMPARE(x, y, z);
}

#define NESTED_LESS(a, b) a < b
#define NESTED_CHAIN(a, b, c) NESTED_LESS(a, b) < c

void nested_macro_test(int x, int y, int z) {
bool result = NESTED_CHAIN(x, y, z);
}

#define LESS_OP <

void operator_macro_test(int x, int y, int z) {
bool result = x LESS_OP y LESS_OP z;
}
// CHECK-MESSAGES: :[[@LINE-2]]:19: warning: chained comparison 'v0 < v1 < v2' may generate unintended results

#define PARTIAL_LESS(a, b) a < b

void mixed_macro_test(int x, int y, int z) {
bool result = PARTIAL_LESS(x, y) < z;
}

void if_macro_test(int x, int y, int z) {
if (CHAINED_COMPARE(x, y, z)) {}
}

#define LONG_CHAIN_MACRO(v) v[0] < v[1] < v[2] < v[3]

void long_chain_macro_test(int v[4]) {
bool result = LONG_CHAIN_MACRO(v);
}

+ 41
- 0
clang-tools-extra/test/clang-tidy/checkers/bugprone/chained-comparison.cpp View File

@@ -89,3 +89,44 @@ bool mixedBinaryAndCpp(Value a, Value b, bool c) {
return a < b == c;
}
// CHECK-MESSAGES: :[[@LINE-2]]:12: warning: chained comparison 'v0 < v1 == v2' may generate unintended results, use parentheses to specify order of evaluation or a logical operator to separate comparison expressions [bugprone-chained-comparison]

#define CHAINED_COMPARE(a, b, c) (a < b < c)

void macro_test(int x, int y, int z) {
bool result = CHAINED_COMPARE(x, y, z);
}
// CHECK-MESSAGES: :[[@LINE-2]]:35: warning: chained comparison 'v0 < v1 < v2' may generate unintended results, use parentheses to specify order of evaluation or a logical operator to separate comparison expressions [bugprone-chained-comparison]

#define NESTED_LESS(a, b) a < b
#define NESTED_CHAIN(a, b, c) NESTED_LESS(a, b) < c

void nested_macro_test(int x, int y, int z) {
bool result = NESTED_CHAIN(x, y, z);
}
// CHECK-MESSAGES: :[[@LINE-2]]:32: warning: chained comparison 'v0 < v1 < v2' may generate unintended results, use parentheses to specify order of evaluation or a logical operator to separate comparison expressions [bugprone-chained-comparison]

#define LESS_OP <

void operator_macro_test(int x, int y, int z) {
bool result = x LESS_OP y LESS_OP z;
}
// CHECK-MESSAGES: :[[@LINE-2]]:19: warning: chained comparison 'v0 < v1 < v2' may generate unintended results, use parentheses to specify order of evaluation or a logical operator to separate comparison expressions [bugprone-chained-comparison]

#define PARTIAL_LESS(a, b) a < b

void mixed_macro_test(int x, int y, int z) {
bool result = PARTIAL_LESS(x, y) < z;
}
// CHECK-MESSAGES: :[[@LINE-2]]:32: warning: chained comparison 'v0 < v1 < v2' may generate unintended results, use parentheses to specify order of evaluation or a logical operator to separate comparison expressions [bugprone-chained-comparison]

void if_macro_test(int x, int y, int z) {
if (CHAINED_COMPARE(x, y, z)) {}
}
// CHECK-MESSAGES: :[[@LINE-2]]:25: warning: chained comparison 'v0 < v1 < v2' may generate unintended results, use parentheses to specify order of evaluation or a logical operator to separate comparison expressions [bugprone-chained-comparison]

#define LONG_CHAIN_MACRO(v) v[0] < v[1] < v[2] < v[3]

void long_chain_macro_test(int v[4]) {
bool result = LONG_CHAIN_MACRO(v);
}
// CHECK-MESSAGES: :[[@LINE-2]]:36: warning: chained comparison 'v0 < v1 < v2 < v3' may generate unintended results, use parentheses to specify order of evaluation or a logical operator to separate comparison expressions [bugprone-chained-comparison]

clang-tools-extra/test/clang-tidy/checkers/fuchsia/multiple-inheritance.cpp → clang-tools-extra/test/clang-tidy/checkers/misc/multiple-inheritance.cpp View File

@@ -1,4 +1,4 @@
// RUN: %check_clang_tidy %s fuchsia-multiple-inheritance %t
// RUN: %check_clang_tidy %s misc-multiple-inheritance %t

class Base_A {
public:
@@ -45,16 +45,16 @@ public:
class Bad_Child1;

// Inherits from multiple concrete classes.
// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [misc-multiple-inheritance]
// CHECK-NEXT: class Bad_Child1 : public Base_A, Base_B {};
class Bad_Child1 : public Base_A, Base_B {};

// CHECK-MESSAGES: [[@LINE+1]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
// CHECK-MESSAGES: [[@LINE+1]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [misc-multiple-inheritance]
class Bad_Child2 : public Base_A, Interface_A_with_member {
virtual int foo() override { return 0; }
};

// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [misc-multiple-inheritance]
// CHECK-NEXT: class Bad_Child3 : public Interface_with_A_Parent, Base_B {
class Bad_Child3 : public Interface_with_A_Parent, Base_B {
virtual int baz() override { return 0; }
@@ -83,7 +83,7 @@ class Good_Child3 : public Base_A_child, Interface_C, Interface_B {

struct B1 { int x; };
struct B2 { int x;};
// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [misc-multiple-inheritance]
// CHECK-NEXT: struct D : B1, B2 {};
struct D1 : B1, B2 {};

@@ -100,7 +100,7 @@ struct D3 : V3, V4 {};
struct Base3 {};
struct V5 : virtual Base3 { virtual void f(); };
struct V6 : virtual Base3 { virtual void g(); };
// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [misc-multiple-inheritance]
// CHECK-NEXT: struct D4 : V5, V6 {};
struct D4 : V5, V6 {};

@@ -118,7 +118,7 @@ struct Base6 { virtual void f(); };
struct Base7 { virtual void g(); };
struct V15 : virtual Base6 { virtual void f() = 0; };
struct V16 : virtual Base7 { virtual void g() = 0; };
// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
// CHECK-MESSAGES: [[@LINE+2]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [misc-multiple-inheritance]
// CHECK-NEXT: struct D9 : V15, V16 {};
struct D9 : V15, V16 {};

@@ -159,7 +159,7 @@ namespace N {
struct S1 { int i; };
struct S2 { int i; };

// CHECK-MESSAGES: [[@LINE+1]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [fuchsia-multiple-inheritance]
// CHECK-MESSAGES: [[@LINE+1]]:1: warning: inheriting multiple classes that aren't pure virtual is discouraged [misc-multiple-inheritance]
struct S3 : S1, S2 {};

} // namespace N

+ 19
- 3
clang-tools-extra/test/clang-tidy/checkers/readability/redundant-typename.cpp View File

@@ -271,13 +271,21 @@ WHOLE_DECLARATION_IN_MACRO;
template <typename T> struct Wrapper {};
template <typename T>
struct ClassWrapper {
using R = T;
Wrapper<R> f();
using R = T;
Wrapper<R> f();
R g();
};

template <typename T>
Wrapper<typename ClassWrapper<T>::R> ClassWrapper<T>::f() {
return {};
return {};
}

template <typename T>
typename ClassWrapper<T>::R ClassWrapper<T>::g() {
// CHECK-MESSAGES-20: :[[@LINE-1]]:1: warning: redundant 'typename' [readability-redundant-typename]
// CHECK-FIXES-20: ClassWrapper<T>::R ClassWrapper<T>::g() {
return {};
}

template <typename T> struct StructWrapper {};
@@ -285,9 +293,17 @@ template <typename T>
class ClassWithNestedStruct {
struct Nested {};
StructWrapper<Nested> f();
Nested g();
};

template <typename T>
StructWrapper<typename ClassWithNestedStruct<T>::Nested> ClassWithNestedStruct<T>::f() {
return {};
}

template <typename T>
typename ClassWithNestedStruct<T>::Nested ClassWithNestedStruct<T>::g() {
// CHECK-MESSAGES-20: :[[@LINE-1]]:1: warning: redundant 'typename' [readability-redundant-typename]
// CHECK-FIXES-20: ClassWithNestedStruct<T>::Nested ClassWithNestedStruct<T>::g() {
return {};
}

+ 5
- 1
clang-tools-extra/unittests/clang-doc/JSONGeneratorTest.cpp View File

@@ -175,7 +175,10 @@ TEST_F(JSONGeneratorTest, emitRecordJSON) {
"TagType": "class",
"Template": {
"Parameters": [
"class T"
{
"End": true,
"Param": "class T"
}
]
},
"USR": "0000000000000000000000000000000000000000",
@@ -243,6 +246,7 @@ TEST_F(JSONGeneratorTest, emitNamespaceJSON) {
}
],
"HasEnums": true,
"HasFunctions": true,
"HasRecords": true,
"InfoType": "namespace",
"Name": "Global Namespace",


+ 31
- 0
clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp View File

@@ -107,6 +107,37 @@ TEST(ParseConfiguration, ChecksSeparatedByNewlines) {
EXPECT_EQ("-*,misc-*\nllvm-*\n-clang-*,\ngoogle-*\n", *Options->Checks);
}

TEST(ParseConfiguration, WarningsAsErrorsSeparatedByNewlines) {
const auto MemoryBuffer = llvm::MemoryBufferRef("WarningsAsErrors: |\n"
" -*,misc-*\n"
" llvm-*\n"
" -clang-*,\n"
" google-*",
"Options");

const auto Options = parseConfiguration(MemoryBuffer);

EXPECT_TRUE(!!Options);
EXPECT_EQ("-*,misc-*\nllvm-*\n-clang-*,\ngoogle-*\n",
*Options->WarningsAsErrors);
}

TEST(ParseConfiguration, WarningsAsErrorsAsList) {
const auto MemoryBuffer = llvm::MemoryBufferRef("WarningsAsErrors: [\n"
" '-*',\n"
" 'misc-*',\n"
" 'llvm-*',\n"
" '-clang-*',\n"
" 'google-*'\n"
"]",
"Options");

const auto Options = parseConfiguration(MemoryBuffer);

EXPECT_TRUE(!!Options);
EXPECT_EQ("-*,misc-*,llvm-*,-clang-*,google-*", *Options->WarningsAsErrors);
}

TEST(ParseConfiguration, MergeConfigurations) {
llvm::ErrorOr<ClangTidyOptions> Options1 =
parseConfiguration(llvm::MemoryBufferRef(R"(


+ 1
- 1
clang/docs/Modules.rst View File

@@ -297,7 +297,7 @@ First let us use an explicit mapping from modules to files.
clang -cc1 -emit-module -o prebuilt/B.pcm -fmodules module.modulemap -fmodule-name=B -fmodule-file=A=prebuilt/A.pcm
clang -cc1 -emit-obj use.c -fmodules -fmodule-map-file=module.modulemap -fmodule-file=A=prebuilt/A.pcm -fmodule-file=B=prebuilt/B.pcm

Instead of of specifying the mappings manually, it can be convenient to use the ``-fprebuilt-module-path`` option. Let's also use ``-fimplicit-module-maps`` instead of manually pointing to our module map.
Instead of specifying the mappings manually, it can be convenient to use the ``-fprebuilt-module-path`` option. Let's also use ``-fimplicit-module-maps`` instead of manually pointing to our module map.

.. code-block:: sh



+ 15
- 0
clang/docs/ReleaseNotes.rst View File

@@ -86,6 +86,12 @@ Potentially Breaking Changes
options-related code has been moved out of the Driver into a separate library.
- The ``clangFrontend`` library no longer depends on ``clangDriver``, which may
break downstream projects that relied on this transitive dependency.
- Clang now supports MSVC vector deleting destructors when targeting Windows.
This means that vtables of classes with virtual destructors will contain a
pointer to vector deleting destructor (instead of scalar deleting destructor)
which in fact is a different symbol with different name and linkage. This
may cause runtime failures if two binaries using the same class defining a
virtual destructor are compiled with different versions of clang.

C/C++ Language Potentially Breaking Changes
-------------------------------------------
@@ -373,6 +379,12 @@ Attribute Changes in Clang
multilibs for printf features. Requires cooperation with the libc
implementation.

- On targets with Itanium C++ ABI, Clang now supports ``[[gnu:gcc_struct]]``
with the behavior similar to one existing in GCC. In particular, whenever
``-mms-bitfields`` command line option is provided (or if Microsoft-compatible
structure layout is default on the target), ``[[gnu::gcc_struct]]`` requests
the compiler to follow Itanium rules for the layout of an annotated structure.

Improvements to Clang's diagnostics
-----------------------------------
- Diagnostics messages now refer to ``structured binding`` instead of ``decomposition``,
@@ -593,6 +605,7 @@ Bug Fixes to C++ Support
- Diagnose unresolved overload sets in non-dependent compound requirements. (#GH51246) (#GH97753)
- Fix a crash when extracting unavailable member type from alias in template deduction. (#GH165560)
- Fix incorrect diagnostics for lambdas with init-captures inside braced initializers. (#GH163498)
- Fixed an issue where templates prevented nested anonymous records from checking the deletion of special members. (#GH167217)
- Fixed spurious diagnoses of certain nested lambda expressions. (#GH149121) (#GH156579)
- Fix the result of ``__is_pointer_interconvertible_base_of`` when arguments are qualified and passed via template parameters. (#GH135273)

@@ -653,6 +666,8 @@ Windows Support
- clang-cl now supports /arch:AVX10.1 and /arch:AVX10.2.
- clang-cl now supports /vlen, /vlen=256 and /vlen=512.

- Clang now supports MSVC vector deleting destructors (GH19772).

LoongArch Support
^^^^^^^^^^^^^^^^^
- Enable linker relaxation by default for loongarch64.


+ 31
- 0
clang/include/clang/AST/ASTContext.h View File

@@ -370,6 +370,21 @@ class ASTContext : public RefCountedBase<ASTContext> {
mutable llvm::DenseSet<const FunctionDecl *> DestroyingOperatorDeletes;
mutable llvm::DenseSet<const FunctionDecl *> TypeAwareOperatorNewAndDeletes;

/// Global and array operators delete are only required for MSVC deleting
/// destructors support. Store them here to avoid keeping 4 pointers that are
/// not always used in each redeclaration of the destructor.
mutable llvm::DenseMap<const CXXDestructorDecl *, FunctionDecl *>
OperatorDeletesForVirtualDtor;
mutable llvm::DenseMap<const CXXDestructorDecl *, FunctionDecl *>
GlobalOperatorDeletesForVirtualDtor;
mutable llvm::DenseMap<const CXXDestructorDecl *, FunctionDecl *>
ArrayOperatorDeletesForVirtualDtor;
mutable llvm::DenseMap<const CXXDestructorDecl *, FunctionDecl *>
GlobalArrayOperatorDeletesForVirtualDtor;

/// To remember which types did require a vector deleting dtor.
llvm::DenseSet<const CXXRecordDecl *> RequireVectorDeletingDtor;

/// The next string literal "version" to allocate during constant evaluation.
/// This is used to distinguish between repeated evaluations of the same
/// string literal.
@@ -2795,6 +2810,10 @@ public:
/// runtime, such as those using the Itanium C++ ABI.
CharUnits getExnObjectAlignment() const;

/// Return whether unannotated records are treated as if they have
/// [[gnu::ms_struct]].
bool defaultsToMsStruct() const;

/// Get or compute information about the layout of the specified
/// record (struct/union/class) \p D, which indicates its size and field
/// position information.
@@ -3489,6 +3508,18 @@ public:
bool IsTypeAware);
bool isTypeAwareOperatorNewOrDelete(const FunctionDecl *FD) const;

enum OperatorDeleteKind { Regular, GlobalRegular, Array, ArrayGlobal };

void addOperatorDeleteForVDtor(const CXXDestructorDecl *Dtor,
FunctionDecl *OperatorDelete,
OperatorDeleteKind K) const;
FunctionDecl *getOperatorDeleteForVDtor(const CXXDestructorDecl *Dtor,
OperatorDeleteKind K) const;
bool dtorHasOperatorDelete(const CXXDestructorDecl *Dtor,
OperatorDeleteKind K) const;
void setClassNeedsVectorDeletingDestructor(const CXXRecordDecl *RD);
bool classNeedsVectorDeletingDestructor(const CXXRecordDecl *RD);

/// Retrieve the context for computing mangling numbers in the given
/// DeclContext.
MangleNumberingContext &getManglingNumberContext(const DeclContext *DC);


+ 9
- 0
clang/include/clang/AST/ASTMutationListener.h View File

@@ -90,6 +90,15 @@ public:
virtual void ResolvedOperatorGlobDelete(const CXXDestructorDecl *DD,
const FunctionDecl *GlobDelete) {}

/// A virtual destructor's operator array delete has been resolved.
virtual void ResolvedOperatorArrayDelete(const CXXDestructorDecl *DD,
const FunctionDecl *ArrayDelete) {}

/// A virtual destructor's operator global array delete has been resolved.
virtual void
ResolvedOperatorGlobArrayDelete(const CXXDestructorDecl *DD,
const FunctionDecl *GlobArrayDelete) {}

/// An implicit member got a definition.
virtual void CompletedImplicitDefinition(const FunctionDecl *D) {}



+ 6
- 10
clang/include/clang/AST/DeclCXX.h View File

@@ -2872,8 +2872,6 @@ class CXXDestructorDecl : public CXXMethodDecl {

// FIXME: Don't allocate storage for these except in the first declaration
// of a virtual destructor.
FunctionDecl *OperatorDelete = nullptr;
FunctionDecl *OperatorGlobalDelete = nullptr;
Expr *OperatorDeleteThisArg = nullptr;

CXXDestructorDecl(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc,
@@ -2900,14 +2898,12 @@ public:

void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg);
void setOperatorGlobalDelete(FunctionDecl *OD);

const FunctionDecl *getOperatorDelete() const {
return getCanonicalDecl()->OperatorDelete;
}

const FunctionDecl *getOperatorGlobalDelete() const {
return getCanonicalDecl()->OperatorGlobalDelete;
}
void setOperatorArrayDelete(FunctionDecl *OD);
void setGlobalOperatorArrayDelete(FunctionDecl *OD);
const FunctionDecl *getOperatorDelete() const;
const FunctionDecl *getOperatorGlobalDelete() const;
const FunctionDecl *getArrayOperatorDelete() const;
const FunctionDecl *getGlobalArrayOperatorDelete() const;

Expr *getOperatorDeleteThisArg() const {
return getCanonicalDecl()->OperatorDeleteThisArg;


+ 13
- 25
clang/include/clang/AST/VTableBuilder.h View File

@@ -150,7 +150,7 @@ public:

bool isRTTIKind() const { return isRTTIKind(getKind()); }

GlobalDecl getGlobalDecl() const {
GlobalDecl getGlobalDecl(bool HasVectorDeletingDtors) const {
assert(isUsedFunctionPointerKind() &&
"GlobalDecl can be created only from virtual function");

@@ -161,7 +161,9 @@ public:
case CK_CompleteDtorPointer:
return GlobalDecl(DtorDecl, CXXDtorType::Dtor_Complete);
case CK_DeletingDtorPointer:
return GlobalDecl(DtorDecl, CXXDtorType::Dtor_Deleting);
return GlobalDecl(DtorDecl, (HasVectorDeletingDtors)
? CXXDtorType::Dtor_VectorDeleting
: CXXDtorType::Dtor_Deleting);
case CK_VCallOffset:
case CK_VBaseOffset:
case CK_OffsetToTop:
@@ -244,12 +246,12 @@ public:
// point for a given vtable index.
typedef llvm::SmallVector<unsigned, 4> AddressPointsIndexMapTy;

using VTableIndicesTy = llvm::SmallVector<std::size_t>;

private:
// Stores the component indices of the first component of each virtual table in
// the virtual table group. To save a little memory in the common case where
// the vtable group contains a single vtable, an empty vector here represents
// the vector {0}.
OwningArrayRef<size_t> VTableIndices;
// Stores the component indices of the first component of each virtual table
// in the virtual table group.
VTableIndicesTy VTableIndices;

OwningArrayRef<VTableComponent> VTableComponents;

@@ -263,7 +265,8 @@ private:
AddressPointsIndexMapTy AddressPointIndices;

public:
VTableLayout(ArrayRef<size_t> VTableIndices,
// Requires `VTableIndices.front() == 0`
VTableLayout(VTableIndicesTy VTableIndices,
ArrayRef<VTableComponent> VTableComponents,
ArrayRef<VTableThunkTy> VTableThunks,
const AddressPointsMapTy &AddressPoints);
@@ -290,26 +293,11 @@ public:
return AddressPointIndices;
}

size_t getNumVTables() const {
if (VTableIndices.empty())
return 1;
return VTableIndices.size();
}
size_t getNumVTables() const { return VTableIndices.size(); }

size_t getVTableOffset(size_t i) const {
if (VTableIndices.empty()) {
assert(i == 0);
return 0;
}
return VTableIndices[i];
}
size_t getVTableOffset(size_t i) const { return VTableIndices[i]; }

size_t getVTableSize(size_t i) const {
if (VTableIndices.empty()) {
assert(i == 0);
return vtable_components().size();
}

size_t thisIndex = VTableIndices[i];
size_t nextIndex = (i + 1 == VTableIndices.size())
? vtable_components().size()


+ 6
- 5
clang/include/clang/Basic/ABI.h View File

@@ -32,11 +32,12 @@ enum CXXCtorType {

/// C++ destructor types.
enum CXXDtorType {
Dtor_Deleting, ///< Deleting dtor
Dtor_Complete, ///< Complete object dtor
Dtor_Base, ///< Base object dtor
Dtor_Comdat, ///< The COMDAT used for dtors
Dtor_Unified, ///< GCC-style unified dtor
Dtor_Deleting, ///< Deleting dtor
Dtor_Complete, ///< Complete object dtor
Dtor_Base, ///< Base object dtor
Dtor_Comdat, ///< The COMDAT used for dtors
Dtor_Unified, ///< GCC-style unified dtor
Dtor_VectorDeleting, ///< Vector deleting dtor
};

} // end namespace clang


+ 7
- 2
clang/include/clang/Basic/Attr.td View File

@@ -4387,8 +4387,13 @@ def CFGuard : InheritableAttr, TargetSpecificAttr<TargetWindows> {
def MSStruct : InheritableAttr {
let Spellings = [GCC<"ms_struct">];
let Subjects = SubjectList<[Record]>;
let Documentation = [Undocumented];
let SimpleHandler = 1;
let Documentation = [MSStructDocs];
}

def GCCStruct : InheritableAttr {
let Spellings = [GCC<"gcc_struct">];
let Subjects = SubjectList<[Record]>;
let Documentation = [MSStructDocs]; // Covers this attribute too.
}

def DLLExport : InheritableAttr, TargetSpecificAttr<TargetHasDLLImportExport> {


+ 22
- 1
clang/include/clang/Basic/AttrDocs.td View File

@@ -4140,7 +4140,7 @@ of 2.
.. code-block:: c

typedef double * aligned_double_ptr __attribute__((align_value(64)));
void foo(double & x __attribute__((align_value(128)),
void foo(double & x __attribute__((align_value(128))),
aligned_double_ptr y) { ... }

If the pointer value does not have the specified alignment at runtime, the
@@ -9682,3 +9682,24 @@ The following aspects are currently supported:
- ``float``: The call has a floating point argument
}];
}

def MSStructDocs : Documentation {
let Category = DocCatDecl;
let Content = [{
The ``ms_struct`` and ``gcc_struct`` attributes request the compiler to enter a
special record layout compatibility mode which mimics the layout of Microsoft or
Itanium C++ ABI respectively. Obviously, if the current C++ ABI matches the
requested ABI, the attribute does nothing. However, if it does not, annotated
structure or class is laid out in a special compatibility mode, which slightly
changes offsets for fields and bit-fields. The intention is to match the layout
of the requested ABI for structures which only use C features.

Note that the default behavior can be controlled by ``-mms-bitfields`` and
``-mno-ms-bitfields`` switches and via ``#pragma ms_struct``.

The primary difference is for bitfields, where the MS variant only packs
adjacent fields into the same allocation unit if they have integral types
of the same size, while the GCC/Itanium variant packs all fields in a bitfield
tightly.
}];
}

+ 12
- 0
clang/include/clang/Basic/Builtins.td View File

@@ -5284,6 +5284,18 @@ def HLSLDdyCoarse : LangBuiltin<"HLSL_LANG"> {
let Prototype = "void(...)";
}

def HLSLDdxFine : LangBuiltin<"HLSL_LANG"> {
let Spellings = ["__builtin_hlsl_elementwise_ddx_fine"];
let Attributes = [NoThrow, Const, CustomTypeChecking];
let Prototype = "void(...)";
}

def HLSLDdyFine : LangBuiltin<"HLSL_LANG"> {
let Spellings = ["__builtin_hlsl_elementwise_ddy_fine"];
let Attributes = [NoThrow, Const, CustomTypeChecking];
let Prototype = "void(...)";
}

// Builtins for XRay.
def XRayCustomEvent : Builtin {
let Spellings = ["__xray_customevent"];


+ 3
- 0
clang/include/clang/Basic/DiagnosticASTKinds.td View File

@@ -1040,6 +1040,9 @@ def warn_npot_ms_struct : Warning<
"data types with sizes that aren't a power of two">,
DefaultError, InGroup<IncompatibleMSStruct>;

def err_itanium_layout_unimplemented : Error<
"Itanium-compatible layout for the Microsoft C++ ABI is not yet supported">;

// -Wpadded-bitfield
def warn_padded_struct_bitfield : Warning<
"padding %select{struct|interface|class}0 %1 with %2 "


+ 2
- 0
clang/include/clang/Basic/DiagnosticDriverKinds.td View File

@@ -826,6 +826,8 @@ def err_drv_target_variant_invalid : Error<

def err_drv_invalid_directx_shader_module : Error<
"invalid profile : %0">;
def err_drv_dxc_invalid_matrix_layout : Error<
"cannot specify /Zpr and /Zpc together">;
def err_drv_dxc_missing_target_profile : Error<
"target profile option (-T) is missing">;
def err_drv_hlsl_unsupported_target : Error<


+ 3
- 1
clang/include/clang/Basic/LangOptions.def View File

@@ -104,7 +104,9 @@ LANGOPT(AssumeNothrowExceptionDtor , 1, 0, NotCompatible, "Assume exception obje
LANGOPT(TraditionalCPP , 1, 0, NotCompatible, "traditional CPP emulation")
LANGOPT(RTTI , 1, 1, NotCompatible, "run-time type information")
LANGOPT(RTTIData , 1, 1, NotCompatible, "emit run-time type information data")
LANGOPT(MSBitfields , 1, 0, NotCompatible, "Microsoft-compatible structure layout")
ENUM_LANGOPT(LayoutCompatibility, LayoutCompatibilityKind, 2,
LayoutCompatibilityKind::Default, NotCompatible,
"Microsoft-compatible structure layout")
LANGOPT(MSVolatile , 1, 0, NotCompatible, "Microsoft-compatible volatile loads and stores")
LANGOPT(Freestanding , 1, 0, NotCompatible, "freestanding implementation")
LANGOPT(NoBuiltin , 1, 0, NotCompatible, "disable builtin functions")


+ 10
- 0
clang/include/clang/Basic/LangOptions.h View File

@@ -421,6 +421,16 @@ public:
None,
};

enum class LayoutCompatibilityKind {
/// Use default layout rules of the target.
Default = 0,
/// Use Itanium rules for bit-field layout and fundamental types alignment.
Itanium = 1,
/// Use Microsoft C++ ABI rules for bit-field layout and fundamental types
/// alignment.
Microsoft = 2,
};

// Define simple language options (with no accessors).
#define LANGOPT(Name, Bits, Default, Compatibility, Description) \
unsigned Name : Bits;


+ 5
- 0
clang/include/clang/Basic/TargetInfo.h View File

@@ -1798,6 +1798,11 @@ public:
/// destructor body.
virtual bool callGlobalDeleteInDeletingDtor(const LangOptions &) const;

/// Controls whether to emit MSVC vector deleting destructors. The support for
/// vector deleting affects vtable layout and therefore is an ABI breaking
/// change. The support was only implemented at Clang 22 timeframe.
virtual bool emitVectorDeletingDtors(const LangOptions &) const;

/// Controls if __builtin_longjmp / __builtin_setjmp can be lowered to
/// llvm.eh.sjlj.longjmp / llvm.eh.sjlj.setjmp.
virtual bool hasSjLjLowering() const {


+ 3
- 2
clang/include/clang/Basic/arm_mve.td View File

@@ -598,7 +598,7 @@ foreach half = [ "b", "t" ] in {
} // params = [f16], pnt = PNT_None
} // loop over half = "b", "t"

multiclass float_int_conversions<Type FScalar, Type IScalar, IRBuilderBase ftoi, IRBuilderBase itof> {
multiclass float_int_conversions<Type FScalar, Type IScalar, Builder ftoi, Builder itof> {
defvar FVector = VecOf<FScalar>;
defvar IVector = VecOf<IScalar>;

@@ -700,7 +700,8 @@ let params = [s16, s32] in {

multiclass vrnd<IRIntBase ir_int, string suffix> {
let params = T.Float in {
def "": Intrinsic<Vector, (args Vector:$a), (ir_int $a)>;
def "": Intrinsic<Vector, (args Vector:$a),
(strictFPAlt<ir_int, IRInt<"vrint"#suffix, [Vector]>> $a)>;
defm "": IntrinsicMX<Vector, (args Vector:$a, Predicate:$pred),
(IRInt<"vrint"#suffix#"_predicated", [Vector, Predicate]>
$a, $pred, $inactive)>;


+ 32
- 12
clang/include/clang/Basic/arm_mve_defs.td View File

@@ -114,19 +114,19 @@ def icmp_sgt: IRBuilder<"CreateICmpSGT">;
def icmp_sge: IRBuilder<"CreateICmpSGE">;
def icmp_slt: IRBuilder<"CreateICmpSLT">;
def icmp_sle: IRBuilder<"CreateICmpSLE">;
def fcmp_eq: IRBuilder<"CreateFCmpOEQ">;
def fcmp_ne: IRBuilder<"CreateFCmpUNE">; // not O: it must return true on NaNs
def fcmp_gt: IRBuilder<"CreateFCmpOGT">;
def fcmp_ge: IRBuilder<"CreateFCmpOGE">;
def fcmp_ult: IRBuilder<"CreateFCmpULT">;
def fcmp_ule: IRBuilder<"CreateFCmpULE">;
def fcmp_eq_node: IRBuilder<"CreateFCmpOEQ">;
def fcmp_ne_node: IRBuilder<"CreateFCmpUNE">; // not O: it must return true on NaNs
def fcmp_gt_node: IRBuilder<"CreateFCmpOGT">;
def fcmp_ge_node: IRBuilder<"CreateFCmpOGE">;
def fcmp_ult_node: IRBuilder<"CreateFCmpULT">;
def fcmp_ule_node: IRBuilder<"CreateFCmpULE">;
def splat: CGHelperFn<"ARMMVEVectorSplat">;
def select: IRBuilder<"CreateSelect">;
def fneg: IRBuilder<"CreateFNeg">;
def sitofp: IRBuilder<"CreateSIToFP">;
def uitofp: IRBuilder<"CreateUIToFP">;
def fptosi: IRBuilder<"CreateFPToSI">;
def fptoui: IRBuilder<"CreateFPToUI">;
def sitofp_node: IRBuilder<"CreateSIToFP">;
def uitofp_node: IRBuilder<"CreateUIToFP">;
def fptosi_node: IRBuilder<"CreateFPToSI">;
def fptoui_node: IRBuilder<"CreateFPToUI">;
def vrev: CGHelperFn<"ARMMVEVectorElementReverse"> {
let special_params = [IRBuilderIntParam<1, "unsigned">];
}
@@ -215,9 +215,9 @@ def bitsize;

// strictFPAlt allows a node to have different code generation under strict-fp.
// TODO: The standard node can be IRBuilderBase or IRIntBase.
class strictFPAlt<Builder standard_, IRIntBase strictfp_> : Builder {
class strictFPAlt<Builder standard_, Builder strictfp_> : Builder {
Builder standard = standard_;
IRIntBase strictfp = strictfp_;
Builder strictfp = strictfp_;
}

// If you put CustomCodegen<"foo"> in an intrinsic's codegen field, it
@@ -593,6 +593,26 @@ def fminnm : strictFPAlt<IRIntBase<"minnum", [Vector]>,
IRInt<"vminnm", [Vector]>>;
def fmaxnm : strictFPAlt<IRIntBase<"maxnum", [Vector]>,
IRInt<"vmaxnm", [Vector]>>;
def fcmp_eq : strictFPAlt<fcmp_eq_node,
IRInt<"cmp_eq", [Predicate, Vector]>>;
def fcmp_ne : strictFPAlt<fcmp_ne_node,
IRInt<"cmp_ne", [Predicate, Vector]>>;
def fcmp_gt : strictFPAlt<fcmp_gt_node,
IRInt<"cmp_gt", [Predicate, Vector]>>;
def fcmp_ge : strictFPAlt<fcmp_ge_node,
IRInt<"cmp_ge", [Predicate, Vector]>>;
def fcmp_ult : strictFPAlt<fcmp_ult_node,
IRInt<"cmp_lt", [Predicate, Vector]>>;
def fcmp_ule : strictFPAlt<fcmp_ule_node,
IRInt<"cmp_le", [Predicate, Vector]>>;
def sitofp: strictFPAlt<sitofp_node,
CGFHelperFn<"ARMMVECreateSIToFP">>;
def uitofp: strictFPAlt<uitofp_node,
CGFHelperFn<"ARMMVECreateUIToFP">>;
def fptosi: strictFPAlt<fptosi_node,
CGFHelperFn<"ARMMVECreateFPToSI">>;
def fptoui: strictFPAlt<fptoui_node,
CGFHelperFn<"ARMMVECreateFPToUI">>;

// -----------------------------------------------------------------------------
// Convenience lists of parameter types. 'T' is just a container record, so you


+ 4
- 4
clang/include/clang/Basic/arm_sve.td View File

@@ -1292,10 +1292,10 @@ defm SVQSUB_S : SInstZPZZ<"svqsub", "csli", "aarch64_sve_sqsub", "aarch64
defm SVQSUB_U : SInstZPZZ<"svqsub", "UcUsUiUl", "aarch64_sve_uqsub", "aarch64_sve_uqsub_u">;
defm SVQSUBR_S : SInstZPZZ<"svqsubr", "csli", "aarch64_sve_sqsubr", "aarch64_sve_sqsub_u", [ReverseMergeAnyBinOp]>;
defm SVQSUBR_U : SInstZPZZ<"svqsubr", "UcUsUiUl", "aarch64_sve_uqsubr", "aarch64_sve_uqsub_u", [ReverseMergeAnyBinOp]>;
defm SVHSUB_S : SInstZPZZ<"svhsub", "csli", "aarch64_sve_shsub", "aarch64_sve_shsub">;
defm SVHSUB_U : SInstZPZZ<"svhsub", "UcUsUiUl", "aarch64_sve_uhsub", "aarch64_sve_uhsub">;
defm SVHSUBR_S : SInstZPZZ<"svhsubr", "csli", "aarch64_sve_shsubr", "aarch64_sve_shsubr">;
defm SVHSUBR_U : SInstZPZZ<"svhsubr", "UcUsUiUl", "aarch64_sve_uhsubr", "aarch64_sve_uhsubr">;
defm SVHSUB_S : SInstZPZZ<"svhsub", "csli", "aarch64_sve_shsub", "aarch64_sve_shsub_u">;
defm SVHSUB_U : SInstZPZZ<"svhsub", "UcUsUiUl", "aarch64_sve_uhsub", "aarch64_sve_uhsub_u">;
defm SVHSUBR_S : SInstZPZZ<"svhsubr", "csli", "aarch64_sve_shsubr", "aarch64_sve_shsub_u", [ReverseMergeAnyBinOp]>;
defm SVHSUBR_U : SInstZPZZ<"svhsubr", "UcUsUiUl", "aarch64_sve_uhsubr", "aarch64_sve_uhsub_u", [ReverseMergeAnyBinOp]>;

defm SVQABS : SInstZPZ<"svqabs", "csil", "aarch64_sve_sqabs">;
defm SVQNEG : SInstZPZ<"svqneg", "csil", "aarch64_sve_sqneg">;


+ 5
- 0
clang/include/clang/CIR/Dialect/IR/CIROps.td View File

@@ -2746,6 +2746,10 @@ def CIR_FuncOp : CIR_Op<"func", [
The `always_inline` attribute marks a function that should always be inlined.
The `inline_hint` attribute suggests that the function should be inlined.

The `personality` attribute specifies the personality function to use for
exception handling. This is a symbol reference to the personality function
(e.g., `@__gxx_personality_v0` for C++ exceptions).

Example:

```mlir
@@ -2792,6 +2796,7 @@ def CIR_FuncOp : CIR_Op<"func", [
OptionalAttr<DictArrayAttr>:$arg_attrs,
OptionalAttr<DictArrayAttr>:$res_attrs,
OptionalAttr<FlatSymbolRefAttr>:$aliasee,
OptionalAttr<FlatSymbolRefAttr>:$personality,
CIR_OptionalPriorityAttr:$global_ctor_priority,
CIR_OptionalPriorityAttr:$global_dtor_priority,
OptionalAttr<CIR_CXXSpecialMemberAttr>:$cxx_special_member


+ 1
- 1
clang/include/clang/CIR/MissingFeatures.h View File

@@ -93,7 +93,6 @@ struct MissingFeatures {
static bool opFuncNoReturn() { return false; }
static bool setFunctionAttributes() { return false; }
static bool setLLVMFunctionFEnvAttributes() { return false; }
static bool setFunctionPersonality() { return false; }

// CallOp handling
static bool opCallAggregateArgs() { return false; }
@@ -279,6 +278,7 @@ struct MissingFeatures {

static bool fpConstraints() { return false; }
static bool generateDebugInfo() { return false; }
static bool getRuntimeFunctionDecl() { return false; }
static bool globalViewIndices() { return false; }
static bool globalViewIntLowering() { return false; }
static bool handleBuiltinICEArguments() { return false; }


+ 5
- 17
clang/include/clang/DependencyScanning/DependencyScannerImpl.h View File

@@ -17,6 +17,7 @@
#include "clang/Frontend/CompilerInvocation.h"
#include "clang/Frontend/TextDiagnosticPrinter.h"
#include "clang/Serialization/ObjectFilePCHContainerReader.h"
#include "llvm/Support/VirtualFileSystem.h"

namespace clang {
class DiagnosticConsumer;
@@ -143,22 +144,11 @@ class CompilerInstanceWithContext {
llvm::StringRef CWD;
std::vector<std::string> CommandLine;

// Context - file systems
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFS;

// Context - Diagnostics engine.
std::unique_ptr<TextDiagnosticsPrinterWithOutput> DiagPrinterWithOS;
// DiagConsumer may points to DiagPrinterWithOS->DiagPrinter, or a custom
// DiagnosticConsumer passed in from initialize.
DiagnosticConsumer *DiagConsumer = nullptr;
std::unique_ptr<DiagnosticsEngineWithDiagOpts> DiagEngineWithCmdAndOpts;

// Context - compiler invocation
// Compilation's command's arguments may be owned by Alloc when expanded from
// response files, so we need to keep Alloc alive in the context.
llvm::BumpPtrAllocator Alloc;
std::unique_ptr<clang::driver::Driver> Driver;
std::unique_ptr<clang::driver::Compilation> Compilation;
std::unique_ptr<CompilerInvocation> OriginalInvocation;

// Context - output options
@@ -180,15 +170,13 @@ public:
: Worker(Worker), CWD(CWD), CommandLine(CMD) {};

// The three methods below returns false when they fail, with the detail
// accumulated in DiagConsumer.
bool initialize(DiagnosticConsumer *DC);
// accumulated in \c DiagEngineWithDiagOpts's diagnostic consumer.
bool initialize(
std::unique_ptr<DiagnosticsEngineWithDiagOpts> DiagEngineWithDiagOpts,
IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFS);
bool computeDependencies(StringRef ModuleName, DependencyConsumer &Consumer,
DependencyActionController &Controller);
bool finalize();

// The method below turns the return status from the above methods
// into an llvm::Error using a default DiagnosticConsumer.
llvm::Error handleReturnStatus(bool Success);
};
} // namespace dependencies
} // namespace clang


+ 25
- 21
clang/include/clang/DependencyScanning/DependencyScanningWorker.h View File

@@ -12,12 +12,14 @@
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/LLVM.h"
#include "clang/DependencyScanning/DependencyScannerImpl.h"
#include "clang/DependencyScanning/DependencyScanningService.h"
#include "clang/DependencyScanning/ModuleDepCollector.h"
#include "clang/Frontend/PCHContainerOperations.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBufferRef.h"
#include "llvm/Support/VirtualFileSystem.h"
#include <optional>
#include <string>

@@ -119,13 +121,28 @@ public:
/// dependency scanning. They together enable the dependency scanning worker
/// to more effectively perform scanning for a sequence of modules
/// by name when the CWD and CommandLine do not change across the queries.
/// The initialization function asks the client for a DiagnosticsConsumer
/// that it direct the diagnostics to.

/// @brief Initializing the context and the compiler instance.
/// @param CWD The current working directory used during the scan.
/// @param CommandLine The commandline used for the scan.
/// @return Error if the initializaiton fails.
llvm::Error initializeCompilerInstanceWithContextOrError(
StringRef CWD, ArrayRef<std::string> CommandLine);
/// @return False if the initializaiton fails.
bool initializeCompilerInstanceWithContext(StringRef CWD,
ArrayRef<std::string> CommandLine,
DiagnosticConsumer &DC);

/// @brief Initializing the context and the compiler instance.
/// @param CWD The current working directory used during the scan.
/// @param CommandLine The commandline used for the scan.
/// @param DiagEngineWithCmdAndOpts Preconfigured diagnostics engine and
/// options associated with the cc1 command line.
/// @param FS The overlay file system to use for this compiler instance.
/// @return False if the initializaiton fails.
bool initializeCompilerInstanceWithContext(
StringRef CWD, ArrayRef<std::string> CommandLine,
std::unique_ptr<DiagnosticsEngineWithDiagOpts> DiagEngineWithCmdAndOpts,
IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFS);

/// @brief Performaces dependency scanning for the module whose name is
/// specified.
@@ -133,28 +150,15 @@ public:
/// scanned.
/// @param Consumer The dependency consumer that stores the results.
/// @param Controller The controller for the dependency scanning action.
/// @return Error if the scanner incurs errors.
llvm::Error computeDependenciesByNameWithContextOrError(
StringRef ModuleName, DependencyConsumer &Consumer,
DependencyActionController &Controller);

/// @brief Finalizes the diagnostics engine and deletes the compiler instance.
/// @return Error if errors occur during finalization.
llvm::Error finalizeCompilerInstanceWithContextOrError();

/// The three methods below provides the same functionality as the
/// three methods above. Instead of returning `llvm::Error`s, these
/// three methods return a flag to indicate if the call is successful.
/// The initialization function asks the client for a DiagnosticsConsumer
/// that it direct the diagnostics to.
bool initializeCompilerInstanceWithContext(StringRef CWD,
ArrayRef<std::string> CommandLine,
DiagnosticConsumer *DC = nullptr);
/// @return False if the scanner incurs errors.
bool
computeDependenciesByNameWithContext(StringRef ModuleName,
DependencyConsumer &Consumer,
DependencyActionController &Controller);
bool finalizeCompilerInstance();

/// @brief Finalizes the diagnostics engine and deletes the compiler instance.
/// @return False if errors occur during finalization.
bool finalizeCompilerInstanceWithContext();

llvm::vfs::FileSystem &getVFS() const { return *DepFS; }



+ 5
- 0
clang/include/clang/Frontend/ASTUnit.h View File

@@ -476,6 +476,11 @@ public:
return *LangOpts;
}

const CodeGenOptions &getCodeGenOpts() const {
assert(CodeGenOpts && "ASTUnit does not have codegen options");
return *CodeGenOpts;
}

const HeaderSearchOptions &getHeaderSearchOpts() const {
assert(HSOpts && "ASTUnit does not have header search options");
return *HSOpts;


+ 9
- 3
clang/include/clang/Options/Options.td View File

@@ -5219,9 +5219,7 @@ def : Joined<["-"], "mmacosx-version-min=">,
Visibility<[ClangOption, CC1Option, FC1Option, FlangOption]>,
Group<m_Group>, Alias<mmacos_version_min_EQ>;
def mms_bitfields : Flag<["-"], "mms-bitfields">, Group<m_Group>,
Visibility<[ClangOption, CC1Option]>,
HelpText<"Set the default structure layout to be compatible with the Microsoft compiler standard">,
MarshallingInfoFlag<LangOpts<"MSBitfields">>;
HelpText<"Set the default structure layout to be compatible with the Microsoft compiler standard">;
def moutline : Flag<["-"], "moutline">, Group<f_clang_Group>,
Visibility<[ClangOption, CC1Option]>,
HelpText<"Enable function outlining (AArch64 only)">;
@@ -5230,6 +5228,12 @@ def mno_outline : Flag<["-"], "mno-outline">, Group<f_clang_Group>,
HelpText<"Disable function outlining (AArch64 only)">;
def mno_ms_bitfields : Flag<["-"], "mno-ms-bitfields">, Group<m_Group>,
HelpText<"Do not set the default structure layout to be compatible with the Microsoft compiler standard">;
def fms_layout_compatibility_EQ : Joined<["-"], "fms-layout-compatibility=">,
Visibility<[CC1Option]>,
HelpText<"Structure layout compatibility with Microsoft C++ ABI">,
Values<"default,itanium,microsoft">,
NormalizedValues<["Default", "Itanium", "Microsoft"]>, NormalizedValuesScope<"LangOptions::LayoutCompatibilityKind">,
MarshallingInfoEnum<LangOpts<"LayoutCompatibility">, "Default">;
def mskip_rax_setup : Flag<["-"], "mskip-rax-setup">, Group<m_Group>,
Visibility<[ClangOption, CC1Option]>,
HelpText<"Skip setting up RAX register when passing variable arguments (x86 only)">,
@@ -9603,6 +9607,8 @@ class DXCJoinedOrSeparate<string name> : Option<["/", "-"], name,
KIND_JOINED_OR_SEPARATE>, Group<dxc_Group>,
Visibility<[DXCOption]>;

def dxc_col_major : DXCFlag<"Zpc">, HelpText<"Pack matrices in column-major order">;
def dxc_row_major : DXCFlag<"Zpr">, HelpText<"Pack matrices in row-major order">;
def dxc_no_stdinc : DXCFlag<"hlsl-no-stdinc">,
HelpText<"HLSL only. Disables all standard includes containing non-native compiler types and functions.">;
def dxc_Fo : DXCJoinedOrSeparate<"Fo">,


+ 3
- 0
clang/include/clang/Sema/Overload.h View File

@@ -207,6 +207,9 @@ class Sema;
// HLSL vector splat from scalar or boolean type.
ICK_HLSL_Vector_Splat,

/// HLSL matrix splat from scalar or boolean type.
ICK_HLSL_Matrix_Splat,

/// The number of conversion kinds
ICK_Num_Conversion_Kinds,
};


+ 6
- 1
clang/include/clang/Sema/Sema.h View File

@@ -7944,6 +7944,10 @@ public:
/// implicit casts if necessary.
ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr);

/// Prepare `SplattedExpr` for a matrix splat operation, adding
/// implicit casts if necessary.
ExprResult prepareMatrixSplat(QualType MatrixTy, Expr *SplattedExpr);

// CheckExtVectorCast - check type constraints for extended vectors.
// Since vectors are an extension, there are no C standard reference for this.
// We allow casting between vectors and integer datatypes of the same size,
@@ -8586,7 +8590,8 @@ public:
FunctionDecl *FindDeallocationFunctionForDestructor(SourceLocation StartLoc,
CXXRecordDecl *RD,
bool Diagnose,
bool LookForGlobal);
bool LookForGlobal,
DeclarationName Name);

/// ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
/// @code ::delete ptr; @endcode


+ 4
- 0
clang/include/clang/Serialization/ASTWriter.h View File

@@ -955,6 +955,10 @@ private:
Expr *ThisArg) override;
void ResolvedOperatorGlobDelete(const CXXDestructorDecl *DD,
const FunctionDecl *Delete) override;
void ResolvedOperatorArrayDelete(const CXXDestructorDecl *DD,
const FunctionDecl *Delete) override;
void ResolvedOperatorGlobArrayDelete(const CXXDestructorDecl *DD,
const FunctionDecl *Delete) override;
void CompletedImplicitDefinition(const FunctionDecl *D) override;
void InstantiationRequested(const ValueDecl *D) override;
void VariableDefinitionInstantiated(const VarDecl *D) override;


+ 5
- 5
clang/include/clang/Tooling/DependencyScanningTool.h View File

@@ -9,6 +9,7 @@
#ifndef LLVM_CLANG_TOOLING_DEPENDENCYSCANNINGTOOL_H
#define LLVM_CLANG_TOOLING_DEPENDENCYSCANNINGTOOL_H

#include "clang/DependencyScanning/DependencyScannerImpl.h"
#include "clang/DependencyScanning/DependencyScanningService.h"
#include "clang/DependencyScanning/DependencyScanningUtils.h"
#include "clang/DependencyScanning/DependencyScanningWorker.h"
@@ -119,9 +120,8 @@ public:
/// @param CWD The current working directory used during the scan.
/// @param CommandLine The commandline used for the scan.
/// @return Error if the initializaiton fails.
llvm::Error
initializeCompilerInstanceWithContext(StringRef CWD,
ArrayRef<std::string> CommandLine);
llvm::Error initializeCompilerInstanceWithContextOrError(
StringRef CWD, ArrayRef<std::string> CommandLine);

/// @brief Computes the dependeny for the module named ModuleName.
/// @param ModuleName The name of the module for which this method computes
@@ -138,7 +138,7 @@ public:
/// @return An instance of \c TranslationUnitDeps if the scan is successful.
/// Otherwise it returns an error.
llvm::Expected<dependencies::TranslationUnitDeps>
computeDependenciesByNameWithContext(
computeDependenciesByNameWithContextOrError(
StringRef ModuleName,
const llvm::DenseSet<dependencies::ModuleID> &AlreadySeen,
dependencies::LookupModuleOutputCallback LookupModuleOutput);
@@ -147,7 +147,7 @@ public:
/// diagnostics and deletes the compiler instance. Call this method
/// once all names for a same commandline are scanned.
/// @return Error if an error occured during finalization.
llvm::Error finalizeCompilerInstanceWithContext();
llvm::Error finalizeCompilerInstanceWithContextOrError();

llvm::vfs::FileSystem &getWorkerVFS() const { return Worker.getVFS(); }



+ 85
- 0
clang/lib/AST/ASTContext.cpp View File

@@ -13348,6 +13348,91 @@ bool ASTContext::isTypeAwareOperatorNewOrDelete(const FunctionDecl *FD) const {
return TypeAwareOperatorNewAndDeletes.contains(FD->getCanonicalDecl());
}

void ASTContext::addOperatorDeleteForVDtor(const CXXDestructorDecl *Dtor,
FunctionDecl *OperatorDelete,
OperatorDeleteKind K) const {
switch (K) {
case OperatorDeleteKind::Regular:
OperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] = OperatorDelete;
break;
case OperatorDeleteKind::GlobalRegular:
GlobalOperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] =
OperatorDelete;
break;
case OperatorDeleteKind::Array:
ArrayOperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] =
OperatorDelete;
break;
case OperatorDeleteKind::ArrayGlobal:
GlobalArrayOperatorDeletesForVirtualDtor[Dtor->getCanonicalDecl()] =
OperatorDelete;
break;
}
}

bool ASTContext::dtorHasOperatorDelete(const CXXDestructorDecl *Dtor,
OperatorDeleteKind K) const {
switch (K) {
case OperatorDeleteKind::Regular:
return OperatorDeletesForVirtualDtor.contains(Dtor->getCanonicalDecl());
case OperatorDeleteKind::GlobalRegular:
return GlobalOperatorDeletesForVirtualDtor.contains(
Dtor->getCanonicalDecl());
case OperatorDeleteKind::Array:
return ArrayOperatorDeletesForVirtualDtor.contains(
Dtor->getCanonicalDecl());
case OperatorDeleteKind::ArrayGlobal:
return GlobalArrayOperatorDeletesForVirtualDtor.contains(
Dtor->getCanonicalDecl());
}
return false;
}

FunctionDecl *
ASTContext::getOperatorDeleteForVDtor(const CXXDestructorDecl *Dtor,
OperatorDeleteKind K) const {
const CXXDestructorDecl *Canon = Dtor->getCanonicalDecl();
switch (K) {
case OperatorDeleteKind::Regular:
if (OperatorDeletesForVirtualDtor.contains(Canon))
return OperatorDeletesForVirtualDtor[Canon];
return nullptr;
case OperatorDeleteKind::GlobalRegular:
if (GlobalOperatorDeletesForVirtualDtor.contains(Canon))
return GlobalOperatorDeletesForVirtualDtor[Canon];
return nullptr;
case OperatorDeleteKind::Array:
if (ArrayOperatorDeletesForVirtualDtor.contains(Canon))
return ArrayOperatorDeletesForVirtualDtor[Canon];
return nullptr;
case OperatorDeleteKind::ArrayGlobal:
if (GlobalArrayOperatorDeletesForVirtualDtor.contains(Canon))
return GlobalArrayOperatorDeletesForVirtualDtor[Canon];
return nullptr;
}
return nullptr;
}

bool ASTContext::classNeedsVectorDeletingDestructor(const CXXRecordDecl *RD) {
if (!getTargetInfo().emitVectorDeletingDtors(getLangOpts()))
return false;
CXXDestructorDecl *Dtor = RD->getDestructor();
// The compiler can't know if new[]/delete[] will be used outside of the DLL,
// so just force vector deleting destructor emission if dllexport is present.
// This matches MSVC behavior.
if (Dtor && Dtor->isVirtual() && Dtor->hasAttr<DLLExportAttr>())
return true;

return RequireVectorDeletingDtor.count(RD);
}

void ASTContext::setClassNeedsVectorDeletingDestructor(
const CXXRecordDecl *RD) {
if (!getTargetInfo().emitVectorDeletingDtors(getLangOpts()))
return;
RequireVectorDeletingDtor.insert(RD);
}

MangleNumberingContext &
ASTContext::getManglingNumberContext(const DeclContext *DC) {
assert(LangOpts.CPlusPlus); // We don't need mangling numbers for plain C.


+ 8
- 1
clang/lib/AST/Decl.cpp View File

@@ -5244,7 +5244,14 @@ void RecordDecl::completeDefinition() {
/// This which can be turned on with an attribute, pragma, or the
/// -mms-bitfields command-line option.
bool RecordDecl::isMsStruct(const ASTContext &C) const {
return hasAttr<MSStructAttr>() || C.getLangOpts().MSBitfields == 1;
if (hasAttr<GCCStructAttr>())
return false;
if (hasAttr<MSStructAttr>())
return true;
auto LayoutCompatibility = C.getLangOpts().getLayoutCompatibility();
if (LayoutCompatibility == LangOptions::LayoutCompatibilityKind::Default)
return C.defaultsToMsStruct();
return LayoutCompatibility == LangOptions::LayoutCompatibilityKind::Microsoft;
}

void RecordDecl::reorderDecls(const SmallVectorImpl<Decl *> &Decls) {


+ 63
- 10
clang/lib/AST/DeclCXX.cpp View File

@@ -3110,12 +3110,15 @@ CXXDestructorDecl *CXXDestructorDecl::Create(
}

void CXXDestructorDecl::setOperatorDelete(FunctionDecl *OD, Expr *ThisArg) {
auto *First = cast<CXXDestructorDecl>(getFirstDecl());
if (OD && !First->OperatorDelete) {
First->OperatorDelete = OD;
First->OperatorDeleteThisArg = ThisArg;
assert(!OD || (OD->getDeclName().getCXXOverloadedOperator() == OO_Delete));
if (OD && !getASTContext().dtorHasOperatorDelete(
this, ASTContext::OperatorDeleteKind::Regular)) {
getASTContext().addOperatorDeleteForVDtor(
this, OD, ASTContext::OperatorDeleteKind::Regular);
getCanonicalDecl()->OperatorDeleteThisArg = ThisArg;
if (auto *L = getASTMutationListener())
L->ResolvedOperatorDelete(First, OD, ThisArg);
L->ResolvedOperatorDelete(cast<CXXDestructorDecl>(getCanonicalDecl()), OD,
ThisArg);
}
}

@@ -3127,14 +3130,63 @@ void CXXDestructorDecl::setOperatorGlobalDelete(FunctionDecl *OD) {
assert(!OD ||
(OD->getDeclName().getCXXOverloadedOperator() == OO_Delete &&
OD->getDeclContext()->getRedeclContext()->isTranslationUnit()));
auto *Canonical = cast<CXXDestructorDecl>(getCanonicalDecl());
if (!Canonical->OperatorGlobalDelete) {
Canonical->OperatorGlobalDelete = OD;
if (OD && !getASTContext().dtorHasOperatorDelete(
this, ASTContext::OperatorDeleteKind::GlobalRegular)) {
getASTContext().addOperatorDeleteForVDtor(
this, OD, ASTContext::OperatorDeleteKind::GlobalRegular);
if (auto *L = getASTMutationListener())
L->ResolvedOperatorGlobDelete(Canonical, OD);
L->ResolvedOperatorGlobDelete(cast<CXXDestructorDecl>(getCanonicalDecl()),
OD);
}
}

void CXXDestructorDecl::setOperatorArrayDelete(FunctionDecl *OD) {
assert(!OD ||
(OD->getDeclName().getCXXOverloadedOperator() == OO_Array_Delete));
if (OD && !getASTContext().dtorHasOperatorDelete(
this, ASTContext::OperatorDeleteKind::Array)) {
getASTContext().addOperatorDeleteForVDtor(
this, OD, ASTContext::OperatorDeleteKind::Array);
if (auto *L = getASTMutationListener())
L->ResolvedOperatorArrayDelete(
cast<CXXDestructorDecl>(getCanonicalDecl()), OD);
}
}

void CXXDestructorDecl::setGlobalOperatorArrayDelete(FunctionDecl *OD) {
assert(!OD ||
(OD->getDeclName().getCXXOverloadedOperator() == OO_Array_Delete &&
OD->getDeclContext()->getRedeclContext()->isTranslationUnit()));
if (OD && !getASTContext().dtorHasOperatorDelete(
this, ASTContext::OperatorDeleteKind::ArrayGlobal)) {
getASTContext().addOperatorDeleteForVDtor(
this, OD, ASTContext::OperatorDeleteKind::ArrayGlobal);
if (auto *L = getASTMutationListener())
L->ResolvedOperatorGlobArrayDelete(
cast<CXXDestructorDecl>(getCanonicalDecl()), OD);
}
}

const FunctionDecl *CXXDestructorDecl::getOperatorDelete() const {
return getASTContext().getOperatorDeleteForVDtor(
this, ASTContext::OperatorDeleteKind::Regular);
}

const FunctionDecl *CXXDestructorDecl::getOperatorGlobalDelete() const {
return getASTContext().getOperatorDeleteForVDtor(
this, ASTContext::OperatorDeleteKind::GlobalRegular);
}

const FunctionDecl *CXXDestructorDecl::getArrayOperatorDelete() const {
return getASTContext().getOperatorDeleteForVDtor(
this, ASTContext::OperatorDeleteKind::Array);
}

const FunctionDecl *CXXDestructorDecl::getGlobalArrayOperatorDelete() const {
return getASTContext().getOperatorDeleteForVDtor(
this, ASTContext::OperatorDeleteKind::ArrayGlobal);
}

bool CXXDestructorDecl::isCalledByDelete(const FunctionDecl *OpDel) const {
// C++20 [expr.delete]p6: If the value of the operand of the delete-
// expression is not a null pointer value and the selected deallocation
@@ -3146,7 +3198,8 @@ bool CXXDestructorDecl::isCalledByDelete(const FunctionDecl *OpDel) const {
// delete operator, as that destructor is never called, unless the
// destructor is virtual (see [expr.delete]p8.1) because then the
// selected operator depends on the dynamic type of the pointer.
const FunctionDecl *SelectedOperatorDelete = OpDel ? OpDel : OperatorDelete;
const FunctionDecl *SelectedOperatorDelete =
OpDel ? OpDel : getOperatorDelete();
if (!SelectedOperatorDelete)
return true;



Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save
Baidu
map