diff options
author | dim <dim@FreeBSD.org> | 2011-05-02 19:39:53 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2011-05-02 19:39:53 +0000 |
commit | 110eaaceddcec790f7e6a5e3bf1261c9aa1e73ab (patch) | |
tree | 64a10f4c4154739d4a8191d7e1b52ce497f4ebd6 /lib/Frontend/HeaderIncludeGen.cpp | |
parent | a0fb00f9837bd0d2e5948f16f6a6b82a7a628f51 (diff) | |
download | FreeBSD-src-110eaaceddcec790f7e6a5e3bf1261c9aa1e73ab.zip FreeBSD-src-110eaaceddcec790f7e6a5e3bf1261c9aa1e73ab.tar.gz |
Vendor import of clang trunk r130700:
http://llvm.org/svn/llvm-project/cfe/trunk@130700
Diffstat (limited to 'lib/Frontend/HeaderIncludeGen.cpp')
-rw-r--r-- | lib/Frontend/HeaderIncludeGen.cpp | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/lib/Frontend/HeaderIncludeGen.cpp b/lib/Frontend/HeaderIncludeGen.cpp index 45ff1d2..51dec96 100644 --- a/lib/Frontend/HeaderIncludeGen.cpp +++ b/lib/Frontend/HeaderIncludeGen.cpp @@ -22,13 +22,16 @@ class HeaderIncludesCallback : public PPCallbacks { bool HasProcessedPredefines; bool OwnsOutputFile; bool ShowAllHeaders; + bool ShowDepth; public: HeaderIncludesCallback(const Preprocessor *PP, bool ShowAllHeaders_, - llvm::raw_ostream *OutputFile_, bool OwnsOutputFile_) + llvm::raw_ostream *OutputFile_, bool OwnsOutputFile_, + bool ShowDepth_) : SM(PP->getSourceManager()), OutputFile(OutputFile_), CurrentIncludeDepth(0), HasProcessedPredefines(false), - OwnsOutputFile(OwnsOutputFile_), ShowAllHeaders(ShowAllHeaders_) {} + OwnsOutputFile(OwnsOutputFile_), ShowAllHeaders(ShowAllHeaders_), + ShowDepth(ShowDepth_) {} ~HeaderIncludesCallback() { if (OwnsOutputFile) @@ -41,7 +44,7 @@ public: } void clang::AttachHeaderIncludeGen(Preprocessor &PP, bool ShowAllHeaders, - llvm::StringRef OutputPath) { + llvm::StringRef OutputPath, bool ShowDepth) { llvm::raw_ostream *OutputFile = &llvm::errs(); bool OwnsOutputFile = false; @@ -63,7 +66,8 @@ void clang::AttachHeaderIncludeGen(Preprocessor &PP, bool ShowAllHeaders, } PP.addPPCallbacks(new HeaderIncludesCallback(&PP, ShowAllHeaders, - OutputFile, OwnsOutputFile)); + OutputFile, OwnsOutputFile, + ShowDepth)); } void HeaderIncludesCallback::FileChanged(SourceLocation Loc, @@ -78,15 +82,18 @@ void HeaderIncludesCallback::FileChanged(SourceLocation Loc, // Adjust the current include depth. if (Reason == PPCallbacks::EnterFile) { ++CurrentIncludeDepth; - } else { + } else if (Reason == PPCallbacks::ExitFile) { if (CurrentIncludeDepth) --CurrentIncludeDepth; // We track when we are done with the predefines by watching for the first - // place where we drop back to a nesting depth of 0. - if (CurrentIncludeDepth == 0 && !HasProcessedPredefines) + // place where we drop back to a nesting depth of 1. + if (CurrentIncludeDepth == 1 && !HasProcessedPredefines) HasProcessedPredefines = true; - } + + return; + } else + return; // Show the header if we are (a) past the predefines, or (b) showing all // headers and in the predefines at a depth past the initial file and command @@ -102,9 +109,12 @@ void HeaderIncludesCallback::FileChanged(SourceLocation Loc, Lexer::Stringify(Filename); llvm::SmallString<256> Msg; - for (unsigned i = 0; i != CurrentIncludeDepth; ++i) - Msg += '.'; - Msg += ' '; + if (ShowDepth) { + // The main source file is at depth 1, so skip one dot. + for (unsigned i = 1; i != CurrentIncludeDepth; ++i) + Msg += '.'; + Msg += ' '; + } Msg += Filename; Msg += '\n'; |