<html>
<head></head>
<body>
<p>Hi again,</p>
<p>Please, I need some help with the preprocessor directives. I will describe my situation.<br/>
I have a directive in my file:</p>
<p>#define MY_DIRECTIVE( param ) { ... }</p>
<p>Then, I invoke the directive within a method:</p>
<p>void MyClass::Method() <br />{ <br /> ...<br /> MY_DIRECTIVE (param1);<br/>
...<br />}</p>
<p>My goal is to perform a change in the param passed, for instance, changing param1 by param2. I can make the modification with replaceText without any problem; however, it produces a "Stack dump" when I get the content with:</p>
<p>const RewriteBuffer *RewriteBuf = Rewrite.getRewriteBufferFor(file_id);</p>
<p>What is the problem? How can I handle this? I'm really lost with the expansions...</p>
<br/>
<blockquote class="replyBlock" style="border-left: 2px solid #000083; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><p>Hi,</p>
<p>Yesterday I tested my tool with a progam containing preprocessor directives. It was the first time I had this possibility into account and I had an stack dump when triying to obtain the file:</p>
<p>FullSourceLoc FullLocation = Context->getFullLoc(sourceLoc);<br />... <br />file = Context->getSourceManager().getFileEntryForID(FullLocation.getFileID())->getName();</p>
<p>Then, I added:</p>
<p>if(Context->getSourceManager().getSLocEntry(FullLocation.getFileID()).isExpansion()){<br /> FullLocation = FullLocation.getExpansionLoc();<br /> file= Context->getSourceManager()<br /> .getFileEntryForID(FullLocation.getFileID())->getName();<br />}<br />else{<br />...<br />}</p>
<p>And the result seemed ok. But when I tried to obtain again the file with:</p>
<p>Context->getSourceManager().getFileEntryForID(FullLocation.getFileID());</p>
<p>I had another stack dump. How do you handle these directives? There are so many methods... that I'm not able to find a solution because I cannot understand very well whay is an expansion, an SEntryLoc...</p>
<p>My intention is to make a change in the directive. For instance, in this directive:<br />#define delete( a ) { <br /> a.release(); <br />}<br />when the calling to the method release is found, my tool should include an argument in the method. </p>
<p>A doubt: when I make that change, it affects to every inkovation to the directive, isn't it? But, is there a way that the change only affects to a single directive invokation?</p>
<p>Thanks in advance,</p>
<p>Pedro.</p>
</blockquote>
</body>
</html>