From: Daniel Dunbar Date: Fri, 17 Oct 2008 20:58:01 +0000 (+0000) Subject: Emit error unsupported when asm string conversion fails instead of X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=281f55c8c6aed79f1ac1c6ee848bd94ebd7f936f;p=clang Emit error unsupported when asm string conversion fails instead of assert. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57721 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index 20312de5ba..ece4aeeff8 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -624,7 +624,9 @@ void CodeGenFunction::EmitSwitchStmt(const SwitchStmt &S) { } static std::string ConvertAsmString(const char *Start, unsigned NumOperands, - bool IsSimple) { + bool IsSimple, bool &Failed) { + Failed = false; + static unsigned AsmCounter = 0; AsmCounter++; std::string Result; @@ -696,7 +698,8 @@ static std::string ConvertAsmString(const char *Start, unsigned NumOperands, Result += "${" + llvm::utostr(n) + ':' + EscapedChar + '}'; Start = End - 1; } else { - assert(0 && "Unhandled asm escaped character!"); + Failed = true; + return ""; } } Start++; @@ -731,10 +734,17 @@ static std::string SimplifyConstraint(const char* Constraint, } void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) { + bool Failed; std::string AsmString = ConvertAsmString(std::string(S.getAsmString()->getStrData(), S.getAsmString()->getByteLength()).c_str(), - S.getNumOutputs() + S.getNumInputs(), S.isSimple()); + S.getNumOutputs() + S.getNumInputs(), S.isSimple(), + Failed); + + if (Failed) { + ErrorUnsupported(&S, "asm string"); + return; + } std::string Constraints;