summaryrefslogtreecommitdiff
path: root/lib/Frontend/HeaderIncludeGen.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2016-03-13 02:44:13 +0000
committerNico Weber <nicolasweber@gmx.de>2016-03-13 02:44:13 +0000
commitfdde4e46019e20bc540106b117c58740ef0ffede (patch)
treef084f2f275f4451751344b7c366a3bab76f0567c /lib/Frontend/HeaderIncludeGen.cpp
parentd59a142ef50bf041797143db71d2d4777fd32d27 (diff)
downloadclang-fdde4e46019e20bc540106b117c58740ef0ffede.tar.gz
clang-cl: Add /Yc argument to /showIncludes output.
To make this work, delay printing of ExtraDeps in HeaderIncludesCallback a bit, so that it happens after CompilerInstance::InitializeSourceManager() has run. General /FI arguments are still missing from /showIncludes output, this still needs to be fixed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263352 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/HeaderIncludeGen.cpp')
-rw-r--r--lib/Frontend/HeaderIncludeGen.cpp44
1 files changed, 24 insertions, 20 deletions
diff --git a/lib/Frontend/HeaderIncludeGen.cpp b/lib/Frontend/HeaderIncludeGen.cpp
index 0bc1169ba0..bb053c6e80 100644
--- a/lib/Frontend/HeaderIncludeGen.cpp
+++ b/lib/Frontend/HeaderIncludeGen.cpp
@@ -19,21 +19,25 @@ namespace {
class HeaderIncludesCallback : public PPCallbacks {
SourceManager &SM;
raw_ostream *OutputFile;
+ const std::vector<std::string> &ExtraHeaders;
unsigned CurrentIncludeDepth;
bool HasProcessedPredefines;
bool OwnsOutputFile;
bool ShowAllHeaders;
bool ShowDepth;
bool MSStyle;
+ bool PrintedExtraHeaders;
public:
HeaderIncludesCallback(const Preprocessor *PP, bool ShowAllHeaders_,
- raw_ostream *OutputFile_, bool OwnsOutputFile_,
- bool ShowDepth_, bool MSStyle_)
- : SM(PP->getSourceManager()), OutputFile(OutputFile_),
- CurrentIncludeDepth(0), HasProcessedPredefines(false),
- OwnsOutputFile(OwnsOutputFile_), ShowAllHeaders(ShowAllHeaders_),
- ShowDepth(ShowDepth_), MSStyle(MSStyle_) {}
+ raw_ostream *OutputFile_,
+ const std::vector<std::string> &ExtraHeaders,
+ bool OwnsOutputFile_, bool ShowDepth_, bool MSStyle_)
+ : SM(PP->getSourceManager()), OutputFile(OutputFile_),
+ ExtraHeaders(ExtraHeaders), CurrentIncludeDepth(0),
+ HasProcessedPredefines(false), OwnsOutputFile(OwnsOutputFile_),
+ ShowAllHeaders(ShowAllHeaders_), ShowDepth(ShowDepth_),
+ MSStyle(MSStyle_), PrintedExtraHeaders(false) {}
~HeaderIncludesCallback() override {
if (OwnsOutputFile)
@@ -97,26 +101,26 @@ void clang::AttachHeaderIncludeGen(Preprocessor &PP,
}
}
- // Print header info for extra headers, pretending they were discovered
- // by the regular preprocessor. The primary use case is to support
- // proper generation of Make / Ninja file dependencies for implicit includes,
- // such as sanitizer blacklists. It's only important for cl.exe
- // compatibility, the GNU way to generate rules is -M / -MM / -MD / -MMD.
- for (auto Header : ExtraHeaders) {
- PrintHeaderInfo(OutputFile, Header.c_str(), ShowDepth, 2, MSStyle);
- }
- PP.addPPCallbacks(llvm::make_unique<HeaderIncludesCallback>(&PP,
- ShowAllHeaders,
- OutputFile,
- OwnsOutputFile,
- ShowDepth,
- MSStyle));
+ PP.addPPCallbacks(llvm::make_unique<HeaderIncludesCallback>(
+ &PP, ShowAllHeaders, OutputFile, ExtraHeaders, OwnsOutputFile, ShowDepth,
+ MSStyle));
}
void HeaderIncludesCallback::FileChanged(SourceLocation Loc,
FileChangeReason Reason,
SrcMgr::CharacteristicKind NewFileType,
FileID PrevFID) {
+ if (!PrintedExtraHeaders) {
+ // Print header info for extra headers, pretending they were discovered by
+ // the regular preprocessor. The primary use case is to support proper
+ // generation of Make / Ninja file dependencies for implicit includes, such
+ // as sanitizer blacklists. It's only important for cl.exe compatibility,
+ // the GNU way to generate rules is -M / -MM / -MD / -MMD.
+ for (auto Header : ExtraHeaders)
+ PrintHeaderInfo(OutputFile, Header.c_str(), ShowDepth, 2, MSStyle);
+ PrintedExtraHeaders = true;
+ }
+
// Unless we are exiting a #include, make sure to skip ahead to the line the
// #include directive was at.
PresumedLoc UserLoc = SM.getPresumedLoc(Loc);