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

499 Коммитов

Автор SHA1 Сообщение Дата
Argyrios Kyrtzidis 5e24f2d830 [PCH] Make the new PCH format (control block) backwards compatible and
don't crash when loading a PCH with the older format.

The introduction of the control block broke compatibility with PCHs from
older versions. This patch allows loading (and rejecting) PCHs from an older
version and allows newer PCHs to be rejected from older clang versions as well.

rdar://12821386

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170150 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-13 21:38:23 +00:00
Argyrios Kyrtzidis f64d25c633 [PCH] Remove redundant stat call when validating the input files.
This became redundant after we removed the stat cache.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169830 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-11 07:48:14 +00:00
Chandler Carruth 55fc873017 Sort all of Clang's files under 'lib', and fix up the broken headers
uncovered.

This required manually correcting all of the incorrect main-module
headers I could find, and running the new llvm/utils/sort_includes.py
script over the files.

I also manually added quite a few missing headers that were uncovered by
shuffling the order or moving headers up to be main-module-headers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169237 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 09:13:33 +00:00
Argyrios Kyrtzidis 37ed12720a Refactor recording the preprocessor conditional directive regions out of
PreprocessingRecord and into its own class, PPConditionalDirectiveRecord.

Decoupling allows a client to use the functionality of PPConditionalDirectiveRecord
without needing a PreprocessingRecord.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169229 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 07:27:05 +00:00
Douglas Gregor 6c3254316d When we're emitting a diagnostic with a source location in an imported
module, provide a module import stack similar to what we would get for
an include stack, e.g.,

In module 'DependsOnModule' imported from build-fail-notes.m:4:
In module 'Module' imported from DependsOnModule.framework/Headers/DependsOnModule.h:1:
Inputs/Module.framework/Headers/Module.h:15:12: note: previous definition is here
@interface Module

<rdar://problem/12696425>


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169042 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-30 21:58:49 +00:00
Douglas Gregor 87e2cfcec7 Actually keep track of the source locations at which particular module
files are loaded.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169027 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-30 19:28:05 +00:00
Argyrios Kyrtzidis 2a82ca255b Introduce ASTUnresolvedSet, an UnresolvedSet-like class, whose contents are
allocated using the allocator associated with an ASTContext.

Use this inside CXXRecordDecl::DefinitionData instead of an UnresolvedSet to
avoid a potential memory leak.

rdar://12761275

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168771 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-28 03:56:16 +00:00
Argyrios Kyrtzidis 992d917421 [modules] Use a memory buffer directly as input for the module includes,
instead of messing with virtual files.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168062 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-15 18:57:27 +00:00
Argyrios Kyrtzidis 958bcaf3d4 [modules] Setup the import location of a module file and use it
as the include location of the main file of an imported module.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168061 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-15 18:57:22 +00:00
Eli Friedman 4fa4b48027 Suppress elided variadic macro argument extension diagnostic for macros using
the related comma pasting extension.

In certain cases, we used to get two diagnostics for what is essentially one
extension.  This change suppresses the first diagnostic in certain cases
where we know we're going to print the second diagnostic.  The
diagnostic is redundant, and it can't be suppressed in the definition
of the macro because it points at the use of the macro, so we want to
avoid printing it if possible.

The implementation works by detecting constructs which look like comma
pasting at the time of the definition of the macro; this information
is then used when the macro is used.  (We can't actually detect
whether we're using the comma pasting extension until the macro is
actually used, but we can detecting constructs which will be comma
pasting if the varargs argument is elided.)

<rdar://problem/12292192>



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167907 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-14 02:18:46 +00:00
Argyrios Kyrtzidis ecd27bf256 Add a FileCharacteristic parameter to SourceManager::createFileIDForMemBuffer
for completeness and use it in CompilerInstance::InitializeSourceManager if
the input is a memory buffer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167628 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-09 19:40:45 +00:00
Douglas Gregor 7cdd28162d When loading a module fails because it is out of date, rebuild that
module in place. <rdar://problem/10138913>


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167539 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-07 17:46:15 +00:00
Douglas Gregor 9e60371ba0 Tease out the routine that reads the control block of an AST file from
the validation of an AST file against a specific set of options.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167504 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-06 23:40:54 +00:00
Argyrios Kyrtzidis 23de7cedc7 [PCH] Take into account the 'include' source location of a SM_SLOC_BUFFER_ENTRY.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167426 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-06 00:35:04 +00:00
Argyrios Kyrtzidis ce254928e9 [libclang] Correct how the index inside the local preprocessed entities array
is getting converted to a global PreprocessedEntityID.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167280 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-02 02:31:22 +00:00
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