[lld] r272892 - Add support for # comments.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 16 06:29:48 PDT 2016
Author: rafael
Date: Thu Jun 16 08:29:48 2016
New Revision: 272892
URL: http://llvm.org/viewvc/llvm-project?rev=272892&view=rev
Log:
Add support for # comments.
Modified:
lld/trunk/ELF/ScriptParser.cpp
lld/trunk/test/ELF/version-script.s
Modified: lld/trunk/ELF/ScriptParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ScriptParser.cpp?rev=272892&r1=272891&r2=272892&view=diff
==============================================================================
--- lld/trunk/ELF/ScriptParser.cpp (original)
+++ lld/trunk/ELF/ScriptParser.cpp Thu Jun 16 08:29:48 2016
@@ -85,7 +85,7 @@ std::vector<StringRef> ScriptParserBase:
}
}
-// Skip leading whitespace characters or /**/-style comments.
+// Skip leading whitespace characters or comments.
StringRef ScriptParserBase::skipSpace(StringRef S) {
for (;;) {
if (S.startswith("/*")) {
@@ -97,6 +97,13 @@ StringRef ScriptParserBase::skipSpace(St
S = S.substr(E + 2);
continue;
}
+ if (S.startswith("#")) {
+ size_t E = S.find('\n', 1);
+ if (E == StringRef::npos)
+ E = S.size() - 1;
+ S = S.substr(E + 1);
+ continue;
+ }
size_t Size = S.size();
S = S.ltrim();
if (S.size() == Size)
Modified: lld/trunk/test/ELF/version-script.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/version-script.s?rev=272892&r1=272891&r2=272892&view=diff
==============================================================================
--- lld/trunk/test/ELF/version-script.s (original)
+++ lld/trunk/test/ELF/version-script.s Thu Jun 16 08:29:48 2016
@@ -8,7 +8,9 @@
# RUN: ld.lld --version-script %t.script -shared %t.o %t2.so -o %t.so
# RUN: llvm-readobj -dyn-symbols %t.so | FileCheck --check-prefix=DSO %s
-# RUN: echo "{ local: *; };" > %t3.script
+# RUN: echo "# comment" > %t3.script
+# RUN: echo "{ local: *; # comment" >> %t3.script
+# RUN: echo -n "}; # comment" >> %t3.script
# RUN: ld.lld --version-script %t3.script -shared %t.o %t2.so -o %t3.so
# RUN: llvm-readobj -dyn-symbols %t3.so | FileCheck --check-prefix=DSO2 %s
More information about the llvm-commits
mailing list