aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Index/IndexDecl.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-04-03[clang] support pack expansions for trailing requires clauses (#133190)Matheus Izvekov1-2/+2
2024-12-12[clang] Migrate away from PointerUnion::{is,get} (NFC) (#119724)Kazu Hirata1-1/+1
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-12-11[clang] Migrate away from PointerUnion::{is,get} (NFC) (#119654)Kazu Hirata1-2/+2
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-05-22[clang] NFCI: use TemplateArgumentLoc for NTTP DefaultArgument (#92852)Matheus Izvekov1-1/+2
This is an enabler for https://github.com/llvm/llvm-project/pull/92855 This allows an NTTP default argument to be set as an arbitrary TemplateArgument, not just an expression. This allows template parameter packs to have default arguments in the AST, even though the language proper doesn't support the syntax for it. This allows NTTP default arguments to be other kinds of arguments, like packs, integral constants, and such.
2024-05-21[clang] NFCI: use TemplateArgumentLoc for type-param DefaultArgument (#92854)Matheus Izvekov1-1/+2
This is an enabler for a future patch. This allows an type-parameter default argument to be set as an arbitrary TemplateArgument, not just a type. This allows template parameter packs to have default arguments in the AST, even though the language proper doesn't support the syntax for it. This will be used in a later patch which synthesizes template parameter lists with arbitrary default arguments taken from template specializations. There are a few places we used SubsType, because we only had a type, now we use SubstTemplateArgument. SubstTemplateArgument was missing arguments for setting Instantiation location and entity names. Adding those is needed so we don't regress in diagnostics.
2024-05-14Reapply "[Clang] Unify interface for accessing template arguments as written ↵Krystian Stasiowski1-3/+6
for class/variable template specializations (#81642)" (#91393) Reapplies #81642, fixing the crash which occurs when running the lldb test suite.
2024-05-07Revert "[Clang] Unify interface for accessing template arguments as written ↵Adrian Prantl1-6/+3
for class/variable template specializations (#81642)" This reverts commit 7115ed0fff027b65fa76fdfae215ed1382ed1473. This commit broke several LLDB tests. https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/3480/
2024-05-07[Clang] Unify interface for accessing template arguments as written for ↵Krystian Stasiowski1-3/+6
class/variable template specializations (#81642) Our current method of storing the template arguments as written for `(Class/Var)Template(Partial)SpecializationDecl` suffers from a number of flaws: - We use `TypeSourceInfo` to store `TemplateArgumentLocs` for class template/variable template partial/explicit specializations. For variable template specializations, this is a rather unintuitive hack (as we store a non-type specialization as a type). Moreover, we don't ever *need* the type as written -- in almost all cases, we only want the template arguments (e.g. in tooling use-cases). - The template arguments as written are stored in a number of redundant data members. For example, `(Class/Var)TemplatePartialSpecialization` have their own `ArgsAsWritten` member that stores an `ASTTemplateArgumentListInfo` (the template arguments). `VarTemplateSpecializationDecl` has yet _another_ redundant member "`TemplateArgsInfo`" that also stores an `ASTTemplateArgumentListInfo`. This patch eliminates all `(Class/Var)Template(Partial)SpecializationDecl` members which store the template arguments as written, and turns the `ExplicitInfo` member into a `llvm::PointerUnion<const ASTTemplateArgumentListInfo*, ExplicitInstantiationInfo*>` (to avoid unnecessary allocations when the declaration isn't an explicit instantiation). The template arguments as written are now accessed via `getTemplateArgsWritten` in all cases. The "most breaking" change is to AST Matchers, insofar that `hasTypeLoc` will no longer match class template specializations (since they no longer store the type as written).
2023-06-20[clangd] Index the type of a non-type template parameterNathan Ridge1-0/+1
Fixes https://github.com/clangd/clangd/issues/1666 Differential Revision: https://reviews.llvm.org/D153251
2022-04-26[Index] [clangd] Support for concept declarations and requires expressionsIlya Biryukov1-19/+40
Add support for concepts and requires expression in the clang index. Genarate USRs for concepts. Also change how `RecursiveASTVisitor` handles return type requirement in requires expressions. The new code unpacks the synthetic template parameter list used for storing the actual expression. This simplifies implementation of the indexing. No code seems to depend on the original traversal anyway and the synthesized template parameter list is easily accessible from inside the requires expression if needed. Add tests in the clangd codebase. Fixes https://github.com/clangd/clangd/issues/1103. Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D124441
2022-04-22[Index] Remove reference to `UnresolvedUsingIfExists`Ben Barham1-1/+8
Assuming `ns::foo` doesn't exist, given: ``` using ns::foo __attribute__((using_if_exists)); ``` The AST will look something like: UsingDecl UsingShadowDecl UnresolvedUsingIfExistsDecl Thus we end up adding a reference to `UnresolvedUsingIfExistsDecl` when processing `UsingDecl`, but never add the decl itself. In this case the decl is really the `UsingDecl` anyway though (which we do output), so it makes more sense to just remove the extra reference. Differential Revision: https://reviews.llvm.org/D124288
2021-10-25[clang] Visit enum base specifiers in libIndexKadir Cetinkaya1-0/+10
Fixes https://github.com/clangd/clangd/issues/878. Differential Revision: https://reviews.llvm.org/D111260
2021-05-06[Index] Ignore nullptr decls for indexingAlex Hoppen1-1/+1
We can end up with a call to `indexTopLevelDecl(D)` with `D == nullptr` in non-assert builds e.g. when indexing a module in `indexModule` and - `ASTReader::GetDecl` returns `nullptr` if `Index >= DeclsLoaded.size()`, thus returning `nullptr` => `ModuleDeclIterator::operator*` returns `nullptr` => we call `IndexCtx.indexTopLevelDecl` with `nullptr` Be resilient and just ignore the `nullptr` decls during indexing. Reviewed By: akyrtzi Differential Revision: https://reviews.llvm.org/D102001
2020-05-26[clangd] Don't traverse the AST within uninteresting files during indexingSam McCall1-0/+3
Summary: We already skip function bodies from these files while parsing, and drop symbols found in them. However, traversing their ASTs still takes a substantial amount of time. Non-scientific benchmark on my machine: background-indexing llvm-project (llvm+clang+clang-tools-extra), wall time before: 7:46 after: 5:13 change: -33% Indexer.cpp libclang should be updated too, I'm less familiar with that code, and it's doing tricky things with the ShouldSkipFunctionBody callback, so it needs to be done separately. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D80296
2020-02-18[NFC] Remove trailing spaceJim Lin1-1/+1
sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h,td}
2020-02-17[clang][Index] Visit the default parameter arguements in libindex.Haojian Wu1-4/+9
Summary: We are missing the default parmeter arguments when IndexFunctionLocals is true. Fixes https://github.com/clangd/clangd/issues/285. Reviewers: kadircet Subscribers: kristof.beyls, ilya-biryukov, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D74610
2019-12-06Remove Expr.h include from ASTContext.h, NFCReid Kleckner1-1/+2
ASTContext.h is popular, prune its includes. Expr.h brings in Attr.h, which is also expensive. Move BlockVarCopyInit to Expr.h to accomplish this.
2019-11-08Redeclare Objective-C property accessors inside the ObjCImplDecl in which ↵Adrian Prantl1-13/+13
they are synthesized. This patch is motivated by (and factored out from) https://reviews.llvm.org/D66121 which is a debug info bugfix. Starting with DWARF 5 all Objective-C methods are nested inside their containing type, and that patch implements this for synthesized Objective-C properties. 1. SemaObjCProperty populates a list of synthesized accessors that may need to inserted into an ObjCImplDecl. 2. SemaDeclObjC::ActOnEnd inserts forward-declarations for all accessors for which no override was provided into their ObjCImplDecl. This patch does *not* synthesize AST function *bodies*. Moving that code from the static analyzer into Sema may be a good idea though. 3. Places that expect all methods to have bodies have been updated. I did not update the static analyzer's inliner for synthesized properties to point back to the property declaration (see test/Analysis/Inputs/expected-plists/nullability-notes.m.plist), which I believed to be more bug than a feature. Differential Revision: https://reviews.llvm.org/D68108 rdar://problem/53782400
2019-07-16Fix parameter name comments using clang-tidy. NFC.Rui Ueyama1-2/+2
This patch applies clang-tidy's bugprone-argument-comment tool to LLVM, clang and lld source trees. Here is how I created this patch: $ git clone https://github.com/llvm/llvm-project.git $ cd llvm-project $ mkdir build $ cd build $ cmake -GNinja -DCMAKE_BUILD_TYPE=Debug \ -DLLVM_ENABLE_PROJECTS='clang;lld;clang-tools-extra' \ -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DLLVM_ENABLE_LLD=On \ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ../llvm $ ninja $ parallel clang-tidy -checks='-*,bugprone-argument-comment' \ -config='{CheckOptions: [{key: StrictMode, value: 1}]}' -fix \ ::: ../llvm/lib/**/*.{cpp,h} ../clang/lib/**/*.{cpp,h} ../lld/**/*.{cpp,h} llvm-svn: 366177
2019-07-10[Concepts] Concept definitions (D40381)Saar Raz1-2/+2
First in a series of patches to land C++2a Concepts support. This patch adds AST and parsing support for concept-declarations. llvm-svn: 365699
2019-03-08[clang][Index] Mark references from Constructors and Destructors to class as ↵Kadir Cetinkaya1-2/+4
NameReference Summary: In current indexing logic we get references to class itself when we see a constructor/destructor which is only syntactically true. Semantically this information is not correct. This patch marks that reference as NameReference to let clients deal with it. Reviewers: akyrtzi, gribozavr, nathawes, benlangmuir Reviewed By: gribozavr, nathawes Subscribers: nathawes, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58814 llvm-svn: 355668
2019-02-27[index] Improve indexing support for MSPropertyDecl.Volodymyr Sapsai1-0/+1
Currently the symbol for MSPropertyDecl has kind `SymbolKind::Unknown` which can trip up various indexing tools. rdar://problem/46764224 Reviewers: akyrtzi, benlangmuir, jkorous Reviewed By: jkorous Subscribers: dexonsmith, cfe-commits, jkorous, jdoerfert, arphaman Differential Revision: https://reviews.llvm.org/D57628 llvm-svn: 354942
2019-02-26[clang][Index] Visit UsingDecls and generate USRs for themKadir Cetinkaya1-1/+2
Summary: Add indexing of UsingDecl itself. Also enable generation of USRs for UsingDecls, using the qualified name of the decl. Reviewers: ilya-biryukov, akyrtzi Subscribers: arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58340 llvm-svn: 354878
2019-02-21[clang][Index] Enable indexing of Template Type Parameters behind a flagKadir Cetinkaya1-0/+2
Summary: clangd uses indexing api to provide references and it was not possible to perform symbol information for template parameters. This patch enables visiting of TemplateTypeParmTypeLocs. Reviewers: ilya-biryukov, akyrtzi Subscribers: javed.absar, kristof.beyls, ioeric, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58293 llvm-svn: 354560
2019-02-11[clang][Index] Add a knob to index function parameters in declarationsKadir Cetinkaya1-4/+4
Summary: Parameters in declarations are useful for clangd, so that we can provide symbol information for them as well. It also helps clangd to be consistent whether a function's definition is accessible or not. Reviewers: hokein, akyrtzi Subscribers: ilya-biryukov, ioeric, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57949 llvm-svn: 353695
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-08-09Port getLocStart -> getBeginLocStephen Kelly1-1/+1
Reviewers: teemperor! Subscribers: jholewinski, whisperity, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50350 llvm-svn: 339385
2018-07-09[Index] Add index::IndexingOptions::IndexImplicitInstantiationFangrui Song1-1/+1
Summary: With IndexImplicitInstantiation=true, the following case records an occurrence of B::bar in A::foo, which will benefit cross reference tools. template <class T> struct B { void bar() {}}; template <class T> struct A { void foo(B<T> *x) { x->bar(); }}; int main() { A<int> a; a.foo(0); } Reviewers: akyrtzi, arphaman, rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D49002 llvm-svn: 336606
2018-05-09Remove \brief commands from doxygen comments.Adrian Prantl1-1/+1
This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
2018-01-26[index] Fix crash when indexing a C++14 PCH/module related to ↵Argyrios Kyrtzidis1-2/+5
TemplateTemplateParmDecls of alias templates TemplateTemplateParmDecls of alias templates ended-up serialized as 'file-level decls' which was causing a crash while trying to index a PCH/module file that contained them. Commit makes sure TemplateTemplateParmDecls are not recorded as such kind of decls. Fixes crash of rdar://36608297 Differential Revision: https://reviews.llvm.org/D42588 llvm-svn: 323549
2017-12-17Refactor overridden methods iteration to avoid double lookups.Benjamin Kramer1-3/+2
Convert most uses to range-for loops. No functionality change intended. llvm-svn: 320954
2017-11-09[index] tag declarations should use the decl role instead of refAlex Lorenz1-4/+2
The 'decl' role is more canonical than the 'ref'. This helps us establish the 'specialization-of' relation just by looking at decls or defs. rdar://31884960 llvm-svn: 317832
2017-10-10Fix indexer crash for default template template parameter valueJan Korous1-2/+1
rdar://33058798 Differential Revision: https://reviews.llvm.org/D38755 llvm-svn: 315367
2017-08-16[index] Add indexing for unresolved-using declarationsBen Langmuir1-0/+18
In dependent contexts we end up referencing these, so make sure they have USRs, and have their declarations indexed. For the most part they behave like typedefs, but we also need to worry about having multiple using declarations with the same "name". rdar://problem/33883650 llvm-svn: 311053
2017-08-15[index] Update indexing to handle CXXDeductionGuideDecls properlyArgyrios Kyrtzidis1-0/+4
CXXDeductionGuideDecls can't be referenced so there's no need to output a symbol occurrence for them. Also handle DeducedTemplateSpecializationTypeLocs in the TypeIndexer so we don't miss the symbol occurrences of the corresponding template decls. Patch by Nathan Hawes! Differential Revision: https://reviews.llvm.org/D36641 llvm-svn: 310933
2017-07-04[index] Index nested name qualifiers in a forward declaration of aAlex Lorenz1-0/+2
class template specialization rdar://33122110 llvm-svn: 307074
2017-06-22[index] Add the "SpecializationOf" relation to the forward declarationsAlex Lorenz1-12/+10
of class template specializations This commit fixes an issue where a forward declaration of a class template specialization was not related to the base template. We need to relate even forward declarations because specializations don't have to be defined. rdar://32869409 Differential Revision: https://reviews.llvm.org/D34462 llvm-svn: 305996
2017-06-21[index] Nested class declarations should be annotated with theAlex Lorenz1-1/+3
"specializationOf" relation if they pseudo-override a type in the base template This commit fixes an issue where Xcode's renaming engine couldn't find the reference to the second occurrence of "InnerClass" in this example: template<typename T> struct Ts { template<typename U> struct InnerClass { }; }; template<> struct Ts<int> { template<typename U> struct InnerClass; // This occurrence wasn't renamed }; rdar://31884960 Differential Revision: https://reviews.llvm.org/D34392 llvm-svn: 305911
2017-06-15[index] Record C++17 global binding declarationsAlex Lorenz1-0/+6
The global C++17 binding declarations should be indexed as variable symbols. Differential Revision: https://reviews.llvm.org/D33920 llvm-svn: 305508
2017-06-15[index] Index static_assert declarationsAlex Lorenz1-0/+7
static_assert declarations have to be visited while indexing so that we can gather the references to declarations that are present in their assert expression. Differential Revision: https://reviews.llvm.org/D33913 llvm-svn: 305504
2017-05-22[index] Index the default template parameter valuesAlex Lorenz1-0/+46
rdar://32323724 llvm-svn: 303568
2017-05-22[index] Index the deleted functionsAlex Lorenz1-3/+0
rdar://32323386 llvm-svn: 303563
2017-05-22[index] Visit the default argument values in function definitionsAlex Lorenz1-0/+11
rdar://32323315 llvm-svn: 303559
2017-05-22[index] 'using namespace' declarations in functions should recordAlex Lorenz1-2/+6
the reference to the namespace rdar://32323190 llvm-svn: 303555
2017-05-15[index] Visit and store information about namespace alias declarationsAlex Lorenz1-0/+8
rdar://32195226 llvm-svn: 303048
2017-05-12[index] Index template specialization arguments for function templatsAlex Lorenz1-0/+22
Also ensure that class template specialization arguments are covered rdar://31812032 llvm-svn: 302918
2017-05-04[Index] The relation between the declarations in templateAlex Lorenz1-3/+1
specializations that 'override' declarations in the base template should use the 'specializationOf' relation instead of 'specializationOf | overrideOf'. The indexer relations are meant to be orthogonal, so 'specializationOf' is better than the combined relation. llvm-svn: 302136
2017-04-27[index] Mark the ObjC implicit accessor method definitions as 'dynamic' as wellArgyrios Kyrtzidis1-4/+4
llvm-svn: 301548
2017-04-25[index] Index type source info for class specializationsAlex Lorenz1-0/+3
rdar://31758344 llvm-svn: 301315
2017-04-25[index] Record the 'SpecializationOf' relation for function specializationsAlex Lorenz1-0/+4
rdar://31603531 llvm-svn: 301310