summaryrefslogtreecommitdiffstats
path: root/clang/lib
Commit message (Collapse)AuthorAgeFilesLines
* StaticAnalyzer: fix compiler warning. NFCPavel Labath2018-03-141-1/+1
| | | | | | | | | | | | My compiler (clang-3.8) complains that the RCC variable is unused. That's not really true, as it's checked by the if-declaration, but it's also kinda true, because we don't need to declaration if we only check it in the if statement. In reality, all this means that the dyn_cast<> can be replaced by isa<>, so that's what I do here. llvm-svn: 327491
* Check that a field is not annotated with attribute "unavailable" beforeAkira Hatanaka2018-03-131-1/+1
| | | | | | | | | | | | setting the NonTrivialToPrimitive* flags of a record. Union fields that have non-trivial Objective-C ownership qualifications are normally not legal, but if the union is declared in a system header, the fields are annotated with attribute "unavailable". rdar://problem/38431072 llvm-svn: 327464
* [OpenMP] Add flag for linking runtime bitcode libraryGheorghe-Teodor Bercea2018-03-131-0/+38
| | | | | | | | | | | | | | Summary: This patch adds an additional flag to the OpenMP device offloading toolchain to link in the runtime library bitcode. Reviewers: Hahnfeld, ABataev, carlo.bertolli, caomhin, grokos, hfinkel Reviewed By: ABataev, grokos Subscribers: jholewinski, guansong, cfe-commits Differential Revision: https://reviews.llvm.org/D43197 llvm-svn: 327460
* [ARM] ACLE FP16 feature test macrosSjoerd Meijer2018-03-132-0/+13
| | | | | | | | | This is a partial recommit of r327189 that was reverted due to test issues. I.e., this recommits minimal functional change, the FP16 feature test macros, and adds tests that were missing in the original commit. llvm-svn: 327455
* [Analysis] Fix some Clang-tidy modernize and Include What You Use warnings; ↵Eugene Zelenko2018-03-134-157/+124
| | | | | | other minor fixes (NFC). llvm-svn: 327453
* Revert revision 327438.Gheorghe-Teodor Bercea2018-03-131-38/+0
| | | | llvm-svn: 327447
* [OpenMP] Add flag for linking runtime bitcode libraryGheorghe-Teodor Bercea2018-03-131-0/+39
| | | | | | | | | | | | | | Summary: This patch adds an additional flag to the OpenMP device offloading toolchain to link in the runtime library bitcode. Reviewers: Hahnfeld, ABataev, carlo.bertolli, caomhin, grokos, hfinkel Reviewed By: ABataev, grokos Subscribers: jholewinski, guansong, cfe-commits Differential Revision: https://reviews.llvm.org/D43197 llvm-svn: 327438
* This reverts "r327189 - [ARM] Add ARMv8.2-A FP16 vector intrinsic"Sjoerd Meijer2018-03-134-76/+57
| | | | | | | This is causing problems in testing, and PR36683 was raised. Reverting it until we have sorted out how to pass f16 vectors. llvm-svn: 327437
* Serialize the NonTrivialToPrimitive* flags I added in r326307.Akira Hatanaka2018-03-133-3/+17
| | | | | | rdar://problem/38421774 llvm-svn: 327434
* [analyzer] Fix the matcher for GCDAntipattern to look for "signal" call in ↵George Karpenkov2018-03-131-2/+2
| | | | | | | | all parameters rdar://38405904 llvm-svn: 327426
* Reland "[Attr] Fix parameter indexing for several attributes"Joel E. Denny2018-03-138-127/+103
| | | | | | | | | Relands r326602 (reverted in r326862) with new test and fix for PR36620. Differential Revision: https://reviews.llvm.org/D43248 llvm-svn: 327405
* [CFG] [analyzer] Don't add construction context to a return-by-reference call.Artem Dergachev2018-03-121-2/+2
| | | | | | | | | | | | | | Call expressions that return objects by an lvalue reference or an rvalue reference have a value type in the AST but wear an auxiliary flag of being an lvalue or an xvalue respectively. Use the helper method for obtaining the actual return type of the function. Fixes a crash. Differential Revision: https://reviews.llvm.org/D44273 llvm-svn: 327352
* [analyzer] Support temporaries conjured by conservatively evaluated functions.Artem Dergachev2018-03-121-14/+30
| | | | | | | | | | | | | | Properly perform destruction and lifetime extension of such temporaries. C++ object-type return values of conservatively evaluated functions are now represented as compound values of well-defined temporary object regions. The function creates a region that represents the temporary object and will later be used for destruction or materialization, invalidates it, and returns the invalidated compound value of the object. Differential Revision: https://reviews.llvm.org/D44131 llvm-svn: 327348
* [analyzer] NFC: Move the code for setting temp object lifetime into method.Artem Dergachev2018-03-122-61/+61
| | | | | | Differential Revision: https://reviews.llvm.org/D44129 llvm-svn: 327347
* [analyzer] Destroy and lifetime-extend inlined function return values properly.Artem Dergachev2018-03-121-29/+58
| | | | | | | | | | | | | | | This patch uses the newly added CFGCXXRecordTypedCall element at the call site of the caller to construct the return value within the callee directly into the caller's stack frame. This way it is also capable of populating the temporary destructor and lifetime extension maps for the temporary, which allows temporary destructors and lifetime extension to work correctly. This patch does not affect temporaries that were returned from conservatively evaluated functions. Differential Revision: https://reviews.llvm.org/D44124 llvm-svn: 327345
* [CFG] [analyzer] Add construction context to C++ return-by-value call elements.Artem Dergachev2018-03-123-56/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds a new CFGStmt sub-class, CFGCXXRecordTypedCall, which replaces the regular CFGStmt for the respective CallExpr whenever the CFG has additional information to provide regarding the lifetime of the returned value. This additional call site information is represented by a ConstructionContext (which was previously used for CFGConstructor elements) that provides references to CXXBindTemporaryExpr and MaterializeTemporaryExpr that surround the call. This corresponds to the common C++ calling convention solution of providing the target address for constructing the return value as an auxiliary implicit argument during function call. One of the use cases for such extra context at the call site would be to perform any sort of inter-procedural analysis over the CFG that involves functions returning objects by value. In this case the elidable constructor at the return site would construct the object explained by the context at the call site, and its lifetime would also be managed by the caller, not the callee. The extra context would also be useful for properly handling the return-value temporary at the call site, even if the callee is not being analyzed inter-procedurally. Differential Revision: https://reviews.llvm.org/D44120 llvm-svn: 327343
* Re-land "[Sema] Make getCurFunction() return null outside function parsing"Reid Kleckner2018-03-129-96/+109
| | | | | | | | | | | | | | This relands r326965. There was a null dereference in typo correction that was triggered in Sema/diagnose_if.c. We are not always in a function scope when doing typo correction. The fix is to add a null check. LLVM's optimizer made it hard to find this bug. I wrote it up in a not-very-well-editted blog post here: http://qinsb.blogspot.com/2018/03/ub-will-delete-your-null-checks.html llvm-svn: 327334
* [Tooling] Clear the PreambleSrcLocCache when preamble is discarded during ↵Alex Lorenz2018-03-121-0/+1
| | | | | | | | | | | reparsing This ensures that diagnostics are not remapped to incorrect preamble locations after the second reparse with a remapped header file occurs. rdar://37502480 llvm-svn: 327322
* [analyzer] Move the GCDAsyncSemaphoreChecker to optin.performanceGeorge Karpenkov2018-03-122-19/+26
| | | | | | | | rdar://38383753 Differential Revision: https://reviews.llvm.org/D44228 llvm-svn: 327309
* Revert "[ObjC] Allow declaring __weak pointer fields in C structs inAkira Hatanaka2018-03-1213-129/+32
| | | | | | | | | | | ARC." This reverts commit r327206 as there were test failures caused by this patch. http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180312/221427.html llvm-svn: 327294
* [clang-format] Improve detection of Objective-C block typesBen Hamilton2018-03-121-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously, clang-format would detect the following as an Objective-C block type: FOO(^); when it actually must be a C or C++ macro dealing with an XOR statement or an XOR operator overload. According to the Clang Block Language Spec: https://clang.llvm.org/docs/BlockLanguageSpec.html block types are of the form: int (^)(char, float) and block variables of block type are of the form: void (^blockReturningVoidWithVoidArgument)(void); int (^blockReturningIntWithIntAndCharArguments)(int, char); void (^arrayOfTenBlocksReturningVoidWithIntArgument[10])(int); This tightens up the detection so we don't unnecessarily detect C macros which pass in the XOR operator. Depends On D43904 Test Plan: New tests added. Ran tests with: make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests Reviewers: krasimir, jolesiak, djasper Reviewed By: djasper Subscribers: djasper, cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D43906 llvm-svn: 327285
* [clang-format] Don't detect C++11 attribute specifiers as ObjCBen Hamilton2018-03-123-13/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously, clang-format would detect C++11 and C++17 attribute specifiers like the following as Objective-C method invocations: [[noreturn]]; [[clang::fallthrough]]; [[noreturn, deprecated("so sorry")]]; [[using gsl: suppress("type")]]; To fix this, I ported part of the logic from tools/clang/lib/Parse/ParseTentative.cpp into TokenAnnotator.cpp so we can explicitly parse and identify C++11 attribute specifiers. This allows the guessLanguage() and getStyle() APIs to correctly guess files containing the C++11 attribute specifiers as C++, not Objective-C. Test Plan: New tests added. Ran tests with: make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests Reviewers: krasimir, jolesiak, djasper Reviewed By: djasper Subscribers: aaron.ballman, cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D43902 llvm-svn: 327284
* [analyzer] Add scope information to CFGMaxim Ostapenko2018-03-126-7/+167
| | | | | | | | | | | This patch adds two new CFG elements CFGScopeBegin and CFGScopeEnd that indicate when a local scope begins and ends respectively. We use first VarDecl declared in a scope to uniquely identify it and add CFGScopeBegin and CFGScopeEnd elements into corresponding basic blocks. Differential Revision: https://reviews.llvm.org/D16403 llvm-svn: 327258
* clang-format: Properly handle implicit string concatenation in text protosDaniel Jasper2018-03-123-2/+5
| | | | | | | | | | | | | Three issues to fix: - char_constants weren't properly treated as string literals - Prevening the break after "label: " does not make sense in concunction with AlwaysBreakBeforeMultilineStrings. It leads to situations where clang-format just cannot find a viable format (it must break and yet it must not break). - AlwaysBreakBeforeMultilineStrings should not be on for LK_TextProto in Google style. llvm-svn: 327255
* Don't re-format raw string literal contents when formatting is disableDaniel Jasper2018-03-121-1/+1
| | | | | | | Not entirely sure this is the best place to put this check, but it fixes the immediate issue. llvm-svn: 327253
* [Driver] Update the comment about incompatible sanitizersPetr Hosek2018-03-121-1/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D44371 llvm-svn: 327249
* [CodeGen] Eagerly emit lifetime.end markers for callsGeorge Burgess IV2018-03-101-6/+28
| | | | | | | | | | | | | | | | | | | | | | In C, we'll wait until the end of the scope to clean up aggregate temporaries used for returns from calls. This means in cases like: { // Assuming that `Bar` is large enough to warrant indirect returns struct Bar b = {}; b = foo(&b); b = foo(&b); b = foo(&b); b = foo(&b); } ...We'll allocate space for 5 Bars on the stack (`b`, and 4 temporaries). This becomes painful in things like large switch statements. If cleaning up sooner is trivial, we should do it. llvm-svn: 327229
* [ObjC] Allow declaring __weak pointer fields in C structs in ARC.Akira Hatanaka2018-03-1013-32/+129
| | | | | | | | | | | | This patch uses the infrastructure added in r326307 for enabling non-trivial fields to be declared in C structs to allow __weak fields in C structs in ARC. rdar://problem/33599681 Differential Revision: https://reviews.llvm.org/D44095 llvm-svn: 327206
* [Driver] Pass Default=false to hasFlag.Akira Hatanaka2018-03-101-1/+1
| | | | | | I forgot to do this in r326530. llvm-svn: 327204
* Revert r326946. It caused stack overflows by significantly increasing the ↵Richard Smith2018-03-1012-201/+108
| | | | | | size of a CallArgList. llvm-svn: 327195
* [CodeGen] Try to not call a dtor after lifetime.endGeorge Burgess IV2018-03-101-47/+51
| | | | | | | | | | | | | | | | | | | | If CodeGenFunction::EmitCall is: - asked to emit a call with an indirectly returned value, - given an invalid return value slot, and - told the return value of the function it's calling is unused then it'll make its own temporary, and add lifetime markers so that the temporary's lifetime ends immediately after the call. The early lifetime.end becomes problematic when we need to run a destructor on the result of the function. Instead of unconditionally saying that results of all calls are used here (which would be correct, but would also cause us to never emit lifetime markers for these temporaries), we just build our own temporary to pass in when a dtor has to be run. llvm-svn: 327192
* [ARM] Add ARMv8.2-A FP16 vector intrinsicAbderrazek Zaafrani2018-03-094-57/+76
| | | | | | | | Add the fp16 neon vector intrinsic for ARM as described in the ARM ACLE document. Reviews in https://reviews.llvm.org/D43650 llvm-svn: 327189
* Don't use -pie in relocatable link.Evgeniy Stepanov2018-03-091-1/+2
| | | | | | | | | | | | | | Summary: Android, in particular, got PIE enabled by default in r316606. It resulted in relocatable links passing both -r and -pie to the linker, which is not allowed. Reviewers: srhines Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D44229 llvm-svn: 327165
* [OPENMP] Fix the address of the original variable in task reductions.Alexey Bataev2018-03-091-0/+3
| | | | | | | | If initialization of the task reductions requires pointer to original variable, which is stored in the threadprivate storage, we used the address of this pointer instead. llvm-svn: 327136
* [SemaOverload] Fixed crash on code completionIlya Biryukov2018-03-091-6/+11
| | | | | | | | | | | | | | | | | | Summary: The relevant failing assertion message is: ../tools/clang/lib/Sema/SemaInit.cpp:8411: PerformCopyInitialization(): Assertion `InitE && "No initialization expression?"' failed. See the added test case for a repro. Reviewers: bkramer, sammccall, ioeric, hokein Reviewed By: sammccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D44300 llvm-svn: 327134
* CodeGen: simplify and validate exception personalitiesSaleem Abdulrasool2018-03-091-19/+13
| | | | | | | | | | | | Simplify the dispatching for the personality routines. This really had no test coverage previously, so add test coverage for the various cases. This turns out to be pretty complicated as the various languages and models interact to change personalities around. You really should feel bad for the compiler if you are using exceptions. There is no reason for this type of cruelty. llvm-svn: 327105
* PR36645: Go looking for an appropriate array bound when constant-evaluating aRichard Smith2018-03-091-4/+12
| | | | | | name of an array object. llvm-svn: 327099
* [analyzer] MmapWriteExecChecker: Add support for mprotect().Artem Dergachev2018-03-091-3/+4
| | | | | | | | | | | mprotect() allows setting memory access flags similarly to mmap(), causing similar security issues if these flags are needlessly broad. Patch by David Carlier! Differential Revision: https://reviews.llvm.org/D44250 llvm-svn: 327098
* [CFG] [analyzer] Add construction context for implicit constructor conversions.Artem Dergachev2018-03-092-2/+10
| | | | | | | | | | | | | Implicit constructor conversions such as A a = B() are represented by surrounding the constructor for B() with an ImplicitCastExpr of CK_ConstructorConversion kind, similarly to how explicit constructor conversions are surrounded by a CXXFunctionalCastExpr. Support this syntax pattern when extracting the construction context for the implicit constructor that performs the conversion. Differential Revision: https://reviews.llvm.org/D44051 llvm-svn: 327096
* [DOXYGEN] Fix doxygen and content issues in mmintrin.hDouglas Yung2018-03-091-9/+11
| | | | | | | | | | - Fix instruction mappings/listings for various intrinsics This patch was made by Craig Flores Differential Revision: https://reviews.llvm.org/D41517 llvm-svn: 327090
* [StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use ↵Eugene Zelenko2018-03-082-188/+200
| | | | | | warnings; other minor fixes (NFC). llvm-svn: 327074
* [OPENMP] Emit sizes/init ptrs etc. data for task reductions beforeAlexey Bataev2018-03-081-10/+10
| | | | | | | | | | | using. We may emit the code in wrong order because of incorrect implementation of the runtime functions for task reductions. Threadprivate storages may be initialized after real initialization of the reduction items. Patch fixes this problem. llvm-svn: 327008
* [clang-format] Use NestedBlockIndent as a 0 column in formatted raw stringsKrasimir Georgiev2018-03-081-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This makes the formatter of raw string literals use NestedBlockIndent for determining the 0 column of the content inside. This makes the formatting use less horizonal space and fixes a case where two newlines before and after the raw string prefix were selected instead of a single newline after it: Before: ``` aaaa = ffff( R"pb( key: value)pb"); ``` After: ``` aaaa = ffff(R"pb( key: value)pb"); ``` Reviewers: djasper, sammccall Reviewed By: sammccall Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D44141 llvm-svn: 326996
* Propagate DLLAttr to friend re-declarations of member functionsStephan Bergmann2018-03-081-0/+15
| | | | | | | | | | | ...that have already been constructed (e.g., in inner classes) while parsing the class definition. They would otherwise lack any DLLAttr inherited from the class, which are only set here (called from Sema::CheckCompletedClass) after the class definition has been parsed completely. Differential revision: https://reviews.llvm.org/D16632 llvm-svn: 326990
* [CodeGen] Emit lifetime.ends in both EH and non-EH blocksGeorge Burgess IV2018-03-081-9/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this, we'd only emit lifetime.ends for these temps in non-exceptional paths. This potentially made our stack larger than it needed to be for any code that follows an EH cleanup. e.g. in ``` struct Foo { char cs[32]; }; void escape(void *); struct Bar { ~Bar() { char cs[64]; escape(cs); } }; Foo getFoo(); void baz() { Bar b; getFoo(); } ``` baz() would require 96 bytes of stack, since the temporary from getFoo() only had a lifetime.end on the non-exceptional path. This also makes us keep hold of the Value* returned by EmitLifetimeStart, so we don't have to remake it later. llvm-svn: 326988
* [analyzer] Correctly model iteration through "nil" objectsGeorge Karpenkov2018-03-082-39/+58
| | | | | | | | | | | | | | | | | | | | Previously, iteration through nil objects which resulted from objc-messages being set to nil were modeled incorrectly. There are a couple of notes about this patch: In principle, ExprEngineObjC might be left untouched IFF osx.loops checker is enabled. I however think that we should not do something completely incorrect depending on what checkers are left on. We should evaluate and potentially remove altogether the isConsumedExpr performance heuristic, as it seems very fragile. rdar://22205149 Differential Revision: https://reviews.llvm.org/D44178 llvm-svn: 326982
* Fix an unused variable warning; NFCGeorge Burgess IV2018-03-081-1/+1
| | | | llvm-svn: 326980
* Revert "[Sema] Make getCurFunction() return null outside function parsing"Reid Kleckner2018-03-088-107/+95
| | | | | | | | | | This reverts r326965. It seems to have caused repeating test failures in clang/test/Sema/diagnose_if.c on some buildbots. I cannot reproduce the problem, and it's not immediately obvious what the problem is, so let's revert to green. llvm-svn: 326974
* When substituting previously-checked template arguments into a templateRichard Smith2018-03-082-12/+21
| | | | | | | | | | | | | template parameter that is an expanded parameter pack, only substitute into the current slice, not the entire pack. This reduces the checking of N template template arguments for an expanded parameter pack containing N parameters from quadratic time to linear time in the length of the pack. This is important because one (and possibly the only?) general technique for splitting a template parameter pack in linear time depends on doing this. llvm-svn: 326973
* [MS] Pass CVRU qualifiers properly in Itanium manglerReid Kleckner2018-03-081-1/+1
| | | | | | | | | We already have a mangling for the __unaligned qualifier, we just have to call Qualifiers::getFromCVRUMask instead of getFromCVRMask. PR36638 llvm-svn: 326971
OpenPOWER on IntegriCloud