Skip to content

Commit b721b68

Browse files
committed
Add more comments for Lexer::makeFileCharRange.
llvm-svn: 156188
1 parent 93a586f commit b721b68

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

clang/include/clang/Lex/Lexer.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,28 @@ class Lexer : public PreprocessorLexer {
335335
///
336336
/// Returns a null range if a part of the range resides inside a macro
337337
/// expansion or the range does not reside on the same FileID.
338+
///
339+
/// This function is trying to deal with macros and return a range based on
340+
/// file locations. The cases where it can successfully handle macros are:
341+
///
342+
/// -begin or end range lies at the start or end of a macro expansion, in
343+
/// which case the location will be set to the expansion point, e.g:
344+
/// #define M 1 2
345+
/// a M
346+
/// If you have a range [a, 2] (where 2 came from the macro), the function
347+
/// will return a range for "a M"
348+
/// if you have range [a, 1], the function will fail because the range
349+
/// overlaps with only a part of the macro
350+
///
351+
/// -The macro is a function macro and the range can be mapped to the macro
352+
/// arguments, e.g:
353+
/// #define M 1 2
354+
/// #define FM(x) x
355+
/// FM(a b M)
356+
/// if you have range [b, 2], the function will return the file range "b M"
357+
/// inside the macro arguments.
358+
/// if you have range [a, 2], the function will return the file range
359+
/// "FM(a b M)" since the range includes all of the macro expansion.
338360
static CharSourceRange makeFileCharRange(CharSourceRange Range,
339361
const SourceManager &SM,
340362
const LangOptions &LangOpts);

0 commit comments

Comments
 (0)