[clang-tools-extra] acc4ffb - [clangd] Reorder FindTarget.h - group targetDecl() stuff and findExplicitReferences(). NFC
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 2 09:01:46 PST 2020
Author: Sam McCall
Date: 2020-01-02T18:01:29+01:00
New Revision: acc4ffbb4733ec716d6ca3ad4d1e4605b9a2bcea
URL: https://github.com/llvm/llvm-project/commit/acc4ffbb4733ec716d6ca3ad4d1e4605b9a2bcea
DIFF: https://github.com/llvm/llvm-project/commit/acc4ffbb4733ec716d6ca3ad4d1e4605b9a2bcea.diff
LOG: [clangd] Reorder FindTarget.h - group targetDecl() stuff and findExplicitReferences(). NFC
Added:
Modified:
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/FindTarget.h
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/FindTarget.cpp b/clang-tools-extra/clangd/FindTarget.cpp
index 55bb8a0b70ea..f9332ee4f220 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -617,13 +617,13 @@ llvm::SmallVector<ReferenceLoc, 2> refInTypeLoc(TypeLoc L) {
DependentTemplateSpecializationTypeLoc L) {
Ref = ReferenceLoc{
L.getQualifierLoc(), L.getTemplateNameLoc(), /*IsDecl=*/false,
- explicitReferenceTargets(DynTypedNode::create(L.getType()))};
+ explicitReferenceTargets(DynTypedNode::create(L.getType()), {})};
}
void VisitDependentNameTypeLoc(DependentNameTypeLoc L) {
Ref = ReferenceLoc{
L.getQualifierLoc(), L.getNameLoc(), /*IsDecl=*/false,
- explicitReferenceTargets(DynTypedNode::create(L.getType()))};
+ explicitReferenceTargets(DynTypedNode::create(L.getType()), {})};
}
void VisitTypedefTypeLoc(TypedefTypeLoc L) {
diff --git a/clang-tools-extra/clangd/FindTarget.h b/clang-tools-extra/clangd/FindTarget.h
index 39c00b0f6df0..2f6c26ca6912 100644
--- a/clang-tools-extra/clangd/FindTarget.h
+++ b/clang-tools-extra/clangd/FindTarget.h
@@ -79,6 +79,36 @@ class DeclRelationSet;
llvm::SmallVector<const Decl *, 1>
targetDecl(const ast_type_traits::DynTypedNode &, DeclRelationSet Mask);
+/// Similar to targetDecl(), however instead of applying a filter, all possible
+/// decls are returned along with their DeclRelationSets.
+/// This is suitable for indexing, where everything is recorded and filtering
+/// is applied later.
+llvm::SmallVector<std::pair<const Decl *, DeclRelationSet>, 1>
+allTargetDecls(const ast_type_traits::DynTypedNode &);
+
+enum class DeclRelation : unsigned {
+ // Template options apply when the declaration is an instantiated template.
+ // e.g. [[vector<int>]] vec;
+
+ /// This is the template instantiation that was referred to.
+ /// e.g. template<> class vector<int> (the implicit specialization)
+ TemplateInstantiation,
+ /// This is the pattern the template specialization was instantiated from.
+ /// e.g. class vector<T> (the pattern within the primary template)
+ TemplatePattern,
+
+ // Alias options apply when the declaration is an alias.
+ // e.g. namespace clang { [[StringRef]] S; }
+
+ /// This declaration is an alias that was referred to.
+ /// e.g. using llvm::StringRef (the UsingDecl directly referenced).
+ Alias,
+ /// This is the underlying declaration for an alias, decltype etc.
+ /// e.g. class llvm::StringRef (the underlying declaration referenced).
+ Underlying,
+};
+llvm::raw_ostream &operator<<(llvm::raw_ostream &, DeclRelation);
+
/// Information about a reference written in the source code, independent of the
/// actual AST node that this reference lives in.
/// Useful for tools that are source-aware, e.g. refactorings.
@@ -111,35 +141,20 @@ void findExplicitReferences(const Decl *D,
void findExplicitReferences(const ASTContext &AST,
llvm::function_ref<void(ReferenceLoc)> Out);
-/// Similar to targetDecl(), however instead of applying a filter, all possible
-/// decls are returned along with their DeclRelationSets.
-/// This is suitable for indexing, where everything is recorded and filtering
-/// is applied later.
-llvm::SmallVector<std::pair<const Decl *, DeclRelationSet>, 1>
-allTargetDecls(const ast_type_traits::DynTypedNode &);
-
-enum class DeclRelation : unsigned {
- // Template options apply when the declaration is an instantiated template.
- // e.g. [[vector<int>]] vec;
-
- /// This is the template instantiation that was referred to.
- /// e.g. template<> class vector<int> (the implicit specialization)
- TemplateInstantiation,
- /// This is the pattern the template specialization was instantiated from.
- /// e.g. class vector<T> (the pattern within the primary template)
- TemplatePattern,
-
- // Alias options apply when the declaration is an alias.
- // e.g. namespace clang { [[StringRef]] S; }
+/// Find declarations explicitly referenced in the source code defined by \p N.
+/// For templates, will prefer to return a template instantiation whenever
+/// possible. However, can also return a template pattern if the specialization
+/// cannot be picked, e.g. in dependent code or when there is no corresponding
+/// Decl for a template instantitation, e.g. for templated using decls:
+/// template <class T> using Ptr = T*;
+/// Ptr<int> x;
+/// ^~~ there is no Decl for 'Ptr<int>', so we return the template pattern.
+/// \p Mask should not contain TemplatePattern or TemplateInstantiation.
+llvm::SmallVector<const NamedDecl *, 1>
+explicitReferenceTargets(ast_type_traits::DynTypedNode N,
+ DeclRelationSet Mask);
- /// This declaration is an alias that was referred to.
- /// e.g. using llvm::StringRef (the UsingDecl directly referenced).
- Alias,
- /// This is the underlying declaration for an alias, decltype etc.
- /// e.g. class llvm::StringRef (the underlying declaration referenced).
- Underlying,
-};
-llvm::raw_ostream &operator<<(llvm::raw_ostream &, DeclRelation);
+// Boring implementation details of bitfield.
class DeclRelationSet {
using Set = std::bitset<static_cast<unsigned>(DeclRelation::Underlying) + 1>;
@@ -182,18 +197,6 @@ inline DeclRelationSet operator&(DeclRelation L, DeclRelation R) {
inline DeclRelationSet operator~(DeclRelation R) { return ~DeclRelationSet(R); }
llvm::raw_ostream &operator<<(llvm::raw_ostream &, DeclRelationSet);
-/// Find declarations explicitly referenced in the source code defined by \p N.
-/// For templates, will prefer to return a template instantiation whenever
-/// possible. However, can also return a template pattern if the specialization
-/// cannot be picked, e.g. in dependent code or when there is no corresponding
-/// Decl for a template instantitation, e.g. for templated using decls:
-/// template <class T> using Ptr = T*;
-/// Ptr<int> x;
-/// ^~~ there is no Decl for 'Ptr<int>', so we return the template pattern.
-/// \p Mask should not contain TemplatePattern or TemplateInstantiation.
-llvm::SmallVector<const NamedDecl *, 1>
-explicitReferenceTargets(ast_type_traits::DynTypedNode N,
- DeclRelationSet Mask = {});
} // namespace clangd
} // namespace clang
More information about the cfe-commits
mailing list