You might want to have a look at my CIrewriter.cpp example at <a href="https://github.com/loarabia/Clang-tutorial">https://github.com/loarabia/Clang-tutorial</a> which has some useful information including:<br><br>    // Note Stmt::getLocEnd() returns the source location prior to the<br>
    // token at the end of the line.  For instance, for:<br>    // var = 123;<br>    //      ^---- getLocEnd() points here.<br><br>    SourceLocation END = s->getLocEnd();<br><br>    // MeasureTokenLength gets us past the last token, and adding 1 gets<br>
    // us past the ';'.<br>    int offset = Lexer::MeasureTokenLength(END,<br>                                           ci->getSourceManager(),<br>                                           ci->getLangOpts()) + 1;<br>
<br>    SourceLocation END1 = END.getLocWithOffset(offset);<br>    Rewrite.InsertText(END1, "\n}", true, true);<br>  }<br><br>  // Also note getLocEnd() on a CompoundStmt points ahead of the '}'.<br>  // Use getLocEnd().getLocWithOffset(1) to point past it.<br>
<br>Robert Ankeney<br><br><div class="gmail_quote">On Mon, Feb 4, 2013 at 3:39 AM,  <span dir="ltr"><<a href="mailto:cfe-dev-request@cs.uiuc.edu" target="_blank">cfe-dev-request@cs.uiuc.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Send cfe-dev mailing list submissions to<br>
        <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
or, via email, send a message with subject or body 'help' to<br>
        <a href="mailto:cfe-dev-request@cs.uiuc.edu">cfe-dev-request@cs.uiuc.edu</a><br>
<br>
You can reach the person managing the list at<br>
        <a href="mailto:cfe-dev-owner@cs.uiuc.edu">cfe-dev-owner@cs.uiuc.edu</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of cfe-dev digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
   1. Re: c++11 and invalid opcode (Piotr Madali?ski)<br>
   2. Static Analyzer symbolic execution path (Arthur Yoo)<br>
   3. basic block traversal for conditions and loops (Rajendra)<br>
   4. Re: Stmt.getLocEnd() (Antoine Trouve)<br>
   5. Re: Stmt.getLocEnd() (James Dennett)<br>
   6. Error in Tutorial for building tools using LibTooling and<br>
      LibASTMatchers (Pedro Delgado Perez)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Mon, 04 Feb 2013 02:39:21 +0100<br>
From: Piotr Madali?ski <<a href="mailto:piotr@madtricks.pl">piotr@madtricks.pl</a>><br>
To: Sean Silva <<a href="mailto:silvas@purdue.edu">silvas@purdue.edu</a>><br>
Cc: Clang <<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a>><br>
Subject: Re: [cfe-dev] c++11 and invalid opcode<br>
Message-ID: <<a href="mailto:510F1149.4060306@madtricks.pl">510F1149.4060306@madtricks.pl</a>><br>
Content-Type: text/plain; charset=UTF-8; format=flowed<br>
<br>
On 04.02.2013 02:01, Sean Silva wrote:<br>
>> Your flip() function is causing undefined behaviour, as string::end()<br>
>> returns an iterator to the character *following* the last character of<br>
>> the string.  Dereferencing that iterator is not allowed, you can only<br>
>> compare it against other iterators.<br>
> Where exactly does it dereference the off-the-end iterator?<br>
> std::reverse takes a half-open range.<br>
><br>
> -- Sean Silva<br>
><br>
><br>
Right. I think, that the code is correct.<br>
The issue is probably some ABI-related problem on my machine.<br>
<br>
<br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Sun, 3 Feb 2013 00:25:56 +0800<br>
From: Arthur Yoo <<a href="mailto:phjy007@gmail.com">phjy007@gmail.com</a>><br>
To: <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
Subject: [cfe-dev] Static Analyzer symbolic execution path<br>
Message-ID:<br>
        <<a href="mailto:CAEsbxu1ofbcujEV5LZEX7ySwqdquAqfb%2B9%2BoCOs4c_SBdagePg@mail.gmail.com">CAEsbxu1ofbcujEV5LZEX7ySwqdquAqfb+9+oCOs4c_SBdagePg@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<br>
<br>
Hi all,<br>
<br>
Recently I am working on developing a checker of Clang Static Analyzer.<br>
Because Clang Static Analyzer has a powerful symbolic execution engine, I<br>
choose Clang Static Analyzer as the platform for my work. My Checker mainly<br>
does some analysis work for C source code files. The checker will make use<br>
of the program states during its analysis execution and it will generate a<br>
report for each analysis.<br>
<br>
In my understanding, symbolic execution(Clang static analyzer) will cover<br>
all possible paths. For example, here is an sample source code which will<br>
be analyzed by static analyzer:<br>
 1  void func(int arg) {<br>
 2    int v;<br>
 3     if(arg > 0)<br>
 4         v = arg + 1;<br>
 5     else<br>
 6         v = arg + 999;<br>
 7     int a, b;<br>
 8     a = 99;<br>
 9     b = a;<br>
10  }<br>
The symbolic execution path can be roughly represented as follow(based on<br>
ExplodedGraph):<br>
<a href="http://ww2.sinaimg.cn/large/a74ecc4cjw1e1fipmgpy5j.jpg" target="_blank">http://ww2.sinaimg.cn/large/a74ecc4cjw1e1fipmgpy5j.jpg</a><br>
And the execution sequence is 1-2-3-(1)-4-5. However, is there any possible<br>
means to change the execution sequence to be linear? That is to say, is<br>
there any possible means to change the execution sequence to be 1-2-(1)-4-5?<br>
Thanks for the help.<br>
<br>
------<br>
Best regards,<br>
Arthur Yoo<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://lists.cs.uiuc.edu/pipermail/cfe-dev/attachments/20130203/e9281502/attachment-0001.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/cfe-dev/attachments/20130203/e9281502/attachment-0001.html</a>><br>

<br>
------------------------------<br>
<br>
Message: 3<br>
Date: Mon, 04 Feb 2013 12:25:32 +0530<br>
From: Rajendra <<a href="mailto:rks@cse.iitb.ac.in">rks@cse.iitb.ac.in</a>><br>
To: <<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a>><br>
Subject: [cfe-dev] basic block traversal for conditions and loops<br>
Message-ID: <<a href="mailto:74c363f94ce5642c3f1fccb88185905f@cse.iitb.ac.in">74c363f94ce5642c3f1fccb88185905f@cse.iitb.ac.in</a>><br>
Content-Type: text/plain; charset=UTF-8; format=flowed<br>
<br>
Hello,<br>
<br>
I am working for static analysis of C programs and I have CFG generated<br>
from Clang.<br>
<br>
I want to know how to traverse basic blocks for if-else and while loop<br>
- a common method that will work for both given a CFG.<br>
<br>
Is there any piece of Clang code I can make use of? or any pointers?<br>
<br>
Thank you.<br>
<br>
- Rajendra<br>
<br>
<br>
------------------------------<br>
<br>
Message: 4<br>
Date: Mon, 4 Feb 2013 16:35:09 +0900<br>
From: Antoine Trouve <<a href="mailto:trouve@isit.or.jp">trouve@isit.or.jp</a>><br>
To: Jordan Rose <<a href="mailto:jordan_rose@apple.com">jordan_rose@apple.com</a>><br>
Cc: Antoine Trouve <<a href="mailto:trouve@isit.or.jp">trouve@isit.or.jp</a>>, clang-dev Developers<br>
        <<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a>><br>
Subject: Re: [cfe-dev] Stmt.getLocEnd()<br>
Message-ID: <<a href="mailto:EDAE486C-797E-4340-A469-328331C5C6B2@isit.or.jp">EDAE486C-797E-4340-A469-328331C5C6B2@isit.or.jp</a>><br>
Content-Type: text/plain; charset=iso-8859-1<br>
<br>
Le H.25/02/02 ? 2:28, Jordan Rose <<a href="mailto:jordan_rose@apple.com">jordan_rose@apple.com</a>> a ?crit :<br>
<br>
><br>
> On Feb 1, 2013, at 1:02 , Manuel Klimek <<a href="mailto:klimek@google.com">klimek@google.com</a>> wrote:<br>
><br>
>> On Fri, Feb 1, 2013 at 9:25 AM, Antoine Trouve <<a href="mailto:trouve@isit.or.jp">trouve@isit.or.jp</a>> wrote:<br>
>> Hi everybody,<br>
>><br>
>> I am now using LibTooling with the RefactoringTool to add some comments in some C codes.<br>
>><br>
>> I am now trying to add comments after a given statement (the body of a for to say the truth);<br>
>> in order to detect the location of the end of a statement I use "Stmt.getLocEnd()", but I seems that its output is often inaccurate.<br>
>><br>
>> Here are two examples, if I insert "/* HERE */" at the end location:<br>
>><br>
>>         for(i=0; i<N/2; i++) res +=mand(i,N/4/* HERE */);<br>
>>         for(i=0; i<mand(N,N); i++) res /* HERE */++;<br>
>><br>
>> I would expect the following output:<br>
>><br>
>>         for(i=0; i<N/2; i++) res +=mand(i,N/4);/* HERE */<br>
>>         for(i=0; i<mand(N,N); i++) res ++;/* HERE */<br>
>><br>
>> It looks like a bug. Am I right or did I miss something ?<br>
>><br>
>> I found a previous recent discussion about this matter (<a href="http://clang-developers.42468.n3.nabble.com/Statements-that-end-with-td4028311.html" target="_blank">http://clang-developers.42468.n3.nabble.com/Statements-that-end-with-td4028311.html</a>), but It looks like nothing has been done.<br>

>><br>
>> Yes, this is a known issue, and as far as I'm aware nothing has been done. We're usually working around this by looking for the next ';' token.<br>
>><br>
>> I guess it's the good old "patches welcome" answer - or wait until it becomes important enough for somebody else to solve.<br>
><br>
> The other issue here is that (by design) getLocEnd() doesn't actually return the SourceLocation just past the end of the statement, but the SourceLocation of the start of the last token in the statement. If you actually want the SourceLocation following the statement, you'll have to use Lexer::getLocForEndOfToken.<br>

><br>
> Jordan<br>
<br>
I tried using "Lexer::getLoxForEndOfToken()", but that still wouldn't give the desired behaviour.<br>
<br>
For instance, for<br>
<br>
         for(i=0; i<mand(N,N); i++) res /* HERE */++;<br>
<br>
It would now return the following location:<br>
<br>
         for(i=0; i<mand(N,N); i++) res +/* HERE */+;<br>
<br>
The token is only the first "+", not the whole "++".<br>
<br>
I used the quick-and-dirty trick of Manuel, searching for the next ";", and that works. Still I feel insecure about this solution.<br>
<br>
Any idea to follow Jordan's proposal ? (so that I would get the location after the "++" and not only the first "+")<br>
<br>
Regards,<br>
<br>
- Antoine<br>
<br>
<br>
------------------------------<br>
<br>
Message: 5<br>
Date: Mon, 4 Feb 2013 00:06:20 -0800<br>
From: James Dennett <<a href="mailto:james.dennett@gmail.com">james.dennett@gmail.com</a>><br>
To: Antoine Trouve <<a href="mailto:trouve@isit.or.jp">trouve@isit.or.jp</a>><br>
Cc: clang-dev Developers <<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a>><br>
Subject: Re: [cfe-dev] Stmt.getLocEnd()<br>
Message-ID:<br>
        <CAKNGpgrSCw228E=DSu9B9Lt5z1ar9M=<a href="mailto:2oJMaq1JevnCUrMMRNA@mail.gmail.com">2oJMaq1JevnCUrMMRNA@mail.gmail.com</a>><br>
Content-Type: text/plain; charset=ISO-8859-1<br>
<br>
On Sun, Feb 3, 2013 at 11:35 PM, Antoine Trouve <<a href="mailto:trouve@isit.or.jp">trouve@isit.or.jp</a>> wrote:<br>
> Le H.25/02/02 ? 2:28, Jordan Rose <<a href="mailto:jordan_rose@apple.com">jordan_rose@apple.com</a>> a ?crit :<br>
><br>
>><br>
>> On Feb 1, 2013, at 1:02 , Manuel Klimek <<a href="mailto:klimek@google.com">klimek@google.com</a>> wrote:<br>
>><br>
>>> On Fri, Feb 1, 2013 at 9:25 AM, Antoine Trouve <<a href="mailto:trouve@isit.or.jp">trouve@isit.or.jp</a>> wrote:<br>
>>> Hi everybody,<br>
>>><br>
>>> I am now using LibTooling with the RefactoringTool to add some comments in some C codes.<br>
>>><br>
>>> I am now trying to add comments after a given statement (the body of a for to say the truth);<br>
>>> in order to detect the location of the end of a statement I use "Stmt.getLocEnd()", but I seems that its output is often inaccurate.<br>
>>><br>
>>> Here are two examples, if I insert "/* HERE */" at the end location:<br>
>>><br>
>>>         for(i=0; i<N/2; i++) res +=mand(i,N/4/* HERE */);<br>
>>>         for(i=0; i<mand(N,N); i++) res /* HERE */++;<br>
>>><br>
>>> I would expect the following output:<br>
>>><br>
>>>         for(i=0; i<N/2; i++) res +=mand(i,N/4);/* HERE */<br>
>>>         for(i=0; i<mand(N,N); i++) res ++;/* HERE */<br>
>>><br>
>>> It looks like a bug. Am I right or did I miss something ?<br>
>>><br>
>>> I found a previous recent discussion about this matter (<a href="http://clang-developers.42468.n3.nabble.com/Statements-that-end-with-td4028311.html" target="_blank">http://clang-developers.42468.n3.nabble.com/Statements-that-end-with-td4028311.html</a>), but It looks like nothing has been done.<br>

>>><br>
>>> Yes, this is a known issue, and as far as I'm aware nothing has been done. We're usually working around this by looking for the next ';' token.<br>
>>><br>
>>> I guess it's the good old "patches welcome" answer - or wait until it becomes important enough for somebody else to solve.<br>
>><br>
>> The other issue here is that (by design) getLocEnd() doesn't actually return the SourceLocation just past the end of the statement, but the SourceLocation of the start of the last token in the statement. If you actually want the SourceLocation following the statement, you'll have to use Lexer::getLocForEndOfToken.<br>

>><br>
>> Jordan<br>
><br>
> I tried using "Lexer::getLoxForEndOfToken()", but that still wouldn't give the desired behaviour.<br>
><br>
> For instance, for<br>
><br>
>          for(i=0; i<mand(N,N); i++) res /* HERE */++;<br>
><br>
> It would now return the following location:<br>
><br>
>          for(i=0; i<mand(N,N); i++) res +/* HERE */+;<br>
><br>
> The token is only the first "+", not the whole "++".<br>
<br>
That sounds wrong; the token is definitely "++", not "+".  What code<br>
are you using to find that it's a single "+"?<br>
<br>
-- James<br>
<br>
<br>
<br>
------------------------------<br>
<br>
Message: 6<br>
Date: Mon, 4 Feb 2013 12:39:04 +0100 (CET)<br>
From: Pedro Delgado Perez <<a href="mailto:pedro.delgadoperez@mail.uca.es">pedro.delgadoperez@mail.uca.es</a>><br>
To: <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
Subject: [cfe-dev] Error in Tutorial for building tools using<br>
        LibTooling and LibASTMatchers<br>
Message-ID: <1922734252.3843.1359977944608.JavaMail.tomcat@draco><br>
Content-Type: text/plain; charset="us-ascii"<br>
<br>
<br>
Hello everyone,<br>
<br>
I've been following the Tutorial for building tools using LibTooling and LibASTMatchers:<br>
<br>
<a href="http://clang.llvm.org/docs/LibASTMatchersTutorial.html" target="_blank">http://clang.llvm.org/docs/LibASTMatchersTutorial.html</a> [ <a href="http://clang.llvm.org/docs/LibASTMatchersTutorial.html" target="_blank">http://clang.llvm.org/docs/LibASTMatchersTutorial.html</a> ]<br>

<br>
I didn't accomplish the Step 0 as I had followed the "getting started guide" before to get llvm and clang. Then, everything was right until I reached to the instruction:<br>
<br>
cmake -G Ninja ../llvm -DLLVM_BUILD_TESTS=ON<br>
<br>
Then, I got the next errors:<br>
<br>
> -- The C compiler identification is GNU 4.6.3<br>
> -- Check for working C compiler using: Ninja<br>
> -- Check for working C compiler using: Ninja -- works<br>
> -- Detecting C compiler ABI info<br>
> -- Detecting C compiler ABI info - done<br>
> -- The CXX compiler identification is GNU 4.6.3<br>
> -- Check for working CXX compiler using: Ninja<br>
> -- Check for working CXX compiler using: Ninja -- works<br>
> -- Detecting CXX compiler ABI info<br>
> -- Detecting CXX compiler ABI info - done<br>
> CMake Error at CMakeLists.txt:23 (include):<br>
>  include could not find load file:<br>
><br>
>    VersionFromVCS<br>
><br>
><br>
> CMake Error at CMakeLists.txt:153 (include):<br>
>  include could not find load file:<br>
><br>
>    AddLLVMDefinitions<br>
><br>
><br>
> CMake Error at CMakeLists.txt:239 (include):<br>
>  include could not find load file:<br>
><br>
>    config-ix<br>
><br>
><br>
> CMake Error at CMakeLists.txt:247 (include):<br>
>  include could not find load file:<br>
><br>
>    HandleLLVMOptions<br>
><br>
><br>
> -- Found PythonInterp: /usr/bin/python (found version "2.7.3")<br>
> -- Constructing LLVMBuild project information<br>
> CMake Error at CMakeLists.txt:306 (message):<br>
>  Unexpected failure executing llvm-build: Usage: llvm-build [options]<br>
><br>
><br>
><br>
>  llvm-build: error: invalid native target: '' (not in project)<br>
><br>
><br>
> -- Configuring incomplete, errors occurred!<br>
><br>
What's happening?<br>
<br>
By the way, the directory would be ../../llvm, wouldn't it? I'm in /usr/llvm/build and when I write ../llvm it says: "The source directory /usr/llvm/llvm does not exist"<br>
<br>
Thanks in advance,<br>
<br>
Pedro.<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://lists.cs.uiuc.edu/pipermail/cfe-dev/attachments/20130204/3bfb72a6/attachment.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/cfe-dev/attachments/20130204/3bfb72a6/attachment.html</a>><br>

<br>
------------------------------<br>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br>
<br>
End of cfe-dev Digest, Vol 68, Issue 10<br>
***************************************<br>
</blockquote></div><br>