[PATCH] D13760: ELF2: Implement __start_SECNAME and __stop_SECNAME.

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 14 23:30:51 PDT 2015


majnemer added a subscriber: majnemer.

================
Comment at: ELF/Writer.cpp:522-535
@@ -512,1 +521,16 @@
 
+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 identifier.
+static bool isValidCIdentifier(StringRef S) {
+  if (S.empty() || !isAlpha(S[0]))
+    return false;
+  return std::all_of(S.begin() + 1, S.end(), isAlnum);
+}
+
----------------
`$` can be used in an identifier in clang:
  echo 'int x$a;' | clang -x c -fsyntax-only - ; echo $?
  0

gcc as well:
  echo 'int x$a;' | clang -x c -fsyntax-only - ; echo $?
  0


http://reviews.llvm.org/D13760





More information about the llvm-commits mailing list