Commit Graph

1375 Commits

Author SHA1 Message Date
Rafael Espindola 8a8e554adc Include system_error directly.
llvm-svn: 210802
2014-06-12 17:19:42 +00:00
Rafael Espindola c080917ec2 Replace llvm::error_code with std::error_code.
llvm-svn: 210780
2014-06-12 14:02:15 +00:00
Alp Toker 46df1c0db8 Complete the switch from mappings to declarative diagnostic severities
This begins to address cognitive dissonance caused by treating the Note
diagnostic level as a severity in the diagnostic engine.

No change in functionality.

llvm-svn: 210758
2014-06-12 10:15:20 +00:00
Alp Toker c726c367f4 Improve diagnostic mapping terminology
Diagnostic mappings are used to calculate the final severity of diagnostic
instances.

Detangle the implementation to reflect the terminology used in documentation
and bindings.

No change in functionality.

llvm-svn: 210518
2014-06-10 09:31:37 +00:00
Alexander Musman 1bb328cca5 [OPENMP] Parsing/Sema for OMPLasprivateClause.
Parsing this clause, allowing it on directive ‘omp simd’ and semantic checks.

llvm-svn: 210184
2014-06-04 13:06:39 +00:00
Rafael Espindola 3ae0620a45 There is no std::errc:success, remove the llvm one.
llvm-svn: 209959
2014-05-31 03:20:52 +00:00
Ben Langmuir 4f05478c97 Invalidate the file system cache entries for files that may rebuild
This reapplies r209910 with a fix for the assertion failures hit on the
buildbots.

original commit message:
I thought we could get away without this, but it means that the
FileEntry objects actually refer to the wrong files, since pcms are not
updated inplace, they are atomically renamed into place after compiling
a module.

So we are close to the original behaviour of invalidating the cache for
all modules being removed, but now we should only invalidate the ones
that depend on whichever module failed to load.

Unfortunately I haven't come up with a new test that didn't require
a race between parallel invocations of clang.

<rdar://problem/17038180>

llvm-svn: 209922
2014-05-30 21:20:54 +00:00
Ben Langmuir e45b4e328f Revert "Invalidate the file system cache entries for files that may rebuild"
This reverts commit r209910, which is breaking some of the bots.

llvm-svn: 209911
2014-05-30 17:54:59 +00:00
Ben Langmuir 04b9c70da6 Invalidate the file system cache entries for files that may rebuild
I thought we could get away without this, but it means that the
FileEntry objects actually refer to the wrong files, since pcms are not
updated inplace, they are atomically renamed into place after compiling
a module.

So we are close to the original behaviour of invalidating the cache for
all modules being removed, but now we should only invalidate the ones
that depend on whichever module failed to load.

Unfortunately I haven't come up with a new test that didn't require
a race between parallel invocations of clang.

<rdar://problem/17038180>

llvm-svn: 209910
2014-05-30 17:42:15 +00:00
Alexander Musman f0d76e7dc3 Parsing/Sema for OMPAlignedClause.
llvm-svn: 209816
2014-05-29 14:36:25 +00:00
Richard Smith 195d8ef452 When merging functions across modules (and in particular, instantiations of
member functions), ensure that the redecl chain never transitions from 'inline'
to 'not inline', since that violates an AST invariant.

llvm-svn: 209794
2014-05-29 03:15:31 +00:00
Alexander Musman 8bd31e69a4 Parsing/Sema for OMPCollapseClause.
Actual usage in Sema for collapsing loops will in some future patch.

llvm-svn: 209660
2014-05-27 15:12:19 +00:00
Richard Smith a1406fa513 Recompute the injected class name type for a class template specialization
rather than saving and restoring it.

llvm-svn: 209557
2014-05-23 21:31:59 +00:00
Dario Domizioli 13a0a38fe0 Implemented support for "pragma clang optimize on/off", based on attribute 'optnone'.
This patch implements support for selectively disabling optimizations on a
range of function definitions through a pragma. The implementation is that
all function definitions in the range are decorated with attribute
'optnone'.

    #pragma clang optimize off
    // All function definitions in here are decorated with 'optnone'.
    #pragma clang optimize on
    // Compilation resumes as normal.

llvm-svn: 209510
2014-05-23 12:13:25 +00:00
Richard Smith 64c0630585 Avoid allocating extra memory to handle the lazy definition data pointer for
CXXRecordDecls when modules is enabled.

llvm-svn: 209482
2014-05-22 23:19:02 +00:00
Richard Smith df3520581a If a class template specialization from one module has its definition
instantiated in another module, and the instantiation uses a partial
specialization, include the partial specialization and its template arguments
in the update record. We'll need them if someone imports the second module and
tries to instantiate a member of the template.

llvm-svn: 209472
2014-05-22 20:59:29 +00:00
Justin Bogner c65a66ddfe Frontend: Propagate ASTReaderListener API in ChainedASTReaderListener
ASTReaderListener's documentation states that visitInputFile will be
called based on the return values of needsInputFileVisitation and
needsSystemInputFileVisitation, but ChainedASTReaderListener may call
these methods on a child listener based on the values returned by the
other child.

Even worse, the calls to visitInputFile may be short-circuited due to
the use of the boolean or, so the calls to visit may not occur at all
for the second listener.

This updates ChainedASTReaderListener::visitInputFile to propagate the
ASTReaderListener behaviour to both children.

llvm-svn: 209394
2014-05-22 06:04:59 +00:00
Craig Topper a13603a247 [C++11] Use 'nullptr'. Serialization edition.
llvm-svn: 209392
2014-05-22 05:54:18 +00:00
Ben Langmuir 5988590363 Speculative fix for Windows buildbot after r209138
It appears that Windows doesn't like renaming over open files, which we
do in clearOutputFiles. The file being compiled should be safe to
removed, but this isn't very satisfying - we don't want to manually
manage the lifetime of files we cannot prove have no references.

llvm-svn: 209195
2014-05-20 05:55:04 +00:00
Richard Smith 851072efb7 If two sibling modules declare the same entity, and we indirectly pull a
declaration of that entity in from one of those modules, keep track of the fact
that we've not completed the redeclaration chain yet so that we can pull the
remaining declarations in from the other module if they're needed.

llvm-svn: 209161
2014-05-19 20:59:20 +00:00
Ben Langmuir caea13185e Don't refresh stat() info for pcm files
Follow-up fix for 209138.  Actually, since we already have this file
open, we don't want to refresh the stat() info, since that might be
newer than what we have open (bad!).

llvm-svn: 209143
2014-05-19 17:04:28 +00:00
Ben Langmuir ca39214f4e Fix use-after-free and spurious error during module load
FileManager::invalidateCache is not safe to call when there may be
existing references to the file. What module load failure needs is
to refresh so stale stat() info isn't stored.

This may be the last user of invalidateCache; I'll take a look and
remove it if possible in a future commit.

This caused a use-after-free error as well as a spurious error message
that a module was "found in both 'X.pcm' and 'X.pcm'" in some cases.

llvm-svn: 209138
2014-05-19 16:13:45 +00:00
Richard Smith 053f6c6c9e If a declaration is loaded, and then a module import adds a redeclaration, then
ensure that querying the first declaration for its most recent declaration
checks for redeclarations from the imported module.

This works as follows:
 * The 'most recent' pointer on a canonical declaration grows a pointer to the
   external AST source and a generation number (space- and time-optimized for
   the case where there is no external source).
 * Each time the 'most recent' pointer is queried, if it has an external source,
   we check whether it's up to date, and update it if not.
 * The ancillary data stored on the canonical declaration is allocated lazily
   to avoid filling it in for declarations that end up being non-canonical.
   We'll still perform a redundant (ASTContext) allocation if someone asks for
   the most recent declaration from a decl before setPreviousDecl is called,
   but such cases are probably all bugs, and are now easy to find.

Some finessing is still in order here -- in particular, we use a very general
mechanism for handling the DefinitionData pointer on CXXRecordData, and a more
targeted approach would be more compact.

Also, the MayHaveOutOfDateDef mechanism should now be expunged, since it was
addressing only a corner of the full problem space here. That's not covered
by this patch.

Early performance benchmarks show that this makes no measurable difference to 
Clang performance without modules enabled (and fixes a major correctness issue
with modules enabled). I'll revert if a full performance comparison shows any
problems.

llvm-svn: 209046
2014-05-16 23:01:30 +00:00
Alp Toker 2e9ce4c565 Merge a couple of copy-and-pasted functions
No change in functionality.

llvm-svn: 209005
2014-05-16 18:59:21 +00:00
Alp Toker 6ac2cd01d2 Rename SourceManager::createFileIDForMemBuffer()
It makes more sense to just overload createFileID().

Gardening only.

llvm-svn: 209002
2014-05-16 17:23:01 +00:00
Aaron Ballman f3d9b09dea No longer triggering a checked iterator assert on Windows when using std::copy while deserializing attributed statements with more than one attribute.
llvm-svn: 208702
2014-05-13 14:55:01 +00:00
Richard Smith b321ecbdcf Refactor to avoid explicitly listing all the different flavours of redeclarable
declarations, and duplicating code between them.

llvm-svn: 208662
2014-05-13 01:15:00 +00:00
Benjamin Kramer f3ca269839 Decouple ExprCXX.h and DeclCXX.h and clean up includes a bit.
Required pulling LambdaExpr::Capture into its own header.
No functionality change.

llvm-svn: 208470
2014-05-10 16:31:55 +00:00
Nico Weber 824285ec53 Let ASTReader optionally delete its ASTDeserializationListener.
Use this to fix the leak of DeserializedDeclsDumper and DeserializedDeclsChecker
in FrontendAction (found by LSan), PR19560.

The "delete this" bool is necessary because both PCHGenerator and ASTUnit
return the same object from both getDeserializationListener() and
getASTMutationListener(), so ASTReader can't just have a unique_ptr.

It's also not possible to just let FrontendAction (or CompilerInstance) own
these listeners due to lifetime issues (see comments on PR19560).

Finally, ASTDeserializationListener can't easily be refcounted, since several of
the current listeners are allocated on the stack.

Having this bool isn't ideal, but it's a pattern that's used in other places in
the codebase too, and it seems better than leaking.

llvm-svn: 208277
2014-05-08 04:26:47 +00:00
Richard Smith 93914a9518 Fix latent bug. This can't actually manifest at the moment, but is a time-bomb
for the next time someone adds something to this function.

llvm-svn: 208270
2014-05-08 00:25:01 +00:00
Alexey Bataev 9959db5fa9 [OPENMP] Initial codegen for '#pragma omp parallel'
llvm-svn: 208077
2014-05-06 10:08:46 +00:00
Alexey Bataev bcbadb65ab [OPENMP] 'proc_bind' clause support - Parsing and sema analysis for OpenMP clause 'proc_bind'
llvm-svn: 208060
2014-05-06 06:04:14 +00:00
Ben Langmuir 027731d7b5 Fix a use-after-free bug I recently introduced in lookupModuleFile
llvm-svn: 207932
2014-05-04 05:20:54 +00:00
Benjamin Kramer 834652ade0 Replace one-element SmallVectors inside DenseMaps with TinyPtrVector.
That's exactly what TinyPtrVector was designed for. No functionality change.

llvm-svn: 207919
2014-05-03 18:44:26 +00:00
David Majnemer daff37013c AST: Mangle reference temporaries reliably
Summary:
Previously, we would generate a single name for all reference
temporaries and allow LLVM to rename them for us.  Instead, number the
reference temporaries as we build them in Sema.

Reviewers: rsmith

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D3554

llvm-svn: 207776
2014-05-01 17:50:17 +00:00
Ben Langmuir 05f82ba252 Avoid a potential race between stat() and open() of ASTFile
We need to open an ASTFile while checking its expected size and
modification time, or another clang instance can modify the file between
the stat() and the open().

llvm-svn: 207735
2014-05-01 03:33:36 +00:00
Richard Smith d1c4674603 Defer loading any pending update records until we've finished deserializing.
This fixes a bug where an update record causes us to load an entity that refers
to an entity we've not finished loading yet, resulting in badness.

llvm-svn: 207603
2014-04-30 02:24:17 +00:00
Argyrios Kyrtzidis fe6b880de5 [PCH/Modules] Don't tie TargetOptions::LinkerVersion to a module/PCH, it's a driver only thing and doesn't affect any language/preprocessor/etc. semantics.
rdar://16714526

llvm-svn: 207570
2014-04-29 18:45:01 +00:00
Ben Langmuir b92de02f17 Reapply r207477 and r207479 without cyclic dependency
Fixed by moving ProcessWarningOptions from Frontend into Basic. All of
the dependencies for ProcessWarningOptions were already in Basic, so
this was a small change.

llvm-svn: 207549
2014-04-29 16:25:26 +00:00
NAKAMURA Takumi 366363dac1 Revert r207477 (and r207479), "Check -Werror options during module validation"
It tried to introduce cyclic dependencies. Serialization shouldn't depend on Frontend, since Frontend depends on Serialization.

llvm-svn: 207497
2014-04-29 06:58:59 +00:00
Ben Langmuir be84adbf1b Check -Werror options during module validation
This patch checks whether the diagnostic options that could lead to
errors (principally -Werror) are consistent between when a module was
built and when it is loaded.  If there are new -Werror flags, then the
module is rebuilt.  In order to canonicalize the options we do this
check at the level of the constructed DiagnosticsEngine, which contains
the final set of diag to diagnostic level mappings.  Currently we only
rebuild with the new diagnostic options, but we intend to refine this in
the future to include the union of the new and old flags, since we know
the old ones did not cause errors.  System modules are only rebuilt when
-Wsystem-headers is enabled.

One oddity is that unlike checking language options, we don’t perform
this diagnostic option checking when loading from a precompiled header.
The reason for this is that the compiler cannot rebuild the PCH, so
anything that requires it to be rebuilt effectively leaks into the build
system.  And in this case, that would mean the build system
understanding the complex relationship between diagnostic options and
the underlying diagnostic mappings, which is unreasonable.  Skipping the
check is safe, because these options do not affect the generated AST.
You simply won’t get new build errors due to changed -Werror options
automatically, which is also true for non-module cases.

llvm-svn: 207477
2014-04-29 00:36:53 +00:00
Nico Weber e68b847fdb Fix leak of GlobalModuleIndex::IdentifierIndex, found by LSan.
llvm-svn: 207262
2014-04-25 19:45:23 +00:00
Richard Smith f17fdbd791 When two templates get merged together, also merge their pattern declarations
together. This is extremely hairy, because in general we need to have loaded
both the template and the pattern before we can determine whether either should
be merged, so we temporarily violate the rule that all merging happens before
reading a decl ends, but *only* in the case where a template's pattern is being
loaded while loading the template itself.

In order to accomodate this for class templates, delay loading the injected
class name type for the pattern of the template until after we've loaded the
template itself, if we happen to load the template first.

llvm-svn: 207063
2014-04-24 02:25:27 +00:00
Richard Smith 5b21db89d0 Make TypeDecl much less friendly.
llvm-svn: 207007
2014-04-23 18:20:42 +00:00
Alexander Musman 8dba66412b [OPENMP] parsing 'linear' clause (for directive 'omp simd')
Differential Revision: http://reviews.llvm.org/D3272

llvm-svn: 206891
2014-04-22 13:09:42 +00:00
Richard Smith cd45dbc5f2 When a module completes the definition of a class template specialization imported from another module, emit an update record, rather than using the broken decl rewriting mechanism. If multiple modules do this, merge the definitions together, much as we would if they were separate declarations.
llvm-svn: 206680
2014-04-19 03:48:30 +00:00
Justin Bogner 25463f1577 Teach users of OnDiskHashTable to define hash_value and offset types
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-18 20:27:24 +00:00
Justin Bogner bb094f0669 Remove OnDiskHashTable.h, since it's been moved to llvm
llvm-svn: 206637
2014-04-18 19:57:06 +00:00
Richard Smith b45a6f72b6 Add missing serialization code for one of the CXXRecordDecl definition flags.
llvm-svn: 206493
2014-04-17 20:33:01 +00:00
John Thompson 4f52d44dce Revised per Dmitri's comments. My first exposure to range-based for loops, thanks!
llvm-svn: 206483
2014-04-17 18:17:36 +00:00