summaryrefslogtreecommitdiffstats
path: root/include/clang/Sema/Lookup.h
diff options
context:
space:
mode:
authorEugene Zelenko <eugene.zelenko@gmail.com>2018-02-21 01:45:26 +0000
committerEugene Zelenko <eugene.zelenko@gmail.com>2018-02-21 01:45:26 +0000
commit315b188f4501b590fc2f870e6f6d8234c1270898 (patch)
treef72138df1f965c8879b45546b94cd04f57ac94ab /include/clang/Sema/Lookup.h
parent0a0f7ec18a298d524da89cb3058c6da9ca533511 (diff)
[Sema] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325659 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Sema/Lookup.h')
-rw-r--r--include/clang/Sema/Lookup.h112
1 files changed, 49 insertions, 63 deletions
diff --git a/include/clang/Sema/Lookup.h b/include/clang/Sema/Lookup.h
index 0e8dcada74..a151bda3a9 100644
--- a/include/clang/Sema/Lookup.h
+++ b/include/clang/Sema/Lookup.h
@@ -1,4 +1,4 @@
-//===--- Lookup.h - Classes for name lookup ---------------------*- C++ -*-===//
+//===- Lookup.h - Classes for name lookup -----------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -15,13 +15,28 @@
#ifndef LLVM_CLANG_SEMA_LOOKUP_H
#define LLVM_CLANG_SEMA_LOOKUP_H
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
#include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclarationName.h"
+#include "clang/AST/Type.h"
+#include "clang/AST/UnresolvedSet.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/Specifiers.h"
#include "clang/Sema/Sema.h"
-
+#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Casting.h"
+#include <cassert>
+#include <utility>
namespace clang {
+class CXXBasePaths;
+
/// @brief Represents the results of name lookup.
///
/// An instance of the LookupResult class captures the results of a
@@ -126,25 +141,15 @@ public:
Temporary
};
- typedef UnresolvedSetImpl::iterator iterator;
+ using iterator = UnresolvedSetImpl::iterator;
LookupResult(Sema &SemaRef, const DeclarationNameInfo &NameInfo,
Sema::LookupNameKind LookupKind,
Sema::RedeclarationKind Redecl = Sema::NotForRedeclaration)
- : ResultKind(NotFound),
- Paths(nullptr),
- NamingClass(nullptr),
- SemaPtr(&SemaRef),
- NameInfo(NameInfo),
- LookupKind(LookupKind),
- IDNS(0),
- Redecl(Redecl != Sema::NotForRedeclaration),
- ExternalRedecl(Redecl == Sema::ForExternalRedeclaration),
- HideTags(true),
- Diagnose(Redecl == Sema::NotForRedeclaration),
- AllowHidden(false),
- Shadowed(false)
- {
+ : SemaPtr(&SemaRef), NameInfo(NameInfo), LookupKind(LookupKind),
+ Redecl(Redecl != Sema::NotForRedeclaration),
+ ExternalRedecl(Redecl == Sema::ForExternalRedeclaration),
+ Diagnose(Redecl == Sema::NotForRedeclaration) {
configure();
}
@@ -154,20 +159,10 @@ public:
LookupResult(Sema &SemaRef, DeclarationName Name,
SourceLocation NameLoc, Sema::LookupNameKind LookupKind,
Sema::RedeclarationKind Redecl = Sema::NotForRedeclaration)
- : ResultKind(NotFound),
- Paths(nullptr),
- NamingClass(nullptr),
- SemaPtr(&SemaRef),
- NameInfo(Name, NameLoc),
- LookupKind(LookupKind),
- IDNS(0),
- Redecl(Redecl != Sema::NotForRedeclaration),
- ExternalRedecl(Redecl == Sema::ForExternalRedeclaration),
- HideTags(true),
- Diagnose(Redecl == Sema::NotForRedeclaration),
- AllowHidden(false),
- Shadowed(false)
- {
+ : SemaPtr(&SemaRef), NameInfo(Name, NameLoc), LookupKind(LookupKind),
+ Redecl(Redecl != Sema::NotForRedeclaration),
+ ExternalRedecl(Redecl == Sema::ForExternalRedeclaration),
+ Diagnose(Redecl == Sema::NotForRedeclaration) {
configure();
}
@@ -175,20 +170,10 @@ public:
/// using the information from another result. Diagnostics are always
/// disabled.
LookupResult(TemporaryToken _, const LookupResult &Other)
- : ResultKind(NotFound),
- Paths(nullptr),
- NamingClass(nullptr),
- SemaPtr(Other.SemaPtr),
- NameInfo(Other.NameInfo),
- LookupKind(Other.LookupKind),
- IDNS(Other.IDNS),
- Redecl(Other.Redecl),
- ExternalRedecl(Other.ExternalRedecl),
- HideTags(Other.HideTags),
- Diagnose(false),
- AllowHidden(Other.AllowHidden),
- Shadowed(false)
- {}
+ : SemaPtr(Other.SemaPtr), NameInfo(Other.NameInfo),
+ LookupKind(Other.LookupKind), IDNS(Other.IDNS), Redecl(Other.Redecl),
+ ExternalRedecl(Other.ExternalRedecl), HideTags(Other.HideTags),
+ AllowHidden(Other.AllowHidden) {}
// FIXME: Remove these deleted methods once the default build includes
// -Wdeprecated.
@@ -213,6 +198,7 @@ public:
Other.Paths = nullptr;
Other.Diagnose = false;
}
+
LookupResult &operator=(LookupResult &&Other) {
ResultKind = std::move(Other.ResultKind);
Ambiguity = std::move(Other.Ambiguity);
@@ -618,15 +604,14 @@ public:
/// filtering out results. The results returned are possibly
/// sugared.
class Filter {
+ friend class LookupResult;
+
LookupResult &Results;
LookupResult::iterator I;
- bool Changed;
- bool CalledDone;
+ bool Changed = false;
+ bool CalledDone = false;
- friend class LookupResult;
- Filter(LookupResult &Results)
- : Results(Results), I(Results.begin()), Changed(false), CalledDone(false)
- {}
+ Filter(LookupResult &Results) : Results(Results), I(Results.begin()) {}
public:
Filter(Filter &&F)
@@ -634,6 +619,7 @@ public:
CalledDone(F.CalledDone) {
F.CalledDone = true;
}
+
~Filter() {
assert(CalledDone &&
"LookupResult::Filter destroyed without done() call");
@@ -722,11 +708,11 @@ private:
static void deletePaths(CXXBasePaths *);
// Results.
- LookupResultKind ResultKind;
+ LookupResultKind ResultKind = NotFound;
AmbiguityKind Ambiguity; // ill-defined unless ambiguous
UnresolvedSet<8> Decls;
- CXXBasePaths *Paths;
- CXXRecordDecl *NamingClass;
+ CXXBasePaths *Paths = nullptr;
+ CXXRecordDecl *NamingClass = nullptr;
QualType BaseObjectType;
// Parameters.
@@ -734,24 +720,24 @@ private:
DeclarationNameInfo NameInfo;
SourceRange NameContextRange;
Sema::LookupNameKind LookupKind;
- unsigned IDNS; // set by configure()
+ unsigned IDNS = 0; // set by configure()
bool Redecl;
bool ExternalRedecl;
/// \brief True if tag declarations should be hidden if non-tags
/// are present
- bool HideTags;
+ bool HideTags = true;
- bool Diagnose;
+ bool Diagnose = false;
/// \brief True if we should allow hidden declarations to be 'visible'.
- bool AllowHidden;
+ bool AllowHidden = false;
/// \brief True if the found declarations were shadowed by some other
/// declaration that we skipped. This only happens when \c LookupKind
/// is \c LookupRedeclarationWithLinkage.
- bool Shadowed;
+ bool Shadowed = false;
};
/// \brief Consumes visible declarations found when searching for
@@ -813,13 +799,13 @@ public:
Decls.erase(cast<NamedDecl>(D->getCanonicalDecl()));
}
- typedef llvm::mapped_iterator<decltype(Decls)::iterator, select_second>
- iterator;
+ using iterator =
+ llvm::mapped_iterator<decltype(Decls)::iterator, select_second>;
iterator begin() { return iterator(Decls.begin(), select_second()); }
iterator end() { return iterator(Decls.end(), select_second()); }
};
-}
+} // namespace clang
-#endif
+#endif // LLVM_CLANG_SEMA_LOOKUP_H