[cfe-commits] r79941 - in /cfe/trunk: lib/Analysis/CFG.cpp test/SemaTemplate/fun-template-def.cpp

Chris Lattner clattner at apple.com
Mon Aug 24 23:14:43 PDT 2009


On Aug 24, 2009, at 5:41 PM, Douglas Gregor wrote:
On Aug 24, 2009, at 3:38 PM, Chris Lattner wrote:
>> On Aug 24, 2009, at 2:39 PM, Douglas Gregor wrote:
>>> Author: dgregor
>>> Date: Mon Aug 24 16:39:56 2009
>>> New Revision: 79941
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=79941&view=rev
>>> Log:
>>> Don't try to evaluate an expression that is type- or value- 
>>> dependent while building the CFG
>>
>> Does it really make sense to build a CFG of an uninstantiated  
>> template?
>
> It might. The control flow of a template doesn't really depend on  
> its template parameters, with two notable exceptions:
>
>  (1) A dependent function call might end up calling a noreturn  
> function in every instantiation.
>  (2) A value- or type-dependent expression used in a branch might  
> evaluate true (or false) in every instantiation.
>
> Maybe that's enough reason to turn off the flow-control diagnostics  
> for templates, but I will point out that Clang's flow-control  
> diagnostics managed to catch a missing "return" in an uninstantiated  
> template today, in real code :)

Ok point taken.  Here's another way to look at it: is it worthwhile  
(in terms of compile time) to check all uninstantiated templates?  It  
would be better to only do these "heavier" semantic checks on inline  
functions and templates that are actually used in a translation unit  
rather than in every translation unit that they are parsed in.  This  
applies equally well to C inline functions as it does to all the fun C+ 
+ stuff, it's just that C++ will suffer more if we don't do something  
like this.

Thoughts?

-Chris



More information about the cfe-commits mailing list