[llvm-dev] cross-checking external declarations / debug info for declarations

Vedant Kumar via llvm-dev llvm-dev at lists.llvm.org
Thu Dec 8 17:50:39 PST 2016


Have you considered creating a clang-based tool?

I'd approach this by creating a RecursiveASTVisitor, overriding VisitFuncDecl,
and dumping out the return / param types. You can mark extern decls in some
way, sort the output, and check for inconsistencies.

One advantage over looking at IR is that you don't have to use the extern'd
decl in a TU to have it show up.

vedant

> On Dec 8, 2016, at 7:43 AM, David Callahan via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> I am interested in putting together a tool which can verify that an external declaration conforms with the actual definition.
> 
> A.c:
> extern int32_t foo();
> Int bar() { return foo(); }
> 
> B.c:
> int64_t foo() {  … } 
> 
> I had thought that I could use the debug information but the debug information in A.o does not include the type of the declaration “foo”, just the type of bar.
> 
> Is there a way to include declarations as well as definitions such as a above? It appears there is a notion of “retained” types, perhaps I add a flag to retain declarations? 
> 
> Perhaps a different approach?
> 
> Thanks
> —david
> 
> 
> 
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



More information about the llvm-dev mailing list