[cfe-commits] r59502 - in /cfe/trunk: Driver/ include/clang/Analysis/ include/clang/Analysis/PathSensitive/ include/clang/Basic/ include/clang/Driver/ lib/Analysis/ lib/Basic/ lib/CodeGen/ lib/Driver/ lib/Lex/ lib/Parse/ lib/Sema/
Chris Lattner
sabre at nondot.org
Thu Nov 20 22:50:01 PST 2008
On Nov 20, 2008, at 5:30 AM, Douglas Gregor wrote:
>> This is the source line:
>> Lexer *L; char Res;
>> ...
>> L->Diag(CP-2, diag::trigraph_converted) << std::string()+Res;
>
> The basic problem is that Diag() is returning a temporary, but a non-
> const (lvalue) reference can't bind to a temporary. I suggest making
> the first parameter to these operator<<'s either a const
> DiagnosticInfo& or a DiagnosticInfo. (The former will require a
> bunch of other member functions to be const, but so what?)
Right. It isn't logically const, but that will definitely fix it.
I'll do it.
>
>> This is a good point where we can step back and look at the amazing
>> awfulness of this diagnostic. It's 'pretty' printing out the
>> expression in question, in a horribly mangled form. Then it dumps
>> out a candidate list, but manages to not tell me the types that it
>> actually *has* on the LHS/RHS of the <<.
>
> We should use this kind of thing as a test case for our diagnostics,
> to see how clear we can make them.
I filed this PR with a testcase:
http://llvm.org/bugs/show_bug.cgi?id=3104
Interestingly enough, if you run clang on the .ii file, we get these
diagnostics to start with:
Debug/Lexer.ii:2073:1: error: expected unqualified-id
template <typename T> struct SerializeTrait;
^
Debug/Lexer.ii:2228:12: error: incompatible type returning 'class
SourceLocation', expected 'class SourceLocation'
return X;
^
Debug/Lexer.ii:2209:12: error: incompatible type returning 'class
SourceLocation', expected 'class SourceLocation'
return getFileLoc(FileID, Offset);
^~~~~~~~~~~~~~~~~~~~~~~~~~
Debug/Lexer.ii:2164:12: error: incompatible type returning 'class
SourceLocation', expected 'class SourceLocation'
return L;
^
Debug/Lexer.ii:2144:12: error: incompatible type returning 'class
SourceLocation', expected 'class SourceLocation'
return L;
^
Debug/Lexer.ii:2239:14: error: no member named 'getRawEncoding'
return LHS.getRawEncoding() == RHS.getRawEncoding();
~~~ ^
Debug/Lexer.ii:2261:35: error: no member named 'isValid'
bool isValid() const { return B.isValid() && E.isValid(); }
~ ^
Debug/Lexer.ii:2251:20: error: class constructors are not supported yet
SourceRange(): B(SourceLocation()), E(SourceLocation()) {}
^
Debug/Lexer.ii:2251:41: error: class constructors are not supported yet
SourceRange(): B(SourceLocation()), E(SourceLocation()) {}
^
Debug/Lexer.ii:2294:24: error: functions that differ only in their
return type cannot be overloaded
const SourceManager& getManager() const {
^
Debug/Lexer.ii:2289:18: error: previous declaration is here
SourceManager& getManager() {
^
...
The first issue is obvious (no templates). The new few look strange
though and are probably easy to fix. The next couple are about
methods not implemented. The 'not implemented' ones are very
cute :). It looks like overloading + const methods isn't wired up yet.
It's pretty impressive how much C++ is starting to parse now!
-Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20081120/5fee1868/attachment.html>
More information about the cfe-commits
mailing list