Commit Graph

454 Commits

Author SHA1 Message Date
Rafael Espindola 47de149565 Return a pointer instead of having a pointer outparam and a bool return.
llvm-svn: 234590
2015-04-10 12:54:53 +00:00
Yaron Keren 92e1b62d45 Remove many superfluous SmallString::str() calls.
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-03-18 10:17:07 +00:00
Chandler Carruth 0d745bcf66 [modules] Teach the AST reader to handle the case of importing a module
with a subset of the existing target CPU features or mismatched CPU
names.

While we can't check that the CPU name used to build the module will end
up being able to codegen correctly for the translation unit, we actually
check that the imported features are a subset of the existing features.

While here, rewrite the code to use std::set_difference and have it
diagnose all of the differences found.

Test case added which walks the set relationships and ensures we
diagnose all the right cases and accept the others.

No functional change for implicit modules here, just better diagnostics.

llvm-svn: 232248
2015-03-14 04:47:43 +00:00
Argyrios Kyrtzidis f0b4cd1ed3 [ASTUnit] Fix crash when trying to load a module file via ASTUnit::LoadFromASTFile.
rdar://19997358

llvm-svn: 231060
2015-03-03 08:04:19 +00:00
Adrian Prantl cbc368c5b5 Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."
llvm-svn: 230454
2015-02-25 02:44:04 +00:00
Adrian Prantl 8bf7af3de8 Wrap clang module files in a Mach-O, ELF, or COFF container.
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-25 01:31:45 +00:00
Adrian Prantl a39924a1f8 Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."
This reverts commit r230305.
Off to fix another round of missing dependencies on various platforms.

llvm-svn: 230309
2015-02-24 05:14:17 +00:00
Adrian Prantl fc360dc30b Wrap clang module files in a Mach-O, ELF, or COFF container.
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-24 04:25:59 +00:00
Adrian Prantl 67fbfa3773 Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."
This reverts commit 230099.

The Linux configure+make build variant still needs some work.

llvm-svn: 230103
2015-02-21 00:29:14 +00:00
Adrian Prantl f2b0cd91eb Wrap clang module files in a Mach-O, ELF, or COFF container.
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-20 23:34:26 +00:00
Adrian Prantl 690b2f7746 Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."
This reverts commit r230067.

Investigating another batch of problems found by the bots.

llvm-svn: 230073
2015-02-20 22:12:19 +00:00
Adrian Prantl b59bc1a528 Wrap clang module files in a Mach-O, ELF, or COFF container.
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-20 21:53:12 +00:00
Adrian Prantl a4f522fa19 Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."
This reverts commit r230044 while dealing with buildbot breakage.

Conflicts:
	test/Modules/module_container.m

llvm-svn: 230052
2015-02-20 20:00:27 +00:00
Adrian Prantl c4091aa74e Wrap clang module files in a Mach-O, ELF, or COFF container.
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
2015-02-20 19:44:52 +00:00
Benjamin Kramer a401b9b267 ASTUnit: Fix a name clash in GCC builds.
Should fix the build. Looks like GCC 4.9 is using different scoping rules for
range-based for loops.

llvm-svn: 228424
2015-02-06 18:58:04 +00:00
Benjamin Kramer 6a96ae5ecb ASTUnit: Use range-based for loops.
llvm-svn: 228420
2015-02-06 18:36:04 +00:00
Benjamin Kramer b4ef66832d Update APIs that return a pair of iterators to return an iterator_range instead.
Convert uses of those APIs into ranged for loops. NFC.

llvm-svn: 228404
2015-02-06 17:25:10 +00:00
Alexander Kornienko 41c247a677 Make DiagnosticsEngine::takeClient return std::unique_ptr<>
Summary:
Make DiagnosticsEngine::takeClient return std::unique_ptr<>. Updated
callers to store conditional ownership using a pair of pointer and unique_ptr
instead of a pointer + bool. Updated code that temporarily registers clients to
use the non-owning registration (+ removed extra calls to takeClient).

Reviewers: dblaikie

Reviewed By: dblaikie

Subscribers: cfe-commits

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

llvm-svn: 222193
2014-11-17 23:46:02 +00:00
Argyrios Kyrtzidis 06e8d69ac7 [libclang] Disable spell-checking and warnings during code-completion since they are not needed.
llvm-svn: 220966
2014-10-31 16:44:32 +00:00
Richard Smith 1e2cf0dd4b [modules] When a .pcm file is explicitly built separately from the translation
unit, allow the -O settings of the two compilations to differ.

llvm-svn: 220943
2014-10-31 02:28:58 +00:00
Benjamin Kramer a885796d5f Make VFS and FileManager match the current MemoryBuffer API.
This eliminates converting back and forth between the 3 formats and
gives us a more homogeneous interface.

llvm-svn: 220657
2014-10-26 22:44:13 +00:00
Richard Smith e842a47452 [modules] Initial support for explicitly loading .pcm files.
Implicit module builds are not well-suited to a lot of build systems. In
particular, they fare badly in distributed build systems, and they lead to
build artifacts that are not tracked as part of the usual dependency management
process. This change allows explicitly-built module files (which are already
supported through the -emit-module flag) to be explicitly loaded into a build,
allowing build systems to opt to manage module builds and dependencies
themselves.

This is only the first step in supporting such configurations, and it should
be considered experimental and subject to change or removal for now.

llvm-svn: 220359
2014-10-22 02:05:46 +00:00
Justin Bogner d512c1edf0 Frontend: Don't accept null DiagnosticsEngines when building ASTUnits
The various ways to create an ASTUnit all take a refcounted pointer to
a diagnostics engine as an argument, and if it isn't pointing at
anything they initialize it. This is a pretty confusing API, and it
really makes more sense for the caller to initialize the thing since
they control the lifetime anyway.

This fixes the one caller that didn't bother initializing the pointer
and asserts that the argument is initialized.

llvm-svn: 219752
2014-10-15 00:33:06 +00:00
Justin Bogner dbbcb11f0e Frontend: Remove some unused arguments in ASTUnit (NFC)
llvm-svn: 219747
2014-10-14 23:36:06 +00:00
Benjamin Kramer 1a6e0a9b40 ASTUnit: Replace out parameter with return value, we have NRVO for this.
And elide the copy when pushing the return value into a vector. NFC.

llvm-svn: 219001
2014-10-03 18:52:54 +00:00
Craig Topper b8a7053055 Unique_ptrify PPCallbacks ownership.
Unique_ptr creation stil needs to be moved earlier at some of the call sites.

llvm-svn: 217474
2014-09-10 04:53:53 +00:00
David Blaikie d6902a1403 Improve unique_ptr-y ownership in ASTUnit::ComputePreamble
Rather than having a pair of pairs and a reference out parameter, build
a structure with everything together and named. A raw pointer and a
unique_ptr, rather than a raw pointer and a boolean, are used to
communicate ownership transfer.

It's possible one day we'll end up with a conditional pointer (probably
represented by a raw pointer and a boolean) abstraction to use in places
like this. Conditional ownership seems to be coming up more often than
I'd hoped...

llvm-svn: 216712
2014-08-29 06:34:53 +00:00
Alexey Samsonov b4f99dd077 Don't create a null reference in ASTUnit::LoadFromCommandLine.
This change is the last in the pack of five commits
(also see r216691, r216694, r216695, and r216696) that reduces the number
of test failures in "check-clang" invocation in UBSan bootstrap
from 2443 down to 5.

llvm-svn: 216697
2014-08-28 23:51:01 +00:00
Rafael Espindola d87f8d76e0 Update for LLVM api change.
llvm-svn: 216585
2014-08-27 20:03:29 +00:00
Rafael Espindola 16e1ba1e0b Return a std::unique_ptr from getBufferForFile. NFC.
llvm-svn: 216478
2014-08-26 20:17:44 +00:00
Rafael Espindola 6406f7b8e0 Return a std::unique_ptr from getBufferForFile. NFC.
llvm-svn: 216476
2014-08-26 19:54:40 +00:00
Dylan Noblesmith cdd3151987 Frontend: unique_ptr-ify
NFC.

llvm-svn: 216347
2014-08-24 18:59:52 +00:00
Rafael Espindola 2346a37599 return a std::unique_ptr from getMainBufferWithPrecompiledPreamble. NFC.
llvm-svn: 215927
2014-08-18 18:47:08 +00:00
Rafael Espindola 32482080fe Simplify ASTUnit::Parse a bit by passing a std::unique_ptr to it.
llvm-svn: 215900
2014-08-18 16:23:45 +00:00
Rafael Espindola 4674a876cd Small cleanup: Don't duplicate default behavior.
std::unique_ptr is null initialized and reset default to null.

Thanks to David Blaikie for noticing.

llvm-svn: 215560
2014-08-13 17:08:22 +00:00
Rafael Espindola fa49c0bf10 Use std::unique_ptr to simplify memory management a bit.
llvm-svn: 215559
2014-08-13 16:47:00 +00:00
Rafael Espindola cd0b380a3c Use StringRef instead of MemoryBuffer&.
This code doesn't care where the data it is processing comes from, so a
StringRef is probably the most natural interface.

llvm-svn: 215448
2014-08-12 15:46:24 +00:00
David Blaikie 3d95d858f9 Change MemoryBuffer* to MemoryBuffer& parameter to Lexer::ComputePreamble
(dropping const from the reference as MemoryBuffer is immutable already,
so const is just redundant - and while I'd personally put const
everywhere, that's not the LLVM Way (see llvm::Type for another example
of an immutable type where "const" is omitted for brevity))

Changing the pointer argument to a reference parameter makes call sites
identical between callers with unique_ptrs or raw pointers, minimizing
the churn in a pending unique_ptr migrations.

llvm-svn: 215391
2014-08-11 22:08:06 +00:00
David Blaikie 6beb6aa8f0 Recommit 213307: unique_ptr-ify ownership of ASTConsumers (reverted in r213325)
After post-commit review and community discussion, this seems like a
reasonable direction to continue, making ownership semantics explicit in
the source using the type system.

llvm-svn: 215323
2014-08-10 19:56:51 +00:00
David Blaikie ec99b5ee0d unique_ptr-ify CompilerInstance::takeSema
llvm-svn: 215321
2014-08-10 19:14:48 +00:00
David Blaikie 6f7382ddd1 std::unique_ptr-ify the result of ASTUnit::LoadFromASTFile
llvm-svn: 215320
2014-08-10 19:08:04 +00:00
David Blaikie 2721c32e47 unique_ptr-ify ASTReaderListener in the ASTReader
llvm-svn: 215317
2014-08-10 16:54:39 +00:00
David Blaikie 62a56f39b7 Revert "unique_ptr-ify ownership of ASTConsumers"
This reverts commit r213307.

Reverting to have some on-list discussion/confirmation about the ongoing
direction of smart pointer usage in the LLVM project.

llvm-svn: 213325
2014-07-17 22:34:12 +00:00
David Blaikie a51666a4d6 unique_ptr-ify ownership of ASTConsumers
(after fixing a bug in MultiplexConsumer I noticed the ownership of the
nested consumers was implemented with raw pointers - so this fixes
that... and follows the source back to its origin pushing unique_ptr
ownership up through there too)

llvm-svn: 213307
2014-07-17 20:40:36 +00:00
Alp Toker 221285bde7 Remove unused sys/stat.h includes
The facility was abstracted to LLVM in r187364.

llvm-svn: 212441
2014-07-07 08:37:15 +00:00
Alp Toker 1b070d25ca Peel away old-style file remapping typedefs and cruft
llvm-svn: 212438
2014-07-07 07:47:20 +00:00
Alp Toker 80758084f7 Use non-intrusive refcounting for TargetOptions
llvm-svn: 212388
2014-07-06 05:26:44 +00:00
Alp Toker 269d840e40 Use non-intrusive refcounting for LangOptions
This type is only refcounted in a couple of places so making ownership explicit
improves clarity.

llvm-svn: 212387
2014-07-06 05:26:07 +00:00
Alp Toker 74437975c4 Constify a read-only parameter and give function a better name
This makes it clear that TargetInfo doesn't capture the LangOptions object,
rather uses it to apply adjustments.

llvm-svn: 212386
2014-07-06 05:14:24 +00:00
Alp Toker f994cef836 Track IntrusiveRefCntPtr::get() changes from LLVM r212366
llvm-svn: 212369
2014-07-05 03:08:06 +00:00