[flang-commits] [flang] [flang][cli] Add diagnostic flags to the CLI (PR #142022)
Tarun Prabhu via flang-commits
flang-commits at lists.llvm.org
Sun Jun 8 10:16:04 PDT 2025
================
@@ -8,11 +8,71 @@
#include "flang/Support/Fortran-features.h"
#include "flang/Common/idioms.h"
+#include "flang/Parser/characters.h"
#include "flang/Support/Fortran.h"
+#include <string>
+#include <string_view>
namespace Fortran::common {
+static std::vector<std::string_view> SplitCamelCase(std::string_view x) {
+ std::vector<std::string_view> result;
+ // NB, we start at 1 because the first character is never a word boundary.
+ size_t xSize{x.size()}, wordStart{0}, wordEnd{1};
+ for (; wordEnd < xSize; ++wordEnd) {
+ // Identify when wordEnd is at the start of a new word.
+ if ((!parser::IsUpperCaseLetter(x[wordEnd - 1]) &&
+ parser::IsUpperCaseLetter(x[wordEnd])) ||
+ // ACCUsage => ACC-Usage, CComment => C-Comment, etc.
+ (parser::IsUpperCaseLetter(x[wordEnd]) && wordEnd + 1 < xSize &&
+ parser::IsLowerCaseLetter(x[wordEnd + 1]))) {
+ result.push_back(x.substr(wordStart, wordEnd - wordStart));
+ wordStart = wordEnd;
+ }
+ }
+ // We went one past the end of the last word.
+ result.push_back(x.substr(wordStart, wordEnd - wordStart));
+ return result;
+}
+
+// Namespace for helper functions for parsing Cli options used instead of static
+// so that there can be unit tests for this function.
+namespace featuresHelpers {
----------------
tarunprabhu wrote:
A very common pattern in LLVM is to have a namespace named detail for helper functions and other details that are not intended to be part of the main API, but are sometimes exposed for testing. There is some use of `*helper` too, but it is considerably less common.
https://github.com/llvm/llvm-project/pull/142022
More information about the flang-commits
mailing list