diff options
| -rw-r--r-- | lld/ELF/OutputSections.cpp | 13 | ||||
| -rw-r--r-- | lld/ELF/Strings.cpp | 13 | ||||
| -rw-r--r-- | lld/ELF/Strings.h | 1 | ||||
| -rw-r--r-- | lld/ELF/Writer.cpp | 1 |
4 files changed, 16 insertions, 12 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 4636b9990b0..4be8447391b 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 llvm::ELF; 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 a7aecf09035..21d7f428e85 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 @@ std::vector<uint8_t> elf::parseHex(StringRef S) { } 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 1930a0aab10..002e8c2b843 100644 --- a/lld/ELF/Strings.h +++ b/lld/ELF/Strings.h @@ -17,6 +17,7 @@ namespace lld { 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 849a67f03ae..323a791c3de 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" |

