aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Serialization/GlobalModuleIndex.cpp
AgeCommit message (Collapse)AuthorFilesLines
2017-03-13Modules: Use hash of PCM content for SIGNATUREDuncan P. N. Exon Smith1-10/+66
Change ASTFileSignature from a random 32-bit number to the hash of the PCM content. - Move definition ASTFileSignature to Basic/Module.h so Module and ASTSourceDescriptor can use it. - Change the signature from uint64_t to std::array<uint32_t,5>. - Stop using (saving/reading) the size and modification time of PCM files when there is a valid SIGNATURE. - Add UNHASHED_CONTROL_BLOCK, and use it to store the SIGNATURE record and other records that shouldn't affect the hash. Because implicit modules reuses the same file for multiple levels of -Werror, this includes DIAGNOSTIC_OPTIONS and DIAG_PRAGMA_MAPPINGS. This helps to solve a PCH + implicit Modules dependency issue: PCH files are handled by the external build system, whereas implicit modules are handled by internal compiler build system. This prevents invalidating a PCH when the compiler overwrites a PCM file with the same content (modulo the diagnostic differences). Design and original patch by Manman Ren! llvm-svn: 297655
2017-01-04Fix for LLVM Bitcode API change (to use std::shared_ptr)David Blaikie1-2/+2
llvm-svn: 291018
2016-11-08Bitcode: Decouple block info block state from reader.Peter Collingbourne1-7/+2
As proposed on llvm-dev: http://lists.llvm.org/pipermail/llvm-dev/2016-October/106630.html Move block info block state to a new class, BitstreamBlockInfo. Clients may set the block info for a particular cursor with the BitstreamCursor::setBlockInfo() method. At this point BitstreamReader is not much more than a container for an ArrayRef<uint8_t>, so remove it and replace all uses with direct uses of memory buffers. Differential Revision: https://reviews.llvm.org/D26259 llvm-svn: 286207
2016-11-02Bitcode: Change reader interface to take memory buffers.Peter Collingbourne1-2/+1
As proposed on llvm-dev: http://lists.llvm.org/pipermail/llvm-dev/2016-October/106595.html This change also fixes an API oddity where BitstreamCursor::Read() would return zero for the first read past the end of the bitstream, but would report_fatal_error for subsequent reads. Now we always report_fatal_error for all reads past the end. Updated clients to check for the end of the bitstream before reading from it. I also needed to add padding to the invalid bitcode tests in test/Bitcode/. This is because the streaming interface was not checking that the file size is a multiple of 4. Differential Revision: https://reviews.llvm.org/D26219 llvm-svn: 285773
2016-11-01Bitcode: Simplify BitstreamWriter::EnterBlockInfoBlock() interface.Peter Collingbourne1-1/+1
No block info block should need to define local abbreviations, so we can always use a code width of 2. Also change all block info block writers to use EnterBlockInfoBlock. Differential Revision: https://reviews.llvm.org/D26168 llvm-svn: 285660
2016-01-29Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith ↵Yaron Keren1-1/+1
r259192 post commit comment. llvm-svn: 259232
2015-09-10EmitRecord* API change: accepts ArrayRef instead of a SmallVector (NFC)Mehdi Amini1-3/+1
This reapply a variant commit r247179 after post-commit review from D.Blaikie. Hopefully I got it right this time: lifetime of initializer list ends as with any expression, which make invalid the pattern: ArrayRef<int> Arr = { 1, 2, 3, 4}; Just like StringRef, ArrayRef shouldn't be used to initialize local variable but only as function argument. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 247233
2015-09-09Revert "EmitRecordWith* API change: takes an ArrayRef instead of a ↵Mehdi Amini1-1/+3
SmallVector (NFC)" This reverts commit r247179. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 247183
2015-09-09EmitRecordWith* API change: takes an ArrayRef instead of a SmallVector (NFC)Mehdi Amini1-3/+1
From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 247179
2015-07-17Make the clang module container format selectable from the command line.Adrian Prantl1-6/+6
- introduces a new cc1 option -fmodule-format=[raw,obj] with 'raw' being the default - supports arbitrary module container formats that libclang is agnostic to - adds the format to the module hash to avoid collisions - splits the old PCHContainerOperations into PCHContainerWriter and a PCHContainerReader. Thanks to Richard Smith for reviewing this patch! llvm-svn: 242499
2015-06-22Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko1-6/+6
llvm-svn: 240353
2015-06-22Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko1-6/+6
The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
2015-06-20Introduce a PCHContainerOperations interface (NFC).Adrian Prantl1-6/+11
A PCHContainerOperations abstract interface provides operations for creating and unwrapping containers for serialized ASTs (precompiled headers and clang modules). The default implementation is RawPCHContainerOperations, which uses a flat file for the output. The main application for this interface will be an ObjectFilePCHContainerOperations implementation that uses LLVM to wrap the module in an ELF/Mach-O/COFF container to store debug info alongside the AST. rdar://problem/20091852 llvm-svn: 240225
2015-03-18Remove many superfluous SmallString::str() calls.Yaron Keren1-4/+4
Now that SmallString is a first-class citizen, most SmallString::str() calls are not required. This patch removes a whole bunch of them, yet there are lots more. There are two use cases where str() is really needed: 1) To use one of StringRef member functions which is not available in SmallString. 2) To convert to std::string, as StringRef implicitly converts while SmallString do not. We may wish to change this, but it may introduce ambiguity. llvm-svn: 232622
2015-02-25Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."Adrian Prantl1-3/+2
llvm-svn: 230454
2015-02-25Wrap clang module files in a Mach-O, ELF, or COFF container.Adrian Prantl1-2/+3
This is a necessary prerequisite for debugging with modules. The .pcm files become containers that hold the serialized AST which allows us to store debug information in the module file that can be shared by all object files that were built importing the module. This reapplies r230044 with a fixed configure+make build and updated dependencies and testcase requirements. Over the last iteration this version adds - missing target requirements for testcases that specify an x86 triple, - a missing clangCodeGen.a dependency to libClang.a in the make build. rdar://problem/19104245 llvm-svn: 230423
2015-02-24Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."Adrian Prantl1-3/+2
This reverts commit r230305. Off to fix another round of missing dependencies on various platforms. llvm-svn: 230309
2015-02-24Wrap clang module files in a Mach-O, ELF, or COFF container.Adrian Prantl1-2/+3
This is a necessary prerequisite for debugging with modules. The .pcm files become containers that hold the serialized AST which allows us to store debug information in the module file that can be shared by all object files that were built importing the module. rdar://problem/19104245 This reapplies r230044 with a fixed configure+make build and updated dependencies. Take 3. llvm-svn: 230305
2015-02-21Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."Adrian Prantl1-3/+2
This reverts commit 230099. The Linux configure+make build variant still needs some work. llvm-svn: 230103
2015-02-20Wrap clang module files in a Mach-O, ELF, or COFF container.Adrian Prantl1-2/+3
This is a necessary prerequisite for debugging with modules. The .pcm files become containers that hold the serialized AST which allows us to store debug information in the module file that can be shared by all object files that were built importing the module. rdar://problem/19104245 This reapplies r230044 with a fixed configure+make build and updated dependencies. Take 2. llvm-svn: 230089
2015-02-20Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."Adrian Prantl1-3/+2
This reverts commit r230067. Investigating another batch of problems found by the bots. llvm-svn: 230073
2015-02-20Wrap clang module files in a Mach-O, ELF, or COFF container.Adrian Prantl1-2/+3
This is a necessary prerequisite for debugging with modules. The .pcm files become containers that hold the serialized AST which allows us to store debug information in the module file that can be shared by all object files that were built importing the module. rdar://problem/19104245 This reapplies r230044 with a fixed configure+make build and updated dependencies. llvm-svn: 230067
2015-02-20Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."Adrian Prantl1-3/+2
This reverts commit r230044 while dealing with buildbot breakage. Conflicts: test/Modules/module_container.m llvm-svn: 230052
2015-02-20Wrap clang module files in a Mach-O, ELF, or COFF container.Adrian Prantl1-2/+3
This is a necessary prerequisite for debugging with modules. The .pcm files become containers that hold the serialized AST which allows us to store debug information in the module file that can be shared by all object files that were built importing the module. rdar://problem/19104245 llvm-svn: 230044
2014-11-12Simplify code a bit by passing StreamFile to the BitstreamCursor constructor.Rafael Espindola1-2/+1
llvm-svn: 221784
2014-10-26Make VFS and FileManager match the current MemoryBuffer API.Benjamin Kramer1-5/+3
This eliminates converting back and forth between the 3 formats and gives us a more homogeneous interface. llvm-svn: 220657
2014-10-23Add a "signature" to AST files to verify that they haven't changedBen Langmuir1-0/+4
Since the order of the IDs in the AST file (e.g. DeclIDs, SelectorIDs) is not stable, it is not safe to load an AST file that depends on another AST file that has been rebuilt since the importer was built, even if "nothing changed". We previously used size and modtime to check this, but I've seen cases where a module rebuilt quickly enough to foil this check and caused very hard to debug build errors. To save cycles when we're loading the AST, we just generate a random nonce value and check that it hasn't changed when we load an imported module, rather than actually hash the whole file. This is slightly complicated by the fact that we need to verify the signature inside addModule, since we might otherwise consider that a mdoule is "OutOfDate" when really it is the importer that is out of date. I didn't see any regressions in module load time after this change. llvm-svn: 220493
2014-08-26Return a std::unique_ptr from getBufferForFile. NFC.Rafael Espindola1-2/+3
llvm-svn: 216476
2014-08-11unique_ptr-ify the MemoryBuffer parameter of GlobalModuleIndexDavid Blaikie1-5/+4
llvm-svn: 215376
2014-07-06Update for llvm api change.Rafael Espindola1-2/+4
llvm-svn: 212408
2014-06-12Replace llvm::error_code with std::error_code.Rafael Espindola1-1/+1
llvm-svn: 210780
2014-05-31There is no std::errc:success, remove the llvm one.Rafael Espindola1-2/+1
llvm-svn: 209959
2014-05-22[C++11] Use 'nullptr'. Serialization edition.Craig Topper1-3/+3
llvm-svn: 209392
2014-04-25Fix leak of GlobalModuleIndex::IdentifierIndex, found by LSan.Nico Weber1-1/+3
llvm-svn: 207262
2014-04-18Teach users of OnDiskHashTable to define hash_value and offset typesJustin Bogner1-2/+6
This paves the way to making OnDiskHashTable work with hashes that are not 32 bits wide and to making OnDiskHashTable work very large hash tables. The LLVM change to use these types is upcoming. llvm-svn: 206640
2014-04-18Remove OnDiskHashTable.h, since it's been moved to llvmJustin Bogner1-6/+5
llvm-svn: 206637
2014-04-17Revised per Dmitri's comments. My first exposure to range-based for loops, ↵John Thompson1-1/+1
thanks! llvm-svn: 206483
2014-04-17Revised per Dmitri's comments. My first exposure to range-based for loops, ↵John Thompson1-10/+8
thanks! llvm-svn: 206474
2014-04-16Added dump method for global module index.John Thompson1-0/+15
llvm-svn: 206418
2014-04-14Allow multiple modules with the same name to coexist in the module cacheBen Langmuir1-2/+8
To differentiate between two modules with the same name, we will consider the path the module map file that they are defined by* part of the ‘key’ for looking up the precompiled module (pcm file). Specifically, this patch renames the precompiled module (pcm) files from cache-path/<module hash>/Foo.pcm to cache-path/<module hash>/Foo-<hash of module map path>.pcm In addition, I’ve taught the ASTReader to re-resolve the names of imported modules during module loading so that if the header search context changes between when a module was originally built and when it is loaded we can rebuild it if necessary. For example, if module A imports module B first time: clang -I /path/to/A -I /path/to/B ... second time: clang -I /path/to/A -I /different/path/to/B ... will now rebuild A as expected. * in the case of inferred modules, we use the module map file that allowed the inference, not the __inferred_module.map file, since the inferred file path is the same for every inferred module. llvm-svn: 206201
2014-04-14OnDiskHashTable: Make the iterable version separate.Justin Bogner1-6/+9
Currently the on disk hash table's key_iterator and data_iterator make the assumption that the table data starts exactly four bytes after the base of the table. This happens to be true for all of the tables we currently iterate over, but not for all of the OnDiskHashTables we currently use. For example, key_ and data_iterator would iterate over meaningless data if they were used on the hash tables in PTHLexer. We make the API safer by breaking this into two types. One doesn't have the iterators, and the other must be told where the payload starts. llvm-svn: 206189
2014-03-28Reapply "OnDiskHashTable: Use Endian.h to read little endian ostreams"Justin Bogner1-7/+7
Committed this by accident before it was done last time. Original message: Rather than rolling our own functions to read little endian data from a buffer, we can use the support in llvm's Endian.h. No functional change. llvm-svn: 205062
2014-03-28Reapply "OnDiskHashTable: Use EndianStream.h to write little endian ostreams"Justin Bogner1-4/+8
Committed this by accident before it was done last time. Original message: Rather than rolling our own functions to write little endian data to an ostream, we can use the support in llvm's EndianStream.h. No functional change. llvm-svn: 205061
2014-03-28Revert "OnDiskHashTable: Use Endian.h to read little endian ostreams"Justin Bogner1-7/+7
This reverts commit r205045. llvm-svn: 205048
2014-03-28Revert "OnDiskHashTable: Use EndianStream.h to write little endian ostreams"Justin Bogner1-8/+4
This reverts commit r205044. llvm-svn: 205047
2014-03-28OnDiskHashTable: Use Endian.h to read little endian ostreamsJustin Bogner1-7/+7
Rather than rolling our own functions to read little endian data from a buffer, we can use the support in llvm's Endian.h. No functional change. llvm-svn: 205045
2014-03-28OnDiskHashTable: Use EndianStream.h to write little endian ostreamsJustin Bogner1-4/+8
Rather than rolling our own functions to write little endian data to an ostream, we can use the support in llvm's EndianStream.h. No functional change. llvm-svn: 205044
2014-03-13[C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper1-1/+1
class. llvm-svn: 203746
2014-03-07Replace OwningPtr with std::unique_ptr.Ahmed Charles1-6/+6
This compiles cleanly with lldb/lld/clang-tools-extra/llvm. llvm-svn: 203279
2014-03-07Change OwningPtr::take() to OwningPtr::release().Ahmed Charles1-2/+3
This is a precursor to moving to std::unique_ptr. llvm-svn: 203275