summaryrefslogtreecommitdiffstats
path: root/clang/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* [Coroutines] Find custom allocators in class scopeBrian Gesiak2018-04-012-19/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: https://reviews.llvm.org/rL325291 implemented Coroutines TS N4723 section [dcl.fct.def.coroutine]/7, but it performed lookup of allocator functions within both the global and class scope, whereas the specified behavior is to perform lookup for custom allocators within just the class scope. To fix, add parameters to the `Sema::FindAllocationFunctions` function such that it can be used to lookup allocators in global scope, class scope, or both (instead of just being able to look up in just global scope or in both global and class scope). Then, use those parameters from within the coroutine Sema. This incorrect behavior had the unfortunate side-effect of causing the bug https://bugs.llvm.org/show_bug.cgi?id=36578 (or at least the reports of that bug in C++ programs). That bug would occur for any C++ user with a coroutine frame that took a single pointer argument, since it would then find the global placement form `operator new`, described in the C++ standard 18.6.1.3.1. This patch prevents Clang from generating code that triggers the LLVM assert described in that bug report. Test Plan: `check-clang` Reviewers: GorNishanov, eric_niebler, lewissbaker Reviewed By: GorNishanov Subscribers: EricWF, cfe-commits Differential Revision: https://reviews.llvm.org/D44552 llvm-svn: 328949
* Fix a major swiftcall ABI bug with trivial C++ class types.John McCall2018-04-011-16/+4
| | | | | | | | | | | | | | | | | | | | | | The problem with the previous logic was that there might not be any explicit copy/move constructor declarations, e.g. if the type is trivial and we've never type-checked a copy of it. Relying on Sema's computation seems much more reliable. Also, I believe Richard's recommendation is exactly the rule we use now on the Itanium ABI, modulo the trivial_abi attribute (which this change of course fixes our handling of in Swift). This does mean that we have a less portable rule for deciding indirectness for swiftcall. I would prefer it if we just applied the Itanium rule universally under swiftcall, but in the meantime, I need to fix this bug. This only arises when defining functions with class-type arguments in C++, as we do in the Swift runtime. It doesn't affect normal Swift operation because we don't import code as C++. llvm-svn: 328942
* Revert r328845, it caused crbug.com/827810.Nico Weber2018-03-314-25/+36
| | | | llvm-svn: 328922
* [analyzer] Unroll the loop when it has a unsigned counter.Henry Wong2018-03-311-7/+9
| | | | | | | | | | | | | | | | | Summary: The original implementation in the `LoopUnrolling.cpp` didn't consider the case where the counter is unsigned. This case is only handled in `simpleCondition()`, but this is not enough, we also need to deal with the unsinged counter with the counter initialization. Since `IntegerLiteral` is `signed`, there is a `ImplicitCastExpr<IntegralCast>` in `unsigned counter = IntergerLiteral`. This patch add the `ignoringParenImpCasts()` in the `IntegerLiteral` matcher. Reviewers: szepet, a.sidorin, NoQ, george.karpenkov Reviewed By: szepet, george.karpenkov Subscribers: xazax.hun, rnkovacs, cfe-commits, MTC Differential Revision: https://reviews.llvm.org/D45086 llvm-svn: 328919
* [analyzer] Fix assertion crash in CStringCheckerGeorge Karpenkov2018-03-311-5/+8
| | | | | | | | | | An offset might be unknown. rdar://39054939 Differential Revision: https://reviews.llvm.org/D45115 llvm-svn: 328912
* [analyzer] Cache offset computation for MemRegionGeorge Karpenkov2018-03-311-31/+36
| | | | | | | | | | | | | Achieves almost a 200% speedup on the example where the performance of visitors was problematic. Performance on sqlite3 is unaffected. rdar://38818362 Differential Revision: https://reviews.llvm.org/D45113 llvm-svn: 328911
* [analyzer] Fix liveness calculation for C++17 structured bindingsGeorge Karpenkov2018-03-311-24/+59
| | | | | | | | | | | | | C++ structured bindings for non-tuple-types are defined in a peculiar way, where the resulting declaration is not a VarDecl, but a BindingDecl. That means a lot of existing machinery stops working. rdar://36912381 Differential Revision: https://reviews.llvm.org/D44956 llvm-svn: 328910
* [analyzer] Track null or undef values through pointer arithmetic.Artem Dergachev2018-03-301-8/+18
| | | | | | | | | | | | | | | | | | Pointer arithmetic on null or undefined pointers results in null or undefined pointers. This is obvious for undefined pointers; for null pointers it follows from our incorrect-but-somehow-working approach that declares that 0 (Loc) doesn't necessarily represent a pointer of numeric address value 0, but instead it represents any pointer that will cause a valid "null pointer dereference" issue when dereferenced. For now we've been seeing through pointer arithmetic at the original dereference expression, i.e. in bugreporter::getDerefExpr(), but not during further investigation of the value's origins in bugreporter::trackNullOrUndefValue(). The patch fixes it. Differential Revision: https://reviews.llvm.org/D45071 llvm-svn: 328896
* [CFG] [analyzer] Work around a disappearing CXXBindTemporaryExpr.Artem Dergachev2018-03-302-12/+15
| | | | | | | | | | | | | Sometimes template instantiation causes CXXBindTemporaryExpr to be missing in its usual spot. In CFG, temporary destructors work by relying on CXXBindTemporaryExprs, so they won't work in this case. Avoid the crash and notify the clients that we've encountered an unsupported AST by failing to provide the ill-formed construction context for the temporary. Differential Revision: https://reviews.llvm.org/D44955 llvm-svn: 328895
* [CFG] [analyzer] Avoid modeling C++17 constructors that aren't fully supported.Artem Dergachev2018-03-302-6/+26
| | | | | | | | | | | | | | Not enough work has been done so far to ensure correctness of construction contexts in the CFG when C++17 copy elision is in effect, so for now we should drop construction contexts in the CFG and in the analyzer when they seem different from what we support anyway. This includes initializations with conditional operators and return values across multiple stack frames. Differential Revision: https://reviews.llvm.org/D44854 llvm-svn: 328893
* [OPENMP] Added emission of offloading data sections for declare targetAlexey Bataev2018-03-306-159/+386
| | | | | | | | | | variables. Added emission of the offloading data sections for the variables within declare target regions + fixes emission of the declare target variables marked as declare target not within the declare target region. llvm-svn: 328888
* [clang-format] Ensure wrapped ObjC selectors with 1 arg obey ↵Ben Hamilton2018-03-301-6/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | IndentWrappedFunctionNames Summary: In D43121, @Typz introduced logic to avoid indenting 2-or-more argument ObjC selectors too far to the right if the first component of the selector was longer than the others. This had a small side effect of causing wrapped ObjC selectors with exactly 1 argument to not obey IndentWrappedFunctionNames: ``` - (aaaaaaaaaa) aaaaaaaaaa; ``` This diff fixes the issue by ensuring we align wrapped 1-argument ObjC selectors correctly: ``` - (aaaaaaaaaa) aaaaaaaaaa; ``` Test Plan: New tests added. Test failed before change, passed after change. Ran tests with: % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests Reviewers: djasper, klimek, Typz, jolesiak Reviewed By: djasper, jolesiak Subscribers: cfe-commits, Typz Differential Revision: https://reviews.llvm.org/D44994 llvm-svn: 328871
* [analyzer] Remove the unused method declaration in `ValistChecker.cpp`.Henry Wong2018-03-301-1/+0
| | | | | | | | | | | | | | Summary: `getVariableNameFromRegion()` seems useless. Reviewers: xazax.hun, george.karpenkov Reviewed By: xazax.hun Subscribers: szepet, rnkovacs, a.sidorin, cfe-commits, MTC Differential Revision: https://reviews.llvm.org/D45081 llvm-svn: 328860
* [Modules] Improve fixit for framework private module mapsBruno Cardoso Lopes2018-03-301-6/+11
| | | | | | | | | The wrong source range was being provided in some case, fix that to get a better fixit. rdar://problem/38520199 llvm-svn: 328857
* Hoist MethodVFTableLocation out of MicrosoftVTableContext, NFCReid Kleckner2018-03-294-36/+25
| | | | | | | | | | | | | This allows forward declaring it so that we can add it to MicrosoftMangleContext::mangleVirtualMemPtrThunk without including VTableBuilder.h. That saves a hashtable lookup when emitting virtual member pointer functions. It also shortens a really long type name. This struct has "VFtable" in the name, so it seems pretty unlikely that someone will assume it is generally useful for non-MS C++ ABI stuff. llvm-svn: 328845
* Set dso_local on cfi_slowpath.Rafael Espindola2018-03-291-4/+5
| | | | llvm-svn: 328836
* [analyzer] Better pretty-printing of regions in exploded graphGeorge Karpenkov2018-03-292-3/+8
| | | | | | Differential Revision: https://reviews.llvm.org/D45010 llvm-svn: 328835
* [AArch64]: Add support for parsing rN registers.Manoj Gupta2018-03-291-1/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Allow rN registers to be simply parsed as correspoing xN registers. The "register ... asm("rN")" is an command to the compiler's register allocator, not an operand to any individual assembly instruction. GCC documents this syntax as "...the name of the register that should be used." This is needed to support the changes in Linux kernel (see https://lkml.org/lkml/2018/3/1/268 ) Note: This will add support only for the limited use case of register ... asm("rN"). Any other uses that make rN leak into assembly are not supported. Reviewers: kristof.beyls, rengolin, peter.smith, t.p.northover Reviewed By: peter.smith Subscribers: javed.absar, eraman, cfe-commits, srhines Differential Revision: https://reviews.llvm.org/D44815 llvm-svn: 328829
* [analyzer] Path-insensitive checker for writes into an auto-releasing pointerGeorge Karpenkov2018-03-292-0/+158
| | | | | | | | | | from the wrong auto-releasing pool, as such writes may crash. rdar://25301111 Differential Revision: https://reviews.llvm.org/D44722 llvm-svn: 328827
* [AST] Fix some Clang-tidy modernize-use-auto warnings; other minor fixes (NFC).Eugene Zelenko2018-03-292-198/+188
| | | | llvm-svn: 328826
* Mark __cfi_check as dso_local.Rafael Espindola2018-03-291-0/+1
| | | | llvm-svn: 328825
* Generalize NRVO to cover C structs.Akira Hatanaka2018-03-293-17/+48
| | | | | | | | | | | This commit generalizes NRVO to cover C structs (both trivial and non-trivial structs). rdar://problem/33599681 Differential Revision: https://reviews.llvm.org/D44968 llvm-svn: 328809
* [Sema] Make deprecation fix-it replace all multi-parameter ObjC method slots.Volodymyr Sapsai2018-03-294-36/+109
| | | | | | | | | | | | | | | | | | Deprecation replacement can be any text but if it looks like a name of ObjC method and has the same number of arguments as original method, replace all slot names so after applying a fix-it you have valid code. rdar://problem/36660853 Reviewers: aaron.ballman, erik.pilkington, rsmith Reviewed By: erik.pilkington Subscribers: cfe-commits, jkorous-apple Differential Revision: https://reviews.llvm.org/D44589 llvm-svn: 328807
* Set dso_local when clearing dllimport.Rafael Espindola2018-03-291-1/+3
| | | | llvm-svn: 328801
* Set calling convention for CUDA kernelYaxun Liu2018-03-2910-1/+45
| | | | | | | | | | | This patch sets target specific calling convention for CUDA kernels in IR. Patch by Greg Rodgers. Revised and lit test added by Yaxun Liu. Differential Revision: https://reviews.llvm.org/D44747 llvm-svn: 328795
* Disable emitting static extern C aliases for amdgcn target for CUDAYaxun Liu2018-03-293-3/+16
| | | | | | | | | Patch by Greg Rodgers. Revised and lit test added by Yaxun Liu. Differential Revision: https://reviews.llvm.org/D44987 llvm-svn: 328793
* [Hexagon] Aid bit-reverse load intrinsics lowering with bitcodeKrzysztof Parzyszek2018-03-291-0/+51
| | | | | | | | | | | The conversion of operatios to bitcode helps to eliminate an additional store in certain cases. We used to lower these load intrinsics in DAG to DAG conversion by which time, the "Dead Store Elimination" pass is already run. There is an associated LLVM patch. Patch by Sumanth Gundapaneni. llvm-svn: 328776
* Refactor some code for a warning. NFC.Richard Trieu2018-03-291-65/+39
| | | | | | | | | Use range-based for-loops instead of iterators to walk over vectors. Switch the key of the DenseMap so a custom key handler is no longer needed. Remove unncessary adds to the DenseMap. Use unique_ptr instead of manual memory management. llvm-svn: 328763
* [astmatchers] Fix linking issueGeorge Karpenkov2018-03-291-0/+3
| | | | llvm-svn: 328754
* [astmatchers] Move a matcher out of internal namespace: blind debugging of ↵George Karpenkov2018-03-291-9/+10
| | | | | | MSVC issues llvm-svn: 328750
* [ast] Do not auto-initialize Objective-C for-loop variables in Objective-C++ ↵George Karpenkov2018-03-294-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in templatized code under ARC The AST for the fragment ``` @interface I @end template <typename> void decode(I *p) { for (I *k in p) {} } void decode(I *p) { decode<int>(p); } ``` differs heavily when templatized and non-templatized: ``` |-FunctionTemplateDecl 0x7fbfe0863940 <line:4:1, line:7:1> line:5:6 decode | |-TemplateTypeParmDecl 0x7fbfe0863690 <line:4:11> col:11 typename depth 0 index 0 | |-FunctionDecl 0x7fbfe08638a0 <line:5:1, line:7:1> line:5:6 decode 'void (I *__strong)' | | |-ParmVarDecl 0x7fbfe08637a0 <col:13, col:16> col:16 referenced p 'I *__strong' | | `-CompoundStmt 0x7fbfe0863b88 <col:19, line:7:1> | |   `-ObjCForCollectionStmt 0x7fbfe0863b50 <line:6:3, col:20> | |     |-DeclStmt 0x7fbfe0863a50 <col:8, col:13> | |     | `-VarDecl 0x7fbfe08639f0 <col:8, col:11> col:11 k 'I *const __strong' | |     |-ImplicitCastExpr 0x7fbfe0863a90 <col:16> 'I *' <LValueToRValue> | |     | `-DeclRefExpr 0x7fbfe0863a68 <col:16> 'I *__strong' lvalue ParmVar 0x7fbfe08637a0 'p' 'I *__strong' | |     `-CompoundStmt 0x7fbfe0863b78 <col:19, col:20> | `-FunctionDecl 0x7fbfe0863f80 <line:5:1, line:7:1> line:5:6 used decode 'void (I *__strong)' |   |-TemplateArgument type 'int' |   |-ParmVarDecl 0x7fbfe0863ef8 <col:13, col:16> col:16 used p 'I *__strong' |   `-CompoundStmt 0x7fbfe0890cf0 <col:19, line:7:1> |     `-ObjCForCollectionStmt 0x7fbfe0890cc8 <line:6:3, col:20> |       |-DeclStmt 0x7fbfe0890c70 <col:8, col:13> |       | `-VarDecl 0x7fbfe0890c00 <col:8, col:11> col:11 k 'I *__strong' callinit |       |   `-ImplicitValueInitExpr 0x7fbfe0890c60 <<invalid sloc>> 'I *__strong' |       |-ImplicitCastExpr 0x7fbfe0890cb0 <col:16> 'I *' <LValueToRValue> |       | `-DeclRefExpr 0x7fbfe0890c88 <col:16> 'I *__strong' lvalue ParmVar 0x7fbfe0863ef8 'p' 'I *__strong' |       `-CompoundStmt 0x7fbfe0863b78 <col:19, col:20> ``` Note how in the instantiated version ImplicitValueInitExpr unexpectedly appears. While objects are auto-initialized under ARC, it does not make sense to have an initializer for a for-loop variable, and it makes even less sense to have such a different AST for instantiated and non-instantiated version. Digging deeper, I have found that there are two separate Sema* files for dealing with templates and for dealing with non-templatized code. In a non-templatized version, an initialization was performed only for variables which are not loop variables for an Objective-C loop and not variables for a C++ for-in loop: ```   if (FRI && (Tok.is(tok::colon) || isTokIdentifier_in())) {     bool IsForRangeLoop = false;     if (TryConsumeToken(tok::colon, FRI->ColonLoc)) {       IsForRangeLoop = true;       if (Tok.is(tok::l_brace))         FRI->RangeExpr = ParseBraceInitializer();       else         FRI->RangeExpr = ParseExpression();     }     Decl *ThisDecl = Actions.ActOnDeclarator(getCurScope(), D);     if (IsForRangeLoop)       Actions.ActOnCXXForRangeDecl(ThisDecl);     Actions.FinalizeDeclaration(ThisDecl);     D.complete(ThisDecl);     return Actions.FinalizeDeclaratorGroup(getCurScope(), DS, ThisDecl);   }   SmallVector<Decl *, 8> DeclsInGroup;   Decl *FirstDecl = ParseDeclarationAfterDeclaratorAndAttributes(       D, ParsedTemplateInfo(), FRI); ``` However the code in SemaTemplateInstantiateDecl was inconsistent, guarding only against C++ for-in loops. rdar://38391075 Differential Revision: https://reviews.llvm.org/D44989 llvm-svn: 328749
* [ASTMatchers] Introduce a matcher for matching any given Objective-C selectorGeorge Karpenkov2018-03-292-4/+25
| | | | | | | | Incudes a tiny related refactoring. Differential Revision: https://reviews.llvm.org/D44858 llvm-svn: 328747
* [Basic] Fix some Clang-tidy modernize and Include What You Use warnings; ↵Eugene Zelenko2018-03-284-103/+193
| | | | | | other minor fixes (NFC). llvm-svn: 328735
* [ObjC++] Make parameter passing and function return compatible with ObjCAkira Hatanaka2018-03-2816-119/+165
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ObjC and ObjC++ pass non-trivial structs in a way that is incompatible with each other. For example: typedef struct { id f0; __weak id f1; } S; // this code is compiled in c++. extern "C" { void foo(S s); } void caller() { // the caller passes the parameter indirectly and destructs it. foo(S()); } // this function is compiled in c. // 'a' is passed directly and is destructed in the callee. void foo(S a) { } This patch fixes the incompatibility by passing and returning structs with __strong or weak fields using the C ABI in C++ mode. __strong and __weak fields in a struct do not cause the struct to be destructed in the caller and __strong fields do not cause the struct to be passed indirectly. Also, this patch fixes the microsoft ABI bug mentioned here: https://reviews.llvm.org/D41039?id=128767#inline-364710 rdar://problem/38887866 Differential Revision: https://reviews.llvm.org/D44908 llvm-svn: 328731
* [Hexagon] Add support for "new" circular buffer intrinsicsKrzysztof Parzyszek2018-03-281-0/+94
| | | | | | | | | | | | | These instructions have been around for a long time, but we haven't supported intrinsics for them. The "new" vesrions use the CSx register for the start of the buffer instead of the K field in the Mx register. There is a related llvm patch. Patch by Brendon Cahoon. llvm-svn: 328725
* [MS] Fix bug in method vfptr location codeReid Kleckner2018-03-281-5/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We were assuming that vbtable indices were assigned in layout order in our comparison, which is not the case. When a virtual method, such as the destructor, appears in multiple vftables, the vftable that appears first in object layout order is the one that points to the main implementation of that method. The later vftables use thunks. In this layout, we adjusted "this" in the main implementation by the amount that is appropriate for 'B' instead of 'A', even though the main implementation is found in D's vftable for A: struct A { virtual ~A() {} }; struct B { virtual ~B() {} }; struct C : virtual B {}; struct D : virtual A, C {}; D's layout looks like: 0 D subobject (empty) 0 C base suboject 8 A base subobject 16 B base subobject With this fix, we correctly adjust by -8 in D's deleting destructor instead of -16. Fixes PR36921. llvm-svn: 328723
* Fix for LLVM header changesDavid Blaikie2018-03-281-0/+1
| | | | llvm-svn: 328718
* [Diag] Avoid emitting a redefinition note if no location is available.Matt Davis2018-03-281-1/+2
| | | | | | | | | | | | | | | | | Summary: The "previous definition is here" note is not helpful if there is no location information. The note will reference nothing in such a case. This patch first checks to see if there is location data, and if so the note diagnostic is emitted. This fixes PR15409. The issue in the first comment seems to already be resolved. This patch addresses the second example. Reviewers: bruno, rsmith Reviewed By: bruno Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D44901 llvm-svn: 328712
* [OPENMP] Codegen for ctor|dtor of declare target variables.Alexey Bataev2018-03-285-75/+221
| | | | | | | | When the declare target variables are emitted for the device, constructors|destructors for these variables must emitted and registered by the runtime in the offloading sections. llvm-svn: 328705
* [PATCH] [RISCV] Verify the input value of -march=Shiva Chen2018-03-281-6/+67
| | | | | | | | | | | | | | Summary: This patch doing more check and verify the -march= string and will issue an error if it's a invalid combination. Reviewers: asb, apazos Differential Revision: https://reviews.llvm.org/D44189 Patch by Kito Cheng. llvm-svn: 328690
* Fix some handling of AST nodes with diagnostics.Richard Trieu2018-03-289-27/+26
| | | | | | | | | The diagnostic system for Clang can already handle many AST nodes. Instead of converting them to strings first, just hand the AST node directly to the diagnostic system and let it handle the output. Minor changes in some diagnostic output. llvm-svn: 328688
* [ObjC] Make C++ triviality type traits available to non-trivial CAkira Hatanaka2018-03-281-0/+12
| | | | | | | | | | | | | | | | | | | | | | structs. r326307 and r327870 made changes that allowed using non-trivial C structs with fields qualified with __strong or __weak. This commit makes the following C++ triviality type traits available to non-trivial C structs: __has_trivial_assign __has_trivial_move_assign __has_trivial_copy __has_trivial_move_constructor __has_trivial_constructor __has_trivial_destructor rdar://problem/33599681 Differential Revision: https://reviews.llvm.org/D44913 llvm-svn: 328680
* [Driver] Add fuzzer-no-link into the list of supported Fuchsia sanitizersPetr Hosek2018-03-271-0/+1
| | | | | | | | This is needed in addition to fuzzer in order to use libFuzzer. Differential Revision: https://reviews.llvm.org/D44947 llvm-svn: 328672
* [Sema] Emit -Winteger-overflow for arguments in function calls, ObjC messages.Volodymyr Sapsai2018-03-271-7/+11
| | | | | | | | | | | | | | rdar://problem/35539384 Reviewers: ahatanak, nicholas, rsmith, jkorous-apple Reviewed By: jkorous-apple Subscribers: cfe-commits, jkorous-apple Differential Revision: https://reviews.llvm.org/D42938 llvm-svn: 328671
* [coroutines] Do not attempt to typo-correct when coroutine is looking for ↵Gor Nishanov2018-03-271-0/+9
| | | | | | | | | | required members When SemaCoroutine looks for await_resume, it means it. No need for helpful: "Did you mean await_ready?" messages. Fixes PR33477 and a couple of FIXMEs in test/SemaCXX/coroutines.cpp llvm-svn: 328663
* AMDGPU: Update datalayout for stack alignmentMatt Arsenault2018-03-271-2/+2
| | | | llvm-svn: 328657
* [Sema] Avoid crash for category implementation without interfaceShoaib Meenai2018-03-271-0/+3
| | | | | | | | | | | When we have a category implementation without a corresponding interface (which is an error by itself), semantic checks for property accesses will attempt to access a null interface declaration and then segfault. Error out in such cases instead. Differential Revision: https://reviews.llvm.org/D44916 llvm-svn: 328654
* [clang] Change std::sort to llvm::sort in response to r327219Mandeep Singh Grang2018-03-2728-69/+70
| | | | | | | | | | | r327219 added wrappers to std::sort which randomly shuffle the container before sorting. This will help in uncovering non-determinism caused due to undefined sorting order of objects having the same key. To make use of that infrastructure we need to invoke llvm::sort instead of std::sort. llvm-svn: 328636
* [clang-format] Refine ObjC guesser to handle child lines of child linesBen Hamilton2018-03-271-10/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This fixes an issue brought up by djasper@ in his review of D44790. We handled top-level child lines, but if those child lines themselves had child lines, we didn't handle them. Rather than use recursion (which could blow out the stack), I use a DenseSet to hold the set of lines we haven't yet checked (since order doesn't matter), and update the set to add the children of each line as we check it. Test Plan: New tests added. Confirmed tests failed before fix and passed after fix. Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D44831 llvm-svn: 328628
* [clang-format] Do not insert space before closing brace in ObjC dict literalBen Hamilton2018-03-271-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously, `clang-format` would sometimes insert a space before the closing brace in an Objective-C dictionary literal. Unlike array literals (which obey `Style.SpacesInContainerLiterals` to add a space after `[` and before `]`), Objective-C dictionary literals currently are not meant to insert a space after `{` and before `}`, regardless of `Style.SpacesInContainerLiterals`. However, some constructs like `@{foo : @(bar)}` caused `clang-format` to insert a space between `)` and `}`. This fixes the issue and adds tests. (I understand the behavior is not consistent between array literals and dictionary literals, but that's existing behavior that's a much larger change.) Test Plan: New tests added. Ran tests with: % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests Reviewers: djasper, jolesiak, Wizard Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D44816 llvm-svn: 328627
OpenPOWER on IntegriCloud