[PATCH] D87522: [SyntaxTree] Add const qualifiers, from [llvm-qualified-auto]
Eduardo Caldas via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 11 09:34:42 PDT 2020
eduucaldas created this revision.
eduucaldas added a reviewer: gribozavr2.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D87522
Files:
clang/lib/Tooling/Syntax/BuildTree.cpp
clang/lib/Tooling/Syntax/ComputeReplacements.cpp
clang/lib/Tooling/Syntax/Tree.cpp
Index: clang/lib/Tooling/Syntax/Tree.cpp
===================================================================
--- clang/lib/Tooling/Syntax/Tree.cpp
+++ clang/lib/Tooling/Syntax/Tree.cpp
@@ -19,7 +19,7 @@
static void traverse(const syntax::Node *N,
llvm::function_ref<void(const syntax::Node *)> Visit) {
if (auto *T = dyn_cast<syntax::Tree>(N)) {
- for (auto *C = T->getFirstChild(); C; C = C->getNextSibling())
+ for (const auto *C = T->getFirstChild(); C; C = C->getNextSibling())
traverse(C, Visit);
}
Visit(N);
@@ -226,7 +226,7 @@
auto *T = dyn_cast<Tree>(this);
if (!T)
return;
- for (auto *C = T->getFirstChild(); C; C = C->getNextSibling()) {
+ for (const auto *C = T->getFirstChild(); C; C = C->getNextSibling()) {
if (T->isOriginal())
assert(C->isOriginal());
assert(!C->isDetached());
Index: clang/lib/Tooling/Syntax/ComputeReplacements.cpp
===================================================================
--- clang/lib/Tooling/Syntax/ComputeReplacements.cpp
+++ clang/lib/Tooling/Syntax/ComputeReplacements.cpp
@@ -32,7 +32,7 @@
private:
void process(const syntax::Node *N) {
if (auto *T = dyn_cast<syntax::Tree>(N)) {
- for (auto *C = T->getFirstChild(); C != nullptr;
+ for (const auto *C = T->getFirstChild(); C != nullptr;
C = C->getNextSibling())
process(C);
return;
@@ -64,8 +64,8 @@
syntax::FileRange rangeOfExpanded(const syntax::Arena &A,
llvm::ArrayRef<syntax::Token> Expanded) {
- auto &Buffer = A.getTokenBuffer();
- auto &SM = A.getSourceManager();
+ const auto &Buffer = A.getTokenBuffer();
+ const auto &SM = A.getSourceManager();
// Check that \p Expanded actually points into expanded tokens.
assert(Buffer.expandedTokens().begin() <= Expanded.begin());
@@ -85,8 +85,8 @@
tooling::Replacements
syntax::computeReplacements(const syntax::Arena &A,
const syntax::TranslationUnit &TU) {
- auto &Buffer = A.getTokenBuffer();
- auto &SM = A.getSourceManager();
+ const auto &Buffer = A.getTokenBuffer();
+ const auto &SM = A.getSourceManager();
tooling::Replacements Replacements;
// Text inserted by the replacement we are building now.
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===================================================================
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -558,7 +558,7 @@
assert(A.getTokenBuffer().expandedTokens().back().kind() == tok::eof);
// Create all leaf nodes.
// Note that we do not have 'eof' in the tree.
- for (auto &T : A.getTokenBuffer().expandedTokens().drop_back()) {
+ for (const auto &T : A.getTokenBuffer().expandedTokens().drop_back()) {
auto *L = new (A.getAllocator()) syntax::Leaf(&T);
L->Original = true;
L->CanModify = A.getTokenBuffer().spelledForExpanded(T).hasValue();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87522.291251.patch
Type: text/x-patch
Size: 2996 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200911/221aaebb/attachment.bin>
More information about the cfe-commits
mailing list