r203210 - Add a bunch of missing changes from r203208
Ben Langmuir
blangmuir at apple.com
Thu Mar 6 23:27:49 PST 2014
Author: benlangmuir
Date: Fri Mar 7 01:27:49 2014
New Revision: 203210
URL: http://llvm.org/viewvc/llvm-project?rev=203210&view=rev
Log:
Add a bunch of missing changes from r203208
Somehow lost these in a git operation.
Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/dependency-gen.m
Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=203210&r1=203209&r2=203210&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Fri Mar 7 01:27:49 2014
@@ -545,7 +545,7 @@ private:
assert(getKind() == Macro && "Hidden name is not a macro!");
return std::make_pair(Id, MMI);
}
-};
+ };
typedef llvm::SmallDenseMap<IdentifierInfo*,
ModuleMacroInfo*> HiddenMacrosMap;
@@ -1024,6 +1024,13 @@ private:
/// \brief Reads a statement from the specified cursor.
Stmt *ReadStmtFromStream(ModuleFile &F);
+ /// \brief Reads the stored information about an input file.
+ void readInputFileInfo(ModuleFile &F, unsigned ID, std::string &Filename,
+ off_t &StoredSize, time_t &StoredTime,
+ bool &Overridden);
+ /// \brief A convenience method to read the filename from an input file.
+ std::string getInputFileName(ModuleFile &F, unsigned ID);
+
/// \brief Retrieve the file entry and 'overridden' bit for an input
/// file in the given module file.
serialization::InputFile getInputFile(ModuleFile &F, unsigned ID,
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=203210&r1=203209&r2=203210&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Mar 7 01:27:49 2014
@@ -1870,6 +1870,40 @@ void ASTReader::installImportedMacro(Ide
PP.appendMacroDirective(II, MD);
}
+void ASTReader::readInputFileInfo(ModuleFile &F, unsigned ID,
+ std::string &Filename, off_t &StoredSize,
+ time_t &StoredTime, bool &Overridden) {
+ // Go find this input file.
+ BitstreamCursor &Cursor = F.InputFilesCursor;
+ SavedStreamPosition SavedPosition(Cursor);
+ Cursor.JumpToBit(F.InputFileOffsets[ID-1]);
+
+ unsigned Code = Cursor.ReadCode();
+ RecordData Record;
+ StringRef Blob;
+
+ unsigned Result = Cursor.readRecord(Code, Record, &Blob);
+ assert(static_cast<InputFileRecordTypes>(Result) == INPUT_FILE &&
+ "invalid record type for input file");
+ (void)Result;
+
+ assert(Record[0] == ID && "Bogus stored ID or offset");
+ StoredSize = static_cast<off_t>(Record[1]);
+ StoredTime = static_cast<time_t>(Record[2]);
+ Overridden = static_cast<bool>(Record[3]);
+ Filename = Blob;
+ MaybeAddSystemRootToFilename(F, Filename);
+}
+
+std::string ASTReader::getInputFileName(ModuleFile &F, unsigned int ID) {
+ off_t StoredSize;
+ time_t StoredTime;
+ bool Overridden;
+ std::string Filename;
+ readInputFileInfo(F, ID, Filename, StoredSize, StoredTime, Overridden);
+ return Filename;
+}
+
InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
// If this ID is bogus, just return an empty input file.
if (ID == 0 || ID > F.InputFilesLoaded.size())
@@ -1887,119 +1921,105 @@ InputFile ASTReader::getInputFile(Module
SavedStreamPosition SavedPosition(Cursor);
Cursor.JumpToBit(F.InputFileOffsets[ID-1]);
- unsigned Code = Cursor.ReadCode();
- RecordData Record;
- StringRef Blob;
- switch ((InputFileRecordTypes)Cursor.readRecord(Code, Record, &Blob)) {
- case INPUT_FILE: {
- unsigned StoredID = Record[0];
- assert(ID == StoredID && "Bogus stored ID or offset");
- (void)StoredID;
- off_t StoredSize = (off_t)Record[1];
- time_t StoredTime = (time_t)Record[2];
- bool Overridden = (bool)Record[3];
-
- // Get the file entry for this input file.
- StringRef OrigFilename = Blob;
- std::string Filename = OrigFilename;
- MaybeAddSystemRootToFilename(F, Filename);
- const FileEntry *File
- = Overridden? FileMgr.getVirtualFile(Filename, StoredSize, StoredTime)
- : FileMgr.getFile(Filename, /*OpenFile=*/false);
-
- // If we didn't find the file, resolve it relative to the
- // original directory from which this AST file was created.
- if (File == 0 && !F.OriginalDir.empty() && !CurrentDir.empty() &&
- F.OriginalDir != CurrentDir) {
- std::string Resolved = resolveFileRelativeToOriginalDir(Filename,
- F.OriginalDir,
- CurrentDir);
- if (!Resolved.empty())
- File = FileMgr.getFile(Resolved);
- }
-
- // For an overridden file, create a virtual file with the stored
- // size/timestamp.
- if (Overridden && File == 0) {
- File = FileMgr.getVirtualFile(Filename, StoredSize, StoredTime);
- }
-
- if (File == 0) {
- if (Complain) {
- std::string ErrorStr = "could not find file '";
- ErrorStr += Filename;
- ErrorStr += "' referenced by AST file";
- Error(ErrorStr.c_str());
- }
- // Record that we didn't find the file.
- F.InputFilesLoaded[ID-1] = InputFile::getNotFound();
- return InputFile();
- }
+ off_t StoredSize;
+ time_t StoredTime;
+ bool Overridden;
+ std::string Filename;
+ readInputFileInfo(F, ID, Filename, StoredSize, StoredTime, Overridden);
+
+ const FileEntry *File
+ = Overridden? FileMgr.getVirtualFile(Filename, StoredSize, StoredTime)
+ : FileMgr.getFile(Filename, /*OpenFile=*/false);
+
+ // If we didn't find the file, resolve it relative to the
+ // original directory from which this AST file was created.
+ if (File == 0 && !F.OriginalDir.empty() && !CurrentDir.empty() &&
+ F.OriginalDir != CurrentDir) {
+ std::string Resolved = resolveFileRelativeToOriginalDir(Filename,
+ F.OriginalDir,
+ CurrentDir);
+ if (!Resolved.empty())
+ File = FileMgr.getFile(Resolved);
+ }
- // Check if there was a request to override the contents of the file
- // that was part of the precompiled header. Overridding such a file
- // can lead to problems when lexing using the source locations from the
- // PCH.
- SourceManager &SM = getSourceManager();
- if (!Overridden && SM.isFileOverridden(File)) {
- if (Complain)
- Error(diag::err_fe_pch_file_overridden, Filename);
- // After emitting the diagnostic, recover by disabling the override so
- // that the original file will be used.
- SM.disableFileContentsOverride(File);
- // The FileEntry is a virtual file entry with the size of the contents
- // that would override the original contents. Set it to the original's
- // size/time.
- FileMgr.modifyFileEntry(const_cast<FileEntry*>(File),
- StoredSize, StoredTime);
+ // For an overridden file, create a virtual file with the stored
+ // size/timestamp.
+ if (Overridden && File == 0) {
+ File = FileMgr.getVirtualFile(Filename, StoredSize, StoredTime);
+ }
+
+ if (File == 0) {
+ if (Complain) {
+ std::string ErrorStr = "could not find file '";
+ ErrorStr += Filename;
+ ErrorStr += "' referenced by AST file";
+ Error(ErrorStr.c_str());
}
+ // Record that we didn't find the file.
+ F.InputFilesLoaded[ID-1] = InputFile::getNotFound();
+ return InputFile();
+ }
+
+ // Check if there was a request to override the contents of the file
+ // that was part of the precompiled header. Overridding such a file
+ // can lead to problems when lexing using the source locations from the
+ // PCH.
+ SourceManager &SM = getSourceManager();
+ if (!Overridden && SM.isFileOverridden(File)) {
+ if (Complain)
+ Error(diag::err_fe_pch_file_overridden, Filename);
+ // After emitting the diagnostic, recover by disabling the override so
+ // that the original file will be used.
+ SM.disableFileContentsOverride(File);
+ // The FileEntry is a virtual file entry with the size of the contents
+ // that would override the original contents. Set it to the original's
+ // size/time.
+ FileMgr.modifyFileEntry(const_cast<FileEntry*>(File),
+ StoredSize, StoredTime);
+ }
- bool IsOutOfDate = false;
+ bool IsOutOfDate = false;
- // For an overridden file, there is nothing to validate.
- if (!Overridden && (StoredSize != File->getSize()
+ // For an overridden file, there is nothing to validate.
+ if (!Overridden && (StoredSize != File->getSize()
#if !defined(LLVM_ON_WIN32)
- // In our regression testing, the Windows file system seems to
- // have inconsistent modification times that sometimes
- // erroneously trigger this error-handling path.
- || StoredTime != File->getModificationTime()
+ // In our regression testing, the Windows file system seems to
+ // have inconsistent modification times that sometimes
+ // erroneously trigger this error-handling path.
+ || StoredTime != File->getModificationTime()
#endif
- )) {
- if (Complain) {
- // Build a list of the PCH imports that got us here (in reverse).
- SmallVector<ModuleFile *, 4> ImportStack(1, &F);
- while (ImportStack.back()->ImportedBy.size() > 0)
- ImportStack.push_back(ImportStack.back()->ImportedBy[0]);
-
- // The top-level PCH is stale.
- StringRef TopLevelPCHName(ImportStack.back()->FileName);
- Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
-
- // Print the import stack.
- if (ImportStack.size() > 1 && !Diags.isDiagnosticInFlight()) {
+ )) {
+ if (Complain) {
+ // Build a list of the PCH imports that got us here (in reverse).
+ SmallVector<ModuleFile *, 4> ImportStack(1, &F);
+ while (ImportStack.back()->ImportedBy.size() > 0)
+ ImportStack.push_back(ImportStack.back()->ImportedBy[0]);
+
+ // The top-level PCH is stale.
+ StringRef TopLevelPCHName(ImportStack.back()->FileName);
+ Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
+
+ // Print the import stack.
+ if (ImportStack.size() > 1 && !Diags.isDiagnosticInFlight()) {
+ Diag(diag::note_pch_required_by)
+ << Filename << ImportStack[0]->FileName;
+ for (unsigned I = 1; I < ImportStack.size(); ++I)
Diag(diag::note_pch_required_by)
- << Filename << ImportStack[0]->FileName;
- for (unsigned I = 1; I < ImportStack.size(); ++I)
- Diag(diag::note_pch_required_by)
- << ImportStack[I-1]->FileName << ImportStack[I]->FileName;
- }
-
- if (!Diags.isDiagnosticInFlight())
- Diag(diag::note_pch_rebuild_required) << TopLevelPCHName;
+ << ImportStack[I-1]->FileName << ImportStack[I]->FileName;
}
- IsOutOfDate = true;
+ if (!Diags.isDiagnosticInFlight())
+ Diag(diag::note_pch_rebuild_required) << TopLevelPCHName;
}
- InputFile IF = InputFile(File, Overridden, IsOutOfDate);
-
- // Note that we've loaded this input file.
- F.InputFilesLoaded[ID-1] = IF;
- return IF;
- }
+ IsOutOfDate = true;
}
- return InputFile();
+ InputFile IF = InputFile(File, Overridden, IsOutOfDate);
+
+ // Note that we've loaded this input file.
+ F.InputFilesLoaded[ID-1] = IF;
+ return IF;
}
const FileEntry *ASTReader::getFileEntry(StringRef filenameStrRef) {
@@ -2086,14 +2106,11 @@ ASTReader::ReadControlBlock(ModuleFile &
unsigned N = NumUserInputs;
if (ValidateSystemInputs ||
- (Listener && Listener->needsInputFileVisitation()) ||
(HSOpts.ModulesValidateOncePerBuildSession && F.Kind == MK_Module))
N = NumInputs;
for (unsigned I = 0; I < N; ++I) {
InputFile IF = getInputFile(F, I+1, Complain);
- if (const FileEntry *F = IF.getFile())
- Listener->visitInputFile(F->getName(), I >= NumUserInputs);
if (!IF.getFile() || IF.isOutOfDate())
return OutOfDate;
}
Modified: cfe/trunk/test/Modules/dependency-gen.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/dependency-gen.m?rev=203210&r1=203209&r2=203210&view=diff
==============================================================================
--- cfe/trunk/test/Modules/dependency-gen.m (original)
+++ cfe/trunk/test/Modules/dependency-gen.m Fri Mar 7 01:27:49 2014
@@ -1,20 +1,22 @@
// RUN: rm -rf %t-mcp
// RUN: mkdir -p %t-mcp
-// RUN: %clang_cc1 -x objective-c -dependency-file %t.d.1 -MT %s.o -I %S/Inputs -fsyntax-only -fmodules -fmodules-cache-path=%t-mcp %s
+// RUN: %clang_cc1 -x objective-c -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -dependency-file %t.d.1 -MT %s.o -I %S/Inputs -fsyntax-only -fmodules -fmodules-cache-path=%t-mcp %s
// RUN: FileCheck %s < %t.d.1
// CHECK: dependency-gen.m
// CHECK: Inputs/diamond_top.h
// CHECK: Inputs/module.map
-// CHECK-NOT: string.h
+// CHECK-NOT: usr{{.}}include{{.}}module.map
+// CHECK-NOT: stdint.h
-// RUN: %clang_cc1 -x objective-c -dependency-file %t.d.2 -MT %s.o -I %S/Inputs -sys-header-deps -fsyntax-only -fmodules -fmodules-cache-path=%t-mcp %s
+// RUN: %clang_cc1 -x objective-c -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -dependency-file %t.d.2 -MT %s.o -I %S/Inputs -sys-header-deps -fsyntax-only -fmodules -fmodules-cache-path=%t-mcp %s
// RUN: FileCheck %s -check-prefix=CHECK-SYS < %t.d.2
// CHECK-SYS: dependency-gen.m
// CHECK-SYS: Inputs/diamond_top.h
// CHECK-SYS: Inputs/module.map
-// CHECK-SYS: string.h
+// CHECK-SYS: usr{{.}}include{{.}}module.map
+// CHECK-SYS: stdint.h
#import "diamond_top.h"
-#import "string.h"
+#import "stdint.h" // inside sysroot
More information about the cfe-commits
mailing list