[clang] 600c671 - [clang][syntax] Replace `std::vector<bool>` use
Jan Svoboda via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 26 02:20:24 PST 2022
Author: Jan Svoboda
Date: 2022-01-26T11:20:18+01:00
New Revision: 600c6714ac77915b7b656b860cf71494a7c9ec7f
URL: https://github.com/llvm/llvm-project/commit/600c6714ac77915b7b656b860cf71494a7c9ec7f
DIFF: https://github.com/llvm/llvm-project/commit/600c6714ac77915b7b656b860cf71494a7c9ec7f.diff
LOG: [clang][syntax] Replace `std::vector<bool>` use
LLVM Programmer’s Manual strongly discourages the use of `std::vector<bool>` and suggests `llvm::BitVector` as a possible replacement.
This patch replaces `std::vector<bool>` with `llvm::BitVector` in the Syntax library and replaces range-based for loop with regular for loop. This is necessary due to `llvm::BitVector` not having `begin()` and `end()` (D117116).
Reviewed By: dexonsmith, dblaikie
Differential Revision: https://reviews.llvm.org/D118109
Added:
Modified:
clang/lib/Tooling/Syntax/Tree.cpp
Removed:
################################################################################
diff --git a/clang/lib/Tooling/Syntax/Tree.cpp b/clang/lib/Tooling/Syntax/Tree.cpp
index c813865e95cd8..981bac508f733 100644
--- 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 <cassert>
@@ -202,7 +203,7 @@ static void dumpLeaf(raw_ostream &OS, const syntax::Leaf *L,
}
static void dumpNode(raw_ostream &OS, const syntax::Node *N,
- const SourceManager &SM, std::vector<bool> IndentMask) {
+ const SourceManager &SM, llvm::BitVector IndentMask) {
auto DumpExtraInfo = [&OS](const syntax::Node *N) {
if (N->getRole() != syntax::NodeRole::Unknown)
OS << " " << N->getRole();
@@ -228,8 +229,8 @@ static void dumpNode(raw_ostream &OS, const syntax::Node *N,
OS << "\n";
for (const syntax::Node &It : T->getChildren()) {
- for (bool Filled : IndentMask) {
- if (Filled)
+ for (unsigned Idx = 0; Idx < IndentMask.size(); ++Idx) {
+ if (IndentMask[Idx])
OS << "| ";
else
OS << " ";
More information about the cfe-commits
mailing list