Commit Graph

5834 Commits

Author SHA1 Message Date
David Majnemer 18fac3b1dd AST: Properly calculate the linkage of a IndirectFieldDecl
getLVForNamespaceScopeDecl believed that it wasn't possible for it to
ever see an IndirectFieldDecl.  However, this can occur when determining
whether or not something is a redeclaration of a member of an anonymous
static union.

This fixes PR21858.

llvm-svn: 223975
2014-12-10 22:58:14 +00:00
Sean Callanan b12a855ba8 Fixed an 80-column violation.
Thanks to Nico Weber for spotting this.

llvm-svn: 223966
2014-12-10 21:22:20 +00:00
Sean Callanan 49475327ff Fixed the AST importer ot use redeclaration contexts properly.
To ensure that we don't import duplicates, the ASTImporter often
checks the DeclContext for a Decl before importing it to see if
a Decl with the same name is already present.  

This is problematic if the Decl is inside a transparent context
like an extern "C" block.  Lookup isn't allowed on such contexts,
and in fact they assert() if you do that.  So instead we look at
the redeclaration context -- the containing context that can be
used safely for these kinds of checks -- instead.

llvm-svn: 223912
2014-12-10 03:09:41 +00:00
Sean Callanan 238d897b07 Made the ASTImporter resilient if it can't import
SourceLocations.  LLDB rarely has the same files
mapped into the target AST context as the source
AST context, so the ASTImporter shouldn't expect
to see those files there.

This started to become a problem when importing
entities from modules -- these have proper source
locations, in contrast to all the ASTs LLDB
creates which have empty ones.

llvm-svn: 223900
2014-12-10 01:26:39 +00:00
Sean Callanan 0aae04175b Updated the AST importer to support importing
LinkageSpecDecls.  This is relevant when LLDB
wants to import Decls from non-C++ modules,
since many declarations are in extern "C"
blocks.

llvm-svn: 223860
2014-12-10 00:00:37 +00:00
David Majnemer b511603281 AST: Don't assume two zero sized objects live at different addresses
Zero sized objects may overlap with each other or any other object.

This fixes PR21786.

llvm-svn: 223852
2014-12-09 23:32:34 +00:00
Hans Wennborg 76b005398d ASTDumper: print whether a function is constexpr
llvm-svn: 223538
2014-12-05 22:38:57 +00:00
Fariborz Jahanian 05834e2d5b This patch fixes a crash involving use of predefined
expressions. It fixes crash when mangling name for block's helper
function used inside a constructor/destructor. 
rdar://19065361.

llvm-svn: 223136
2014-12-02 18:42:51 +00:00
Nico Weber cda5c7c764 Fix typo.
llvm-svn: 222964
2014-11-29 23:57:35 +00:00
David Majnemer eea02eefe7 AST: Consider pseudo-struct builtin types as substitutable
We didn't consider types like ObjCSel as a substitution candidate.

This fixes PR21688.

llvm-svn: 222941
2014-11-28 22:22:46 +00:00
Anastasia Stulova 5d8ad8a7b8 [OpenCL] Implemented restrictions for pointer conversions specified in OpenCL v2.0.
OpenCL v2.0 s6.5.5 restricts conversion of pointers to different address spaces:
- the named address spaces (__global, __local, and __private) => __generic - implicitly converted;
- __generic => named - with an explicit cast;
- named <=> named - disallowed;
- __constant <=> any other - disallowed.

llvm-svn: 222834
2014-11-26 15:36:41 +00:00
Anastasia Stulova 2c8dcfbae6 [OpenCL] Generic address space has been added in OpenCL v2.0.
To support it in the frontend, the following has been added:  
- generic address space type attribute;
- documentation for the OpenCL address space attributes;
- parsing of __generic(generic) keyword;
- test code for the parser and diagnostics.

llvm-svn: 222831
2014-11-26 14:10:06 +00:00
David Majnemer 6fc2d813cb Simplify MicrosoftMangleContextImpl::shouldMangleStringLiteral
No functionality changed.

llvm-svn: 222610
2014-11-22 06:20:38 +00:00
David Majnemer 125efd8d4f MS ABI: Mangle u8 string literals
UTF8 string literals are mangled just like ASCII string literals.

llvm-svn: 222591
2014-11-21 23:56:50 +00:00
David Majnemer 98e77a2512 MS ABI: Mangle char16_t and char32_t string literals
We previously had support for char and wchar_t string literals.  VS 2015
added support for char16_t and char32_t.

String literals must be mangled in the MS ABI in order for them to be
deduplicated across translation units: their linker has no notion of
mergeable section.  Instead, they use the mangled name to make a COMDAT
for the string literal; the COMDAT will merge with other COMDATs in
other object files.

This allows strings in object files generated by clang to get merged
with strings in object files generated by MSVC.

llvm-svn: 222564
2014-11-21 19:57:25 +00:00
David Majnemer eca5a201f4 MS ABI: Mangle char16_t and char32_t types
These mangling make clang more compatible with MSVC 2015.
Correctly mangling char16_t and char32_t will take a little more work.

llvm-svn: 222515
2014-11-21 09:06:49 +00:00
Richard Smith e9f130cfdf Preserve numeric literal suffixes during type canonicalization.
Patch by Pierre Gousseau! Test cases altered significantly by me.

llvm-svn: 222404
2014-11-20 03:37:32 +00:00
Richard Smith 6adb42e1ac When mangling member-expressions, skip implicit accesses of anonymous union
objects. This is consistent with GCC's behavior. Patch by Tomasz Miąsko!

llvm-svn: 222402
2014-11-20 01:35:11 +00:00
Jordan Rose 210bfe9c52 Constify a few IdentifierInfo * parameters.
No functionality change.

llvm-svn: 222392
2014-11-19 22:03:46 +00:00
Richard Smith be6dd818fb Fix bug where a trivial constexpr copy/move operation couldn't copy from an
empty non-constexpr object. Such a copy doesn't break any of the constexpr
rules.

llvm-svn: 222387
2014-11-19 21:27:17 +00:00
David Blaikie 82e95a3c79 Update for LLVM API change to make Small(Ptr)Set::insert return pair<iterator, bool> as per the C++ standard's associative container concept.
llvm-svn: 222335
2014-11-19 07:49:47 +00:00
Alexey Bataev 62cec44ca4 [OPENMP] Additional processing of 'omp atomic read' directive.
According to OpenMP standard, Section 2.12.6, atomic Construct, '#pragma omp atomic read' is allowed to be used only for expression statements of form 'v = x;', where x and v (as applicable) are both l-value expressions with scalar type. Patch adds checks for it.

llvm-svn: 222231
2014-11-18 10:14:22 +00:00
Reid Kleckner d60b82f93e Handle use of default member initializers before end of outermost class
Specifically, when we have this situation:
  struct A {
    template <typename T> struct B {
      int m1 = sizeof(A);
    };
    B<int> m2;
  };

We can't parse m1's initializer eagerly because we need A to be
complete.  Therefore we wait until the end of A's class scope to parse
it. However, we can trigger instantiation of B before the end of A,
which will attempt to instantiate the field decls eagerly, and it would
build a bad field decl instantiation that said it had an initializer but
actually lacked one.

Fixed by deferring instantiation of default member initializers until
they are needed during constructor analysis. This addresses a long
standing FIXME in the code.

Fixes PR19195.

Reviewed By: rsmith

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

llvm-svn: 222192
2014-11-17 23:36:45 +00:00
Timur Iskhodzhanov 7081460287 Minor readability tweaks to VFTableBuilder.cpp
llvm-svn: 222140
2014-11-17 15:53:50 +00:00
Timur Iskhodzhanov 7d19fc1c37 Add a couple more examples illustrating why we need vtordisps and how they work
llvm-svn: 222133
2014-11-17 15:11:05 +00:00
Fariborz Jahanian 68e7938361 This patch fixes couple of bugs for predefined expression
used inside blocks. It fixes a crash in naming code
for __func__ etc. when used in a block declared globally.
It also brings back old naming convention for
predefined expression which was broken. rdar://18961148

llvm-svn: 222065
2014-11-14 23:55:27 +00:00
Timur Iskhodzhanov 4d28002728 Replace weird whitespace symbols with good old spaces
llvm-svn: 221997
2014-11-14 14:16:34 +00:00
Timur Iskhodzhanov 46a18efa5a Add one illustrative class hierarchy as an example in a comment to the VFTableBuilder code
llvm-svn: 221996
2014-11-14 14:10:15 +00:00
Richard Smith 98710fc4f5 Fix assert/crash on invalid with __builtin_constant_p conditionals in constant expressions.
llvm-svn: 221942
2014-11-13 23:03:19 +00:00
Richard Smith 0b3a46247e PR21437, final part of DR1330: delay-parsing of exception-specifications. This
is a re-commit of Doug's r154844 (modernized and updated to fit into current
Clang).

llvm-svn: 221918
2014-11-13 20:01:57 +00:00
Richard Smith 2e32155b58 Instantiate exception specifications when instantiating function types (other
than the type of a function declaration). We previously didn't instantiate
these at all! This also covers the pathological case where the only mention of
a parameter pack is within the exception specification; this gives us a second
way (other than alias templates) to reach the horrible state where a type
contains an unexpanded pack, but its canonical type does not.


This is a re-commit of r219977:

r219977 was reverted in r220038 because it hit a wrong-code bug in GCC 4.7.2.
(That's gcc.gnu.org/PR56135, and affects any implicit lambda-capture of
'this' within a template.)


r219977 was a re-commit of r217995, r218011, and r218053:

r217995 was reverted in r218058 because it hit a rejects-valid bug in MSVC.
(Incorrect overload resolution in the presence of using-declarations.)
It was re-committed in r219977 with a workaround for the MSVC rejects-valid.

r218011 was a workaround for an MSVC parser bug. (Incorrect desugaring of
unbraced range-based for loop).

llvm-svn: 221750
2014-11-12 02:00:47 +00:00
Alexey Bataev 9772000a22 [OPENMP] Codegen for threadprivate variables
For all threadprivate variables which have constructor/destructor emit call to void __kmpc_threadprivate_register(ident_t * <Current Location>, void *<Original Global Addr>, kmpc_ctor <Constructor>, kmpc_cctor NULL, kmpc_dtor <Destructor>); 
In expressions all references to such variables are replaced by calls to void *__kmpc_threadprivate_cached(ident_t *<Current Location>, kmp_int32 <Current Thread Id>, void *<Original Global Addr>, size_t <Size of Data>, void ***<Pointer to autogenerated cache – array of private copies of threadprivate variable>);
Test test/OpenMP/threadprivate_codegen.cpp checks that codegen is correct. Also it checks that codegen is correct after serialization/deserialization and one of passes verifies debug info.
Differential Revision: http://reviews.llvm.org/D4002

llvm-svn: 221663
2014-11-11 04:05:39 +00:00
Alexey Samsonov a041610f11 [Sanitizer] Refactor sanitizer options in LangOptions.
Get rid of ugly SanitizerOptions class thrust into LangOptions:
* Make SanitizeAddressFieldPadding a regular language option,
  and rely on default behavior to initialize/reset it.
* Make SanitizerBlacklistFile a regular member LangOptions.
* Introduce the helper class "SanitizerSet" to represent the
  set of enabled sanitizers and make it a member of LangOptions.
  It is exactly the entity we want to cache and modify in CodeGenFunction,
  for instance. We'd also be able to reuse SanitizerSet in
  CodeGenOptions for storing the set of recoverable sanitizers,
  and in the Driver to represent the set of sanitizers
  turned on/off by the commandline flags.

No functionality change.

llvm-svn: 221653
2014-11-11 01:26:14 +00:00
Richard Smith 8e6923b7f2 Update fold-expression mangling to match cxx-abi-dev discussion.
llvm-svn: 221623
2014-11-10 19:44:15 +00:00
Richard Smith 0f0af19b05 [c++1z] N4295: fold-expressions.
This is a new form of expression of the form:

  (expr op ... op expr)

where one of the exprs is a parameter pack. It expands into

  (expr1 op (expr2onwards op ... op expr))

(and likewise if the pack is on the right). The non-pack operand can be
omitted; in that case, an empty pack gives a fallback value or an error,
depending on the operator.

llvm-svn: 221573
2014-11-08 05:07:16 +00:00
Alexey Samsonov edf99a92c0 Introduce a SanitizerKind enum to LangOptions.
Use the bitmask to store the set of enabled sanitizers instead of a
bitfield. On the negative side, it makes syntax for querying the
set of enabled sanitizers a bit more clunky. On the positive side, we
will be able to use SanitizerKind to eventually implement the
new semantics for -fsanitize-recover= flag, that would allow us
to make some sanitizers recoverable, and some non-recoverable.

No functionality change.

llvm-svn: 221558
2014-11-07 22:29:38 +00:00
Will Wilson 5f38367c72 MS ABI: Correctly mangle CV qualifiers from typedefs
llvm-svn: 221344
2014-11-05 13:54:21 +00:00
Reid Kleckner 80944df6f4 Implement IRGen for the x86 vectorcall convention
The most complex aspect of the convention is the handling of homogeneous
vector and floating point aggregates.  Reuse the homogeneous aggregate
classification code that we use on PPC64 and ARM for this.

This convention also has a C mangling, and we apparently implement that
in both Clang and LLVM.

Reviewed By: majnemer

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

llvm-svn: 221006
2014-10-31 22:00:51 +00:00
David Blaikie 11ab078d80 Fix the build
llvm-svn: 220974
2014-10-31 17:18:09 +00:00
David Blaikie 9491a5cd4d Fix unused-function warning differently from r220853
Rather than executing this code only needed for an assertion even in a
non-asserts build, just roll the function into the assert. The assertion
text literally describes the two cases so it doesn't seem like this
benefits much from having a separate function (& have to hassle about
ifndef NDEBUG it out, etc)

llvm-svn: 220970
2014-10-31 17:08:11 +00:00
Richard Smith d5e7ff856c Make QualType::dump() produce a useful dump of the structure of the type,
rather than simply pretty-printing it.

llvm-svn: 220942
2014-10-31 01:17:45 +00:00
NAKAMURA Takumi c73e402ad2 ASTDumper.cpp: Appease g++, for now.
llvm-svn: 220940
2014-10-31 00:30:37 +00:00
Richard Smith f7514454a7 Refactor tree printing in AST dumping.
Instead of manually maintaining a flag indicating whether we're about to print
out the last child of the parent node (to determine whether we print "`" or
"|"), capture a callable to print that child and defer printing it until we
either see a next child or finish the parent.

No functionality change intended.

llvm-svn: 220930
2014-10-30 21:02:37 +00:00
NAKAMURA Takumi 639728da35 clang/lib/AST/Decl.cpp: Tweak isVLATypeCapturingAllowed() for -Asserts. [-Wunused-function]
llvm-svn: 220853
2014-10-29 13:27:44 +00:00
Alexey Bataev 330de03083 Improved capturing variable-length array types in CapturedStmt.
An updated implemnentation of VLA types capturing based on previously committed solution for Lambdas.
This version captures the whole VLA type instead of particular variables which are part of VLA size expression and allows to use previusly calculated size of VLA type in captured regions. Required for OpenMP.
Differential Revision: http://reviews.llvm.org/D5099

llvm-svn: 220850
2014-10-29 12:21:55 +00:00
Fariborz Jahanian 9ad94aa280 Objective-C. revert patch for rdar://17554063.
llvm-svn: 220812
2014-10-28 18:28:16 +00:00
Kostya Serebryany 68c29da4c5 Do not insert asan paddings after fields that have flexible arrays.
Summary:
We should avoid a tail padding not only if the last field
has zero size but also if the last field is a struct with a flexible array.

If/when http://reviews.llvm.org/D5478 is committed,
this will also handle the case of structs with zero-sized arrays.

Reviewers: majnemer, rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

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

llvm-svn: 220708
2014-10-27 19:34:10 +00:00
Kaelyn Takata e1f49d545d Add the initial TypoExpr AST node for delayed typo correction.
llvm-svn: 220692
2014-10-27 18:07:20 +00:00
David Majnemer 90a3b19e64 Itanium ABI: Template template parameters are usable as substitutions
Template template parameters weren't added to the list of substitutions.
This would make the substitution map contain inaccurate mappings,
leading to Clang violating the Itanium ABI and breaking compatibility
with GCC.

This fixes PR21351.

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

llvm-svn: 220588
2014-10-24 20:22:57 +00:00
Reid Kleckner d7857f05f4 Add frontend support for __vectorcall
Wire it through everywhere we have support for fastcall, essentially.

This allows us to parse the MSVC "14" CTP headers, but we will
miscompile them because LLVM doesn't support __vectorcall yet.

Reviewed By: Aaron Ballman

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

llvm-svn: 220573
2014-10-24 17:42:17 +00:00