summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
Commit message (Collapse)AuthorAgeFilesLines
...
* [MS ABI] Rephrase the mangling of array types in parametersDavid Majnemer2015-04-271-6/+5
| | | | | | Make the canonicalization of array types more consistent. llvm-svn: 235831
* Replace getPointeeType()->isFunctionType with isMemberDataPointerTypeDavid Majnemer2015-04-241-1/+1
| | | | llvm-svn: 235682
* [MS ABI] Fix the preferred alignment of member pointersDavid Majnemer2015-04-241-1/+6
| | | | | | | Member pointers in the MS ABI have different alignment depending on whether they were created on the stack or live in a record. llvm-svn: 235681
* Cleanup some MS-ABI specific codeDavid Majnemer2015-04-242-11/+12
| | | | | | No functional change intended. llvm-svn: 235680
* [MS ABI] Add support for mangling VLA typesDavid Majnemer2015-04-231-13/+12
| | | | | | Treat a VLA type like an incomplete array type. llvm-svn: 235575
* [MS ABI] Treat ConstantArrayType like IncompleteArrayType in argsDavid Majnemer2015-04-231-4/+14
| | | | | | | | | | | | | Type backreferences for arguments use the DecayedType's original type. Because of this, arguments with the same canonical type with the same mangling would not backreference each other if one was a ConstantArrayType while the other was an IncompleteArrayType. Solve this by canonicalizing the ConstantArrayType to a suitable IncompleteArrayType. This fixes PR23325. llvm-svn: 235572
* Wrap to 80 columns, fix typo in comment. No behavior change.Nico Weber2015-04-221-7/+7
| | | | llvm-svn: 235470
* Implement target-specific __attribute__((aligned)) valueUlrich Weigand2015-04-211-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The GCC construct __attribute__((aligned)) is defined to set alignment to "the default alignment for the target architecture" according to the GCC documentation: The default alignment is sufficient for all scalar types, but may not be enough for all vector types on a target that supports vector operations. The default alignment is fixed for a particular target ABI. clang currently hard-coded an alignment of 16 bytes for that construct, which is correct on some platforms (including X86), but wrong on others (including SystemZ). Since this value is ABI-relevant, it is important to get correct for compatibility purposes. This patch adds a new TargetInfo member "DefaultAlignForAttributeAligned" that targets can set to the appropriate default __attribute__((aligned)) value. Note that I'm deliberately *not* using the existing "SuitableAlign" value, which is used to set the pre-defined macro __BIGGEST_ALIGNMENT__, since those two values may not be the same on all platforms. In fact, on X86, __attribute__((aligned)) always uses 16-byte alignment, while __BIGGEST_ALIGNMENT__ may be larger if AVX-2 or AVX-512 are supported. (This is actually not yet correctly implemented in clang either.) The patch provides a value for DefaultAlignForAttributeAligned only for SystemZ, and leaves the default for all other targets at 16, which means no visible change in behavior on all other targets. (The value is still wrong for some other targets, but I'd prefer to leave it to the target maintainers for those platforms to fix.) llvm-svn: 235397
* Fix __alignof__ of global variables on SystemZUlrich Weigand2015-04-211-1/+1
| | | | | | | | | | | | | | | | | SystemZ prefers to align all global variables to two bytes, which is implemented by setting the TargetInfo member MinGlobalAlign. However, for compatibility with existing compilers this should *not* change the ABI alignment value as retrieved via __alignof__, which it currently does. This patch fixes the issue by having ASTContext::getDeclAlign ignore the MinGlobalAlign setting in the ForAlignof case. Since SystemZ is the only platform setting MinGlobalAlign, this should cause no change for any other target. llvm-svn: 235395
* Follow-up to r235046: selectany only causes a definition if it's not inherited.Nico Weber2015-04-171-1/+2
| | | | | | | | (For example needed to parse system header inputscope.h, which first has an extern "C" selectany IID and then later an extern "C" declaration of that same IID.) llvm-svn: 235174
* [Objective-C Sema] patch to introduce IndependentClassFariborz Jahanian2015-04-161-0/+5
| | | | | | | | | attribute to be placed on Objective-C pointer typedef to make them strong enough so on their "new" method family no attempt is made to override these types. rdar://20255473 llvm-svn: 235128
* [OPENMP] Codegen for 'copyin' clause in 'parallel' directive.Alexey Bataev2015-04-162-7/+40
| | | | | | | | | | | | | | | Emits the following code for the clause at the beginning of the outlined function for implicit threads: if (<not a master thread>) { ... <thread local copy of var> = <master thread local copy of var>; ... } <sync point>; Checking for a non-master thread is performed by comparing of the address of the thread local variable with the address of the master's variable. Master thread always uses original variables, so you always know the address of the variable in the master thread. Differential Revision: http://reviews.llvm.org/D9026 llvm-svn: 235075
* [OPENMP] Codegen for 'lastprivate' clause in 'for' directive.Alexey Bataev2015-04-162-7/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | #pragma omp for lastprivate(<var>) for (i = a; i < b; ++b) <BODY>; This construct is translated into something like: <last_iter> = alloca i32 <lastprivate_var> = alloca <type> <last_iter> = 0 ; No initializer for simple variables or a default constructor is called for objects. ; For arrays perform element by element initialization by the call of the default constructor. ... OMP_FOR_START(...,<last_iter>, ..); sets <last_iter> to 1 if this is the last iteration. <BODY> ... OMP_FOR_END if (<last_iter> != 0) { <var> = <lastprivate_var> ; Update original variable with the lastprivate value. } call __kmpc_cancel_barrier() ; an implicit barrier to avoid possible data race. Differential Revision: http://reviews.llvm.org/D8658 llvm-svn: 235074
* Comment parsing: fix an assertion failure on a verbatim block terminated ↵Dmitri Gribenko2015-04-151-0/+6
| | | | | | with "**/" llvm-svn: 235057
* Don't crash when a selectany symbol would get common linkageNico Weber2015-04-151-3/+3
| | | | | | | | | | | | | | | | Things can't both be in comdats and have common linkage, so never give things in comdats common linkage. Common linkage is only used in .c files, and the only thing that can trigger a comdat in c is selectany from what I can tell. Fixes PR23243. Also address an over-the-shoulder review comment from rnk by moving the hasAttr<SelectAnyAttr>() in Decl.cpp around a bit. It only makes a minor difference for selectany on global variables, so it goes well with the rest of this patch. http://reviews.llvm.org/D9042 llvm-svn: 235053
* clang-format a line containing nothing but a "{". No behavior change.Nico Weber2015-04-151-3/+2
| | | | llvm-svn: 235047
* Make __declspec(selectany) turn variable declartions into definitions.Nico Weber2015-04-151-2/+2
| | | | | | Fixes PR23242. llvm-svn: 235046
* Change range-based for-loops to be -Wrange-loop-analysis clean.Richard Trieu2015-04-151-1/+1
| | | | | | No functionality change. llvm-svn: 234964
* Reland r234613 (and follow-ups 234614, 234616, 234618)Reid Kleckner2015-04-142-0/+26
| | | | | | | The frameescape intrinsic cannot be inlined, so I fixed the inliner in r234937. This should address PR23216. llvm-svn: 234942
* Revert r234613 (and follow-ups 234614, 234616, 234618), it caused PR23216.Nico Weber2015-04-132-26/+0
| | | | llvm-svn: 234789
* Revert r234786, it contained a bunch of stuff I did not mean to commit.Nico Weber2015-04-132-0/+26
| | | | llvm-svn: 234787
* Revert r234613 (and follow-ups 234614, 234616, 234618), it caused PR23216.Nico Weber2015-04-132-26/+0
| | | | llvm-svn: 234786
* [SEH] Re-land r234532, but use internal linkage for all SEH helpersReid Kleckner2015-04-102-0/+26
| | | | | | | | | | Even though these symbols are in a comdat group, the Microsoft linker really wants them to have internal linkage. I'm planning to tweak the mangling in a follow-up change. This is a straight revert with a 1-line fix. llvm-svn: 234613
* [OPENMP] Codegen for 'reduction' clause in 'parallel' directive.Alexey Bataev2015-04-102-3/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Emit a code for reduction clause. Next code should be emitted for reductions: static kmp_critical_name lock = { 0 }; void reduce_func(void *lhs[<n>], void *rhs[<n>]) { ... *(Type<i> *)lhs[i] = RedOp<i>(*(Type<i> *)lhs[i], *(Type<i> *)rhs[i]); ... } ... void *RedList[<n>] = {&<RHSExprs>[0], ..., &<RHSExprs>[<n> - 1]}; switch (__kmpc_reduce{_nowait}(<loc>, <gtid>, <n>, sizeof(RedList), RedList, reduce_func, &<lock>)) { case 1: ... <LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i]); ... __kmpc_end_reduce{_nowait}(<loc>, <gtid>, &<lock>); break; case 2: ... Atomic(<LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i])); ... break; default: ; } Reduction variables are a kind of a private variables, they have private copies, but initial values are chosen in accordance with the reduction operation. Differential Revision: http://reviews.llvm.org/D8915 llvm-svn: 234583
* Revert r234532 for a bit, it very likely caused http://crbug.com/475768Nico Weber2015-04-102-26/+0
| | | | llvm-svn: 234563
* [SEH] Outline finally blocks using the new variable capture supportReid Kleckner2015-04-092-0/+26
| | | | | | | | | | | | | | | WinEHPrepare was going to have to pattern match the control flow merge and split that the old lowering used, and that wasn't really feasible. Now we can teach WinEHPrepare to pattern match this, which is much simpler: %fp = call i8* @llvm.frameaddress(i32 0) call void @func(iN [01], i8* %fp) This prototype happens to match the prototype used by the Win64 SEH personality function, so this is really simple. llvm-svn: 234532
* Properly implement warn_unused_result checking for classes/structs.Kaelyn Takata2015-04-092-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous implementation would copy the attribute from the class to functions that have the class as their return type when the functions are first declared. This proved to have two flaws: 1) if the class is forward-declared without the attribute and a function or method with the class as a its return type is declared, and afterward the class is defined with warn_unused_result, the function or method would never inherit the attribute, and 2) the check simply failed for functions and methods that are part of a template instantiation, regardless of whether the class with warn_unused_result is part of a specific instantiation or part of the template itself (presumably because those function/method declaration does not hit the same code path as a non-template one and so never inherits the attribute). The new approach is to instead modify the two places where a function or method call is checked for the warn_unused_result attribute on the decl by extending the checks to also look for the attribute on the decl's return type. Additionally, the check for return types that have the warn_unused_result now excludes pointers and references to such types, as such return types do not necessarily imply a transfer of ownership for the underlying object being referred to by the return value. This does not change the behavior of functions that are directly given the warn_unused_result attribute. llvm-svn: 234526
* HasSideEffects() should return false for calls to pure and const functions.Michael Kuperstein2015-04-061-3/+11
| | | | | | Differential Revision: http://reviews.llvm.org/D8548 llvm-svn: 234152
* Replace copy loop with std::copy.Benjamin Kramer2015-04-051-2/+1
| | | | | | No functional change intended. llvm-svn: 234123
* [AST] String literal operator templates have two template args, not oneDavid Majnemer2015-04-051-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | StmtPrinter assumed that the first template arg was the pack and attempted to iterate it. However, the GNU extension (which is really just N3599), has two template arguments. In this case, the second argument is the pack containing the string contents. Handle this by desugaring the call to the explicit operator. For example: "qux" _zombocom will be shown as operator "" _zombocom<char, 'q', 'u', 'x'>() in diagnostics and AST dumps. N.B. It is actually impossible to render the arguments back to the source form without storing more information in the AST. For example, we cannot tell if the user wrote u8"qux" or "qux". We also lose fidelity when it comes to non-char types for this exact reason (e.g. it is hard to render a list of wchar_t back to something that can be printed to the screen even if you don't have to consider surrogate pairs). This fixes PR23120. llvm-svn: 234110
* Added support for attributed types to the ASTImporter.Sean Callanan2015-04-021-0/+22
| | | | | | <rdar://problem/20403544> llvm-svn: 233985
* Lower the default alignment on ASTContext's operator new.Benjamin Kramer2015-04-021-4/+5
| | | | | | | | | | | It was documented as 8 and operator new[] defaults to 8, but the normal operator new was never updated and happily wasted bytes on every other allocation. We still have to allocate all Types with 16 byte alignment, update the allocation calls for Types that were missing explicit alignment. llvm-svn: 233922
* [ast] Put the Stmt hierarchy on a diet for 64 bit targets.Benjamin Kramer2015-04-021-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we would waste 32 bits on alignment, use LLVM_ALIGNAS to free that space for derived classes an place. Sadly still have to #ifdef out MSVC 2013 because it can't align based on a sizeof expr. No intended functionality change. New byte counts: sizeof(before) | sizeof(after) LabelStmt: 32 | LabelStmt: 24 SwitchStmt: 48 | SwitchStmt: 40 WhileStmt: 40 | WhileStmt: 32 DoStmt: 40 | DoStmt: 32 ForStmt: 64 | ForStmt: 56 ContinueStmt: 16 | ContinueStmt: 8 BreakStmt: 16 | BreakStmt: 8 ReturnStmt: 32 | ReturnStmt: 24 AsmStmt: 40 | AsmStmt: 32 GCCAsmStmt: 80 | GCCAsmStmt: 72 MSAsmStmt: 96 | MSAsmStmt: 88 SEHExceptStmt: 32 | SEHExceptStmt: 24 SEHFinallyStmt: 24 | SEHFinallyStmt: 16 SEHLeaveStmt: 16 | SEHLeaveStmt: 8 CapturedStmt: 32 | CapturedStmt: 24 CXXCatchStmt: 32 | CXXCatchStmt: 24 CXXForRangeStmt: 72 | CXXForRangeStmt: 64 ObjCAtFinallyStmt: 24 | ObjCAtFinallyStmt: 16 ObjCAtSynchronizedStmt: 32 | ObjCAtSynchronizedStmt: 24 ObjCAtThrowStmt: 24 | ObjCAtThrowStmt: 16 ObjCAutoreleasePoolStmt: 24 | ObjCAutoreleasePoolStmt: 16 llvm-svn: 233921
* Partially revert "Replace custom alignment enforcement with LLVM_ALIGNAS."Benjamin Kramer2015-04-021-2/+4
| | | | | | | | | MSVC 2013 can't even parse __declspec(align(sizeof(foo))). We'll have to wait until MSVC 2015 for this. This partially reverts commit r233911. llvm-svn: 233912
* Replace custom alignment enforcement with LLVM_ALIGNAS.Benjamin Kramer2015-04-022-4/+6
| | | | | | | | | | This isn't perfect as it still assumes sizeof(void*) == alignof(void*), but we can fix that when compiler support gets better. Shrinks some Stmts that happen to inherit from Stmt and have a SourceLocation as the first member (64 bit archs only). llvm-svn: 233911
* [OPENMP] Sema analysis for 'atomic capture' construct.Alexey Bataev2015-04-011-5/+5
| | | | | | Added sema checks for forms of expressions/statements allowed under control of 'atomic capture' directive + generation of helper objects for future codegen. llvm-svn: 233785
* [OPENMP] Codegen for 'atomic update' construct.Alexey Bataev2015-03-301-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds atomic update codegen for the following forms of expressions: x binop= expr; x++; ++x; x--; --x; x = x binop expr; x = expr binop x; If x and expr are integer and binop is associative or x is a LHS in a RHS of the assignment expression, and atomics are allowed for type of x on the target platform atomicrmw instruction is emitted. Otherwise compare-and-swap sequence is emitted: bb: ... atomic load <x> cont: <expected> = phi [ <x>, label %bb ], [ <new_failed>, %cont ] <desired> = <expected> binop <expr> <res> = cmpxchg atomic &<x>, desired, expected <new_failed> = <res>.field1; br <res>field2, label %exit, label %cont exit: ... Differential Revision: http://reviews.llvm.org/D8536 llvm-svn: 233513
* [MS ABI] Rework .xdata HandlerType emissionDavid Majnemer2015-03-291-14/+7
| | | | | | | | | | Utilizing IMAGEREL relocations for synthetic IR constructs isn't valuable, just clutter. While we are here, simplify HandlerType names by making the numeric value for the 'adjective' part of the mangled name instead of appending '.const', etc. The old scheme made for very long global names and leads to wordy things like '.std_bad_alloc' llvm-svn: 233503
* [modules] Handle defining a tag with a typedef name for linkage purposes on ↵Richard Smith2015-03-271-0/+8
| | | | | | top of an existing imported-but-not-visible definition. llvm-svn: 233345
* Reformatting, NFCRichard Smith2015-03-261-4/+5
| | | | llvm-svn: 233234
* Fix obviously broken assertion, NFCReid Kleckner2015-03-241-4/+4
| | | | llvm-svn: 233138
* Track the source location of the dot or arrow operator in a MemberExpr.Aaron Ballman2015-03-241-12/+8
| | | | | | Patch by Joe Ranieri! llvm-svn: 233085
* [modules] Deserialize CXXCtorInitializer list for a constructor lazily.Richard Smith2015-03-243-0/+14
| | | | | | | | | | | | | Previously we'd deserialize the list of mem-initializers for a constructor when we deserialized the declaration of the constructor. That could trigger a significant amount of unnecessary work (pulling in all base classes recursively, for a start) and was causing problems for the modules buildbot due to cyclic deserializations. We now deserialize these on demand. This creates a certain amount of duplication with the handling of CXXBaseSpecifiers; I'll look into reducing that next. llvm-svn: 233052
* [modules] More removal of unnecessary deserialization of lexical decls.Richard Smith2015-03-241-2/+0
| | | | | | | | Even if we have no external visible declarations, we may still have external lexical decls that lookup() would import to fill its lookup table. It's simpler and faster to always take the no-deserialization path through noload_lookup. llvm-svn: 233046
* When looking for lexical decls from an external source, check all contextsRichard Smith2015-03-241-15/+21
| | | | | | | | rather than just the primary context. This is technically correct but results in no functionality change (in Clang nor LLDB) because all users of this functionality only use it on single-context DCs. llvm-svn: 233045
* Move private classes into anonymous namespacesBenjamin Kramer2015-03-231-2/+2
| | | | | | Also merge anonymous namespaces in Targets.cpp a bit. NFC. llvm-svn: 232945
* [OPENMP] Codegen for 'copyprivate' clause ('single' directive).Alexey Bataev2015-03-232-7/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If there is at least one 'copyprivate' clause is associated with the single directive, the following code is generated: ``` i32 did_it = 0; \\ for 'copyprivate' clause if(__kmpc_single(ident_t *, gtid)) { SingleOpGen(); __kmpc_end_single(ident_t *, gtid); did_it = 1; \\ for 'copyprivate' clause } <copyprivate_list>[0] = &var0; ... <copyprivate_list>[n] = &varn; call __kmpc_copyprivate(ident_t *, gtid, <copyprivate_list_size>, <copyprivate_list>, <copy_func>, did_it); ... void<copy_func>(void *LHSArg, void *RHSArg) { Dst = (void * [n])(LHSArg); Src = (void * [n])(RHSArg); Dst[0] = Src[0]; ... Dst[n] = Src[n]; } ``` All list items from all 'copyprivate' clauses are gathered into single <copyprivate list> (<copyprivate_list_size> is a size in bytes of this list) and <copy_func> is used to propagate values of private or threadprivate variables from the 'single' region to other implicit threads from outer 'parallel' region. Differential Revision: http://reviews.llvm.org/D8410 llvm-svn: 232932
* [modules] Remove redundant import of lexical decls when building a lookup tableRichard Smith2015-03-232-52/+49
| | | | | | | | | | | | | | | for a DeclContext, and fix propagation of exception specifications along redeclaration chains. This reverts r232905, r232907, and r232907, which reverted r232793, r232853, and r232853. One additional change is present here to resolve issues with LLDB: distinguish between whether lexical decls missing from the lookup table are local or are provided by the external AST source, and still look in the external source if that's where they came from. llvm-svn: 232928
* Add a dump function to Stmt that takes only an output stream. No ↵Faisal Vali2015-03-221-0/+5
| | | | | | | | | | functionality change. This allows dumping to any given output stream but without requiring a SourceManager, similar to the interface provided by Decl. It's useful when writing certain generic debug functions, external to the clang code base (for e.g.). llvm-svn: 232912
* Reverting r232793 until some new LLDB failures are discussedVince Harron2015-03-222-6/+31
| | | | llvm-svn: 232905
OpenPOWER on IntegriCloud