diff options
author | Hans Wennborg <hans@hanshq.net> | 2013-08-09 00:32:23 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2013-08-09 00:32:23 +0000 |
commit | 0fd6207d3779b57566b7eb2a28e335d681549a33 (patch) | |
tree | a6732f1201adcabcf8c22a7776070fa35ce4a819 /clang/lib/Frontend/HeaderIncludeGen.cpp | |
parent | 91555bde88dd991b60f4bf467dae74c6ce4f7bfd (diff) | |
download | bcm5719-llvm-0fd6207d3779b57566b7eb2a28e335d681549a33.tar.gz bcm5719-llvm-0fd6207d3779b57566b7eb2a28e335d681549a33.zip |
clang-cl: Support /showIncludes
This option prints information about #included files to stderr. Clang could
already do it, this patch just teaches the existing code about the /showIncludes
style and adds the flag.
Differential Revision: http://llvm-reviews.chandlerc.com/D1333
llvm-svn: 188037
Diffstat (limited to 'clang/lib/Frontend/HeaderIncludeGen.cpp')
-rw-r--r-- | clang/lib/Frontend/HeaderIncludeGen.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/clang/lib/Frontend/HeaderIncludeGen.cpp b/clang/lib/Frontend/HeaderIncludeGen.cpp index 4d8a05cfbc1..237e5b1ac0c 100644 --- a/clang/lib/Frontend/HeaderIncludeGen.cpp +++ b/clang/lib/Frontend/HeaderIncludeGen.cpp @@ -24,15 +24,16 @@ class HeaderIncludesCallback : public PPCallbacks { bool OwnsOutputFile; bool ShowAllHeaders; bool ShowDepth; + bool MSStyle; public: HeaderIncludesCallback(const Preprocessor *PP, bool ShowAllHeaders_, raw_ostream *OutputFile_, bool OwnsOutputFile_, - bool ShowDepth_) + bool ShowDepth_, bool MSStyle_) : SM(PP->getSourceManager()), OutputFile(OutputFile_), CurrentIncludeDepth(0), HasProcessedPredefines(false), OwnsOutputFile(OwnsOutputFile_), ShowAllHeaders(ShowAllHeaders_), - ShowDepth(ShowDepth_) {} + ShowDepth(ShowDepth_), MSStyle(MSStyle_) {} ~HeaderIncludesCallback() { if (OwnsOutputFile) @@ -46,7 +47,8 @@ public: } void clang::AttachHeaderIncludeGen(Preprocessor &PP, bool ShowAllHeaders, - StringRef OutputPath, bool ShowDepth) { + StringRef OutputPath, bool ShowDepth, + bool MSStyle) { raw_ostream *OutputFile = &llvm::errs(); bool OwnsOutputFile = false; @@ -69,7 +71,7 @@ void clang::AttachHeaderIncludeGen(Preprocessor &PP, bool ShowAllHeaders, PP.addPPCallbacks(new HeaderIncludesCallback(&PP, ShowAllHeaders, OutputFile, OwnsOutputFile, - ShowDepth)); + ShowDepth, MSStyle)); } void HeaderIncludesCallback::FileChanged(SourceLocation Loc, @@ -109,14 +111,20 @@ void HeaderIncludesCallback::FileChanged(SourceLocation Loc, if (ShowHeader && Reason == PPCallbacks::EnterFile) { // Write to a temporary string to avoid unnecessary flushing on errs(). SmallString<512> Filename(UserLoc.getFilename()); - Lexer::Stringify(Filename); + if (!MSStyle) + Lexer::Stringify(Filename); SmallString<256> Msg; + if (MSStyle) + Msg += "Note: including file:"; + if (ShowDepth) { // The main source file is at depth 1, so skip one dot. for (unsigned i = 1; i != CurrentIncludeDepth; ++i) - Msg += '.'; - Msg += ' '; + Msg += MSStyle ? ' ' : '.'; + + if (!MSStyle) + Msg += ' '; } Msg += Filename; Msg += '\n'; |