aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/DependencyFile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Frontend/DependencyFile.cpp')
-rw-r--r--lib/Frontend/DependencyFile.cpp44
1 files changed, 20 insertions, 24 deletions
diff --git a/lib/Frontend/DependencyFile.cpp b/lib/Frontend/DependencyFile.cpp
index 1edd09b06c4c..ff3a12392c9f 100644
--- a/lib/Frontend/DependencyFile.cpp
+++ b/lib/Frontend/DependencyFile.cpp
@@ -32,19 +32,19 @@ class DependencyFileCallback : public PPCallbacks {
llvm::StringSet<> FilesSet;
const Preprocessor *PP;
std::vector<std::string> Targets;
- llvm::raw_ostream *OS;
+ raw_ostream *OS;
bool IncludeSystemHeaders;
bool PhonyTarget;
bool AddMissingHeaderDeps;
private:
bool FileMatchesDepCriteria(const char *Filename,
SrcMgr::CharacteristicKind FileType);
- void AddFilename(llvm::StringRef Filename);
+ void AddFilename(StringRef Filename);
void OutputDependencyFile();
public:
DependencyFileCallback(const Preprocessor *_PP,
- llvm::raw_ostream *_OS,
+ raw_ostream *_OS,
const DependencyOutputOptions &Opts)
: PP(_PP), Targets(Opts.Targets), OS(_OS),
IncludeSystemHeaders(Opts.IncludeSystemHeaders),
@@ -52,15 +52,16 @@ public:
AddMissingHeaderDeps(Opts.AddMissingHeaderDeps) {}
virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason,
- SrcMgr::CharacteristicKind FileType);
+ SrcMgr::CharacteristicKind FileType,
+ FileID PrevFID);
virtual void InclusionDirective(SourceLocation HashLoc,
const Token &IncludeTok,
- llvm::StringRef FileName,
+ StringRef FileName,
bool IsAngled,
const FileEntry *File,
SourceLocation EndLoc,
- llvm::StringRef SearchPath,
- llvm::StringRef RelativePath);
+ StringRef SearchPath,
+ StringRef RelativePath);
virtual void EndOfMainFile() {
OutputDependencyFile();
@@ -78,7 +79,7 @@ void clang::AttachDependencyFileGen(Preprocessor &PP,
}
std::string Err;
- llvm::raw_ostream *OS(new llvm::raw_fd_ostream(Opts.OutputFile.c_str(), Err));
+ raw_ostream *OS(new llvm::raw_fd_ostream(Opts.OutputFile.c_str(), Err));
if (!Err.empty()) {
PP.getDiagnostics().Report(diag::err_fe_error_opening)
<< Opts.OutputFile << Err;
@@ -86,14 +87,8 @@ void clang::AttachDependencyFileGen(Preprocessor &PP,
}
// Disable the "file not found" diagnostic if the -MG option was given.
- // FIXME: Ideally this would live in the driver, but we don't have the ability
- // to remap individual diagnostics there without creating a DiagGroup, in
- // which case we would need to prevent the group name from showing up in
- // diagnostics.
- if (Opts.AddMissingHeaderDeps) {
- PP.getDiagnostics().setDiagnosticMapping(diag::warn_pp_file_not_found,
- diag::MAP_IGNORE, SourceLocation());
- }
+ if (Opts.AddMissingHeaderDeps)
+ PP.SetSuppressIncludeNotFoundError(true);
PP.addPPCallbacks(new DependencyFileCallback(&PP, OS, Opts));
}
@@ -113,7 +108,8 @@ bool DependencyFileCallback::FileMatchesDepCriteria(const char *Filename,
void DependencyFileCallback::FileChanged(SourceLocation Loc,
FileChangeReason Reason,
- SrcMgr::CharacteristicKind FileType) {
+ SrcMgr::CharacteristicKind FileType,
+ FileID PrevFID) {
if (Reason != PPCallbacks::EnterFile)
return;
@@ -123,10 +119,10 @@ void DependencyFileCallback::FileChanged(SourceLocation Loc,
SourceManager &SM = PP->getSourceManager();
const FileEntry *FE =
- SM.getFileEntryForID(SM.getFileID(SM.getInstantiationLoc(Loc)));
+ SM.getFileEntryForID(SM.getFileID(SM.getExpansionLoc(Loc)));
if (FE == 0) return;
- llvm::StringRef Filename = FE->getName();
+ StringRef Filename = FE->getName();
if (!FileMatchesDepCriteria(Filename.data(), FileType))
return;
@@ -143,24 +139,24 @@ void DependencyFileCallback::FileChanged(SourceLocation Loc,
void DependencyFileCallback::InclusionDirective(SourceLocation HashLoc,
const Token &IncludeTok,
- llvm::StringRef FileName,
+ StringRef FileName,
bool IsAngled,
const FileEntry *File,
SourceLocation EndLoc,
- llvm::StringRef SearchPath,
- llvm::StringRef RelativePath) {
+ StringRef SearchPath,
+ StringRef RelativePath) {
if (AddMissingHeaderDeps && !File)
AddFilename(FileName);
}
-void DependencyFileCallback::AddFilename(llvm::StringRef Filename) {
+void DependencyFileCallback::AddFilename(StringRef Filename) {
if (FilesSet.insert(Filename))
Files.push_back(Filename);
}
/// PrintFilename - GCC escapes spaces, but apparently not ' or " or other
/// scary characters.
-static void PrintFilename(llvm::raw_ostream &OS, llvm::StringRef Filename) {
+static void PrintFilename(raw_ostream &OS, StringRef Filename) {
for (unsigned i = 0, e = Filename.size(); i != e; ++i) {
if (Filename[i] == ' ')
OS << '\\';