[cfe-commits] r162388 - /cfe/trunk/lib/Sema/SemaStmtAsm.cpp

Chad Rosier mcrosier at apple.com
Wed Aug 22 13:30:58 PDT 2012


Author: mcrosier
Date: Wed Aug 22 15:30:58 2012
New Revision: 162388

URL: http://llvm.org/viewvc/llvm-project?rev=162388&view=rev
Log:
[ms-inline asm] Compute the token range for each instruction within the asm.
Eventually, we'll need a way of mapping tokens (and their IdentifierInfo*) to
the operands computed by buildMSAsmPieces().

Modified:
    cfe/trunk/lib/Sema/SemaStmtAsm.cpp

Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=162388&r1=162387&r2=162388&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Wed Aug 22 15:30:58 2012
@@ -388,13 +388,14 @@
 }
 
 // Build the unmodified MSAsmString.
-static std::string buildMSAsmString(Sema &SemaRef,
-                                    ArrayRef<Token> AsmToks,
-                                    std::vector<std::string> &AsmStrings) {
+static std::string buildMSAsmString(Sema &SemaRef, ArrayRef<Token> AsmToks,
+                                    std::vector<std::string> &AsmStrings,
+                     std::vector<std::pair<unsigned,unsigned> > &AsmTokRanges) {
   assert (!AsmToks.empty() && "Didn't expect an empty AsmToks!");
 
   SmallString<512> Res;
   SmallString<512> Asm;
+  unsigned startTok = 0;
   for (unsigned i = 0, e = AsmToks.size(); i < e; ++i) {
     bool isNewAsm = i == 0 || AsmToks[i].isAtStartOfLine() ||
       AsmToks[i].is(tok::kw_asm);
@@ -402,6 +403,8 @@
     if (isNewAsm) {
       if (i) {
         AsmStrings.push_back(Asm.c_str());
+        AsmTokRanges.push_back(std::make_pair(startTok, i-1));
+        startTok = i;
         Res += Asm;
         Asm.clear();
         Res += '\n';
@@ -418,6 +421,7 @@
     Asm += getSpelling(SemaRef, AsmToks[i]);
   }
   AsmStrings.push_back(Asm.c_str());
+  AsmTokRanges.push_back(std::make_pair(startTok, AsmToks.size()-1));
   Res += Asm;
   return Res.c_str();
 }
@@ -448,7 +452,8 @@
 
   unsigned NumAsmStrings;
   std::vector<std::string> AsmStrings;
-  std::string AsmString = buildMSAsmString(*this, AsmToks, AsmStrings);
+  std::vector<std::pair<unsigned,unsigned> > AsmTokRanges;
+  std::string AsmString = buildMSAsmString(*this, AsmToks, AsmStrings, AsmTokRanges);
   NumAsmStrings = AsmStrings.size();
 
   std::vector<std::vector<StringRef> > Pieces;





More information about the cfe-commits mailing list