Граф коммитов

484 Коммитов

Автор SHA1 Сообщение Дата
Argyrios Kyrtzidis 4182ed6862 [PCH] Remove the stat cache from the PCH file.
The stat cache became essentially useless ever since we started
validating all file entries in the PCH.
But the motivating reason for removing it now is that it also affected
correctness in this situation:

-You have a header without include guards (using "#pragma once" or #import)
-When creating the PCH:
  -The same header is referenced in an #include with different filename cases.
  -In the PCH, of course, we record only one file entry for the header file
  -But we cache in the PCH file the stat info for both filename cases

-Then the source files are updated and the header file is updated in a way that
 its size and modification time are the same but its inode changes

-When using the PCH:
  -We validate the headers, we check that header file and we create a file entry with its current inode
  -There's another #include with a filename with different case than the previously created file entry
  -In order to get its stat info we go through the cached stat info of the PCH and we receive the old inode
  -because of the different inodes, we think they are different files so we go ahead and include its contents.

Removing the stat cache will potentially break clients that are attempting to use the stat cache
as a way of avoiding having the actual input files available. If that use case is important, patches are welcome
to bring it back in a way that will actually work correctly (i.e., emit a PCH that is self-contained, coping with
literal strings, line/column computations, etc.).

This fixes rdar://5502805

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167172 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-31 20:59:50 +00:00
Rafael Espindola 848bc3a5db getOriginalSourceFileName and getOriginalSourceFile can return a StringRef.
MaybeAddSystemRootToFilename doesn't need to return anything, it modifies
its argument.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166988 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-30 00:38:13 +00:00
Argyrios Kyrtzidis 33e1576ef8 [PCH] The diagnostic state points can refer to previously created
diagnostic states; make sure the ASTReader sets the diagnostic state
properly instead of always recreating it.

Fixes rdar://12581618 & http://llvm.org/PR14181

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166987 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-30 00:27:21 +00:00
Douglas Gregor 0ca6e27138 Remove the old predefines-buffer diffing code completely. It's been
replaced by the more efficient, cleaner preprocessor-option version
that occurs earlier in PCH validation.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166654 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-25 00:30:23 +00:00
Douglas Gregor a9b8da4307 Fix computation of predefines buffer from the preprocessor-option
checking, and disable the old predefines-buffer-diff'ing code path.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166653 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-25 00:25:27 +00:00
Douglas Gregor 8769924c97 The the preprocessor option validator to compute suggested
predefines. We're not quite ready to cut over to these suggested
predefines yet, however.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166648 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-25 00:07:54 +00:00
Douglas Gregor 4c0c7e8664 Teach the PCH validator to check the preprocessor options, especially
the macros that are #define'd or #undef'd on the command line. This
checking happens much earlier than the current macro-definition
checking and is far cleaner, because it does a direct comparison
rather than a diff of the predefines buffers. Moreover, it allows us
to use the result of this check to skip over PCH files within a
directory that have non-matching -D's or -U's on the command
line. Finally, it improves the diagnostics a bit for mismatches,
fixing <rdar://problem/8612222>.

The old predefines-buffer diff'ing will go away in a subsequent commit.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166641 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-24 23:41:50 +00:00
Douglas Gregor a71a7d8a1c (De-)serialize the preprocessor options, including macros defined,
-include'd files, etc. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166614 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-24 20:05:57 +00:00
Douglas Gregor bbf38319ed (De-)serialize header search options.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166586 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-24 16:50:34 +00:00
Douglas Gregor 1b2c3c0884 (De-)serialize the file system options.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166577 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-24 15:49:58 +00:00
Douglas Gregor 5f3d8224af Serialize DiagnosticOptions to the AST file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166572 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-24 15:17:15 +00:00
Douglas Gregor 27ffa6caf9 If the precompiled header named by "-include" is actually a directory,
check each of the files within that directory to determine if any of
them is an AST file that matches the language and target options. If
so, the first matching AST file is loaded. This fixes a longstanding
discrepency with GCC's precompiled header implementation.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166469 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-23 06:18:24 +00:00
Douglas Gregor 38295beb73 Allow clients of the AST reader to specify what kinds of AST load
failures they know how to tolerate, e.g., out-of-date input files or
configuration/version mismatches. Suppress the corresponding
diagnostics if the client can handle it.

No clients actually use this functionality, yet.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166449 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-22 23:51:00 +00:00
Douglas Gregor 8b53d141ee Collapse ASTReader::ReadSLocEntryRecord() into its only caller,
ReadSLocEntry(). No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166447 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-22 22:53:10 +00:00
Douglas Gregor 4825fd7fbb Distinguish the various kinds of AST file loading failures:
file corruption, compiler version mismatch, target/language
configuration mismatch, out-of-date AST file. No functionality change
yet.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166446 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-22 22:50:17 +00:00
NAKAMURA Takumi 6b8194e4d7 ASTReader.cpp: Fix a warning. [-Wunused-variable]
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166442 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-22 21:50:39 +00:00
Douglas Gregor a930dc9b46 Eliminate the redundancy between source-file information in the source
manager block and input-file information in the control block. The
source manager entries now point back into the control block. Input
files are now lazily deserialized (if validation is disabled). Reduces
Cocoa's PCH by the ~70k I added when I introduced the redundancy in
r166251.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166429 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-22 18:42:04 +00:00
Douglas Gregor 745e6f168d Move the set of files to be validated in an AST file into the control
block, so the input files are validated early on, before we've
committed to loading the AST file. This (accidentally) fixed a but
wherein the main file used to generate the AST file would *not* be
validated by the existing validation logic.

At the moment, this leads to some duplication of filenames between the
source manager block and input-file blocks, as well as validation
logic. This will be handled via an upcoming patch.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166251 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-19 00:38:02 +00:00
Douglas Gregor 69e160869d Move OriginalDir from ASTReader to ModuleFile.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166233 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-18 21:47:16 +00:00
Douglas Gregor caed060d38 Move the "RelocatablePCH" bit from the ASTReader to the module file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166229 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-18 21:31:35 +00:00
Douglas Gregor 11407b89c9 Move information about the "original file" from the ASTReader into the
module files.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166228 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-18 21:18:25 +00:00
Axel Naumann 0ec56b7add From Vassil Vassilev: enable Sema to deal with multiple ExternalSemaSources.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166208 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-18 19:05:02 +00:00
Douglas Gregor 39c497b6d5 Collapse the original file name and original file ID records into a
single record. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166206 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-18 18:36:53 +00:00
Douglas Gregor 7ae467f02b Collapse the "version control revision/tag" AST file record into the
metadata record, which already had other version information. Clean up
the block info block along the way.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166204 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-18 18:27:37 +00:00
Douglas Gregor ee097c1a3f Split the target options out into their own record within the AST
file's control block.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166195 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-18 17:58:09 +00:00
Douglas Gregor 1d9d9898ce Start factoring the on-disk records for an AST file into a control
block, which stores information about how the AST file to generated,
from the AST block, which stores the actual serialized AST. The
information in the control block should be enough to determine whether
the AST file is up-to-date and compatible with the current translation
unit, and reading it should not cause any side effects that aren't
easy to undo. That way, we can back out from an attempt to read an
incompatible or out-of-date AST file.

Note that there is still more factoring to do. In particular,
information about the source files used to generate the AST file
(along with their time stamps, sizes, etc.) still resides in the
source manager block. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166166 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-18 05:31:06 +00:00
Douglas Gregor 57016dda61 Serialize TargetOptions into an AST file, and make sure that we keep
target options around so they can be accessed at any point (rather
than keeping them transient).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166072 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-16 23:40:58 +00:00
Douglas Gregor 2b49d1f0ad Introduce the notion of excluded headers into the module map
description. Previously, one could emulate this behavior by placing
the header in an always-unavailable submodule, but Argyrios guilted me
into expressing this idea properly.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165921 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-15 06:28:11 +00:00
Douglas Gregor 54c8a40ed6 Track which particular submodule #undef's a macro, so that the actual
#undef only occurs if that submodule is imported.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165773 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-12 00:16:50 +00:00
Douglas Gregor e8219a6551 Diagnose the expansion of ambiguous macro definitions. This can happen
only with modules, when two disjoint modules #define the same
identifier to different token sequences.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165746 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-11 21:07:39 +00:00
Douglas Gregor 3ab50fe3fc Introduce a simple "hint" scheme to eliminate the quadratic behavior
associated with deserializing macro history for an identifier.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165729 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-11 17:41:54 +00:00
Douglas Gregor e9652bf152 Make the deserialization of PendingMacroIDs deterministic.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165727 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-11 17:31:34 +00:00
Douglas Gregor 4145228b75 Remove the ASTDeserializationListener's MacroVisible() callback, which
is no longer necessary, as well as the little bit of infrastructure in
the AST writer that used it.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165684 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-11 00:51:27 +00:00
Douglas Gregor 7097be90d3 Remove an unused bit from the serialized IdentifierInfo
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165683 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-11 00:48:48 +00:00
Douglas Gregor 6c6c54a59a Deserialize macro history when we deserialize an identifier that has
macro history.

When deserializing macro history, we arrange history such that the
macros that have definitions (that haven't been #undef'd) and are
visible come at the beginning of the list, which is what the
preprocessor and other clients of Preprocessor::getMacroInfo()
expect. If additional macro definitions become visible later, they'll
be moved toward the front of the list. Note that it's possible to have
ambiguities, but we don't diagnose them yet.

There is a partially-implemented design decision here that, if a
particular identifier has been defined or #undef'd within the
translation unit, that definition (or #undef) hides any macro
definitions that come from imported modules. There's still a little
work to do to ensure that the right #undef'ing happens.

Additionally, we'll need to scope the update records for #undefs, so
they only kick in when the submodule containing that update record
becomes visible.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165682 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-11 00:46:49 +00:00
Argyrios Kyrtzidis 62288edde2 When indexing a module file, for the ppIncludedFile callback give
an invalid location if the location points to the synthetic buffer
for the module input.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165592 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-10 02:12:47 +00:00
Argyrios Kyrtzidis 2a85718005 [modules] Consistently construct a buffer as input to build the module.
This means the main file for modules will always be a virtual one.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165591 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-10 02:12:39 +00:00
Douglas Gregor a8235d6c40 Rework the (de-)serialization of macros, as stored in
MacroInfo*. Instead of simply dumping an offset into the current file,
give each macro definition a proper ID with all of the standard
modules-remapping facilities. Additionally, when a macro is modified
in a subsequent AST file (e.g., #undef'ing a macro loaded from another
module or from a precompiled header), provide a macro update record
rather than rewriting the entire macro definition. This gives us
greater consistency with the way we handle declarations, and ties
together macro definitions much more cleanly.

Note that we're still not actually deserializing macro history (we
never were), but it's far easy to do properly now.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165560 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-09 23:05:51 +00:00
Douglas Gregor ce12d2f886 Make the order of visitation of the pending bodies in the AST reader
deterministic.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165515 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-09 17:50:23 +00:00
Douglas Gregor 5456b0fe40 When we load a function or method body from an AST file, we check
whether that function/method already has a body (loaded from some
other AST file), as introduced in r165137. Delay this check until
after the redeclaration chains have been wired up.

While I'm here, make the loading of method bodies lazy.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165513 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-09 17:21:28 +00:00
Douglas Gregor 3644d97009 If a macro has been #undef'd in a precompiled header, we still need to
write out the macro history for that macro. Similarly, we need to cope
with reading a macro definition that has been #undef'd.

Take advantage of this new ability so that global code-completion
results can refer to #undef'd macros, rather than losing them
entirely. For multiply defined/#undef'd macros, we will still get the
wrong result, but it's better than getting no result.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165502 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-09 16:01:50 +00:00
Argyrios Kyrtzidis c7782d96c6 [Modules] Introduce Module::TopHeaders which is a set of top-level headers
that are associated with a (sub)module.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165279 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-05 00:22:33 +00:00
Abramo Bagnara 59c0a818a7 Fixed FunctionTypeLoc source range.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165259 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-04 21:42:10 +00:00
Douglas Gregor e5fa3c2691 Revert most of the functionality in r165001. Instead, make sure that
the ASTReader doesn't attach a body to a function that is already
defined elsewhere.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165137 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-03 18:34:48 +00:00
Argyrios Kyrtzidis d64c26f667 Set the file entry for a Module* that was created during deserialization
of a module file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165086 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-03 01:58:42 +00:00
Argyrios Kyrtzidis 2093e0bc4e [libclang] When indexing an AST file, only deserialize the file level
declarations of the current primary module.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165046 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-02 21:09:13 +00:00
Argyrios Kyrtzidis 632dcc92f6 [libclang] When indexing an AST file, only deserialize the preprocessing record
entities of the current primary module.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165023 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-02 16:10:51 +00:00
Argyrios Kyrtzidis 8dd927cf03 Add info in the preprocessing record whether an inclusion directive
resulted in an automatic module import.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165022 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-02 16:10:46 +00:00
Axel Naumann 38c3bb40c2 Only those InterestingDecls that got added to the AST should be passed to the ASTConsumer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165001 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-02 12:18:46 +00:00
Axel Naumann 39d26c3e49 Merge pending instantiations instead of overwriting existing ones.
Check whether a pending instantiation needs to be instantiated (or whether an instantiation already exists).
Verify the size of the PendingInstantiations record (was only checking size of existing PendingInstantiations).

Migrate Obj-C++ part of redecl-merge into separate test, now that this is growing.
templates.mm: test that CodeGen has seen exactly one definition of template instantiations.
redecl-merge.m: use "@" specifier for expected-diagnostics.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164993 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-02 09:09:43 +00:00