[PATCH] D111980: [Flang][flang-omp-report] Switch from std::string to StringRef (where possible)
Josh Mottley via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 18 03:18:06 PDT 2021
josh.mottley.arm created this revision.
Herald added a project: Flang.
josh.mottley.arm requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, sstefan1, jdoerfert.
Herald added a project: LLVM.
This patch makes the following changes to flang-omp-report:
- Update 'normalize_clause_name' parameter to use llvm::StringRef instead of std::sting.
- Change usages of std::tolower to llvm::toLower from "ADT/StringExtras.h".
This is a one of several patches focusing on switching containers from STL to LLVM's ADT library.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D111980
Files:
flang/examples/flang-omp-report-plugin/flang-omp-report-visitor.cpp
flang/examples/flang-omp-report-plugin/flang-omp-report-visitor.h
Index: flang/examples/flang-omp-report-plugin/flang-omp-report-visitor.h
===================================================================
--- flang/examples/flang-omp-report-plugin/flang-omp-report-visitor.h
+++ flang/examples/flang-omp-report-plugin/flang-omp-report-visitor.h
@@ -14,6 +14,7 @@
#include "flang/Parser/parsing.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
#include <deque>
#include <map>
@@ -48,7 +49,7 @@
struct OpenMPCounterVisitor {
std::string normalize_construct_name(std::string s);
- ClauseInfo normalize_clause_name(const std::string &s);
+ ClauseInfo normalize_clause_name(const llvm::StringRef s);
SourcePosition getLocation(const OmpWrapperType &w);
SourcePosition getLocation(const OpenMPDeclarativeConstruct &c);
SourcePosition getLocation(const OpenMPConstruct &c);
Index: flang/examples/flang-omp-report-plugin/flang-omp-report-visitor.cpp
===================================================================
--- flang/examples/flang-omp-report-plugin/flang-omp-report-visitor.cpp
+++ flang/examples/flang-omp-report-plugin/flang-omp-report-visitor.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "flang-omp-report-visitor.h"
+#include "llvm/ADT/StringExtras.h"
namespace Fortran {
namespace parser {
@@ -26,23 +27,24 @@
std::string OpenMPCounterVisitor::normalize_construct_name(std::string s) {
std::transform(s.begin(), s.end(), s.begin(),
- [](unsigned char c) { return std::tolower(c); });
+ [](unsigned char c) { return llvm::toLower(c); });
return s;
}
-ClauseInfo OpenMPCounterVisitor::normalize_clause_name(const std::string &s) {
+ClauseInfo OpenMPCounterVisitor::normalize_clause_name(
+ const llvm::StringRef s) {
std::size_t start = s.find('(');
std::size_t end = s.find(')');
std::string clauseName;
- if (start != std::string::npos && end != std::string::npos) {
+ if (start != llvm::StringRef::npos && end != llvm::StringRef::npos) {
clauseName = s.substr(0, start);
clauseDetails = s.substr(start + 1, end - start - 1);
} else {
clauseName = s;
}
std::transform(clauseName.begin(), clauseName.end(), clauseName.begin(),
- [](unsigned char c) { return std::tolower(c); });
+ [](unsigned char c) { return llvm::toLower(c); });
std::transform(clauseDetails.begin(), clauseDetails.end(),
- clauseDetails.begin(), [](unsigned char c) { return std::tolower(c); });
+ clauseDetails.begin(), [](unsigned char c) { return llvm::toLower(c); });
return ClauseInfo{clauseName, clauseDetails};
}
SourcePosition OpenMPCounterVisitor::getLocation(const OmpWrapperType &w) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111980.380328.patch
Type: text/x-patch
Size: 2715 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211018/e345b9b6/attachment.bin>
More information about the llvm-commits
mailing list