[LLVMbugs] [Bug 8329] New: getDefaultArgRange() returns empty SourceRange
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Oct 7 08:19:49 PDT 2010
http://llvm.org/bugs/show_bug.cgi?id=8329
Summary: getDefaultArgRange() returns empty SourceRange
Product: clang
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: bugzilla-clang at sogetthis.com
CC: llvmbugs at cs.uiuc.edu
When getDefaultArgRange() is called for any ParmVarDecl the resulting
SourceRange's beginning and end are equal. Both refer to the start of the
actual default argument. To get the real source range one has to adapt the end
of the range via Lexer::MeasureTokenLength().
Nevertheless the documentation for getDefaultArgRange() claims it will
"Retrieve the source range that covers the entire default argument." which is
IMHO outright wrong. So either the method needs to return the correct source
range or the comment and probably the method name need to be changed according
to what it actually does, e.g. getDefaultSourceLocation().
example
-------
void bluh(const ParmVarDecl& p, const SourceManager& sm) {
if(p.hasDefaultArg()) {
clang::SourceRange range = p.getDefaultArgRange();
range.getBegin().print(llvm::errs(), sm);
llvm::errs() << " - ";
range.getEnd().print(llvm::errs(), sm);
llvm::errs() << "'\n";
}
}
when wrapped and executed for this code
$ cat test.cpp
void blah(int a = 1);
prints
test.cpp:1:22 - test.cpp:1:22
expected output
test.cpp:1:22 - test.cpp:1:23
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list