aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaCodeComplete.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-09-16[clang][HeuristicResolver] Use HeuristicResolver to implement ↵Nathan Ridge1-90/+7
getApproximateType() in SemaCodeComplete (#156282) This patch ports over the remaining functionality present in SemaCodeComplete's getApproximateType() but not in HeuristicResolver, into HeuristicResolver, and uses HeuristicResolver to reimplement getApproximateType(). This has the effect of enhancing both code completion (which now benefit from the full range of HeuristicResolver's capabilities), and existing consumers of HeuristicResolver like clangd's go-to-definition whose behaviour now has parity with code completion. Fixes https://github.com/clangd/clangd/issues/2432
2025-08-27[clang] NFC: reintroduce clang/include/clang/AST/Type.h (#155050)Matheus Izvekov1-1/+1
This reintroduces `Type.h`, having earlier been renamed to `TypeBase.h`, as a redirection to `TypeBase.h`, and redirects most users to include the former instead. This is a preparatory patch for being able to provide inline definitions for `Type` methods which would otherwise cause a circular dependency with `Decl{,CXX}.h`. Doing these operations into their own NFC patch helps the git rename detection logic work, preserving the history. This patch makes clang just a little slower to build (~0.17%), just because it makes more code indirectly include `DeclCXX.h`.
2025-08-27[clang] NFC: rename clang/include/clang/AST/Type.h to TypeBase.h (#155049)Matheus Izvekov1-1/+1
This is a preparatory patch, to be able to provide inline definitions for `Type` functions which depend on `Decl{,CXX}.h`. As the latter also depends on `Type.h`, this would not be possible without some reorganizing. Splitting this rename into its own patch allows git to track this as a rename, and preserve all git history, and not force any code reformatting. A later NFC patch will reintroduce `Type.h` as redirection to `TypeBase.h`, rewriting most places back to directly including `Type.h` instead of `TypeBase.h`, leaving only a handful of places where this is necessary. Then yet a later patch will exploit this by making more stuff inline.
2025-08-26[clang] NFC: introduce Type::getAsEnumDecl, and cast variants for all ↵Matheus Izvekov1-10/+3
TagDecls (#155463) And make use of those. These changes are split from prior PR #155028, in order to decrease the size of that PR and facilitate review.
2025-08-21[clang][CodeComplete] Consider qualifiers of explicit object parameters in ↵Mythreya Kuricheti1-14/+37
overload suggestions (#154041) Fixes https://github.com/llvm/llvm-project/issues/109608
2025-08-20[clang][CodeComplete] Do not suggest unqualified members in explicit-object ↵Mythreya Kuricheti1-5/+28
member functions (#153760) Fixes https://github.com/llvm/llvm-project/issues/141291
2025-08-09[clang] Improve nested name specifier AST representation (#147835)Matheus Izvekov1-79/+102
This is a major change on how we represent nested name qualifications in the AST. * The nested name specifier itself and how it's stored is changed. The prefixes for types are handled within the type hierarchy, which makes canonicalization for them super cheap, no memory allocation required. Also translating a type into nested name specifier form becomes a no-op. An identifier is stored as a DependentNameType. The nested name specifier gains a lightweight handle class, to be used instead of passing around pointers, which is similar to what is implemented for TemplateName. There is still one free bit available, and this handle can be used within a PointerUnion and PointerIntPair, which should keep bit-packing aficionados happy. * The ElaboratedType node is removed, all type nodes in which it could previously apply to can now store the elaborated keyword and name qualifier, tail allocating when present. * TagTypes can now point to the exact declaration found when producing these, as opposed to the previous situation of there only existing one TagType per entity. This increases the amount of type sugar retained, and can have several applications, for example in tracking module ownership, and other tools which care about source file origins, such as IWYU. These TagTypes are lazily allocated, in order to limit the increase in AST size. This patch offers a great performance benefit. It greatly improves compilation time for [stdexec](https://github.com/NVIDIA/stdexec). For one datapoint, for `test_on2.cpp` in that project, which is the slowest compiling test, this patch improves `-c` compilation time by about 7.2%, with the `-fsyntax-only` improvement being at ~12%. This has great results on compile-time-tracker as well: ![image](https://github.com/user-attachments/assets/700dce98-2cab-4aa8-97d1-b038c0bee831) This patch also further enables other optimziations in the future, and will reduce the performance impact of template specialization resugaring when that lands. It has some other miscelaneous drive-by fixes. About the review: Yes the patch is huge, sorry about that. Part of the reason is that I started by the nested name specifier part, before the ElaboratedType part, but that had a huge performance downside, as ElaboratedType is a big performance hog. I didn't have the steam to go back and change the patch after the fact. There is also a lot of internal API changes, and it made sense to remove ElaboratedType in one go, versus removing it from one type at a time, as that would present much more churn to the users. Also, the nested name specifier having a different API avoids missing changes related to how prefixes work now, which could make existing code compile but not work. How to review: The important changes are all in `clang/include/clang/AST` and `clang/lib/AST`, with also important changes in `clang/lib/Sema/TreeTransform.h`. The rest and bulk of the changes are mostly consequences of the changes in API. PS: TagType::getDecl is renamed to `getOriginalDecl` in this patch, just for easier to rebasing. I plan to rename it back after this lands. Fixes #136624 Fixes https://github.com/llvm/llvm-project/issues/43179 Fixes https://github.com/llvm/llvm-project/issues/68670 Fixes https://github.com/llvm/llvm-project/issues/92757
2025-07-31[clang][CodeComplete] skip explicit obj param when creating signature string ↵Mythreya Kuricheti1-0/+8
(#146649) Fixes clangd/clangd#2284
2025-07-05[clang][Sema] Unify getPrototypeLoc helpers in SemaCodeComplete and clangd ↵Nathan Ridge1-49/+1
(#143345) HeuristicResolver houses the unified implementation. Fixes https://github.com/llvm/llvm-project/issues/143240
2025-07-02[Sema] Remove an unnecessary cast (NFC) (#146703)Kazu Hirata1-3/+1
The only use of Receiver is to initialize RecExpr. This patch renames Receiver to RecExpr while removing the cast statement.
2025-07-01[clang][CodeComplete] skip explicit obj param in code completion string ↵Mythreya1-0/+7
(#146258) Fixes clangd/clangd#2339
2025-06-28[Sema][clangd] add noexcept to override functions during code completion ↵Sirui Mu1-0/+27
(#75937) If a virtual function is declared with `noexcept`, functions that override this function in the derived classes must be declared with `noexcept` as well. This PR updates code completion in clang Sema. It adds `noexcept` specifier to override functions in the code completion result if the functions override a `noexcept` virtual function.
2025-05-04[clang] Remove unused local variables (NFC) (#138453)Kazu Hirata1-1/+0
2025-04-18[Clang] Bypass TAD during overload resolution if a perfect match exists ↵cor3ntin1-2/+4
(#136203) This implements the same overload resolution behavior as GCC, as described in https://wg21.link/p3606 (section 1-2, not 3) If during overload resolution, there is a non-template candidate that would be always be picked - because each of the argument is a perfect match (ie the source and target types are the same), we do not perform deduction for any template candidate that might exists. The goal is to be able to merge https://github.com/llvm/llvm-project/pull/122423 without being too disruptive. This change means that the selection of the best viable candidate and template argument deduction become interleaved. To avoid rewriting half of Clang we store in OverloadCandidateSet enough information to be able to deduce template candidates from OverloadCandidateSet::BestViableFunction. Which means the lifetime of any object used by template argument must outlive a call to Add*Template*Candidate. This two phase resolution is not performed for some initialization as there are cases where template candidate are better match in these cases per the standard. It's also bypassed for code completion. The change has a nice impact on compile times https://llvm-compile-time-tracker.com/compare.php?from=719b029c16eeb1035da522fd641dfcc4cee6be74&to=bf7041045c9408490c395230047c5461de72fc39&stat=instructions%3Au Fixes https://github.com/llvm/llvm-project/issues/62096 Fixes https://github.com/llvm/llvm-project/issues/74581 Reapplies https://github.com/llvm/llvm-project/pull/133426
2025-04-17Reland [clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data ↵yronglin1-4/+4
structures to `IdentifierLoc` (#136077) This PR reland https://github.com/llvm/llvm-project/pull/135808, fixed some missed changes in LLDB. I found this issue when I working on https://github.com/llvm/llvm-project/pull/107168. Currently we have many similiar data structures like: - std::pair<IdentifierInfo *, SourceLocation>. - Element type of ModuleIdPath. - IdentifierLocPair. - IdentifierLoc. This PR unify these data structures to IdentifierLoc, moved IdentifierLoc definition to SourceLocation.h, and deleted other similer data structures. --------- Signed-off-by: yronglin <yronglin777@gmail.com>
2025-04-17Revert "[Clang] Bypass TAD during overload resolution if a perfect match ↵cor3ntin1-4/+2
exists" (#136113) Reverts llvm/llvm-project#136018 Still some bots failing https://lab.llvm.org/buildbot/#/builders/52/builds/7643
2025-04-17[Clang] Bypass TAD during overload resolution if a perfect match exists ↵cor3ntin1-2/+4
(#136018) This implements the same overload resolution behavior as GCC, as described in https://wg21.link/p3606 (section 1-2, not 3) If during overload resolution, there is a non-template candidate that would be always be picked - because each of the argument is a perfect match (ie the source and target types are the same), we do not perform deduction for any template candidate that might exists. The goal is to be able to merge https://github.com/llvm/llvm-project/pull/122423 without being too disruptive. This change means that the selection of the best viable candidate and template argument deduction become interleaved. To avoid rewriting half of Clang we store in `OverloadCandidateSet` enough information to be able to deduce template candidates from `OverloadCandidateSet::BestViableFunction`. Which means the lifetime of any object used by template argument must outlive a call to `Add*Template*Candidate`. This two phase resolution is not performed for some initialization as there are cases where template candidate are better match in these cases per the standard. It's also bypassed for code completion. The change has a nice impact on compile times https://llvm-compile-time-tracker.com/compare.php?from=719b029c16eeb1035da522fd641dfcc4cee6be74&to=bf7041045c9408490c395230047c5461de72fc39&stat=instructions%3Au Fixes https://github.com/llvm/llvm-project/issues/62096 Fixes https://github.com/llvm/llvm-project/issues/74581 Reapplies #133426
2025-04-16Revert "[Clang][RFC] Bypass TAD during overload resolution if a perfect ↵cor3ntin1-4/+2
match exists" (#135993) Reverts llvm/llvm-project#133426 This is failing on some bots https://lab.llvm.org/buildbot/#/builders/163/builds/17265
2025-04-16[Clang][RFC] Bypass TAD during overload resolution if a perfect match exists ↵cor3ntin1-2/+4
(#133426) This implements the same overload resolution behavior as GCC, as described in https://wg21.link/p3606 (sections 1-2, not 3) If, during overload resolution, a non-template candidate is always picked because each argument is a perfect match (i.e., the source and target types are the same), we do not perform deduction for any template candidate that might exist. The goal is to be able to merge #122423 without being too disruptive. This change means that the selection of the best viable candidate and template argument deduction become interleaved. To avoid rewriting half of Clang, we store in `OverloadCandidateSet` enough information to deduce template candidates from `OverloadCandidateSet::BestViableFunction`. This means the lifetime of any object used by the template argument must outlive a call to `Add*Template*Candidate`. This two-phase resolution is not performed for some initialization as there are cases where template candidates are a better match per the standard. It's also bypassed for code completion. The change has a nice impact on compile times https://llvm-compile-time-tracker.com/compare.php?from=edc22c64e527171041876f26a491bb1d03d905d5&to=8170b860bd4b70917005796c05a9be013a95abb2&stat=instructions%3Au Fixes #62096 Fixes #74581 Fixes #53454
2025-04-16Revert "[clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data ↵Michael Buch1-4/+4
structures to `IdentifierLoc`" (#135974) Reverts llvm/llvm-project#135808 Example from the LLDB macOS CI: https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/24084/execution/node/54/log/?consoleFull ``` /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp:360:49: error: no viable conversion from 'std::pair<clang::IdentifierInfo *, clang::SourceLocation>' to 'clang::ModuleIdPath' (aka 'ArrayRef<IdentifierLoc>') clang::Module *top_level_module = DoGetModule(clang_path.front(), false); ^~~~~~~~~~~~~~~~~~ /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:41:40: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'std::pair<clang::IdentifierInfo *, clang::SourceLocation>' to 'const llvm::ArrayRef<clang::IdentifierLoc> &' for 1st argument class LLVM_GSL_POINTER [[nodiscard]] ArrayRef { ^ /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:41:40: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'std::pair<clang::IdentifierInfo *, clang::SourceLocation>' to 'llvm::ArrayRef<clang::IdentifierLoc> &&' for 1st argument /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:70:18: note: candidate constructor not viable: no known conversion from 'std::pair<clang::IdentifierInfo *, clang::SourceLocation>' to 'std::nullopt_t' for 1st argument /*implicit*/ ArrayRef(std::nullopt_t) {} ```
2025-04-16[clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data ↵yronglin1-4/+4
structures to `IdentifierLoc` (#135808) I found this issue when I working on https://github.com/llvm/llvm-project/pull/107168. Currently we have many similiar data structures like: - `std::pair<IdentifierInfo *, SourceLocation>`. - Element type of `ModuleIdPath`. - `IdentifierLocPair`. - `IdentifierLoc`. This PR unify these data structures to `IdentifierLoc`, moved `IdentifierLoc` definition to SourceLocation.h, and deleted other similer data structures. --------- Signed-off-by: yronglin <yronglin777@gmail.com>
2025-04-15[CodeComplete] Don't drop ArrayToPointerDecay when doing member completion ↵Akira Hatanaka1-1/+4
(#134951) Fixes https://github.com/llvm/llvm-project/issues/123146. rdar://138851576
2025-04-11[clang][CodeComplete] Use HeuristicResolver in getAsRecordDecl() (#130473)Nathan Ridge1-28/+15
Fixes https://github.com/llvm/llvm-project/issues/130468
2025-04-01[clang] Concepts: support pack expansions for type constraints (#132626)Matheus Izvekov1-4/+5
This reverts an earlier attempt (adb0d8ddceb143749c519d14b8b31b481071da77 and 50e5411e4247421fd606f0a206682fcdf0303ae3) to support these expansions, which was limited to type arguments and which subverted the purpose of SubstTemplateTypeParmType. This propagates the ArgumentPackSubstitutionIndex along with the AssociatedConstraint, so that the pack expansion works, without needing any new transforms or otherwise any changes to the template instantiation process. This keeps the tests from the reverted commits, and adds a few more showing the new solution also works for NTTPs. Fixes https://github.com/llvm/llvm-project/issues/131798
2025-04-01[clang] improved preservation of template keyword (#133610)Matheus Izvekov1-3/+3
2025-03-17[clang][CodeComplete] Add code completion for if constexpr and consteval ↵Letu Ren1-0/+46
(#124315) Code complete `constexpr` and `consteval` keywords after `if` in the relevant language modes. If pattern completion is enabled, the completions also include placeholders for the condition (in the case of `constexpr`) and statement block.
2025-03-03[clang] Fix CodeComplete crash involving CWG1432 (#129436)Matheus Izvekov1-2/+2
This skips the provisional resolution of CWG1432 just when ordering the candidates for function call code completion, as otherwise this breaks some assumptions the implementation makes about how closely related the candidates are. As a drive-by, deduplicate the implementation with the one used for class template partial ordering, and strenghten an assertion which was previosuly dependent on the order of candidates. Also add a test for the fix for CWG1432 when partial ordering function templates, which was otherwise untested. Fixes #125500
2025-01-30[clang][CodeComplete] Use HeuristicResolver to resolve ↵Nathan Ridge1-17/+4
CXXDependentScopeMemberExpr (#124888)
2025-01-29[Sema] Migrate away from PointerUnion::dyn_cast (NFC) (#124883)Kazu Hirata1-1/+1
Note that PointerUnion::dyn_cast has been soft deprecated in PointerUnion.h: // FIXME: Replace the uses of is(), get() and dyn_cast() with // isa<T>, cast<T> and the llvm::dyn_cast<T> This patch migrates the use of PointerUnion::dyn_cast to dyn_cast_if_present because ShadowMapEntry::Add starts with: if (DeclOrVector.isNull()) { implying that DeclOrVector is not guaranteed to be nonnull.
2025-01-25[Sema] Migrate away from PointerUnion::dyn_cast (NFC) (#124391)Kazu Hirata1-1/+1
Note that PointerUnion::dyn_cast has been soft deprecated in PointerUnion.h: // FIXME: Replace the uses of is(), get() and dyn_cast() with // isa<T>, cast<T> and the llvm::dyn_cast<T> Literal migration would result in dyn_cast_if_present (see the definition of PointerUnion::dyn_cast), but this patch uses dyn_cast because we expect DeclOrIterator to be nonnull.
2025-01-23[clang][CodeComplete] Use HeuristicResolver to resolve DependentNameTypes ↵Nathan Ridge1-7/+17
(#123818) Fixes https://github.com/clangd/clangd/issues/1249
2025-01-22[clang][CodeComplete] Use HeuristicResolver to resolve pointee types (#121315)Nathan Ridge1-5/+10
Fixes https://github.com/clangd/clangd/issues/810
2025-01-14[Sema] Migrate away from PointerUnion::dyn_cast (NFC) (#122855)Kazu Hirata1-3/+2
Note that PointerUnion::dyn_cast has been soft deprecated in PointerUnion.h: // FIXME: Replace the uses of is(), get() and dyn_cast() with // isa<T>, cast<T> and the llvm::dyn_cast<T> Literal migration would result in dyn_cast_if_present (see the definition of PointerUnion::dyn_cast), but this patch uses dyn_cast because we expect DeclOrVector to be nonnull.
2024-11-27[Sema] Migrate away from PointerUnion::{is,get} (NFC) (#117498)Kazu Hirata1-8/+8
Note that PointerUnion::{is,get} have been soft deprecated in PointerUnion.h: // FIXME: Replace the uses of is(), get() and dyn_cast() with // isa<T>, cast<T> and the llvm::dyn_cast<T> I'm not touching PointerUnion::dyn_cast for now because it's a bit complicated; we could blindly migrate it to dyn_cast_if_present, but we should probably use dyn_cast when the operand is known to be non-null.
2024-11-26Add code completion for C++20 keywords. (#107982)ykiko1-0/+128
This commit adds code completion for C++20 keywords, fix https://github.com/llvm/llvm-project/issues/107868. 1. complete `concept` in template context - [x] `template<typename T> conce^` -> `concept` - [ ] `conce^` 2. complete `requires` - [x] constraints in template context: `template<typename T> requi^` -> `requires` - [x] requires expression: `int x = requ^` -> `requires (parameters) { requirements }` - [x] nested requirement: `requires { requ^ }` -> `requires expression ;` 3. complete coroutine keywords - [x] `co_await^` in expression: `co_aw^` -> `co_await expression;` - [x] `co_yield` in function body: `co_yi^` -> `co_yield expression;` - [x] `co_return` in function body: `co_re^` -> `co_return expression;` 4. specifiers: `char8_t`, `consteval`, `constinit`
2024-11-16[Sema] Remove unused includes (NFC) (#116461)Kazu Hirata1-2/+0
Identified with misc-include-cleaner.
2024-11-15[Clang] Use TargetInfo when deciding if an address space is compatible ↵Joseph Huber1-4/+6
(#115777) Summary: Address spaces are used in several embedded and GPU targets to describe accesses to different types of memory. Currently we use the address space enumerations to control which address spaces are considered supersets of eachother, however this is also a target level property as described by the C standard's passing mentions. This patch allows the address space checks to use the target information to decide if a pointer conversion is legal. For AMDGPU and NVPTX, all supported address spaces can be converted to the default address space. More semantic checks can be added on top of this, for now I'm mainly looking to get more standard semantics working for C/C++. Right now the address space conversions must all be done explicitly in C/C++ unlike the offloading languages which define their own custom address spaces that just map to the same target specific ones anyway. The main question is if this behavior is a function of the target or the language.
2024-11-15[Clang] [NFC] Refactor AST visitors in Sema and the static analyser to use ↵Sirraide1-8/+9
DynamicRecursiveASTVisitor (#115144) This pr refactors all recursive AST visitors in `Sema`, `Analyze`, and `StaticAnalysis` to inherit from DRAV instead. This is over half of the visitors that inherit from RAV directly. See also #115132, #110040, #93462 LLVM Compile-Time Tracker link for this branch: https://llvm-compile-time-tracker.com/compare.php?from=5adb5c05a2e9f31385fbba8b0436cbc07d91a44d&to=b58e589a86c06ba28d4d90613864d10be29aa5ba&stat=instructions%3Au
2024-10-24[clang] Use {} instead of std::nullopt to initialize empty ArrayRef (#109399)Jay Foad1-9/+7
Follow up to #109133.
2024-09-16Remove ^^ as a token in OpenCL (#108224)Aaron Ballman1-1/+0
OpenCL has a reserved operator (^^), the use of which was diagnosed as an error (735c6cdebdcd4292928079cb18a90f0dd5cd65fb). However, OpenCL also encourages working with the blocks language extension. This token has a parsing ambiguity as a result. Consider: unsigned x=0; unsigned y=x^^{return 0;}(); This should result in y holding the value zero (0^0) through an immediately invoked block call as the right-hand side of the xor operator. However, it causes errors instead because of this reserved token: https://godbolt.org/z/navf7jTv1 This token is still reserved in OpenCL 3.0, so we still wish to issue a diagnostic for its use. However, we do not need to create a token for an extension point that's been unused for about a decade. So this patch moves the diagnostic from a parsing diagnostic to a lexing diagnostic and no longer forms a single token. The diagnostic behavior is slightly worse as a result, but still seems acceptable. Part of the reason this is coming up is because WG21 is considering using ^^ as a token for reflection, so this token may come back in the future.
2024-07-15[Clang][AST] Move NamespaceDecl bits to DeclContext (#98567)Krystian Stasiowski1-1/+1
Currently, `NamespaceDecl` has a member `AnonOrFirstNamespaceAndFlags` which stores a few pieces of data: - a bit indicating whether the namespace was declared `inline`, and - a bit indicating whether the namespace was declared as a _nested-namespace-definition_, and - a pointer a `NamespaceDecl` that either stores: - a pointer to the first declaration of that namespace if the declaration is no the first declaration, or - a pointer to the unnamed namespace that inhabits the namespace otherwise. `Redeclarable` already stores a pointer to the first declaration of an entity, so it's unnecessary to store this in `NamespaceDecl`. `DeclContext` has 8 bytes in which various bitfields can be stored for a declaration, so it's not necessary to store these in `NamespaceDecl` either. We only need to store a pointer to the unnamed namespace that inhabits the first declaration of a namespace. This patch moves the two bits currently stored in `NamespaceDecl` to `DeclContext`, and only stores a pointer to the unnamed namespace that inhabits a namespace in the first declaration of that namespace. Since `getOriginalNamespace` always returns the same `NamespaceDecl` as `getFirstDecl`, this function is removed to avoid confusion.
2024-07-08[C2y] Remove support for _Imaginary (#97436)Aaron Ballman1-1/+2
WG14 N3274 removed _Imaginary from Annex G. Clang has never fully supported Annex G or _Imaginary, so removal is pretty trivial for us. Note, we are keeping _Imaginary as a keyword so that we get better diagnostic behavior. This is still conforming because _I makes it a reserved identifier, so it's not available for users to use as an identifier anyway.
2024-07-05[clang] Avoid 'raw_string_ostream::str' (NFC)Youngsuk Kim1-5/+2
Since `raw_string_ostream` doesn't own the string buffer, it is desirable (in terms of memory safety) for users to directly reference the string buffer rather than use `raw_string_ostream::str()`. Work towards TODO item to remove `raw_string_ostream::str()`. p.s. also remove some unneeded/dead code.
2024-05-27[clang][CodeComplete] Recurse into the subexpression of deref operator in ↵Younan Zhang1-2/+9
getApproximateType (#93404) The issue with the previous implementation bc31be7 was that getApproximateType could potentially return a null QualType for a dereferencing operator, which is not what its caller wants.
2024-05-17[clang] Introduce `SemaCodeCompletion` (#92311)Vlad Serebrennikov1-611/+695
This patch continues previous efforts to split `Sema` up, this time covering code completion. Context can be found in #84184. Dropping `Code` prefix from function names in `SemaCodeCompletion` would make sense, but I think this PR has enough changes already. As usual, formatting changes are done as a separate commit. Hopefully this helps with the review.
2024-05-13[clang] Introduce `SemaObjC` (#89086)Vlad Serebrennikov1-18/+22
This is continuation of efforts to split `Sema` up, following the example of OpenMP, OpenACC, etc. Context can be found in https://github.com/llvm/llvm-project/pull/82217 and https://github.com/llvm/llvm-project/pull/84184. I split formatting changes into a separate commit to help reviewing the actual changes.
2024-05-11[clang] Use StringRef::operator== instead of StringRef::equals (NFC) (#91844)Kazu Hirata1-5/+4
I'm planning to remove StringRef::equals in favor of StringRef::operator==. - StringRef::operator==/!= outnumber StringRef::equals by a factor of 24 under clang/ in terms of their usage. - The elimination of StringRef::equals brings StringRef closer to std::string_view, which has operator== but not equals. - S == "foo" is more readable than S.equals("foo"), especially for !Long.Expression.equals("str") vs Long.Expression != "str".
2024-05-02[Clang] Prevent null pointer dereference in ↵smanna121-8/+10
Sema::​CodeCompleteQualifiedId() (#90490) The null pointer dereference issue seems happening with in the expression NNS->getAsType(). Although dyn_cast_or_null<TemplateTypeParmType>() correctly handles null pointers, it doesn’t prevent the subsequent dereferencing operation. The fix ensures that NNS pointer is not null before calling the getAsType() method, thus preventing potential runtime errors caused by attempting to access a null pointer.
2024-04-11[NFC][Clang] Improve const correctness for IdentifierInfo (#79365)Bill Wendling1-57/+55
The IdentifierInfo isn't typically modified. Use 'const' wherever possible.
2024-03-25[clang][CodeComplete] Handle deref operator in getApproximateType (#86466)Nathan Ridge1-0/+5
This allows completing after `(*this).` in a dependent context. Fixes https://github.com/clangd/clangd/issues/1952