[cfe-dev] patch: keep llvm module consistent during compilationpatch: keep llvm module consistent during compilation

Chris Lattner clattner at apple.com
Mon Jul 21 15:23:33 PDT 2008


On Jul 18, 2008, at 10:40 AM, Daniel Dunbar wrote:
> The attached patch creates dummy bodies for functions with internal  
> linkage
> when they are created and replaces them when the definition is  
> compiled. This
> helps ensure that the module is in a consistent state after  
> processing each top
> level declaration and prevents crashes in the verifier on malformed  
> inputs. See
> test case.

This is a somewhat interesting issue.  As you know, I strongly believe  
in having clang keep its module consistent where possible.  There are  
two possible solutions to this issue: either give static forward decls  
a body or not mark them internal.

Of the two, I prefer the later because it doesn't require creating  
blocks and instructions only to throw them away later.  What do you  
think?

> This should probably be documented at another level than just a code  
> comment
> but I'm not sure where...

Yeah, clang as a whole is not well documented from the high-level  
perspective.  We have an internals document but it is pretty thin.

> Note that this introduces a problem that modules which declare  
> static functions
> but do not define them will compile (and link!) but this is a bug in  
> sema. Maybe
> we should still be tracking them though to make sure none slip  
> through to the
> outside. This requires CG having some way of knowing when the module  
> is done.

I think we should reject this in sema.

 > p.s. Comments appreciated on a simpler way to write the DG test I  
want (checking

Does it work to use "-emit-llvm -verify" and slap an "expected-error"  
note on the line that an error is expected?

-Chris




More information about the cfe-dev mailing list