<div dir="ltr">Thanks a lot, Reid. This is very helpful.<div><br></div><div>Regards</div><div>-Thejaka Amila</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Sep 3, 2014 at 3:08 AM, Reid Kleckner <span dir="ltr"><<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div class="">On Tue, Sep 2, 2014 at 11:30 PM, Amila Jayasekara <span dir="ltr"><<a href="mailto:thejaka.amila@gmail.com" target="_blank">thejaka.amila@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Nikola,<div><br></div><div>Thanks a lot for the response.</div><div class="gmail_extra"><br><br><div class="gmail_quote">
<div>On Wed, Sep 3, 2014 at 1:56 AM, Nikola Smiljanic <span dir="ltr"><<a href="mailto:popizdeh@gmail.com" target="_blank">popizdeh@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">1. Sema is responsible for building the ast, after doing all the checks. Act methods are 'hooks' that Parser uses to call into Sema. Build methods are used to build the actual ast nodes.<div>
<br></div>
<div>2. Various declaration classes have methods that return QualType, see <a href="http://clang.llvm.org/docs/InternalsManual.html#the-qualtype-class" target="_blank">http://clang.llvm.org/docs/InternalsManual.html#the-qualtype-class</a>. So VarDecl has getType but FunctionDecl in addtion has getReturnType and getFunctionType, etc.</div>
</div></blockquote><div><br></div></div><div>I am actually looking for the class which contains all VarDecl's for a program. As an example, if I have a program as follows;</div><div><br></div><div>int a;</div><div>bool b;</div>
<div>...</div><div>...</div><div><br></div><div>I am assuming there is a some sort of a container in clang which keeps all declaration data.</div><div>Suppose the container is named as TypeEnvironment for the moment. Then I need to query type information about each declaration with code similar to following;</div>
<div><br></div><div>TypeEnvironment.get("a") </div><div>TypeEnvironment.get("b")</div><div><br></div><div>etc ...</div><div><br></div><div>So I am looking for the closest implementation in clang, which gives me the functionality of TypeEnvironment (in example above).</div>
</div></div></div></blockquote><div><br></div></div><div>Clang AST types are attached to the Decl involved. So you would find a's Decl and say something like ADecl->getType(), which is a QualType, which can be examined in many ways.</div>
<div><br></div><div>If you just want to do name lookup, the closest thing to what you are thinking of is a DeclContext. Lots of things like functions, namespaces, classes, unions, etc are DeclContexts, and the lookup is complicated. For example, you can find a type from a base class. You would use Sema::LookupQualifiedName to find what you want, probably. There can be many results of varying kind, and you would have to consider all cases.</div>
</div></div></div>
</blockquote></div><br></div>