[cfe-commits] r117450 - /cfe/trunk/docs/InternalsManual.html

Douglas Gregor dgregor at apple.com
Wed Oct 27 09:02:28 PDT 2010


Author: dgregor
Date: Wed Oct 27 11:02:28 2010
New Revision: 117450

URL: http://llvm.org/viewvc/llvm-project?rev=117450&view=rev
Log:
Document how source ranges work

Modified:
    cfe/trunk/docs/InternalsManual.html

Modified: cfe/trunk/docs/InternalsManual.html
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/InternalsManual.html?rev=117450&r1=117449&r2=117450&view=diff
==============================================================================
--- cfe/trunk/docs/InternalsManual.html (original)
+++ cfe/trunk/docs/InternalsManual.html Wed Oct 27 11:02:28 2010
@@ -25,6 +25,7 @@
   <li><a href="#Diagnostics">The Diagnostics Subsystem</a></li>
   <li><a href="#SourceLocation">The SourceLocation and SourceManager
       classes</a></li>
+  <li><a href="#SourceRange">SourceRange and CharSourceRange</a></li>
   </ul>
 </li>
 <li><a href="#libdriver">The Driver Library</a>
@@ -545,6 +546,30 @@
 Clang depends on being able to find the original input characters for the token.
 This concept maps directly to the "spelling location" for the token.</p>
 
+
+<!-- ======================================================================= -->
+<h3 id="SourceRange">SourceRange and CharSourceRange</h3>
+<!-- ======================================================================= -->
+<!-- mostly taken from
+  http://lists.cs.uiuc.edu/pipermail/cfe-dev/2010-August/010595.html -->
+
+<p>Clang represents most source ranges by [first, last], where first and last
+each point to the beginning of their respective tokens. For example
+consider the SourceRange of the following statement:</p>
+<pre>
+x = foo + bar;
+^first    ^last
+</pre>
+
+<p>To map from this representation to a character-based
+representation, the 'last' location needs to be adjusted to point to
+(or past) the end of that token with either
+<code>Lexer::MeasureTokenLength()</code> or
+<code>Preprocessor::getLocForEndOfToken()</code>. For the rare cases
+where character-level source ranges information is needed we use
+the <code>CharSourceRange</code> class.</p>
+
+
 <!-- ======================================================================= -->
 <h2 id="libdriver">The Driver Library</h2>
 <!-- ======================================================================= -->





More information about the cfe-commits mailing list