[cfe-dev] How to get the Location of SystemFunction,I used the SourceLocation and miss some trouble

Sam Parker S.Parker3 at lboro.ac.uk
Sat May 24 08:43:24 PDT 2014


Hi,
I've always used the getLocStart method to insert text at the beginning of a stmt.

Cheers,
Sam

Sam Parker
Research Student
Electronic Systems Design Group
School of Electronic, Electrical and Systems Engineering
Loughborough University

----- Reply message -----
From: "flappybird" <kingsleynj at 163.com>
To: <cfe-dev at cs.uiuc.edu>
Subject: [cfe-dev]How to get the Location of SystemFunction,I used the SourceLocation and miss some trouble
Date: Sat, May 24, 2014 12:47

hello,I try to Insert some code before a function when it was called.for
example:
char *p,*q;
strcpy(p,q);
^                  ^
I want to insert some code at this two place,but I failed to handle it.
I used just like this:
VisitCallExpr(CallExpr *CE){
if(FunctionDecl *FD=CE->getDirectCallee()) 
{
...
SourceRange sr = FD->getSourceRange();
SourceLocation ST1 = sr.getBegin();
...
}
}

but I found it make no difference when I used  Rewrite.InsertText(ST1,
tempfc, true, true);
trying to insert some code into it.
would you please tell me what's wrong with it and show me how to some this
problem
thank you



--
View this message in context: http://clang-developers.42468.n3.nabble.com/How-to-get-the-Location-of-SystemFunction-I-used-the-SourceLocation-and-miss-some-trouble-tp4039650.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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140524/7885a9cd/attachment.html>


More information about the cfe-dev mailing list