Fix misc style issues in Crubit.
1. (not caught by ClangTidy for some reason): missing `override` marker on virtual function overrides.
2. (ClangTidy) unnecessary `const` qualification of return value (almost completely meaningless as of C++17, since you can, without performing any copies, initialize a non-const `T` from a `const T` return value.)
3. (ClangTidy) `reserve()` call before loop/`push_back`.
PiperOrigin-RevId: 530363796
diff --git a/rs_bindings_from_cc/importer.cc b/rs_bindings_from_cc/importer.cc
index c22d7c9..11607f1 100644
--- a/rs_bindings_from_cc/importer.cc
+++ b/rs_bindings_from_cc/importer.cc
@@ -240,20 +240,20 @@
class Importer::SourceLocationComparator {
public:
- const bool operator()(const clang::SourceLocation& a,
- const clang::SourceLocation& b) const {
+ bool operator()(const clang::SourceLocation& a,
+ const clang::SourceLocation& b) const {
return b.isValid() && a.isValid() && sm.isBeforeInTranslationUnit(a, b);
}
- const bool operator()(const clang::RawComment* a,
- const clang::SourceLocation& b) const {
+ bool operator()(const clang::RawComment* a,
+ const clang::SourceLocation& b) const {
return this->operator()(a->getBeginLoc(), b);
}
- const bool operator()(const clang::SourceLocation& a,
- const clang::RawComment* b) const {
+ bool operator()(const clang::SourceLocation& a,
+ const clang::RawComment* b) const {
return this->operator()(a, b->getBeginLoc());
}
- const bool operator()(const clang::RawComment* a,
- const clang::RawComment* b) const {
+ bool operator()(const clang::RawComment* a,
+ const clang::RawComment* b) const {
return this->operator()(a->getBeginLoc(), b->getBeginLoc());
}
@@ -407,6 +407,7 @@
clang::SourceManager& sm = ctx_.getSourceManager();
std::vector<SourceLocationComparator::OrderedItem> ordered_items;
+ ordered_items.reserve(comments_.size());
for (auto& comment : comments_) {
ordered_items.push_back(
{GetSourceOrderKey(comment),