[llvm] r314973 - [MC] - llvm-mc hangs on non-english characters.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 5 01:15:55 PDT 2017


Author: grimar
Date: Thu Oct  5 01:15:55 2017
New Revision: 314973

URL: http://llvm.org/viewvc/llvm-project?rev=314973&view=rev
Log:
[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

Added:
    llvm/trunk/test/MC/AsmParser/Inputs/non-english-characters-comments.s
    llvm/trunk/test/MC/AsmParser/Inputs/non-english-characters-section-name.s
Modified:
    llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
    llvm/trunk/test/MC/AsmParser/non-english-characters.s

Modified: llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp?rev=314973&r1=314972&r2=314973&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp Thu Oct  5 01:15:55 2017
@@ -247,7 +247,7 @@ bool ELFAsmParser::ParseSectionName(Stri
     return false;
   }
 
-  while (true) {
+  while (!getParser().hasPendingError()) {
     SMLoc PrevLoc = getLexer().getLoc();
     if (getLexer().is(AsmToken::Comma) ||
       getLexer().is(AsmToken::EndOfStatement))

Added: llvm/trunk/test/MC/AsmParser/Inputs/non-english-characters-comments.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/Inputs/non-english-characters-comments.s?rev=314973&view=auto
==============================================================================
--- llvm/trunk/test/MC/AsmParser/Inputs/non-english-characters-comments.s (added)
+++ llvm/trunk/test/MC/AsmParser/Inputs/non-english-characters-comments.s Thu Oct  5 01:15:55 2017
@@ -0,0 +1,10 @@
+# 0bÑ
+# 0xÑ
+# .Ñ4
+# .XÑ
+# .1Ñ
+# .1eÑ
+# 0x.Ñ
+# 0x0pÑ
+.intel_syntax
+# 1Ñ

Added: llvm/trunk/test/MC/AsmParser/Inputs/non-english-characters-section-name.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/Inputs/non-english-characters-section-name.s?rev=314973&view=auto
==============================================================================
--- llvm/trunk/test/MC/AsmParser/Inputs/non-english-characters-section-name.s (added)
+++ llvm/trunk/test/MC/AsmParser/Inputs/non-english-characters-section-name.s Thu Oct  5 01:15:55 2017
@@ -0,0 +1 @@
+.section .ñ

Modified: llvm/trunk/test/MC/AsmParser/non-english-characters.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/non-english-characters.s?rev=314973&r1=314972&r2=314973&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/non-english-characters.s (original)
+++ llvm/trunk/test/MC/AsmParser/non-english-characters.s Thu Oct  5 01:15:55 2017
@@ -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




More information about the llvm-commits mailing list