Commit Graph

1085 Commits

Author SHA1 Message Date
Adrian Prantl 21361fb308 Debug info: Only emit C++ accessibility specifiers when they are diverging
from the default for the containing type.

rdar://problem/18154959

llvm-svn: 216800
2014-08-29 22:44:27 +00:00
Alexey Bataev 39c81e2816 [C++11] Support for capturing of variable length arrays in lambda expression.
Differential Revision: http://reviews.llvm.org/D4368

llvm-svn: 216649
2014-08-28 04:28:19 +00:00
David Blaikie b84498497b Update for LLVM API change to remove discriminator tracking from DILexicalBlock (in favor of DILexicalBlockFile - where a default arg is used to avoid the need for API churn of those callers)
llvm-svn: 216240
2014-08-21 22:46:45 +00:00
Frederic Riss 787d9d640e Debuginfo: Correctly tag variadic ObjC methods with DW_TAG_unspecified_parameter.
Fixes rdar://13690847

llvm-svn: 215423
2014-08-12 04:42:23 +00:00
David Blaikie 77bbb5fd0b DebugInfo: Blocks: Do not depend on LLVM argument numbering when choosing the debug info argument numbering.
Due to the possible presence of return-by-out parameters, using the LLVM
argument number count when numbering debug info arguments can end up
off-by-one. This could produce two arguments with the same number, which
would in turn cause LLVM to emit only one of those arguments (whichever
it found last) or assert (r215157).

llvm-svn: 215227
2014-08-08 17:10:14 +00:00
Reid Kleckner d3b23d611b Debug info: Use the vbtable offset for virtual bases in the MS ABI
There are no vtable offset offsets in the MS ABI, but vbtable offsets
are analogous.  There are no consumers of this information yet, but at
least we don't crash now.

llvm-svn: 215149
2014-08-07 21:29:25 +00:00
Reid Kleckner 65a2f640d1 Revert "Debug info: Use record layout to find vbase offsets instead of vtables"
This reverts commit r215137.

This doesn't work at all, an offset-offset is probably different than an
offset.  I'm scared that this passed our normal test suite.

llvm-svn: 215141
2014-08-07 20:36:48 +00:00
Reid Kleckner 9f6e438022 Debug info: Use record layout to find vbase offsets instead of vtables
This fixes an assertion when generating full debug info in the MS ABI
for classes with virtual bases.

Fixes PR20579.

llvm-svn: 215137
2014-08-07 19:43:01 +00:00
David Majnemer 34b5749989 MS ABI: Consider alignment attributes on typedefs for layout
The MS ABI has a notion of 'required alignment' for fields; this
alignment supercedes pragma pack directives.

MSVC takes into account alignment attributes on typedefs when
determining whether or not a field has a certain required alignment.

Do the same in clang by tracking whether or not we saw such an attribute
when calculating the type's bitwidth and alignment.

This fixes PR20418.

Reviewers: rnk

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

llvm-svn: 214274
2014-07-30 01:30:47 +00:00
Manman Ren 67f005e3b2 [Debug Info] add DISubroutineType and its creation takes DITypeArray.
This is the last patch to unique the type array of a subroutine type.
This is the paired commit with llvm r214132.

llvm-svn: 214133
2014-07-28 22:24:34 +00:00
Manman Ren 51289892d2 [Debug Info] rename getTypeArray to getElements, setTypeArray to setArrays.
This is the paired commit with llvm r214112.

llvm-svn: 214113
2014-07-28 19:14:41 +00:00
Diego Novillo 913690c7bc Add new debug kind LocTrackingOnly.
Summary:
This new debug emission kind supports emitting line location
information in all instructions, but stops code generation
from emitting debug info to the final output.

This mode is useful when the backend wants to track source
locations during code generation, but it does not want to
produce debug info. This is currently used by optimization
remarks (-Rpass, -Rpass-missed and -Rpass-analysis).

When one of the -Rpass flags is used, the front end will enable
location tracking, only if no other debug option is enabled.

To prevent debug information from being generated, a new debug
info kind LocTrackingOnly causes DIBuilder::createCompileUnit() to
not emit the llvm.dbg.cu annotation. This blocks final code generation
from generating debug info in the back end.

Depends on D4234.

Reviewers: echristo, dblaikie

Subscribers: cfe-commits

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

llvm-svn: 211610
2014-06-24 17:02:17 +00:00
Alexey Samsonov 3c6b0c078e Delete apparently unused method
llvm-svn: 210047
2014-06-02 21:05:54 +00:00
David Blaikie f9ea242d4f CGDebugInfo: Simplify/invert createLexicalBlock parameter construction.
llvm-svn: 210033
2014-06-02 16:32:05 +00:00
Craig Topper 8a13c4180e [C++11] Use 'nullptr'. CodeGen edition.
llvm-svn: 209272
2014-05-21 05:09:00 +00:00
David Blaikie aabde05da1 DebugInfo: Avoid creating DILexicalScopeFiles when the filename in the current scope has not changed.
This looks like the right way for this check to work, but there is
another semi-obvious bug, I would think: why is CurLoc not zero'd out
between functions? The possibility for it to bleed between them seems
problematic. (& indeed I caused tests to fail when I fixed this a
different way, by setting CurLoc to SourceLocation() and the end of
EmitFunctionEnd... )

The changes to debug-info-blocks.m are due to a mismatch between the
source manager's file naming and CGDebugInfo's default handling when no
-main-file-name is specified. This actually reveals somewhat of a bug in
the debug info when using source files from standard in, too. See the
comment in CGDebugInfo::CreateCompileUnit for more details.

llvm-svn: 208742
2014-05-14 00:29: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
David Blaikie 87dab87a66 PR19562: Fix another temporary node leak in Clang debug info emission
While constructing ObjC Interface types we might create the declaration
of some normal C++ types, thus adding things to the ReplaceMap. Make
sure we process the ReplaceMap after the ObjC interfaces.

In theory we know at this point, since we're at the end of the TU, that
we won't be upgrading any declarations to definitions, so we could just
construct non-temporary nodes, but that would require extra state in
CGDebugInfo to conditionalize the creation of declaration nodes which
seems annoying/more work than is appropriate.

llvm-svn: 208226
2014-05-07 16:56:58 +00:00
Ed Maste da70602222 DebugInfo: Use enum instead of unsigned
This makes debuging DebugInfo generation with LLDB a little more pleasant.

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

llvm-svn: 208203
2014-05-07 12:49:30 +00:00
David Blaikie 5944d9ce3e PR19562: Fix memory leak when ObjC interface types cause the creation of further interfaces.
llvm-svn: 208161
2014-05-07 06:18:00 +00:00
David Blaikie 483a9da598 Reapply: DebugInfo: Emit the definition of enums when the definition preceeds the declaration and initial use.
Reverting r208106 to reapply r208065 with a fix for the regression. The
issue was that the enum tried to be built even if the declaration hadn't
been constructed for debug info - presenting problems for enum templates
and typedefs of enums with names for linkage purposes.

Original commit message:

This regressed a little further 208055 though it was already a little
broken.

While the requiresCompleteType optimization should be implemented here.
Future (possibly near future) work.

llvm-svn: 208114
2014-05-06 18:35:21 +00:00
David Blaikie 29020cc571 Revert "DebugInfo: Emit the definition of enums when the definition preceeds the declaration and initial use."
This is breaking the compiler-rt build. Reverting while I
investigate/fix.

This reverts commit r208065.

llvm-svn: 208106
2014-05-06 17:02:15 +00:00
David Blaikie 57407525fd DebugInfo: Emit the definition of enums when the definition preceeds the declaration and initial use.
This regressed a little further 208055 though it was already a little
broken.

While the requiresCompleteType optimization should be implemented here.
Future (possibly near future) work.

llvm-svn: 208065
2014-05-06 07:33:30 +00:00
David Blaikie f427b00b9a PR19598: Ensure temporary metadata nodes used in debug info are destroyed.
CGDebugInfo and DIBuilder were lax in their handling of temporary
MDNodes. All temporary nodes need to be deleted, which means they need
to be RAUW'd with a permanent node. This was not happening.

To ensure this, leverage DIBuilder's new ability to create both
permanent and temporary declarations. Ensure all temporary declarations
are RAUW'd, even with itself. (DIDescriptor::RAUW handles the case where
it is replaced with itself and creates a new, duplicate permanent node
to replace itself with)

This means that all temporary declarations must be added to the
ReplacementMap even if they're never upgraded to definitions - so move
the point of insertion into the map to the point of creation of the
declarations.

llvm-svn: 208055
2014-05-06 03:42:01 +00:00
David Blaikie ef8a951882 Build debug info for ObjC interface types at the end of the translation unit to ensure all ivars are included.
This takes a different approach than the
completedType/requiresCompleteType work which relies on AST callbacks to
upgrade the type declaration to a definition. Instead, just defer
constructing the definition to the end of the translation unit.

This works because the definition is never needed by other debug info
(so far as I know), whereas the definition of a struct may be needed by
other debug info before the end of the translation unit (such as
emitting the definition of a member function which must refer to that
member function's declaration).

If we had a callback for whenever an IVar was added to an ObjC interface
we could use that, and remove the need for the ObjCInterfaceCache, which
might be nice. (also would need a callback for when it was more than
just a declaration so we could get properties, etc).

A side benefit is that we also don't need the CompletedTypeCache
anymore. Just rely on the declaration-ness of a type to decide whether
its definition is yet to be emitted.

There's still the PR19562 memory leak, but this should hopefully make
that a bit easier to approach.

llvm-svn: 208015
2014-05-05 23:23:53 +00:00
David Blaikie b8149044e0 Simplify replacement map by avoiding duplicate values and ensuring the values it does contain are necessary.
Items were being redundantly added to the replacement map (both when the
declaration was created, and then again when its definition was
constructed) which caused extra handling to be required when walking the
map (as elements may've already been replaced due to prior entries). By
avoiding adding the duplicates, the checks in the replacement handling
can be replaced with assertions.

llvm-svn: 208000
2014-05-05 21:21:39 +00:00
David Blaikie 1c286f6d8f PR19623: Support typedefs (and alias templates) of void.
llvm-svn: 207781
2014-05-01 18:25:19 +00:00
Chandler Carruth 48ec7c0569 [Modules] Remove the only use of the DEBUG(...) macro in the compiler
parts of Clang. I don't really have any opinion about whether using that
macro is good or bad, but its odd that this is the only one, and Eric
seemed happy with just nuking it for now.

llvm-svn: 206806
2014-04-21 22:32:54 +00:00
Adrian Prantl 649f030819 Further simplify r206430.
rdar://problem/16636569.

llvm-svn: 206434
2014-04-17 01:04:01 +00:00
Adrian Prantl 2c92e9cb53 Debug info: When collecting the parameters of C++ partial template
specializations collect all arguments and not just the ones from the
class template partial specialization from which this class template
specialization was instantiated. The debug info does not represent the
partial specialization otherwise and so specialized parameters would
go missing.

rdar://problem/16636569.

llvm-svn: 206430
2014-04-17 00:30:48 +00:00
Adrian Prantl 42d71b9906 Debug info: (Bugfix) Make sure artificial functions like _GLOBAL__I_a
are not associated with any source lines.

Previously, if the Location of a Decl was empty, EmitFunctionStart would
just keep using CurLoc, which would sometimes be correct (e.g., thunks)
but in other cases would just point to a hilariously random location.

This patch fixes this by completely eliminating all uses of CurLoc from
EmitFunctionStart and rather have clients explicitly pass in a
SourceLocation for the function header and the function body.

rdar://problem/14985269

llvm-svn: 205999
2014-04-10 23:21:53 +00:00
Eric Christopher cab9fae403 Add global static variables for anonymous union fields. This makes
sure that a debugger can find them when stepping through code,
for example from the included testcase:

   12     int test_it() {
   13       c = 1;
   14       d = 2;
-> 15       a = 4;
   16       return (c == 1);
   17     }
   18
(lldb) p a
(int) $0 = 2
(lldb) p c
(int) $1 = 2
(lldb) p d
(int) $2 = 2

and a, c, d are all part of the file static anonymous union:

static union {
  int c;
  int d;
  union {
    int a;
  };
  struct {
    int b;
  };
};

Fixes PR19221.

llvm-svn: 205952
2014-04-10 05:20:00 +00:00
David Blaikie f1b382e87d DebugInfo: Support type alias templates
We already got the type alias correct (though I've included a test case
here) since Clang represents that like any other typedef - but type
alias templates weren't being handled.

llvm-svn: 205691
2014-04-06 17:14:06 +00:00
David Blaikie 551fb0a4ff DebugInfo: emit namespace aliases as named imported declarations instead of named imported entities
Apparently that's how DWARF4 suggests they be emitted. So let's do that.

llvm-svn: 205686
2014-04-06 06:30:03 +00:00
David Blaikie 506a745a0a Reapply r205655, DebugInfo: Place global constants in their appropriate context.
This was reverted in 205664 and seems to be fixed by 205668... though
that may be more by accident than anything well founded.

llvm-svn: 205669
2014-04-05 07:46:57 +00:00
David Blaikie bb11391d04 DebugInfo: Avoid emitting constnants for every use
While the folding set would deduplicate the nodes themselves and LLVM
would handle not emitting the same global twice, it still meant creating
a long/redundant list of global variables.

llvm-svn: 205668
2014-04-05 07:23:17 +00:00
David Blaikie 98db356cc1 Revert "DebugInfo: Place global constants in their appropriate context."
This reverts commit r205655.

Breaks the compiler-rt build with an assertion failure in LLVM...
reverting while I investigate.

llvm-svn: 205664
2014-04-05 03:39:29 +00:00
David Blaikie 2f2df07fa4 DebugInfo: Place global constants in their appropriate context.
We also don't need to duplicate the name in the LinkageName field. Just
leave it empty.

llvm-svn: 205655
2014-04-04 23:16:44 +00:00
David Blaikie a1556556d6 DebugInfo: PR19298: function local const variables duplicated in the root scope
See the comment for CodeGenFunction::tryEmitAsConstant that describes
how in some contexts (lambdas) we must not emit references to the
variable, but instead use the constant directly - because of this we end
up emitting a constant for the variable, as well as emitting the
variable itself.

Should we just skip putting the variable on the stack at all and omit
the debug info for the constant? It's not clear to me - what if the
address of the local is taken?

llvm-svn: 205651
2014-04-04 20:56:17 +00:00
David Blaikie 65813a3bce DebugInfo: Include default template arguments in template type names
This was committed 4 years ago in 108916 with insufficient testing to
explain why the "getTypeAsWritten" case was appropriate. Experience says
that it isn't - the presence or absence of an explicit instantiation
declaration was causing this code to generate either i<int> or i<int,
int>.

That didn't seem to be a useful distinction, and omitting the template
arguments was destructive to debuggers being able to associate the two
types across translation units or across compilers (GCC, reasonably,
never omitted the arguments).

llvm-svn: 205447
2014-04-02 18:21:09 +00:00
Eric Christopher 885c41b28c Partially revert r204517 and fix a different way:
We don't want to encourage the code to emit a lexical block for
a function that needs one in order for the line table to change,
we need to grab the line information from the body of the pattern
that we were instantiated from, this code should do that.

Modify the test case to ensure that we're still looking in the
right place for all of the scopes and also that we haven't
created a lexical block where we didn't need one.

llvm-svn: 205368
2014-04-01 22:25:28 +00:00
Adrian Prantl efb8805161 Debug info: fix a crash when emitting IndirectFieldDecls, which were
previously not handled at all.
rdar://problem/16348575

llvm-svn: 205331
2014-04-01 17:52:06 +00:00
Adrian Prantl 6cdce9ed10 Adapt CGDebugInfo to interface changes in DIBuilder/DIImportedEntity.
The Decl field in a DIImportedEntity is now a DIRef.
Paired commit with LLVM.

llvm-svn: 205278
2014-04-01 03:41:01 +00:00
Eric Christopher 8018e414bb Add an explanatory comment and FIXME about the function declaration
for a subprogram DIE.

llvm-svn: 204949
2014-03-27 18:50:35 +00:00
Eric Christopher 4cbd0d9dc2 Revert "Just call getContextDescriptor to get the context for subprograms"
while I investigate as it seems to be causing issues with the gdb bot.

This reverts commit r204874.

llvm-svn: 204896
2014-03-27 05:29:34 +00:00
Eric Christopher 43daad555d Just call getContextDescriptor to get the context for subprograms
instead of rolling an inefficient version of the function. This
changes some order of emission of metadata nodes, fix up those
testcases and make them more flexible to some changes.

llvm-svn: 204874
2014-03-26 23:09:30 +00:00
Adrian Prantl bebb89359a CGDebugInfo: At the end of EmitFunctionStart, Initialize PrevLoc to the
location that the next call emitLocation() would default to. Otherwise
setLocation() may wrongly believe that the current source file didn't
change, when in fact it did.

llvm-svn: 204517
2014-03-21 21:01:58 +00:00
Aaron Ballman 9371dd2287 [C++11] Replacing BlockDecl iterators capture_begin() and capture_end() with iterator_range captures(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203958
2014-03-14 18:34:04 +00:00
Aaron Ballman b8733c5ba4 [C++11] Replacing FunctionTemplateDecl iterators spec_begin() and spec_end() with iterator_range specializations(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203938
2014-03-14 16:05:56 +00:00
Aaron Ballman d174edffa0 Renaming the recently-created (r203830) props() range API to properties() for clarity.
llvm-svn: 203835
2014-03-13 19:11:50 +00:00
Aaron Ballman dc4bea4676 [C++11] Replacing ObjCContainerDecl iterators prop_begin() and prop_end() with iterator_range props(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203830
2014-03-13 18:47:37 +00:00
Aaron Ballman 574705ed7f [C++11] Replacing CXXRecordDecl iterators bases_begin() and bases_end() with iterator_range bases(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203803
2014-03-13 15:41:46 +00:00
Aaron Ballman e8a8baef44 [C++11] Replacing RecordDecl iterators field_begin() and field_end() with iterator_range fields(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203355
2014-03-08 20:12:42 +00:00
Aaron Ballman 23a6dcb365 [C++11] Replacing EnumDecl iterators enumerator_begin() and enumerator_end() with iterator_range enumerators(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203353
2014-03-08 18:45:14 +00:00
Aaron Ballman 629afaefe0 [C++11] Replacing DeclBase iterators decls_begin() and decls_end() with iterator_range decls(). The same is true for the noload versions of these APIs. Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203278
2014-03-07 19:56:05 +00:00
Aaron Ballman 43b68bebe7 [C++11] Replacing ObjCMethodDecl iterators param_begin() and param_end() with iterator_range params(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203255
2014-03-07 17:50:17 +00:00
Aaron Ballman 86c9390673 [C++11] Replacing iterators redecls_begin() and redecls_end() with iterator_range redecls(). Updating all of the usages of the iterators with range-based for loops, which allows the begin/end forms to be removed entirely.
llvm-svn: 203179
2014-03-06 23:45:36 +00:00
David Blaikie 0856f66dd2 DebugInfo: Refix r202888 (a fix to r202769) in a different way, ensuring types aren't needlessly built during -gmlt
llvm-svn: 202900
2014-03-04 22:01:08 +00:00
Reid Kleckner e0b9201f5a Fix unconditional dereference of a WeakVH in CGDebugInfo TypeCache
This fails an "isa<> used with null pointer" assert during a clang-cl
self-host on Windows.  This was caused by r202769, and I'm currently
reducing a test case.

Reviewers: dblaikie

Differential Revision: http://llvm-reviews.chandlerc.com/D2944

llvm-svn: 202888
2014-03-04 20:51:58 +00:00
David Blaikie f7f2185975 DebugInfo: Improvements/corrections to conservative emission of types in explicit template instantiation declarations
* detect out of line definitions correctly
* detect member function explicit specializations correctly

llvm-svn: 202779
2014-03-04 03:08:14 +00:00
David Blaikie 0e716b42f4 DebugInfo: Emit only the declaration of a class template that has an explicit instantiation declaration (& always emit such a type when there's an explicit instantiation definition)
We should only have this optimization fire when the explicit
instantiation definition would cause at  least one member function to be
emitted, thus ensuring that even a compiler not performing this
optimization would still emit the full type information elsewhere.

But we should also pessimize output still by always emitting the
definition when the explicit instantiation definition appears so that at
some point in the future we can depend on that information even when no
code had to be emitted in that TU. (this shouldn't happen very often,
since people mostly use explicit spec decl/defs to reduce code size -
but perhaps one day they could use it to explicitly reduce debug info
size too)

This was worth about 2% for Clang and LLVM - so not a huge win, but a
win. It looks really great for simple STL programs (include <string> and
just declare a string - 14k -> 1.4k of .dwo)

llvm-svn: 202769
2014-03-03 23:48:23 +00:00
Diego Novillo e6d398189e Update call DIBuilder::createLexicalBlock.
Create lexical blocks with discriminator value 0 by default.

llvm-svn: 202737
2014-03-03 18:53:32 +00:00
Benjamin Kramer 867ea1d426 [C++11] Replace llvm::tie with std::tie.
llvm-svn: 202639
2014-03-02 13:01:17 +00:00
Eric Christopher e4200a291b Pass down the debug emission kind into the compile unit for code
generation purposes.
Paired with a commit to llvm.

llvm-svn: 202334
2014-02-27 01:25:08 +00:00
Eric Christopher 0a1301fe25 80-col and bad line ending fixups.
llvm-svn: 202219
2014-02-26 02:49:36 +00:00
Adrian Prantl 800faef380 Address review comments for r202185, no functionality changes.
llvm-svn: 202208
2014-02-25 23:42:18 +00:00
Adrian Prantl d45ba2527c Debug info: Generate debug info for variadic functions.
Paired commit with LLVM.

rdar://problem/13690847

llvm-svn: 202185
2014-02-25 19:38:11 +00:00
David Blaikie 65ec94e348 DebugInfo: Avoid unnecessarily looking up the context when the declaration is already built.
No functional change intended.

llvm-svn: 201602
2014-02-18 20:52:05 +00:00
Adrian Prantl 381e75589d Debug info: fix a crasher when when emitting debug info for
not-yet-completed templated types. getTypeSize() needs a complete type.

rdar://problem/15931354

llvm-svn: 200797
2014-02-04 21:29:50 +00:00
Alp Toker 314cc81b8c Rename getResultType() on function and method declarations to getReturnType()
A return type is the declared or deduced part of the function type specified in
the declaration.

A result type is the (potentially adjusted) type of the value of an expression
that calls the function.

Rule of thumb:

  * Declarations have return types and parameters.
  * Expressions have result types and arguments.

llvm-svn: 200082
2014-01-25 16:55:45 +00:00
Adrian Prantl 3eff225a44 Debug info: use the file a typedef is defined in as its decl_file instead
of the current compilation unit.
As a side effect this enables many more LTO uniquing opportunities.

This reapplies r199757 with a better testcase.

llvm-svn: 199760
2014-01-21 18:42:27 +00:00
Adrian Prantl cb6e1257ff revert 199757 for buildbot breakage.
llvm-svn: 199758
2014-01-21 18:23:43 +00:00
Adrian Prantl 83788519a5 Debug info: use the file a typedef is defined in as its decl_file instead
of the current compilation unit.
As a side effect this enables many more LTO uniquing opportunities.

rdar://problem/15851206

llvm-svn: 199757
2014-01-21 18:20:52 +00:00
Alp Toker 9cacbabd33 Rename FunctionProtoType accessors from 'arguments' to 'parameters'
Fix a perennial source of confusion in the clang type system: Declarations and
function prototypes have parameters to which arguments are supplied, so calling
these 'arguments' was a stretch even in C mode, let alone C++ where default
arguments, templates and overloading make the distinction important to get
right.

Readability win across the board, especially in the casting, ADL and
overloading implementations which make a lot more sense at a glance now.

Will keep an eye on the builders and update dependent projects shortly.

No functional change.

llvm-svn: 199686
2014-01-20 20:26:09 +00:00
Adrian Prantl d1b151ed7c Debug info: Refactor NoLocation and ArtificialLocation to use a common base
class and use it pervasively to restore debug locations.
Fixes an interaction between cleanup and EH that caused the location
to not be restored properly after emitting a landing pad.
rdar://problem/15208190

llvm-svn: 199444
2014-01-17 00:15:10 +00:00
Adrian Prantl e83b130def Revert "Debug info: Ensure that the last stop point in a function is still within"
This reverts commit r198461.

llvm-svn: 198714
2014-01-07 22:05:52 +00:00
Adrian Prantl c6758879b3 Revert "Debug info: Implement a cleaner version of r198461. For symmetry with"
This reverts commit 198699 so we can get a cleaner patch.

llvm-svn: 198713
2014-01-07 22:05:45 +00:00
Adrian Prantl f5ff0dc29b Debug info: Implement a cleaner version of r198461. For symmetry with
C and C++ don't emit an extra lexical scope for the compound statement
that is the body of an Objective-C method.

rdar://problem/15010825

llvm-svn: 198699
2014-01-07 19:24:24 +00:00
Adrian Prantl d09906ff9c update comment.
llvm-svn: 198670
2014-01-07 02:40:59 +00:00
Adrian Prantl a763447124 Implement a new -fstandalone-debug option. rdar://problem/15685848
It controls everything that -flimit-debug-info used to, plus the
vtable type optimization. The old -fno-limit-debug-info option is now an
alias to -fstandalone-debug and vice versa.

Standalone is the default on Darwin until dtrace is updated to work with
non-standalone debug info (rdar://problem/15758808).

Note: I kept the LimitedDebugInfo name in CodeGenOptions::DebugInfoKind
because NoStandaloneDebugInfo sounded even more confusing.

llvm-svn: 198655
2014-01-07 01:19:08 +00:00
Adrian Prantl 96e70d9148 Debug info: Ensure that the last stop point in a function is still within
the lexical block formed by the compound statement that is the function
body.

rdar://problem/15010825

llvm-svn: 198461
2014-01-03 23:34:30 +00:00
Adrian Prantl 5028dc0fca remove dead code.
llvm-svn: 197916
2013-12-23 19:10:57 +00:00
David Blaikie 3275dc4586 DebugInfo: Do not include implicit members (implicit special members, template instantiations, etc) in the list of members of a structure.
These members will still be lazily added to the relevant DWARF DIEs in
LLVM but when enumerating the members they will not appear. This allows
DWARF type units to be more consistent - the type unit will never
contain these special members (so all instances of the type should have
the same DIEs without some having some special members and others having
others) and the special members will be added to the skeletal
declaration that appears in the relevant compile_unit.

llvm-svn: 197844
2013-12-20 23:19:47 +00:00
Adrian Prantl 0866acd3a3 Debug info: (Bugfix) emit CRV qualifiers for pointers to member functions.
rdar://problem/15678916.

llvm-svn: 197641
2013-12-19 01:38:47 +00:00
Adrian Prantl 0630eb7094 Debug info: Implement (rvalue) reference qualifiers for C++11 non-static
member functions. Paired commit with LLVM.

rdar://problem/15356637

llvm-svn: 197612
2013-12-18 21:48:18 +00:00
Alp Toker d473363876 Correct hyphenations in comments and assert messages
This patch tries to avoid unrelated changes other than fixing a few
hyphen-related ambiguities in nearby lines.

llvm-svn: 196466
2013-12-05 04:47:09 +00:00
Reid Kleckner 0503a870a9 Add an AdjustedType sugar node for adjusting calling conventions
Summary:
In general, this type node can be used to represent any type adjustment
that occurs implicitly without losing type sugar.  The immediate use of
this is to adjust the calling conventions of member function pointer
types without breaking template instantiation.

Fixes PR17996.

Reviewers: rsmith

Differential Revision: http://llvm-reviews.chandlerc.com/D2332

llvm-svn: 196451
2013-12-05 01:23:43 +00:00
David Blaikie ba4773659b DebugInfo: Update caller based on DIType's MDNode* ctor becoming explicit in r195055.
llvm-svn: 195056
2013-11-18 23:38:26 +00:00
Timur Iskhodzhanov 5877663622 Fix vbtable indices when a class shares the vbptr with a non-virtual base
llvm-svn: 194082
2013-11-05 15:54:58 +00:00
Yaron Keren 9fb7e9065f Fix string assignment, David Blaikie suggestion.
llvm-svn: 193116
2013-10-21 20:07:37 +00:00
Eric Christopher 9e6f5f9ac7 Add the context that a function was created in as the context for the
function, not the context of the context.

llvm-svn: 192862
2013-10-17 01:31:21 +00:00
Eric Christopher 07429ffce5 Reflow slightly.
llvm-svn: 192736
2013-10-15 21:22:34 +00:00
Eric Christopher 2df080e802 Remove extra braces.
llvm-svn: 192473
2013-10-11 18:16:51 +00:00
Timur Iskhodzhanov 8b5987eba5 Abstract out the emission of vtables, add basic support for vtable emission when using -cxx-abi microsoft
Reviewed at http://llvm-reviews.chandlerc.com/D1532

llvm-svn: 191523
2013-09-27 14:48:01 +00:00
Adrian Prantl 179af903d2 Debug info: Fix a crash when trying to construct a type with redundant
ownership qualifiers.
Fixes rdar://problem/14990656.

llvm-svn: 191463
2013-09-26 21:35:50 +00:00
Adrian Prantl 7f2ef22452 get rid of extra parentheses.
llvm-svn: 190962
2013-09-18 22:18:17 +00:00
Adrian Prantl 0315f38a92 Debug info: Explicitly set the DIVariable::isIndirect() flag for VLAs.
This allows us to get rid of an ugly hack in the backend.
Paired commit with LLVM.

llvm-svn: 190960
2013-09-18 22:08:57 +00:00
David Blaikie dedd27fc62 DebugInfo: omit debug info for friends
GCC ToT doesn't do this & it's worth about 3.2% on Clang's DWO file size
with Clang. Some or all of this may be due to things like r190715 which
could have source fixes/improvements, but it's not clear that's the case
and that doesn't help other source bases.

llvm-svn: 190716
2013-09-13 18:45:00 +00:00
Benjamin Kramer 1b18a5ec28 CGDebugInfo: Hoist string allocation in a helper function. No functionality change.
llvm-svn: 190314
2013-09-09 16:39:06 +00:00
Benjamin Kramer 60509af49a Fix constructor-related typos.
Noticed by Roman Divacky.

llvm-svn: 190311
2013-09-09 14:48:42 +00:00
Manman Ren 2c826dcc20 Debug Info: pass in DIScope instead of DIDescriptor in createFieldType.
Improve readability. No functionality change.

llvm-svn: 190268
2013-09-08 03:45:05 +00:00
David Blaikie 3b1cc9b858 PR17046, PR17092: Debug Info assert-on-valid due to member loss when context creation recreates the item the context is created for
By removing the possibility of strange partial definitions with no
members that older GCC's produced for the otherwise unreferenced outer
types of referenced inner types, we can simplify debug info generation
and correct this bug. Newer (4.8.1 and ToT) GCC's don't produce this
quirky debug info, and instead produce the full definition for the outer
type (except in the case where that type is dynamic and its vtable is
not emitted in this TU).

During the creation of the context for a type, we may revisit that type
(due to the need to visit template parameters, among other things) and
used to end up visiting it first there. Then when we would reach the
original code attempting to define that type, we would lose debug info
by overwriting its members.

By avoiding the possibility of latent "defined with no members" types,
we can be sure than whenever we already have a type in a cache (either a
definition or declaration), we can just return that. In the case of a
full definition, our work is done. In the case of a partial definition,
we must already be in the process of completing it. And in the case of a
declaration, the completed/vtable/etc callbacks can handle converting it
to a definition.

llvm-svn: 190122
2013-09-06 06:45:04 +00:00
David Blaikie 99dab3b43c Reapply r189013 (reverted in r189906) now that the underlying issue is fixed and tested (in r189996)
Debug info emission was tripping over an IRGen bug (fixed in r189996)
that was resulting in duplicate emission of static data members of class
templates in namespaces.

We could add more test coverage to debug info for this issue
specifically, but I think the underlying IRGen test is more targeted and
sufficient for the issue.

llvm-svn: 190001
2013-09-04 22:03:57 +00:00
David Blaikie ab415a4b35 Revert "DebugInfo: Remove explicit declaration-emissiong handling now that we have a more principled approach (the 'requires complete type' callback)"
This reverts commit r189013.

This is causing a segfault crash in a test case I have. Reverting while
I investigate the issue.

llvm-svn: 189906
2013-09-04 02:12:12 +00:00
Yunzhong Gao 0ebf1bb150 Revert r189649 because it was breaking sanitizer bots.
llvm-svn: 189660
2013-08-30 08:53:09 +00:00
Yunzhong Gao be8d7ba93a Fixing a bug where debug info for a local variable gets emitted at file scope.
The patch was discussed in Phabricator. See:
http://llvm-reviews.chandlerc.com/D1281

llvm-svn: 189649
2013-08-30 05:37:02 +00:00
Manman Ren e0064d8c24 Debug Info: generate a unique identifier for C++ struct, class, union, and enum.
We use CXX mangler to generate unique identifier for external C++ struct,
union, class and enum. Types with unique identifier are added to retained
types by DIBuilder.

Testing cases are updated to reflect the unique identifier generated for types.
The order of MDNodes is changed because of retained types and testing cases
are updated accordingly.

Testing case debug-info-uuid.cpp now emits error with Itanium mangler, since
uuid is not yet handled in Itanium mangler. And it will check for the error
message.

llvm-svn: 189622
2013-08-29 23:19:58 +00:00
Manman Ren f801f808ba Debug Info: this reverts commit r189600.
We had further discussions on how to retain types, whether to do it in front end
or in DIBuilder. And we agree to do it in DIBuilder so front ends
generating unique identifier do not need to worry about retaining them.

llvm-svn: 189609
2013-08-29 20:48:48 +00:00
Manman Ren 035c4b029f Debug Info: generate a unique identifier for C++ struct, class, union, and enum.
We use CXX mangler to generate unique identifier for external C++ struct,
union, class and enum. Types with unique identifier are added to RetainedTypes
to make sure they are treated as used even when all uses are replaced with
the identifiers.

A single type can be added to RetainedTypes multiple times. For example, both 
createForwardDecl and createLimitedType can add the same type to RetainedTypes.
A set is used to avoid duplication when updating AllRetainTypes in DIBuilder.

Testing cases are updated to reflect the unique identifier generated for types.
The order of MDNodes is changed because of retained types and testing cases
are updated accordingly.

Testing case debug-info-uuid.cpp now emits error with Itanium mangler, since
uuid is not yet handled in Itanium mangler.

We choose to update RetainedTypes in clang, then at finalize(), we update
AllRetainTypes in DIBuilder. The other choice is to update AllRetainTypes
in DIBuilder when creating a DICompositeType with unique identifier. This
option requires using ValueHandle for AllRetainTypes in DIBuilder since
the created DICompositeType can be modified later on by setContainingType etc.

llvm-svn: 189600
2013-08-29 18:51:51 +00:00
Eric Christopher f86c4059c6 80-col.
llvm-svn: 189531
2013-08-28 23:12:10 +00:00
David Blaikie f2053af82c DebugInfo: Further fix/improvements to r189494 (and LLVM r189495).
Selfhosting was crashing with the same type of problem but involving
template specializations.

llvm-svn: 189530
2013-08-28 23:06:52 +00:00
Manman Ren 501ecf9fac Format. Thanks David for pointing it out.
llvm-svn: 189521
2013-08-28 21:46:36 +00:00
Manman Ren 1b45702454 Debug Info: update interface for CreateEnumType and getOrCreateRecordFwdDecl.
Both functions will take a Type pointer instead of a Decl pointer. This helps
with follow-up type uniquing patches, which need the Type pointer to call
CXX mangler to generate unique identifiers.

No functionality change.

llvm-svn: 189519
2013-08-28 21:20:28 +00:00
David Blaikie a6cc82114d More comments for r189494.
llvm-svn: 189516
2013-08-28 20:58:00 +00:00
David Blaikie 8c8e8e2376 Comments for r189494
llvm-svn: 189504
2013-08-28 20:24:55 +00:00
David Blaikie fae219a033 PR16995: Failing to associate static members with their enclosing class
In the transition from declaration (with some members) to definition, we
were overwriting the list of members with the empty list when attaching
template parameters.

The fix is in llvm::DICompositeType::addMember (along with asserts that
cause this bug to be covered by existing Clang test cases), including
adding some asserts to catch this sort of issue which found issues fixed
in this commit.

llvm-svn: 189494
2013-08-28 17:27:13 +00:00
David Blaikie ebe87e1cfa Revert "PR14569: Omit debug info for thunks"
This reverts commit r189320.

Alexey Samsonov and Dmitry Vyukov presented some arguments for keeping
these around - though it still seems like those tasks could be solved by
a tool just using the symbol table. In a very small number of cases,
thunks may be inlined & debug info might be able to save profilers &
similar tools from misclassifying those cases as part of the caller.

The extra changes here plumb through the VarDecl for various cases to
CodeGenFunction - this provides better fidelity through a few APIs but
generally just causes the CGF::StartFunction to fallback to using the
name of the IR function as the name in the debug info.

The changes to debug-info-global-ctor-dtor.cpp seem like goodness. The
two names that go missing (in favor of only emitting those names as
linkage names) are names that can be demangled - emitting them only as
the linkage name should encourage tools to do just that.

Again, thanks to Dinesh Dwivedi for investigation/work on this issue.

llvm-svn: 189421
2013-08-27 23:57:18 +00:00
David Majnemer a3644d6046 DebugInfo: Emit info for casted decls in template args
Summary:
Previously the backend wouldn't get to see the underlying GlobalValue
that corresponds to the template argument because it would be hidden by
a cast at the IR level.  Instead strip the pointer casts off of the
value until we see the underlying GlobalValue.

Reviewers: dblaikie, echristo, majnemer

Reviewed By: majnemer

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1508

llvm-svn: 189200
2013-08-25 22:13:27 +00:00
David Majnemer 5559d47266 DebugInfo: Emit info for constant expressions in template arguments
Summary:
This allows us to handle the general case where a non-type template
argument evaluates to a constant expression which isn't integral or a
declaration.

This fixes PR16939.

Reviewers: dblaikie, rsmith

Reviewed By: dblaikie

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1453

llvm-svn: 189165
2013-08-24 08:21:10 +00:00
David Blaikie cf2c8b33cd DebugInfo: Remove explicit declaration-emissiong handling now that we have a more principled approach (the 'requires complete type' callback)
No functionality change intended.

llvm-svn: 189013
2013-08-22 13:36:01 +00:00
David Blaikie eaa49e252d DebugInfo: Require only the declaration of types only used as parameter and return types
llvm-svn: 188962
2013-08-21 23:23:07 +00:00
David Blaikie ce76304627 DebugInfo: comment/inlining based on feedback from Eric & Adrian
llvm-svn: 188834
2013-08-20 21:49:21 +00:00
David Blaikie 8d5e128bd4 DebugInfo: Simplify/clarify propagation of typemembers between declaration and definition
Based on code review feedback from Eric Christopher (on r188739) and
Adrian Prantl (r188642).

llvm-svn: 188829
2013-08-20 21:03:29 +00:00
David Blaikie 6943dea321 Revert "Revert "Revert "Revert "DebugInfo: Omit debug info for dynamic classes in TUs that do not have the vtable for that class""""
This reverts commit r188687 (reverts r188642 (reverts 188600 (reverts
188576))).

With added test coverage & fix for -gline-tables-only.

Thanks Michael Gottesman for reverting this patch when it demonstrated
problems & providing a reproduction/details to help me track this down.

llvm-svn: 188739
2013-08-20 01:28:15 +00:00
Michael Gottesman 349542b171 Revert "Revert "Revert "DebugInfo: Omit debug info for dynamic classes in TUs that do not have the vtable for that class"""
This reverts commit r188642.

This change is causing LTO builds to cause our 16 GB machines to swap and OOM
all weekend. I am going to work with Dave Blaikie to resolve the issue.

Sorry Dave =(.

llvm-svn: 188687
2013-08-19 18:46:16 +00:00
David Blaikie 7fceebf5aa DebugInfo: Do not include line/file info for artificial parameters & parameters of artificial functions
llvm-svn: 188651
2013-08-19 03:37:48 +00:00
David Blaikie 25b2085490 Revert "Revert "DebugInfo: Omit debug info for dynamic classes in TUs that do not have the vtable for that class""
This reverts commit r188600.

r188640/r188639 fixed the root cause of the crash-on-valid that r188600
originally introduced. This now appears to bootstrap debug clang
successfully to the best of my testing.

llvm-svn: 188642
2013-08-18 17:59:12 +00:00
David Blaikie d278589329 DebugInfo: Avoid duplicating types that may be created during the process of creating their context
A partner to r188639, this is a somewhat heavy-handed fix to the general
issue, since even after that prior change the issue does still
unavoidably arise with template parameters (see test case).

There are other ways we could consider addressing this (see FIXME).

llvm-svn: 188640
2013-08-18 17:36:19 +00:00
David Blaikie adfbf993d6 DebugInfo: Don't emit vbase 'containing types' for context chain limited types
Possible minor reduction in debug info & avoid some cases where creating
a context chain could lead to the type the context chain is being
created for, being created. (this is still possible with template
parameters - tests/fixes/improvements to follow)

llvm-svn: 188639
2013-08-18 16:55:33 +00:00
David Blaikie 5043815a60 DebugInfo: don't require full definitions for friend classes
Fixes a crash-on-valid introduced by r188486 (which should've occurred
earlier but for a blatant bug where calling createFwdDecl from the
requireCompleteType callback was useless under -flimit-debug-info and we
were just getting lucky with other later callbacks requiring the type
anyway).

llvm-svn: 188622
2013-08-18 04:50:23 +00:00
David Blaikie 949939cdbb PR16927: Don't assert (or, previously, skip) static data members of enumeration type
llvm-svn: 188612
2013-08-17 20:01:53 +00:00
David Blaikie 7d5d7c7e90 Revert "DebugInfo: Omit debug info for dynamic classes in TUs that do not have the vtable for that class"
This reverts commit r188576.

Reverting while I investigate a selfhosting buildbot failure on Darwin.

llvm-svn: 188600
2013-08-17 00:06:55 +00:00
David Blaikie 9fdedec489 DebugInfo: Canonicalize namespaces to avoid emitting multiple namespaces with the same name but different lines
Updated test case to not rely on line numbers in more cases (it's hard
to use the @ check syntax for debug info test cases (due to the
interesting ordering of metadata) and this case in particular (given the
hash-line directive)) - left a few in there to cover the line number
information for these.

llvm-svn: 188585
2013-08-16 22:52:07 +00:00
David Blaikie 9eddbbd563 DebugInfo: Omit debug info for dynamic classes in TUs that do not have the vtable for that class
This reduces Clang's .dwo (fission debug info) size by 23% over
Clang+LLVM.

llvm-svn: 188576
2013-08-16 20:40:29 +00:00
David Blaikie ab255bb9cf DebugInfo: Contrain the record type parameter for CollectRecordFields
This is the correct type (as is demonstrated by the fact that the caller
didn't need to change) & will be useful in a future patch.

llvm-svn: 188575
2013-08-16 20:40:25 +00:00
Evgeniy Stepanov 37b3f73690 Revert r188498.
This change broke release+asserts build with compiler-rt.

llvm-svn: 188539
2013-08-16 10:35:31 +00:00
David Blaikie ae01946afa DebugInfo: CollectRecordStaticField -> CreateRecordStaticField to return its result.
llvm-svn: 188501
2013-08-15 22:50:29 +00:00
David Blaikie 952dac3b7f Remove unnecessary explicit cast.
llvm-svn: 188500
2013-08-15 22:42:12 +00:00
David Blaikie 6dc689670c DebugInfo: Split out the implementation of getStaticDataMemberDeclaration for future use
llvm-svn: 188498
2013-08-15 22:30:23 +00:00
David Blaikie b840c48de2 Fix assert added in r188494
llvm-svn: 188496
2013-08-15 22:18:13 +00:00
David Blaikie 35b22f6985 DebugInfo: Remove unused conditional
llvm-svn: 188494
2013-08-15 21:55:56 +00:00
David Blaikie a0ef9fa6bf DebugInfo: Make CGDebugInfo::getStaticDataMemberDeclaration's argument type match the semantics
Rather than having a cast immediately inside the function, push that
type requirement out to the callers.

llvm-svn: 188492
2013-08-15 21:42:43 +00:00
David Blaikie 6a7234472e DebugInfo: Add a FIXME, remove a FIXME.
(the removed FIXME no longer applies since we made this debug info
optimization not apply to C)

llvm-svn: 188491
2013-08-15 21:21:19 +00:00
David Blaikie b2e86eb64a DebugInfo: Unify & optimize the lazy addition of record types
Rather than going through the whole getOrCreateType machinery to
manifest a type, cut straight to the implementation because we know we
have to do work.

While the previous implementation was sufficient for the two cases
(completeness and required completeness) we have already (the general
machinery could inspect the type for those attributes & go down the full
definition path), a pending change (to emit info for types when we emit
their vtables) won't have that luxury & we'll need to force the creation
rather than relying on the general purpose routine.

llvm-svn: 188486
2013-08-15 20:49:17 +00:00
David Blaikie 4e7ef80e68 DebugInfo: Revert change to the return type of createRecordFwdDecl
It still does only return DICompositeType, but I've no need to make that
change right now.

llvm-svn: 188482
2013-08-15 20:17:25 +00:00
David Blaikie d18fcc7a22 DebugInfo: remove unnecessary type registration
This happens in the caller a few frames up anyway.

llvm-svn: 188475
2013-08-15 18:59:44 +00:00
David Blaikie d816e2d3b0 DebugInfo: Don't create duplicate forward declaration metadata unnecessarily.
No functionality change, at best a slight (questionable) optimization,
but necessary for correctness of future work.

llvm-svn: 188474
2013-08-15 18:59:40 +00:00
David Blaikie 80d28de87a Drive by cleanup
llvm-svn: 188251
2013-08-13 04:21:38 +00:00
David Blaikie 6b7d060c57 DebugInfo: Simplify declaration building code - relying on the limit debug info checking already in CreateType(RecordType)
llvm-svn: 188222
2013-08-12 23:14:36 +00:00
David Blaikie 4a2b5ef603 DebugInfo: simplify some limited/declaration creation APIs
llvm-svn: 188214
2013-08-12 22:24:20 +00:00
David Blaikie fd07c604a9 Only emit debug info for implicit members that actually get codegen, not just ODR use.
This includes special members (copy/default ctor, copy assign, default
ctor) and template specializations for member function templates.

Good for a 5% decrease (1.80 to 1.71 GB) in size on Clang+LLVM's .dwo
files (when using fission).

llvm-svn: 188085
2013-08-09 17:20:05 +00:00
David Blaikie 79af384d72 DebugInfo: Don't prefer declarations over definitions in -flimit-debug-info in C
Without an ODR, the -flimit-debug-info debug info size optimization of
emitting declarations for fully defined types when only a declaration is
needed by the TU, is incorrect. Emit the full definition whenever it's
available in non-C++.

llvm-svn: 187611
2013-08-01 20:57:40 +00:00
David Blaikie 4a5b8958a8 DebugInfo: Emit template arguments for limited types used for context.
We emit definitions with no members when a nested type is
referenced/required (GCC does the same, to be fair) but failed to attach
the template arguments in such a case.

llvm-svn: 187608
2013-08-01 20:31:40 +00:00
David Blaikie 6f8f6008c2 Reduce a variable's scope (no functionality change)
llvm-svn: 187594
2013-08-01 18:23:24 +00:00
Adrian Prantl 49a78563d2 Debug Info: Fix an oversight of r186553. Ensure that the function prologue
of an artificial function gets an artificial location as well.

llvm-svn: 187074
2013-07-24 20:34:39 +00:00
Adrian Prantl ead2ba4649 Implement a better fix for r186894 by setting the appropriate type for __byref_variable_layout.
rdar://problem/14386148

llvm-svn: 186898
2013-07-23 00:12:14 +00:00
Adrian Prantl 52f5b2502f Debug Info: Acknowledge the alignment when locating byref block variables.
Fixes rdar://problem/14386148

llvm-svn: 186894
2013-07-22 23:44:26 +00:00
Eric Christopher 978c839315 Update createCompileUnit call for llvm changes.
llvm-svn: 186638
2013-07-19 00:51:58 +00:00
Adrian Prantl b75016d299 s/BuiltinLocation/ArtificialLocation/
llvm-svn: 186557
2013-07-18 01:36:04 +00:00
Eric Christopher f8bc4d878c Instead of checking against some version of "isType()" go ahead and
use the conversion to bool to check if we've managed to get a type
that isn't default constructed - as we meant to in the first place.

llvm-svn: 186556
2013-07-18 00:52:50 +00:00
Adrian Prantl 593f10ed81 Fix a compile error caught by bb-chapuni.
llvm-svn: 186555
2013-07-18 00:47:12 +00:00
Adrian Prantl 9aab9002a6 Fix a compile error caught by bb-chapuni.
llvm-svn: 186554
2013-07-18 00:43:29 +00:00
Adrian Prantl 2e0637ff63 Replace llvm::DIBuilder::DisableDebugLocations() with two RAII interfaces
inspired by CodegenFunction::LexicalScope.
- NoLocation temporarily turns off debug locations altogether.
  This is useful for emitting instructions that should be
  counted towards the function prologue.
- BuiltinLocation temporarily switches to an artificial debug location
  that has a valid scope, but no line information. This is useful when
  emitting compiler-generated helper functions that have no source
  location associated with them.

llvm-svn: 186552
2013-07-18 00:28:02 +00:00
Adrian Prantl 02c0caa198 Clarified documentation.
llvm-svn: 186551
2013-07-18 00:27:59 +00:00
Adrian Prantl b1b3bfc068 Simplify logic by using the appropriate function.
llvm-svn: 186550
2013-07-18 00:27:56 +00:00
Eric Christopher ffdeb1eb03 80-column fixes.
llvm-svn: 186542
2013-07-17 22:52:53 +00:00
Eric Christopher 324bbbd16a Move BlockLiteralGeneric earlier in CGDebugInfo and remove
BlockLiteralGenericSet and replace with a call to isType() on the
BlockLiteralGeneric.

llvm-svn: 186293
2013-07-14 21:12:44 +00:00
Eric Christopher 35f1f9fc28 Update a few comments and reformat a decl for clarity.
llvm-svn: 186292
2013-07-14 21:00:07 +00:00
David Blaikie 48ad6dc463 PR16214, PR14467: DebugInfo: use "RequireCompleteType" to decide when to emit the full definition of a type in -flimit-debug-info
This simplifies the core benefit of -flimit-debug-info by taking a more
systematic approach to avoid emitting debug info definitions for types
that only require declarations. The previous ad-hoc approach (3 cases
removed in this patch) had many holes.

The general approach (adding a bit to TagDecl and callback through
ASTConsumer) has been discussed with Richard Smith - though always open
to revision.

llvm-svn: 186262
2013-07-13 21:08:14 +00:00
David Blaikie 66ed89d07f Correctly classify pack expansions as NON_CANONICAL_UNLESS_DEPENDENT
Test coverage for non-dependent pack expansions doesn't demonstrate a
failure prior to this patch (a follow-up commit improving debug info
will cover this commit specifically) but covers a related hole in our
test coverage.

Reviewed by Richard Smith & Eli Friedman.

llvm-svn: 186261
2013-07-13 21:08:08 +00:00
Adrian Prantl 7278788ffe Reapply an improved version of r180816/180817.
Do not generate VLAs as complex variables any more, as they are now
correctly represented as breg+0 locations in the backend.

(Paired commit with LLVM: r185966)

rdar://problem/13658587

llvm-svn: 185967
2013-07-09 20:29:03 +00:00
Manman Ren 0d441f1853 Debug Info: clean up usage of Verify.
No functionality change. It should suffice to check the type of a debug info
metadata, instead of calling Verify.

llvm-svn: 185463
2013-07-02 19:01:53 +00:00
Peter Collingbourne 5c5e6179a0 Use the zero-argument DIBuilder::createNullPtrType in Clang.
Differential Revision: http://llvm-reviews.chandlerc.com/D1051

llvm-svn: 185115
2013-06-27 22:51:01 +00:00
Eli Friedman 2782dacfbc Rewrite record layout for ms_struct structs.
The old implementation of ms_struct in RecordLayoutBuilder was a
complete mess: it depended on complicated conditionals which didn't
really reflect the underlying logic, and placed a burden on users of
the resulting RecordLayout. This commit rips out almost all of the
old code, and replaces it with simple checks in
RecordLayoutBuilder::LayoutBitField.

This commit also fixes <rdar://problem/14252115>, a bug where class
inheritance would cause us to lay out bitfields incorrectly.

llvm-svn: 185018
2013-06-26 20:50:34 +00:00
Reid Kleckner 8a36502a60 [AST] Introduce a new DecayedType sugar node
The goal of this sugar node is to be able to look at an arbitrary
FunctionType and tell if any of the parameters were decayed from an
array or function type.  Ultimately this is necessary to implement
Microsoft's C++ name mangling scheme, which mangles decayed arrays
differently from normal pointers.

Reviewers: rsmith

Differential Revision: http://llvm-reviews.chandlerc.com/D1014

llvm-svn: 184763
2013-06-24 17:51:48 +00:00
David Blaikie ce1ae387d6 DebugInfo: ensure negative enumerators are emitted as such
There's still a problem here - since we're not appropriately using the
signedness/range of the enum to chooset the encoding and emission of
enumerators, but GCC has some bugs around this too so I assume that's
not /such/ a high priority though I may get to it soon out of
completeness.

llvm-svn: 184695
2013-06-24 07:13:13 +00:00
David Blaikie 47c1150f50 DebugInfo: Support (using GNU extensions) for template template parameters and parameter packs
llvm-svn: 184644
2013-06-22 18:59:18 +00:00
David Blaikie 18cfbc53ee DebugInfo: Random tidying up/simplification
No functionality change intended.

llvm-svn: 184614
2013-06-22 00:09:36 +00:00
David Blaikie 940ca4d462 PR16214: Debug info for types first used via pointers or qualified types & later require definitions
llvm-svn: 184594
2013-06-21 21:03:11 +00:00
David Blaikie f7bcb0c279 Fix all the silly things I committed in r184509
llvm-svn: 184512
2013-06-21 00:59:44 +00:00
David Blaikie b8f2fbbe97 Alternative fix for r184473.
This just seems a bit tidier/more principled. Based on a patch provided
by Adrian - with the only minor tweak that it needed to use
"getTypeOrNull" rather than "getCompletedTypeOrNull" since we don't
store declarations in the CompletedTypes cache.

No intended functionality change.

llvm-svn: 184509
2013-06-21 00:40:50 +00:00
Adrian Prantl dba725c0be Debug Info: Attempt to resolve forward declarations if we are not emitting
limited debug info.

This is another small addendum to r184252.

rdar://problem/14101097

llvm-svn: 184473
2013-06-20 21:17:24 +00:00
David Blaikie b9c667d808 Debug Info: PR14763/r183329 - specify that non-trivial pass-by-value parameters are stored indirectly
This is to fix the location information for such parameters to refer to
the object accessible through the pointer rather than to the pointer
parameter itself.

llvm-svn: 184367
2013-06-19 21:53:53 +00:00
Adrian Prantl 1f56b2a4f1 Add some comments to r184252.
rdar://problem/14101097

llvm-svn: 184259
2013-06-18 23:32:21 +00:00
Adrian Prantl c1a3fe7f9b Emit forward decls for structs with declarations only when we are
limiting debug info.

FIXME: There is still work left to do here, the testcase should work even with -flimit-debug-info.

rdar://problem/14101097

llvm-svn: 184252
2013-06-18 23:01:56 +00:00
Eric Christopher 1ecc5634d6 80-column fixup after recent change to getOrCreateType.
llvm-svn: 183586
2013-06-07 22:54:39 +00:00
Adrian Prantl a4ce906bc0 address some comments on r183474:
- factor the name construction part out from constructSetterName
- rename constructSetterName to the more appropriate constructSetterSelector

no functionality change intended.
rdar://problem/14035789

llvm-svn: 183582
2013-06-07 22:29:12 +00:00
Adrian Prantl 817bbb3a81 documentation: remove confusing reference to properties.
llvm-svn: 183475
2013-06-07 01:10:48 +00:00
Adrian Prantl b8fad1a37c ObjC Debug Info: Emit the names of accessors whenever they diverge from
the default names, not just when the isImplicit flag is set.

rdar://problem/14035789

llvm-svn: 183474
2013-06-07 01:10:45 +00:00
Adrian Prantl c4de1ef38c Improve documentation.
llvm-svn: 183473
2013-06-07 01:10:41 +00:00
David Blaikie 205a30d83d PR14763: Debug info for non-trivial record parameters
There seems to have been some erroneous code attempting to describe the
ABI of parameters (non-trivial record parameters are passed by
reference). This would break the type of the function (especially when
it caused a mismatch between the type of a declaration & a definition)
causing PR14763 and PR14645.

llvm-svn: 183329
2013-06-05 18:30:31 +00:00
David Blaikie e36464c2f6 PR16214: Debug Info: -flimit-debug-info doesn't omit definitions for types used via typedefs
In an effort to make -flimit-debug-info more consistent I over-shot the
mark & made types used via typedefs never produce definitions in the
debug info (even if the type was used in a way that would require a
definition).

The fix for this is to do exactly what I was hoping to do at some point
- plumb the declaration/definition choice through the various layers of
"CreateType" in CGDebugInfo. In this way we can produce declarations
whenever they are sufficient & definitions otherwise - including when
qualifiers are used, for example (discovered in PR14467). This may not
be complete (there may be other types/situations where we need to
propagate the "declaration/definition" choice) but it lays the basic
foundation which we can enhance in future iterations.

llvm-svn: 183296
2013-06-05 05:32:23 +00:00
David Blaikie 4583bea0b2 DebugInfo: Rename CreatePointerType to getOrCreateTypeDeclaration
To make this more consistent with 'getOrCreateType' & clarify the
distinction between the two. The only thing I couldn't quite communicate
in the name is that getOrCreateTypeDeclaration may actually produce a
full definition (in -fno-limit-debug-info) but the point is to call it
whenever only a declaration is needed & the implementation can choose
whether to provide a declaration or definition.

(also, unfortunately, getOrCreateType can produce declarations too - we
should sure this up by making it not do that - any caller that can
tolerate a declaration should be calling getOrCreateTypeDeclaration
instead)

llvm-svn: 182674
2013-05-24 21:33:22 +00:00
David Blaikie 22c460a051 PR16091: Error when attempting to emit debug info for undeduced auto return types
Perhaps we should just suppress this, rather than erroring, but since we
have the infrastructure for it I figured I'd use it - if this is
determined to be not the right thing we should probably remove that
infrastructure entirely. I guess it's lying around from the early days
of implementing debug info support.

llvm-svn: 182673
2013-05-24 21:24:35 +00:00
David Blaikie 469f07969e Debug Info: Handle function/method types using the most specific type
llvm-svn: 182533
2013-05-22 23:22:42 +00:00
Adrian Prantl 5f3601016c Comment and cleanup.
rdar://problem/13359718

llvm-svn: 182524
2013-05-22 21:37:49 +00:00
Adrian Prantl ef6fca5536 Bugfix for r181629:
- The return type should be a pointer to the class type.
- Make the condition more specific.

rdar://problem/13359718

llvm-svn: 182504
2013-05-22 19:10:15 +00:00
David Blaikie 8e5939b605 Debug Info: Simplify the code changed in r182403 to reduce indent & avoid a duplicate lookup in the insertion case
llvm-svn: 182404
2013-05-21 18:29:40 +00:00
David Blaikie 77a887bacb Debug Info: don't bother reinserting elements into maps we just retrieved them from
(no intended behavior change)

llvm-svn: 182403
2013-05-21 18:08:19 +00:00
David Blaikie fefc7f7a5d Fix whitespace
llvm-svn: 182400
2013-05-21 17:58:54 +00:00
David Blaikie f121b9302e PR14606: Debug Info for namespace aliases/DW_TAG_imported_module
This resolves the last of the PR14606 failures in the GDB 7.5 test
suite. (but there are still unresolved issues in the imported_decl case
- we need to implement optional/lazy decls for functions & variables
like we already do for types)

llvm-svn: 182329
2013-05-20 22:50:41 +00:00
David Blaikie bd4837665b Revert "Revert "Debug Info: Using declarations/DW_TAG_imported_declaration of variables, types, and functions.""
This reverts commit r181947 (git d2990ce56a16050cac0d7937ec9919ff54c6df62 )

This addresses one of the two issues identified in r181947, ensuring
that types imported via using declarations only result in a declaration
being emitted for the type, not a definition. The second issue (emitting
using declarations that are unused) is hopefully an acceptable increase
as the real fix for this would be a bit difficult (probably at best we
could record which using directives were involved in lookups - but may
not have been the result of the lookup).

This also ensures that DW_TAG_imported_declarations (& directives) are
not emitted in line-tables-only mode as well as ensuring that typedefs
only require/emit declarations (rather than definitions) for referenced
types.

llvm-svn: 182231
2013-05-20 04:58:53 +00:00
Adrian Prantl b39fc142fd Drop the const from the isa test.
llvm-svn: 182178
2013-05-17 23:58:45 +00:00
Adrian Prantl 6e785ec019 ObjC Debug Info: Emit the correct method names for accessors for
properties declared in a protocol.

rdar://problem/13798000

llvm-svn: 182176
2013-05-17 23:49:10 +00:00
Eric Christopher 0fdcb315e3 80-columns.
llvm-svn: 181965
2013-05-16 00:52:20 +00:00
Eric Christopher 75e1768b46 Replace a pile of calls with an instance variable that's set
once. Should be no functional change.

llvm-svn: 181964
2013-05-16 00:45:23 +00:00
Eric Christopher b2a008c615 Whitespace.
llvm-svn: 181960
2013-05-16 00:45:12 +00:00
David Blaikie db35281468 Revert "Debug Info: Using declarations/DW_TAG_imported_declaration of variables, types, and functions."
This reverts commit r181393 (git 3923d6a87fe7b2c91cc4a7dbd90c4ec7e2316bcd).

This seems to be emitting too much extra debug info for two (known)
reasons:
* full class definitions are emitted when only declarations are expected
* unused using declarations still produce DW_TAG_imported_declarations

llvm-svn: 181947
2013-05-15 23:46:19 +00:00
David Blaikie 11ecabf4eb PR15956: Debug Info: Include the appropriate file location in types created due to using declarations
We might benefit from API refactoring here (why pass in a value that's
derived from another parameter?) but this is the immediate issue.

llvm-svn: 181747
2013-05-14 00:34:20 +00:00
David Blaikie d900f98bdf Debug Info: PR14992: Support values for non-type template parameters of function type
llvm-svn: 181685
2013-05-13 06:57:50 +00:00
David Blaikie 4cb63df342 Debug Info: Comment changes in r181393 by request of echristo
llvm-svn: 181672
2013-05-12 18:05:52 +00:00
David Blaikie 2b93c54c4a Debug Info: correct comment
Eric's code review feedback to r181644

llvm-svn: 181650
2013-05-10 23:36:06 +00:00
David Blaikie 7e4c8b0642 Debug Info: Silently accept template argument packs
We could support the GCC extension DW_TAG_GNU_template_parameter_pack if
we're feeling adventurous, at some point - but I don't think GDB's doing
anything useful with it yet anyway.

llvm-svn: 181644
2013-05-10 22:53:25 +00:00
David Blaikie 38079fd26f PR14992: Debug Info: Support more non-type template parameters
* Provide DW_TAG_template_value_parameter for pointers, function
  pointers, member pointers, and member function pointers (still missing
  support for template template parameters which GCC encodes as a
  DW_TAG_GNU_template_template_param)
* Provide values for all but the (member & non-member) function pointer case.
  Simple constant integer values for member pointers (offset within the
  object) and address for the value pointer case. GCC doesn't provide a
  value for the member function pointer case so I'm not sure how, if at
  all, GDB supports encoding that. & non-member function pointers should
  follow shortly in a subsequent patch.
* Null pointer value encodings of all of these types, including
  correctly encoding null data member pointers as -1.

llvm-svn: 181634
2013-05-10 21:53:14 +00:00
Adrian Prantl 7bec903850 ObjC debug info: Substitute the class type for methods that return
a related type (e.g., if they use the instancetype keyword).

rdar://problem/13359718

llvm-svn: 181629
2013-05-10 21:08:31 +00:00
David Blaikie f03b2e8385 Debug Info: Remove unnecessary check for dependent array types
This was added, untested (though the relevant crash was tested), in
r128725/PR9600. Removing it doesn't cause failures & nothing I can
imagine could cause this check to ever return 'true' (we should never be
dealing with dependent types here). The subsequent change to check
"isIncompleteType" (r128855/PR9608) makes a lot more sense.

llvm-svn: 181542
2013-05-09 20:48:12 +00:00
Adrian Prantl c20237d21f typo
llvm-svn: 181485
2013-05-08 23:37:22 +00:00
David Blaikie b0b645cad1 Debug Info: Using declarations/DW_TAG_imported_declaration of variables, types, and functions.
Basic support is implemented here - it still doesn't account for
declared-but-not-defined variables or functions. It cannot handle out of
order (declared, 'using', then defined) cases for variables, but can
handle that for functions (& can handle declared, 'using'd, and not
defined at all cases for types).

llvm-svn: 181393
2013-05-08 06:01:46 +00:00
David Blaikie fd5aa13549 DebugInfo: Support imported modules (using directives) within lexical blocks.
llvm-svn: 181272
2013-05-06 23:33:13 +00:00
Adrian Prantl ab067ae8b0 Revert 180817 because 180816 was reverted.
llvm-svn: 180823
2013-04-30 22:45:09 +00:00
Adrian Prantl 7e2b05c378 Do not generate VLAs as complex variables any more, as they are now
correctly represented as breg+0 locations in the backend.

(Paired commit with LLVM: r180815)

rdar://problem/13658587

llvm-svn: 180817
2013-04-30 22:17:36 +00:00
David Blaikie 9f88fe865c Revert "Revert "PR14606: Debug info for using directives/DW_TAG_imported_module""
This reverts commit 179839 now that the corresponding LLVM patch has been fixed.

llvm-svn: 179997
2013-04-22 06:13:21 +00:00
Adrian Prantl c60dc718c0 Emit the underlying type in the debug info for all kinds of fixed enums
instead of only C++11-scoped-with-class-tag enums.

rdar://problem/13463793

llvm-svn: 179879
2013-04-19 19:56:39 +00:00
Eric Christopher 3669c3c603 Revert "PR14606: Debug info for using directives/DW_TAG_imported_module"
This reverts commit r179837 as it seems to be causing test failures.

llvm-svn: 179839
2013-04-19 07:46:36 +00:00
David Blaikie cf5e5bade1 PR14606: Debug info for using directives/DW_TAG_imported_module
More changes later for using declarations/DW_TAG_imported_declaration.

llvm-svn: 179837
2013-04-19 07:04:02 +00:00
David Blaikie bfa5274df5 Give CGDebugInfo::getContextDescriptor a more specific return type
Not that the DI* hierarchy is terribly type safe, but this makes the contract a
little clearer I think.

llvm-svn: 179835
2013-04-19 06:56:38 +00:00
John McCall c8e0170578 Standardize accesses to the TargetInfo in IR-gen.
Patch by Stephen Lin!

llvm-svn: 179638
2013-04-16 22:48:15 +00:00
Eric Christopher 5c7ee8b996 Revert "Revert r178079, it caused PR15637."
This reverts commit r178497 since the backend has been fixed.

Also add a test to ensure that we're emitting template information for unions.

llvm-svn: 178587
2013-04-02 22:59:11 +00:00
Nico Weber 0f27c6079b Revert r178079, it caused PR15637.
Also add a test for PR15637.

llvm-svn: 178497
2013-04-01 20:33:18 +00:00
Adrian Prantl 0f6df00e4d Bugfix/Followup for r177086.
* Store the .block_descriptor (instead of self) in the alloca so we
  can guarantee that all captured variables are available at -O0.
* Add the missing OpDeref for the alloca.
rdar://problem/12767564

llvm-svn: 178361
2013-03-29 19:20:35 +00:00
Adrian Prantl de17db30d8 Improvement on r177086.
* Let DIType for block-captured self to point to the completed cached
  interface type.
rdar://problem/12767564

llvm-svn: 178360
2013-03-29 19:20:29 +00:00
David Blaikie 49ae6a7cf8 Remove magic number usage from CGDebugInfo with new DICompositeType::setContainingType
llvm-svn: 178092
2013-03-26 23:47:35 +00:00
David Blaikie 2ebf08ecbd Debug Info: remove use of magic numbers to tweak specific debug info metadata fields
llvm-svn: 178079
2013-03-26 22:09:53 +00:00
Nick Lewycky c02bbb61e1 Make clang emit linkage names in debug info for subprograms when coverage info
is enabled. Also add a new -test-coverage cc1 flag which makes testing coverage
possible and add our first clang-side coverage test.

llvm-svn: 177470
2013-03-20 01:38:16 +00:00
Adrian Prantl 616bef4ad1 Always declare the .block_descriptor parameter, not just the local copy.
Un-breaks gdb's invoke-block behavior.

llvm-svn: 177118
2013-03-14 21:52:59 +00:00
Adrian Prantl 51936dd0bc Allocate stack storage for .block_descriptor and captured self at -O0.
This way the register allocator will not optimize away the debug info
for captured variables.

Fixes rdar://problem/12767564

llvm-svn: 177086
2013-03-14 17:53:33 +00:00
Adrian Prantl c782242a12 Force column info to be generated for call expressions so we can
differentiate multiple inlined call sites on the same line
in the debug info.

Fixes rdar://problem/13036237

llvm-svn: 176895
2013-03-12 20:43:25 +00:00
Adrian Prantl 73409ce90f Improve the caching of debuginfo Objective C interface types.
Generate forward declarations that are RAUW'd by finalize().
We thus avoid outputting the same type several times in multiple
stages of completion.

llvm-svn: 176820
2013-03-11 18:33:46 +00:00
Adrian Prantl a03a85a425 Ensure that DIType is regenerated after we visit an implementation
that adds ivars to an interface.

Fixes rdar://13175234

This is an update to r176116 that performs a smart caching of interfaces.

llvm-svn: 176584
2013-03-06 22:03:30 +00:00
Adrian Prantl 68a5750d5d Temporarily revert r176116 for compile-time performance regression.
This reverts commit ea95e4587fd13606fbf63b10a07a7d02026aa39c.

llvm-svn: 176151
2013-02-27 01:31:55 +00:00
Adrian Prantl 71510db7bc Ensure that DIType is regenerated after we visited an implementation that adds ivars to an interface. Fixes rdar://13175234
llvm-svn: 176116
2013-02-26 20:01:46 +00:00
David Blaikie 6d4fe1592d Update Clang for a minor DIBuilder breaking change.
llvm-svn: 176003
2013-02-25 01:07:08 +00:00
Eric Christopher f1545838d7 Propagate the split dwarf file information through into the backend
and through to the debug info in the module. In order to make the
testcase a bit more efficient allow the filename to go through
compilation for compile and not assemble jobs and turn off the
extract for cases where we don't create an object.

llvm-svn: 175935
2013-02-22 23:50:16 +00:00
Benjamin Kramer 9170e914fc Streamify getNameForDiagnostic and remove the string versions of PrintTemplateArgumentList.
llvm-svn: 175894
2013-02-22 15:46:01 +00:00
Eric Christopher c0c5d46c81 Fix formatting and tabs in file.
llvm-svn: 175815
2013-02-21 22:35:08 +00:00
Fariborz Jahanian 65f1fa1bb2 Patch for debug info of qualified-id types is 'id'
By Adrian Pranti.

llvm-svn: 175793
2013-02-21 20:42:11 +00:00
Guy Benyei 610541989a Add OpenCL samplers as Clang builtin types and check sampler related restrictions.
llvm-svn: 174601
2013-02-07 10:55:47 +00:00
David Blaikie b7d1e1ff57 Revert r174246, accidentally committed.
This reverts commit 1513eb9284c23acfd19cf742b95996fbb11ca741.

llvm-svn: 174249
2013-02-02 00:39:32 +00:00
David Blaikie ef50169a03 Basics
llvm-svn: 174246
2013-02-02 00:34:16 +00:00
David Blaikie 357aafb566 Fix exception handling line table problems introduced by r173593
r173593 made us a little too eager to associate all code at the end of a
function with the user-written 'return' line. This caused problems with
breakpoints as they'd be set in exception handling code preceeding the
actual non-exception return handling code, leading to the breakpoint never
being hit in non-exceptional execution.

This change restores the pre-r173593 exception handling line information where
the cleanup code is associated with the '}' not the return line.

llvm-svn: 174206
2013-02-01 19:09:49 +00:00