[cfe-dev] multiple .C files in SourceManager

Argyrios Kyrtzidis akyrtzi at gmail.com
Thu Feb 21 13:20:09 PST 2013


On Feb 20, 2013, at 10:12 PM, Karthik Bhat <blitz.opensource at gmail.com> wrote:

> Hi Sean,
> Thanks for the reply. I'm sorry i didn't make my requirement clear in the last mail.
> 
> As per my understanding compiler Instance operates on one file at a time and hence at a time the Source Manager contains only the information about the current file being processed.
> 
> Given the command -
> 
> clang -cc1 test1.c test2.c
> 
> While processing test1.c Source manager will not have any information about test2.c. Is my understanding correct? 
> 
> Is it possible to provide Sourcemanager with information about test2.c as well while the current file being processed is test1.c?
> 
> 
> In my current requirement i'm trying to emit warnings in case we have a call from a function in test1.c to a function in test2.c which might result in some problems. Hence would require the Source manager to have information of test2.c as well while the current file being processed is test1.c
> 
> Thanks.

You probably need to manually take over parsing and not use a CompilerInstance (e.g. use clang::ParseAST() directly).
Then I think you will be able to use one SourceManager for all files. But you still need to use one Preprocessor per translation unit otherwise macros from one translation unit will pollute others.

> 
> 
> 
> 
> On Wed, Feb 20, 2013 at 11:23 PM, Sean Silva <silvas at purdue.edu> wrote:
> The SourceManager is meant to manage all the sources. Don't use one
> SourceManager per file.
> 
> -- Sean Silva
> 
> _______________________________________________
> 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/20130221/5f12da22/attachment.html>


More information about the cfe-dev mailing list