Move isValidCIdentifier to Strings.cpp.
llvm-svn: 274112
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index 4636b99..4be8447 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -11,6 +11,7 @@
#include "Config.h"
#include "EhFrame.h"
#include "LinkerScript.h"
+#include "Strings.h"
#include "SymbolTable.h"
#include "Target.h"
#include "lld/Core/Parallel.h"
@@ -29,18 +30,6 @@
using namespace lld;
using namespace lld::elf;
-static bool isAlpha(char C) {
- return ('a' <= C && C <= 'z') || ('A' <= C && C <= 'Z') || C == '_';
-}
-
-static bool isAlnum(char C) { return isAlpha(C) || ('0' <= C && C <= '9'); }
-
-// Returns true if S is valid as a C language identifier.
-bool elf::isValidCIdentifier(StringRef S) {
- return !S.empty() && isAlpha(S[0]) &&
- std::all_of(S.begin() + 1, S.end(), isAlnum);
-}
-
template <class ELFT>
OutputSectionBase<ELFT>::OutputSectionBase(StringRef Name, uint32_t Type,
uintX_t Flags)
diff --git a/lld/ELF/Strings.cpp b/lld/ELF/Strings.cpp
index a7aecf0..21d7f42 100644
--- a/lld/ELF/Strings.cpp
+++ b/lld/ELF/Strings.cpp
@@ -11,6 +11,7 @@
#include "Error.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
+#include <algorithm>
using namespace llvm;
using namespace lld;
@@ -55,3 +56,15 @@
}
return Hex;
}
+
+static bool isAlpha(char C) {
+ return ('a' <= C && C <= 'z') || ('A' <= C && C <= 'Z') || C == '_';
+}
+
+static bool isAlnum(char C) { return isAlpha(C) || ('0' <= C && C <= '9'); }
+
+// Returns true if S is valid as a C language identifier.
+bool elf::isValidCIdentifier(StringRef S) {
+ return !S.empty() && isAlpha(S[0]) &&
+ std::all_of(S.begin() + 1, S.end(), isAlnum);
+}
diff --git a/lld/ELF/Strings.h b/lld/ELF/Strings.h
index 1930a0a..002e8c2 100644
--- a/lld/ELF/Strings.h
+++ b/lld/ELF/Strings.h
@@ -17,6 +17,7 @@
namespace elf {
bool globMatch(StringRef S, StringRef T);
std::vector<uint8_t> parseHex(StringRef S);
+bool isValidCIdentifier(StringRef S);
}
}
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 849a67f..323a791 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -12,6 +12,7 @@
#include "LinkerScript.h"
#include "OutputSections.h"
#include "Relocations.h"
+#include "Strings.h"
#include "SymbolTable.h"
#include "Target.h"