summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2017-10-05 08:15:55 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2017-10-05 08:15:55 +0000
commitb074fbcb48ef7e7a7c3500895a911dcbaf94a2ae (patch)
treeec93c10ec5b1c7e12104381f3961dc147d735b7e
parent6603fc0e7be3e182ec120de8de7f9b4bb5cb905b (diff)
downloadbcm5719-llvm-b074fbcb48ef7e7a7c3500895a911dcbaf94a2ae.tar.gz
bcm5719-llvm-b074fbcb48ef7e7a7c3500895a911dcbaf94a2ae.zip
[MC] - llvm-mc hangs on non-english characters.
Currently llvm-mc just hangs inside infinite loop while trying to parse file which has ".section .с" inside, where section name is non-english character. Patch fixes the issue. In this patch I also moved content of non-english-characters.s to test/MC/AsmParser/Inputs folder so that non-english-characters.s becomes a single testcase for all invalid inputs containing non-english symbols. That is convinent because llvm-mc otherwise tries to parse and tokenize the whole testcase file with tools invocations and it is harder to isolate the issue. Differential revision: https://reviews.llvm.org/D38545 llvm-svn: 314973
-rw-r--r--llvm/lib/MC/MCParser/ELFAsmParser.cpp2
-rw-r--r--llvm/test/MC/AsmParser/Inputs/non-english-characters-comments.s10
-rw-r--r--llvm/test/MC/AsmParser/Inputs/non-english-characters-section-name.s1
-rw-r--r--llvm/test/MC/AsmParser/non-english-characters.s17
4 files changed, 18 insertions, 12 deletions
diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
index a407691b0bd..8b8e96a4d51 100644
--- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp
@@ -247,7 +247,7 @@ bool ELFAsmParser::ParseSectionName(StringRef &SectionName) {
return false;
}
- while (true) {
+ while (!getParser().hasPendingError()) {
SMLoc PrevLoc = getLexer().getLoc();
if (getLexer().is(AsmToken::Comma) ||
getLexer().is(AsmToken::EndOfStatement))
diff --git a/llvm/test/MC/AsmParser/Inputs/non-english-characters-comments.s b/llvm/test/MC/AsmParser/Inputs/non-english-characters-comments.s
new file mode 100644
index 00000000000..41711e72424
--- /dev/null
+++ b/llvm/test/MC/AsmParser/Inputs/non-english-characters-comments.s
@@ -0,0 +1,10 @@
+# 0b
+# 0x
+# .4
+# .X
+# .1
+# .1e
+# 0x.
+# 0x0p
+.intel_syntax
+# 1
diff --git a/llvm/test/MC/AsmParser/Inputs/non-english-characters-section-name.s b/llvm/test/MC/AsmParser/Inputs/non-english-characters-section-name.s
new file mode 100644
index 00000000000..7e255d20601
--- /dev/null
+++ b/llvm/test/MC/AsmParser/Inputs/non-english-characters-section-name.s
@@ -0,0 +1 @@
+.section .
diff --git a/llvm/test/MC/AsmParser/non-english-characters.s b/llvm/test/MC/AsmParser/non-english-characters.s
index 12d78ee83be..0e47a943bd3 100644
--- a/llvm/test/MC/AsmParser/non-english-characters.s
+++ b/llvm/test/MC/AsmParser/non-english-characters.s
@@ -1,14 +1,9 @@
-# RUN: llvm-mc -triple i386-linux-gnu -filetype=obj -o %t %s
+# RUN: llvm-mc -triple i386-linux-gnu -filetype=obj -o %t \
+# RUN: %S/Inputs/non-english-characters-comments.s
# RUN: llvm-readobj %t | FileCheck %s
# CHECK: Format: ELF32-i386
-# 0b
-# 0x
-# .4
-# .X
-# .1
-# .1e
-# 0x.
-# 0x0p
-.intel_syntax
-# 1
+# RUN: not llvm-mc -triple i386-linux-gnu -filetype=obj -o %t \
+# RUN: %S/Inputs/non-english-characters-section-name.s 2>&1 | \
+# RUN: FileCheck %s --check-prefix=ERR
+# ERR: invalid character in input
OpenPOWER on IntegriCloud