Looking up another function in code generation


During llvm generation of a function I would like to know, if another function (known to me by name) is defined. So I want to find if a FuncDecl by name exists.

There is probably a really easy way to do it, but I don’t know how.


P.S. This is my state of knowledge:

From what I gathered, I would probably want to find a „DeclContext“ to make a „lookup“. But what I have is „CodeGenFunction" and not much else and I am not subclassing, nor do I really want to.

CodeGenFunction has

  /// CurCodeDecl - This is the inner-most code context, which includes blocks.
  const Decl *CurCodeDecl;

which would then allow me „getDeclContext“. But CurCodeDecl is private :-/

Driving back from work, I figured that my life would probably be easier, if made that check earlier and not during code generation.