diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp --- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp @@ -29,6 +29,7 @@ #include "clang/Lex/Lexer.h" #include "clang/Tooling/Core/Diagnostic.h" #include "clang/Tooling/Core/Replacement.h" +#include "llvm/ADT/BitVector.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringMap.h" @@ -863,7 +864,7 @@ } } - std::vector Apply(ErrorFixes.size(), true); + llvm::BitVector Apply(ErrorFixes.size(), true); for (auto &FileAndEvents : FileEvents) { std::vector &Events = FileAndEvents.second; // Sweep. diff --git a/clang-tools-extra/clang-tidy/readability/FunctionSizeCheck.cpp b/clang-tools-extra/clang-tidy/readability/FunctionSizeCheck.cpp --- a/clang-tools-extra/clang-tidy/readability/FunctionSizeCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/FunctionSizeCheck.cpp @@ -9,6 +9,7 @@ #include "FunctionSizeCheck.h" #include "clang/AST/RecursiveASTVisitor.h" #include "clang/ASTMatchers/ASTMatchFinder.h" +#include "llvm/ADT/BitVector.h" using namespace clang::ast_matchers; @@ -118,7 +119,7 @@ std::vector NestingThresholders; }; FunctionInfo Info; - std::vector TrackedParent; + llvm::BitVector TrackedParent; unsigned StructNesting = 0; unsigned CurrentNestingLevel = 0; }; diff --git a/clang-tools-extra/clangd/Selection.cpp b/clang-tools-extra/clangd/Selection.cpp --- a/clang-tools-extra/clangd/Selection.cpp +++ b/clang-tools-extra/clangd/Selection.cpp @@ -25,6 +25,7 @@ #include "clang/Basic/TokenKinds.h" #include "clang/Lex/Lexer.h" #include "clang/Tooling/Syntax/Tokens.h" +#include "llvm/ADT/BitVector.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/Casting.h" @@ -249,7 +250,7 @@ }); auto Sel = llvm::makeArrayRef(SelFirst, SelLimit); // Find which of these are preprocessed to nothing and should be ignored. - std::vector PPIgnored(Sel.size(), false); + llvm::BitVector PPIgnored(Sel.size(), false); for (const syntax::TokenBuffer::Expansion &X : Buf.expansionsOverlapping(Sel)) { if (X.Expanded.empty()) { diff --git a/clang-tools-extra/clangd/SourceCode.cpp b/clang-tools-extra/clangd/SourceCode.cpp --- a/clang-tools-extra/clangd/SourceCode.cpp +++ b/clang-tools-extra/clangd/SourceCode.cpp @@ -27,6 +27,7 @@ #include "clang/Tooling/Core/Replacement.h" #include "clang/Tooling/Syntax/Tokens.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/BitVector.h" #include "llvm/ADT/None.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" @@ -663,7 +664,7 @@ // Stack of enclosing namespaces, e.g. {"clang", "clangd"} std::vector Enclosing; // Contains e.g. "clang", "clangd" // Stack counts open braces. true if the brace opened a namespace. - std::vector BraceStack; + llvm::BitVector BraceStack; enum { Default, diff --git a/clang/include/clang/Lex/HeaderSearch.h b/clang/include/clang/Lex/HeaderSearch.h --- a/clang/include/clang/Lex/HeaderSearch.h +++ b/clang/include/clang/Lex/HeaderSearch.h @@ -19,6 +19,7 @@ #include "clang/Lex/HeaderMap.h" #include "clang/Lex/ModuleMap.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/BitVector.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallSet.h" @@ -499,11 +500,10 @@ /// Determine which HeaderSearchOptions::UserEntries have been successfully /// used so far and mark their index with 'true' in the resulting bit vector. - // TODO: Use llvm::BitVector instead. - std::vector computeUserEntryUsage() const; + llvm::BitVector computeUserEntryUsage() const; /// Return a bit vector of length \c SearchDirs.size() that indicates for each /// search directory whether it was used. - std::vector getSearchDirUsage() const; + llvm::BitVector getSearchDirUsage() const; /// This method returns a HeaderMap for the specified /// FileEntry, uniquing them through the 'HeaderMaps' datastructure. diff --git a/clang/lib/Format/UnwrappedLineParser.h b/clang/lib/Format/UnwrappedLineParser.h --- a/clang/lib/Format/UnwrappedLineParser.h +++ b/clang/lib/Format/UnwrappedLineParser.h @@ -18,6 +18,7 @@ #include "FormatToken.h" #include "clang/Basic/IdentifierTable.h" #include "clang/Format/Format.h" +#include "llvm/ADT/BitVector.h" #include "llvm/Support/Regex.h" #include #include @@ -220,7 +221,7 @@ // We store for each line whether it must be a declaration depending on // whether we are in a compound statement or not. - std::vector DeclarationScopeStack; + llvm::BitVector DeclarationScopeStack; const FormatStyle &Style; const AdditionalKeywords &Keywords; diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -57,7 +57,7 @@ class ScopedDeclarationState { public: - ScopedDeclarationState(UnwrappedLine &Line, std::vector &Stack, + ScopedDeclarationState(UnwrappedLine &Line, llvm::BitVector &Stack, bool MustBeDeclaration) : Line(Line), Stack(Stack) { Line.MustBeDeclaration = MustBeDeclaration; @@ -73,7 +73,7 @@ private: UnwrappedLine &Line; - std::vector &Stack; + llvm::BitVector &Stack; }; static bool isLineComment(const FormatToken &FormatTok) { diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/lib/Lex/HeaderSearch.cpp @@ -138,8 +138,8 @@ SystemDirIdx++; } -std::vector HeaderSearch::computeUserEntryUsage() const { - std::vector UserEntryUsage(HSOpts->UserEntries.size()); +llvm::BitVector HeaderSearch::computeUserEntryUsage() const { + llvm::BitVector UserEntryUsage(HSOpts->UserEntries.size()); for (const DirectoryLookup *SearchDir : UsedSearchDirs) { if (UsedSearchDirs.contains(SearchDir)) { auto UserEntryIdxIt = SearchDirToHSEntry.find(SearchDir); @@ -151,8 +151,8 @@ return UserEntryUsage; } -std::vector HeaderSearch::getSearchDirUsage() const { - std::vector SearchDirUsage(SearchDirs.size()); +llvm::BitVector HeaderSearch::getSearchDirUsage() const { + llvm::BitVector SearchDirUsage(SearchDirs.size()); for (unsigned I = 0, E = SearchDirs.size(); I < E; ++I) if (UsedSearchDirs.contains(SearchDirs[I])) SearchDirUsage[I] = true; diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -132,7 +132,7 @@ sizeof(T) * v.size()); } -static std::string bytes(const std::vector &V) { +static std::string bytes(const llvm::BitVector &V) { std::string Str; Str.reserve(V.size() / 8); for (unsigned I = 0, E = V.size(); I < E;) { diff --git a/clang/lib/Tooling/Syntax/Tree.cpp b/clang/lib/Tooling/Syntax/Tree.cpp --- a/clang/lib/Tooling/Syntax/Tree.cpp +++ b/clang/lib/Tooling/Syntax/Tree.cpp @@ -9,6 +9,7 @@ #include "clang/Basic/TokenKinds.h" #include "clang/Tooling/Syntax/Nodes.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/BitVector.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Casting.h" #include @@ -202,7 +203,7 @@ } static void dumpNode(raw_ostream &OS, const syntax::Node *N, - const SourceManager &SM, std::vector IndentMask) { + const SourceManager &SM, llvm::BitVector IndentMask) { auto DumpExtraInfo = [&OS](const syntax::Node *N) { if (N->getRole() != syntax::NodeRole::Unknown) OS << " " << N->getRole(); diff --git a/clang/unittests/Lex/HeaderSearchTest.cpp b/clang/unittests/Lex/HeaderSearchTest.cpp --- a/clang/unittests/Lex/HeaderSearchTest.cpp +++ b/clang/unittests/Lex/HeaderSearchTest.cpp @@ -302,8 +302,8 @@ { Module *M2 = Search.lookupModule("M2"); EXPECT_NE(M2, nullptr); - EXPECT_EQ(Search.getSearchDirUsage(), (std::vector{0, 1, 0})); - EXPECT_EQ(Search.computeUserEntryUsage(), (std::vector{0, 1, 0})); + EXPECT_EQ(Search.getSearchDirUsage(), (llvm::BitVector{0, 1, 0})); + EXPECT_EQ(Search.computeUserEntryUsage(), (llvm::BitVector{0, 1, 0})); } addSearchDir("/M1"); @@ -312,8 +312,8 @@ { Module *M1 = Search.lookupModule("M1"); EXPECT_NE(M1, nullptr); - EXPECT_EQ(Search.getSearchDirUsage(), (std::vector{0, 1, 1, 0})); - EXPECT_EQ(Search.computeUserEntryUsage(), (std::vector{0, 1, 0})); + EXPECT_EQ(Search.getSearchDirUsage(), (llvm::BitVector{0, 1, 1, 0})); + EXPECT_EQ(Search.computeUserEntryUsage(), (llvm::BitVector{0, 1, 0})); } }