r203881 - Refactor ASTReader::readInputFileInfo to return a struct containing the related information.
NAKAMURA Takumi
geek4civic at gmail.com
Fri Mar 14 08:08:10 PDT 2014
2014-03-14 11:26 GMT+09:00 Argyrios Kyrtzidis <akyrtzi at gmail.com>:
> Author: akirtzidis
> Date: Thu Mar 13 21:26:27 2014
> New Revision: 203881
>
> URL: http://llvm.org/viewvc/llvm-project?rev=203881&view=rev
> Log:
> Refactor ASTReader::readInputFileInfo to return a struct containing the related information.
>
> No functionality change.
>
> Modified:
> cfe/trunk/include/clang/Serialization/ASTReader.h
> cfe/trunk/lib/Serialization/ASTReader.cpp
>
> Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=203881&r1=203880&r2=203881&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
> +++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Mar 13 21:26:27 2014
> @@ -1022,10 +1022,15 @@ private:
> /// \brief Reads a statement from the specified cursor.
> Stmt *ReadStmtFromStream(ModuleFile &F);
>
> + struct InputFileInfo {
> + std::string Filename;
> + off_t StoredSize;
> + time_t StoredTime;
> + bool Overridden;
> + };
> +
> /// \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);
> + InputFileInfo readInputFileInfo(ModuleFile &F, unsigned ID);
> /// \brief A convenience method to read the filename from an input file.
> std::string getInputFileName(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=203881&r1=203880&r2=203881&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
> +++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Mar 13 21:26:27 2014
> @@ -1870,9 +1870,8 @@ 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) {
> +ASTReader::InputFileInfo
> +ASTReader::readInputFileInfo(ModuleFile &F, unsigned ID) {
> // Go find this input file.
> BitstreamCursor &Cursor = F.InputFilesCursor;
> SavedStreamPosition SavedPosition(Cursor);
> @@ -1887,21 +1886,23 @@ void ASTReader::readInputFileInfo(Module
> "invalid record type for input file");
> (void)Result;
>
> + std::string Filename;
> + off_t StoredSize;
> + time_t StoredTime;
> + bool Overridden;
> +
> 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);
> +
> + return { std::move(Filename), StoredSize, StoredTime, Overridden };
> }
Initializer is incompatible to msvc 2012.
> 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;
> + return readInputFileInfo(F, ID).Filename;
> }
>
> InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
> @@ -1921,11 +1922,11 @@ InputFile ASTReader::getInputFile(Module
> SavedStreamPosition SavedPosition(Cursor);
> Cursor.JumpToBit(F.InputFileOffsets[ID-1]);
>
> - off_t StoredSize;
> - time_t StoredTime;
> - bool Overridden;
> - std::string Filename;
> - readInputFileInfo(F, ID, Filename, StoredSize, StoredTime, Overridden);
> + InputFileInfo FI = readInputFileInfo(F, ID);
> + off_t StoredSize = FI.StoredSize;
> + time_t StoredTime = FI.StoredTime;
> + bool Overridden = FI.Overridden;
> + StringRef Filename = FI.Filename;
>
> const FileEntry *File
> = Overridden? FileMgr.getVirtualFile(Filename, StoredSize, StoredTime)
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list