Hi all,<div><br></div><div>I'm attempting to build an external tool on top of Clang which is approximately (but not exactly) a C++ interpreter. Unfortunately, many of the terms used in Clang are quite generic and not searchable- seems like every compiler in the world ever made uses VarDecl as a type name, and I've had little luck finding documented examples of the C++ API. On top of that, the (not exactly) parts are causing me quite some headache. To begin with, I've been looking at how I'd interpret a simple Hello World program. But I've been a little stumped by some of the Sema's functionality, and have a few questions about how it can be used.</div>
<div><br></div><div>Particularly, there is a function <a href="http://clang.llvm.org/doxygen/classclang_1_1Sema.html#ac66198dbf75b2245d0de5dab5416478d">ArgumentDependentLookup</a> which I need to use. But it takes expressions as arguments, rather than types? I thought that the C++ Standard defined ADL in terms of the argument types. More specifically,</div>
<div><br></div><div>How do I convert a VarDecl to an Expr* so that it can be passed to this function? Logically, I want to pass this object, not it's initializer, and the documentation list only appears to allow me to convert the initializer to an Expr*.</div>
<div><br></div><div>More generally, I'm talking about the "approximately (but not exactly) a C++ interpreter", and we're talking about arguments which do not originate from C++ source code and do not have a Clang Expr* to be used, and possibly, there is no C++ equivalent expression that could ever exist- although there is a C++-equivalent argument type. How could I perform ADL for operations for which there is no C++ expression? </div>
<div><br></div><div>I'm also facing fun when describing external types to Clang. For example, a RecordType can only be constructed from a RecordDecl, even if I inherited from RecordType, but no RecordDecl exists, because the description of this type did not come from a C++ file parsed by Clang. It was created externally. Even if I created a RecordDecl, it presents no methods to insert data about the type. This isn't just POD types, but special members, overloaded operators, and the whole shaboodle. In addition, I'm talking about functions, variables, namespaces, and the whole shaboodle. How can I use Clang's API to inform it of semantic objects that did not originate from a file parsed by Clang?</div>
<div><br></div><div>I've looked at <a href="http://clang.llvm.org/doxygen/classclang_1_1Sema.html#a6a7a57d213e7d5bf8d5cd44cfee83450">LookupOverloadedOperatorName</a>, but apparently the only valid enum is OO_None. I don't think that operator<< is None. How is it possible to use this function to look up an operator?</div>
<div><br></div><div>Once the function has been looked up, I'm going to be needing to convert the function to an LLVM representation, like llvm::Function*, so that I can generate code which calls into these functions through LLVM. For complex objects, I can read up on the ABI later, but for now, I wanted to focus on simple objects. So far, I figured that once I look up the name, I can use the MangleContext to mangle it, and then request the llvm::Function* from the llvm::Module based on the mangled name. Then I can generate LLVM code, link to the library and done. But where can I obtain the llvm::Module* from?</div>
<div><br></div><div>Thanks for any assistance.</div>