diff options
author | Bob Wilson <bob.wilson@apple.com> | 2012-09-24 19:57:59 +0000 |
---|---|---|
committer | Bob Wilson <bob.wilson@apple.com> | 2012-09-24 19:57:59 +0000 |
commit | 317be45091d74fa77205312a523f042ebaee9e1c (patch) | |
tree | 01762bb610c0dd86c0f57fd2b83b14f7503fb319 /clang/lib/Sema/SemaStmtAsm.cpp | |
parent | 0fc64f0b11116b455285b40cff7a83819bfd7bfa (diff) | |
download | bcm5719-llvm-317be45091d74fa77205312a523f042ebaee9e1c.tar.gz bcm5719-llvm-317be45091d74fa77205312a523f042ebaee9e1c.zip |
Replace an assertion with an error for empty __asm statements.
llvm-svn: 164551
Diffstat (limited to 'clang/lib/Sema/SemaStmtAsm.cpp')
-rw-r--r-- | clang/lib/Sema/SemaStmtAsm.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index da4120af228..c0bcf2c15ef 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -415,8 +415,10 @@ static void buildMSAsmPieces(std::vector<std::string> &AsmStrings, } // Build the individual assembly instruction(s) and place them in the AsmStrings -// vector. These strings are fed to the AsmParser. -static void buildMSAsmStrings(Sema &SemaRef, ArrayRef<Token> AsmToks, +// vector. These strings are fed to the AsmParser. Returns true on error. +static bool buildMSAsmStrings(Sema &SemaRef, + SourceLocation AsmLoc, + ArrayRef<Token> AsmToks, std::vector<std::string> &AsmStrings, std::vector<std::pair<unsigned,unsigned> > &AsmTokRanges) { assert (!AsmToks.empty() && "Didn't expect an empty AsmToks!"); @@ -437,7 +439,10 @@ static void buildMSAsmStrings(Sema &SemaRef, ArrayRef<Token> AsmToks, } if (AsmToks[i].is(tok::kw_asm)) { i++; // Skip __asm - assert(i != e && "Expected another token"); + if (i == e) { + SemaRef.Diag(AsmLoc, diag::err_asm_empty); + return true; + } } } @@ -449,6 +454,8 @@ static void buildMSAsmStrings(Sema &SemaRef, ArrayRef<Token> AsmToks, } AsmStrings.push_back(Asm.str()); AsmTokRanges.push_back(std::make_pair(startTok, AsmToks.size()-1)); + + return false; } #define DEF_SIMPLE_MSASM(STR) \ @@ -482,7 +489,8 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, std::vector<std::string> AsmStrings; std::vector<std::pair<unsigned,unsigned> > AsmTokRanges; - buildMSAsmStrings(*this, AsmToks, AsmStrings, AsmTokRanges); + if (buildMSAsmStrings(*this, AsmLoc, AsmToks, AsmStrings, AsmTokRanges)) + return StmtError(); std::vector<std::vector<StringRef> > Pieces(AsmStrings.size()); buildMSAsmPieces(AsmStrings, Pieces); |