[cfe-dev] Semantic Analysis in Clang

Mohammad Adil madil90 at gmail.com
Fri Jan 25 04:13:11 PST 2013


Thanks for the reply. Well, here's the detailed problem. Once all the
syntax checking has been done, the next step before generating IR is to do
semantic analysis and type checking. Let us say that I encounter a code
like this:

string b;
vector<T> a;
cout<<b;
cout<<a;

      How does clang figure out that the 3rd statement is valid because an
operator for string exists, while the 4rth statement is not valid. More
specifically, I want to know how clang searches through all the operators
(or functions). I have to use this functionality. Does the clang api allow
me to do this easily or will I have to replicate this functionality?

Regards,
Adil





On Fri, Jan 25, 2013 at 4:35 PM, Manuel Klimek <klimek at google.com> wrote:

> On Thu, Jan 24, 2013 at 12:49 PM, madil90 <madil90 at gmail.com> wrote:
>
>> Hi,
>>    I am looking to perform some semantic analysis in clang. More
>> specifically, I want to know whether a function exists for a certain type.
>> The function is global. e.g.
>>
>> String toString(A a);
>>
>>     I want to differentiate that this function exists for type A and not
>> for
>> type B. I have built an AST and am parsing it. How can I achieve this?
>> (Whenever I encounter a type)
>>
>
> I'd loop over all declarations of toString and see which type they take...
> Perhaps I'm misunderstanding your problem though :)
>
> Cheers,
> /Manuel
>
>
>> Regards,
>> Adil
>>
>>
>>
>> --
>> View this message in context:
>> http://clang-developers.42468.n3.nabble.com/Semantic-Analysis-in-Clang-tp4030012.html
>> Sent from the Clang Developers mailing list archive at Nabble.com.
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>
>


-- 
Mohammad Adil
LUMS SSE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130125/114fe3e1/attachment.html>


More information about the cfe-dev mailing list