[cfe-dev] How to add custom include dir to the header search path?
Welson Sun
welson.sun at gmail.com
Tue Apr 9 16:06:13 PDT 2013
No, this doesn't work, at least with 3.1.
Search headerSearch or headerSearchOptions in this mailing list, there are
a lot of similar threads.
On Tue, Apr 9, 2013 at 10:43 AM, Robert Ankeney <rrankene at gmail.com> wrote:
> Something like:
> HeaderSearchOptions &headerSearchOptions =
> theCompInst->getHeaderSearchOpts();
> headerSearchOptions.AddPath("D:/test/include", clang::frontend::Angled,
> false, false, false);
>
> should do it.
>
>
>
>>
>> I'm writing a tools (do some static check) using clang lib . This is my
>> code:
>>
>> void main()
>> {
>> DiagnosticOptions diagnosticOptions;
>> TextDiagnosticPrinter *printer = new
>> TextDiagnosticPrinter(llvm::nulls(),
>> diagnosticOptions);
>> llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> diagIDs;
>> DiagnosticsEngine diagnostics(diagIDs, printer);
>> LangOptions langOpts;
>>
>> TargetOptions targetOpts;
>> targetOpts.Triple = llvm::sys::getDefaultTargetTriple();
>> TargetInfo *pti = TargetInfo::CreateTargetInfo(diagnostics,
>> targetOpts);
>> FileSystemOptions fsopts;
>> FileManager fileManager(fsopts);
>> SourceManager sourceManager(diagnostics, fileManager);
>>
>> HeaderSearch headerSearch(fileManager, diagnostics, langOpts, pti);
>>
>> CompilerInstance *theCompInst = new CompilerInstance();
>> theCompInst->setDiagnostics(&diagnostics);
>> Preprocessor *pp = new Preprocessor(diagnostics, langOpts,
>> pti,sourceManager, headerSearch, *theCompInst);
>>
>> const FileEntry *pFile = fileManager.getFile(file_name);
>> sourceManager.createMainFileID(pFile);
>>
>>
>> theCompInst->getDiagnosticClient().BeginSourceFile(theCompInst->getLangOpts(),pp);
>> theCompInst->setPreprocessor(pp);
>> theCompInst->setSourceManager(&sourceManager);
>> theCompInst->setTarget(pti);
>> theCompInst->setDiagnostics(&diagnostics);
>> SourceManager &sourceMgr = theCompInst->getSourceManager();
>> theCompInst->createASTContext();
>> Rewriter rewriter;
>> rewriter.setSourceMgr(sourceMgr,langOpts);
>>
>>
>> MyASTConsumer consumer(rewriter);
>> ParseAST(theCompInst->getPreprocessor(), &consumer,
>> theCompInst->getASTContext());
>> theCompInst->getDiagnosticClient().EndSourceFile();
>> }
>>
>> I want to check some C/C++ code using this tools. But *.h file and *.c
>> file
>> is not in the same filefold.
>>
>> Example:
>> test.c context:
>> #include "test.h"
>> .........
>>
>> test.c in D:\test\test.c
>> test.h in D:\test\include\test.h
>>
>> So I need to add "D:\test\include" to the header search path. How to do
>> that
>> in my code?
>> Thanks all!
>>
>>
>>
>> --
>> View this message in context:
>> http://clang-developers.42468.n3.nabble.com/How-to-add-custom-include-dir-to-the-header-search-path-tp4031389.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
>
>
--
Welson
Phone: (408) 418-8385
Email: welson.sun at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130409/d7ad3e85/attachment.html>
More information about the cfe-dev
mailing list