[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/

Douglas Gregor dgregor at apple.com
Tue Nov 18 11:47:30 PST 2008


On Nov 18, 2008, at 2:01 PM, Chris Lattner wrote:
> On Nov 18, 2008, at 8:13 AM, Douglas Gregor wrote:
>>
>> Is there an easy way to determine whether this diagnostic has been
>> suppressed, such as a method
>>
>> 	bool isSuppressed() const;
>
> Sure, we have stuff like this:
>
>  if (Diags.getDiagnosticLevel(DiagID) != Diagnostic::Ignored)
>    ...

Cool.

>> so, then the operator<<'s for DiagnosticInfo could first check
>> isSuppressed(), and abort early if the diagnostic is suppressed. That
>> way, we never pay for formatting strings (e.g., for a type name or
>> expression) or copying them (see my comment below).
>
> This commit was just one step along the way.  Currently diags still  
> traffic in std::strings.  I'd like to change DiagnosticInfo to use  
> an array of unions of "stuff", some of which may be strings, some  
> may be types, some may be integers etc.  If the diagnostic is never  
> printed, the formatting would just never happen.

I think that we can get much further if diags just have an array of  
std::strings (not pointers to strings), and the behavior of operator<<  
for types, expressions, declarations, etc. is just to create a string  
on-the-fly. It's not the final version---which would use the array of  
unions of "stuff"---but it'll get us further than what we have now. At  
the very least, it'll let us provide overloaded operator<<'s for  
QualType so we can start converting Diags away from explicitly calling  
QualType::getAsString().

>> and an IDE client would
>> want to treat it as one error (perhaps with some interactive
>> exploration of the candidate functions). There's a lot of info we
>> could put into that DiagnosticInfo object, but it's tougher if we
>> can't name it :)
>
> One way to handle this is to introduce a new diag kind,  
> "CONTINUATION" or something like that.  The IDE would just treat a  
> CONTINUATION diag as part of the previous one if it wanted to.

Yup, that's certainly possible.

	- Doug



More information about the cfe-commits mailing list