diff options
author | Chris Lattner <sabre@nondot.org> | 2009-03-10 23:41:04 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-03-10 23:41:04 +0000 |
commit | fb5058ef67c054296c88db18ab1b3717845cb71d (patch) | |
tree | 28b31a230573ad4b481a6a174b479c81029d4894 /lib/Sema/SemaStmt.cpp | |
parent | 458cd9c8a79b25b87dcea43c9d97a4c59f194799 (diff) |
add plumbing to report diagnostics back through sema for malformed asmstrings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66598 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index fcc501c45d..55f556444d 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -958,10 +958,24 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc, exprs.release(); asmString.release(); clobbers.release(); - return Owned(new (Context) AsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs, - NumInputs, Names, Constraints, Exprs, - AsmString, NumClobbers, - Clobbers, RParenLoc)); + AsmStmt *NS = + new (Context) AsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs, NumInputs, + Names, Constraints, Exprs, AsmString, NumClobbers, + Clobbers, RParenLoc); + // Validate the asm string, ensuring it makes sense given the operands we + // have. + llvm::SmallVector<AsmStmt::AsmStringPiece, 8> Pieces; + unsigned DiagOffs; + if (unsigned DiagID = NS->AnalyzeAsmString(Pieces, Context, DiagOffs)) { + // FIXME: get offsets in strings working. + // StringLiteralParser::getOffsetOfStringByte + Diag(AsmString->getLocStart(), DiagID) << AsmString->getSourceRange(); + DeleteStmt(NS); + return StmtError(); + } + + + return Owned(NS); } Action::OwningStmtResult |