Commit Graph

51 Commits

Author SHA1 Message Date
Adrian Prantl 3285546c97 -gmodules: Emit debug info for implicit module imports via #include.
When a type is only used as a template parameter and that type is the
only type imported from another #include'd module, no skeleton CU for
that module is generated, so a consumer doesn't know where to find the
type definition. By emitting an import declaration, we can force a
skeleton CU to be generated for each imported module.

rdar://problem/36266156

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321754 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-03 19:10:21 +00:00
Adrian Prantl 9b777b26d9 Simplify code (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321750 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-03 18:31:04 +00:00
Adrian Prantl 567034c312 Debug Info: Set the MainFileName when generating -gmodules debug info for PCM.
Previously it was uninitialized and thus always defaulted to "<stdin>".
This is mostly a cosmetic change that helps making the debug info more readable.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@308397 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-18 23:58:34 +00:00
Duncan P. N. Exon Smith d15b1db69a Modules: Use hash of PCM content for SIGNATURE
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!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@297655 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-13 18:45:08 +00:00
Saleem Abdulrasool 72e537abaf CodeGen: plumb header search down to the IAS
inline assembly may use the `.include` directive to include other
content into the file.  Without the integrated assembler, the `-I` group
gets passed to the assembler.  Emulate this by collecting the header
search paths and passing them to the IAS.

Resolves PR24811!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291123 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-05 16:02:32 +00:00
Peter Collingbourne cf26f429e8 Bitcode: Decouple block info block state from reader.
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@286207 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-08 04:17:11 +00:00
Peter Collingbourne 202d09ece4 Bitcode: Change reader interface to take memory buffers.
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@285773 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-02 00:08:19 +00:00
Adrian Prantl e6658afdf3 Support object-file-wrapped modules in clang -module-file-info.
rdar://problem/24504815

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@279004 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-17 23:13:53 +00:00
Peter Collingbourne f1bc23840f Frontend: Simplify ownership model for clang's output streams.
This changes the CompilerInstance::createOutputFile function to return
a std::unique_ptr<llvm::raw_ostream>, rather than an llvm::raw_ostream
implicitly owned by the CompilerInstance. This in most cases required that
I move ownership of the output stream to the relevant ASTConsumer.

The motivation for this change is to allow BackendConsumer to be a client
of interfaces such as D20268 which take ownership of the output stream.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@275507 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 00:55:40 +00:00
David Majnemer ba5c7ce848 Use more ArrayRefs
No functional change is intended, just a small refactoring.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@273647 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24 04:05:48 +00:00
Benjamin Kramer 4ff480f17c Apply clang-tidy's misc-move-constructor-init throughout Clang.
No functionality change intended, maybe a tiny performance improvement.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@270996 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 14:27:13 +00:00
David Blaikie 6bd4c225fc [modules][debuginfo] Only include imported modules when targeting LLDB
These constructs are only applicable to a debugger capable of loading a
Clang AST, so omit them for brevity when not doing so.

We could potentially propagate more of CodeGenOptions through the
ObjectFilePCGContainerOperations for consistency (so the next person who
adds some CodeGenOpts feature that tweaks debug info output doesn't get
caught by this), so I'm open to objections/alternatives there, but went
with this for now.

Tested just a couple of basic cases (one direct, one indirect (through
the ObjectFilePCHContainerOperations) & fixed up other cases to pass the
-debugger-tuning flag as appropriate.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@268460 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-03 23:06:40 +00:00
Saleem Abdulrasool fdc51a5580 revert SVN r265702, r265640
Revert the two changes to thread CodeGenOptions into the TargetInfo allocation
and to fix the layering violation by moving CodeGenOptions into Basic.
Code Generation is arguably not particularly "basic".  This addresses Richard's
post-commit review comments.  This change purely does the mechanical revert and
will be followed up with an alternate approach to thread the desired information
into TargetInfo.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@265806 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 16:52:00 +00:00
Saleem Abdulrasool 8cca4d7cdf Basic: move CodeGenOptions from Frontend
This is a mechanical move of CodeGenOptions from libFrontend to libBasic.  This
fixes the layering violation introduced earlier by threading CodeGenOptions into
TargetInfo.  It should also fix the modules based self-hosting builds.  NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@265702 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 17:49:44 +00:00
Adrian Prantl 45b0585fa2 Module Debugging: Fix a crash when emitting debug info for nested tag types
whose DeclContext is not yet complete by deferring their emission.

rdar://problem/24918680

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@262851 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-07 20:58:52 +00:00
James Y Knight e85ad57298 Make TargetInfo store an actual DataLayout instead of a string.
Use it to calculate UserLabelPrefix, instead of specifying it (often
incorrectly).

Note that the *actual* user label prefix has always come from the
DataLayout, and is handled within LLVM. The main thing clang's
TargetInfo::UserLabelPrefix did was to set the #define value. Having
these be different from each-other is just silly.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@262737 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-04 19:00:41 +00:00
Benjamin Kramer 1dde17c5ad Move DebugInfoKind into its own header to cut the cyclic dependency edge from Driver to Frontend.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@259489 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-02 11:06:51 +00:00
Adrian Prantl f5a6cecb8d Module Debugging: Canonicalize the file names used as PCH module names
by stripping the path. Follow-up to r258555.

This is safe because only one PCH per CU is currently supported for
module debugging.

rdar://problem/24301262

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258582 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-22 23:30:56 +00:00
Adrian Prantl d97ae762ac Module debugging: Create a parent DIModule with the PCH name for types
emitted into a precompiled header to mirror the debug info emitted for
object files importing the PCH.

rdar://problem/24290667

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258555 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-22 21:14:41 +00:00
Adrian Prantl c87ca354aa Fix the build by using the correct suffix for 64 bit literals
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258531 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-22 19:29:41 +00:00
Adrian Prantl 9fd9596d49 Fix a typo in r258507 and change the PCH dwoid constant to ~1UL.
rdar://problem/24290667

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258519 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-22 18:46:45 +00:00
Adrian Prantl a892974a4f Module Debugging: Use a nonzero DWO id for precompiled headers.
PCH files don't have a module signature and LLVM uses a nonzero DWO id as
an indicator for skeleton / module CUs. This change pins the DWO id for PCH
files to a known constant value.
The correct long-term solution here is to implement a module signature
that is an actual dterministic hash (at the moment module signatures are
just random nonzero numbers) and then enable this for PCH files as well.

<rdar://problem/24290667>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258507 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-22 17:43:43 +00:00
Adrian Prantl 135b6cd218 Module Debugging: Make sure that anonymous tag decls that define global
variables are visited.

This shouldn't encourage anyone to put global variables into clang modules.
rdar://problem/24199640

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258250 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-19 23:42:44 +00:00
Adrian Prantl ed2c14216c Module Debugging: Defer the emission of anonymous tag decls
until we are visiting their declcontext.

This fixes a regression introduced in r256962:
When building debug info for a typdef'd anonymous tag type, we would be
visiting the inner anonymous type first thus creating a "typedef changes
linkage of anonymous type, but linkage was already computed" error.

rdar://problem/24199640

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258152 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-19 18:02:47 +00:00
Adrian Prantl e74697e20e Module debugging: Defer emitting tag types until their definition
was visited and all decls have been merged.

We only get a single chance to emit the types for virtual classes because
CGDebugInfo::completeRequiredType() categorically doesn't complete them.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256962 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-06 19:22:19 +00:00
Adrian Prantl 00338de691 Module Debugging: Emit module debug info for types inside of Objective-C
containers.

rdar://problem/23196170

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251120 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-23 17:02:22 +00:00
Adrian Prantl 9bb39ed581 Remove a redundant check. NFC
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251116 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-23 16:51:32 +00:00
Adrian Prantl 73315f72a2 Module Debugging: Use the clang module signature as the module's dwo_id
when building a module. Clang already records the module signature when
building a skeleton CU to reference a clang module.

Matching the id in the skeleton with the one in the module allows a DWARF
consumer to verify that they found the correct version of the module
without them needing to know about the clang module format.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248345 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-22 23:26:43 +00:00
Adrian Prantl 9345c88c02 Debug Info: When building a module, emit skeleton CUs for imported modules.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248184 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-21 17:48:37 +00:00
Adrian Prantl a83de9f778 Module debugging: Support submodules in the PCM/PCH debug info.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248127 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-20 16:51:35 +00:00
Adrian Prantl e7217ff0c5 Further simplify the interface of PCHContainerGenerator
by dropping the const qualifier on the CI.

NFC

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248101 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-19 21:42:52 +00:00
Adrian Prantl 9083fb296d Eliminate a redundant check.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248068 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-19 00:10:25 +00:00
Adrian Prantl 5cc443cba8 Simplify the interface of PCHContainerGenerator and friends
by passing in a CompilerInstance instead of all its individual members.

NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248053 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-18 22:10:59 +00:00
Adrian Prantl 4e5a4032df Debug Info: Remove an unnecessary debug type visitor.
Thanks to dblaikie for spotting this.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247303 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-10 17:13:31 +00:00
Hans Wennborg 298c9cbb3d Re-commit r247218: "Fix Clang-tidy misc-use-override warnings, other minor fixes"
This never broke the build; it was the LLVM side, r247216, that caused problems.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247302 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-10 17:07:54 +00:00
Hans Wennborg 38a792cafd Revert r247218: "Fix Clang-tidy misc-use-override warnings, other minor fixes"
Seems it broke the Polly build.
From http://lab.llvm.org:8011/builders/perf-x86_64-penryn-O3-polly-fast/builds/11687/steps/compile/logs/stdio:

In file included from /home/grosser/buildslave/perf-x86_64-penryn-O3-polly-fast/llvm.src/lib/TableGen/Record.cpp:14:0:
/home/grosser/buildslave/perf-x86_64-penryn-O3-polly-fast/llvm.src/include/llvm/TableGen/Record.h:369:3: error: looser throw specifier for 'virtual llvm::TypedInit::~TypedInit()'
/home/grosser/buildslave/perf-x86_64-penryn-O3-polly-fast/llvm.src/include/llvm/TableGen/Record.h:270:11: error:   overriding 'virtual llvm::Init::~Init() noexcept (true)'

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247222 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-10 00:37:18 +00:00
Hans Wennborg 91d4921dc4 Fix Clang-tidy misc-use-override warnings, other minor fixes
Patch by Eugene Zelenko!

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247218 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-10 00:24:40 +00:00
Adrian Prantl d9178eb887 Module Debugging: Emit debug type information into clang ObjC modules.
When -fmodule-format is set to "obj", emit debug info for all types
declared in a module or referenced by a declaration into the module's
object file container.

This patch adds support for Objective-C types and methods.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247068 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-08 20:41:52 +00:00
Adrian Prantl 8d25e29a9e Module Debugging: Emit debug type information into clang modules.
When -fmodule-format is set to "obj", emit debug info for all types
declared in a module or referenced by a declaration into the module's
object file container.

This patch adds support for C and C++ types.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247049 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-08 19:20:27 +00:00
Adrian Prantl 7bbf57e36a Add a -gmodules option to the driver and a -dwarf-ext-refs to cc1
to enable the use of external type references in the debug info
(a.k.a. module debugging).

The driver expands -gmodules to "-g -fmodule-format=obj -dwarf-ext-refs"
and passes that to cc1. All this does at the moment is set a flag
codegenopts.

http://reviews.llvm.org/D11958

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246192 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-27 19:46:20 +00:00
Richard Smith 7537674b90 Initialize the AST consumer as soon as we have both an ASTConsumer and an
ASTContext. Fixes some cases where we could previously initialize the AST
consumer more than once.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@245346 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-18 20:39:29 +00:00
Yaron Keren f49d6b8491 Remove and forbid raw_svector_ostream::flush() calls.
After r244870 flush() will only compare two null pointers and return,
doing nothing but wasting run time. The call is not required any more
as the stream and its SmallString are always in sync.

Thanks to David Blaikie for reviewing.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244928 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-13 18:12:56 +00:00
Richard Smith 5624537c4c [modules] PR22534: Load files specified by -fmodule-file= eagerly. In particular, this avoids the need to re-parse module map files when using such a module.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244416 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-09 08:48:41 +00:00
Eric Christopher b88f708037 Rename DescriptionString -> DataLayoutString as it matches the actual
use of the string.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244178 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-05 23:48:05 +00:00
Mehdi Amini 02595590ed LLVM API Change: the Module always owns the DataLayout
From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243115 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-24 16:04:29 +00:00
Adrian Prantl 1e6cac6da0 Make the clang module container format selectable from the command line.
- 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!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242499 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-17 01:19:54 +00:00
Adrian Prantl fe95d3d2cb Rename ModuleContainerGenerator to PCHContainergenerator for consistency
and re-clang-format (NFC).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241841 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-09 19:46:39 +00:00
Adrian Prantl 09fd829bf4 Revert "Revert r241620 and follow-up commits" and move the initialization
of the llvm targets from clang/CodeGen into ClangCheck.cpp and CIndex.cpp.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241653 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-08 01:00:30 +00:00
Adrian Prantl bf47af3076 Revert r241620 and follow-up commits while investigating linux buildbot failures.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241642 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-07 23:19:46 +00:00
Adrian Prantl 5f180ca911 Cleanup: Use the C++ API to initialize the backend.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241635 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-07 22:34:47 +00:00