From 271b9e136acb87511d35a678ec0b1aa9e142fa52 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Wed, 13 Feb 2013 01:03:13 +0000 Subject: [PATCH] [ms-inline-asm] Make sure the AsmRewrite list is sorted in lexical order. rdar://13202662 llvm-svn: 175021 --- lib/MC/MCParser/AsmParser.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index 7aa381242cb..0644ea341a3 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -4029,6 +4029,10 @@ bool AsmParser::ParseDirectiveMSAlign(SMLoc IDLoc, ParseStatementInfo &Info) { return false; } +bool AsmStringSort (AsmRewrite A, AsmRewrite B) { + return A.Loc.getPointer() < B.Loc.getPointer(); +} + bool AsmParser::ParseMSInlineAsm(void *AsmLoc, std::string &AsmString, unsigned &NumOutputs, unsigned &NumInputs, SmallVectorImpl > &OpDecls, @@ -4153,6 +4157,7 @@ bool AsmParser::ParseMSInlineAsm(void *AsmLoc, std::string &AsmString, AsmRewriteKind PrevKind = AOK_Imm; raw_string_ostream OS(AsmStringIR); const char *Start = SrcMgr.getMemoryBuffer(0)->getBufferStart(); + std::sort (AsmStrRewrites.begin(), AsmStrRewrites.end(), AsmStringSort); for (SmallVectorImpl::iterator I = AsmStrRewrites.begin(), E = AsmStrRewrites.end(); I != E; ++I) { const char *Loc = (*I).Loc.getPointer();