These branch targets will help clang diagnose jumps across inline MS asm blocks.
Details
Diff Detail
Event Timeline
I don't think we need this, LookupInlineAsmLabel should be able to track all the LabelDecl's that got created during inline asm parsing.
Well, LookupInlineAsmLabel would not be able to associate a label name with an MSAsmStmt, which we later on need to use in order to check whether the branch target is defined inside another MSAsmStmt on the clang side. Also, note that this patch provides two bits of information, the "labels defined" and the "branch targets". The branch targets cannot be deciphered from LookupInlineAsmLabel, given the fact that you can do things such as mov eax, LabelName that are not branches.
I was imagining having ClangAsmParserCallback track a list of defined and used LabelDecls. The 'Create' parameter basically means "this label was defined" and could be renamed to reflect that.
I guess the one thing that is completely lost is the branch information. You only know what uses there are, not if the use is a branch. Is that OK? It means we need to reject this code:
void g(); void *f() { __asm foo: nop g(); __asm mov eax, foo }
I guess I'm OK with that. :)
But ClangAsmParserCallback right now doesn't know whether the create vs use happens within the same asm block... And it is invoked before we even create the corresponding MSAsmStmt, so I'm not sure where it would record this information. Any pointers?
I guess the one thing that is completely lost is the branch information. You only know what uses there are, not if the use is a branch. Is that OK? It means we need to reject this code:
void g(); void *f() { __asm foo: nop g(); __asm mov eax, foo }I guess I'm OK with that. :)
That would be a bit unfortunate, since my current patch properly accepts that code. But I guess I don't feel very strongly.