Skip to content
This repository has been archived by the owner on Jan 1, 2023. It is now read-only.

Commit

Permalink
[MC, RISCV] Fixed StringRef Assertion `Index < Length && "Invalid ind…
Browse files Browse the repository at this point in the history
…ex!"'

Summary:
Handle the case IDVal is an empty string.

This bug was uncovered by a LLVM MC Assembler Protocol Buffer
Fuzzer  for the RISC-V assembly language.

Reviewers: rnk

Reviewed By: rnk

Subscribers: rnk, niravd, pcc, peter.smith, asb, grosbach, llvm-commits, bcain, kito-cheng, shiva0217, rogfer01, PkmX

Differential Revision: https://reviews.llvm.org/D50808

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340678 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Ana Pazos committed Aug 25, 2018
1 parent 710afe1 commit 00384fd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/MC/MCParser/AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1842,7 +1842,7 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info,
// Otherwise, we have a normal instruction or directive.

// Directives start with "."
if (IDVal[0] == '.' && IDVal != ".") {
if (IDVal.startswith(".") && IDVal != ".") {
// There are several entities interested in parsing directives:
//
// 1. The target-specific assembly parser. Some directives are target
Expand Down
3 changes: 3 additions & 0 deletions test/Assembler/empty-string.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// REQUIRES: riscv-registered-target
// RUN: not llvm-mc -triple riscv32-unknown-linux-gnu < %s 2>&1 | FileCheck %s
"" # CHECK: error: unrecognized instruction mnemonic

0 comments on commit 00384fd

Please sign in to comment.