summaryrefslogtreecommitdiffstats
path: root/clang
Commit message (Collapse)AuthorAgeFilesLines
...
* [analyzer] Rename test: cxx17-mandatory-elision.cpp -> copy-elision.cppArtem Dergachev2018-07-311-0/+0
| | | | | | It reflects its contents more accurately. No functional change intended. llvm-svn: 338339
* [Sema] Relax a failing assert in TemplateArgumentLocErik Pilkington2018-07-312-1/+14
| | | | | | | | | | | | | Any of these template argument kinds can be represented with an expression, so accept them in this constructor. Patch by Balaji Iyer! rdar://41459965 Differential revision: https://reviews.llvm.org/D49766 llvm-svn: 338338
* [analyzer] CStringChecker: Remember to highlight the argument expression range.Artem Dergachev2018-07-302-0/+16
| | | | | | | | | | | | | | | | | | | | | When emitting a bug report, it is important to highlight which argument of the call-expression is causing the problem. Before: warning: Null pointer argument in call to string comparison function   strcmp(a, b);   ^~~~~~~~~~~~ After: warning: Null pointer argument in call to string comparison function   strcmp(a, b);   ^      ~ Affects other output modes as well, not just text. Differential Revision: https://reviews.llvm.org/D50028 llvm-svn: 338333
* Revert "Add a definition for FieldSize that seems to make sense here."Eric Christopher2018-07-301-1/+0
| | | | | | This reverts commit r338327, the problem was previously fixed in r338321. llvm-svn: 338328
* Add a definition for FieldSize that seems to make sense here.Eric Christopher2018-07-301-0/+1
| | | | | | This could be sunk out of the if statements, but fix the warning for now. llvm-svn: 338327
* [analyzer] [tests] Add an option for showing statistics after running tests.George Karpenkov2018-07-301-1/+3
| | | | | | Do not show statistics by default. llvm-svn: 338323
* [analyzer] [tests] Style fixes for testing harness.George Karpenkov2018-07-302-14/+14
| | | | llvm-svn: 338322
* Fix use of uninitialized variable in r338299Scott Linder2018-07-301-1/+1
| | | | llvm-svn: 338321
* [analyzer] [NFC] Simplify some visitors by giving a convenient getter from ↵George Karpenkov2018-07-303-22/+23
| | | | | | | | state to analysis manager Differential Revision: https://reviews.llvm.org/D49772 llvm-svn: 338315
* [analyzer] Bugfix for autorelease + main run loop leak checkerGeorge Karpenkov2018-07-302-4/+20
| | | | | | | | | Do not warn when the other message-send-expression is correctly wrapped in a different autorelease pool. Differential Revision: https://reviews.llvm.org/D49921 llvm-svn: 338314
* [analyzer] Fix crash in RunLoopAutoreleaseChecker on empty childrenGeorge Karpenkov2018-07-302-3/+13
| | | | | | Differential Revision: https://reviews.llvm.org/D50012 llvm-svn: 338312
* [docs] UndefinedBehaviorSanitizer.rst: {,un}signed-integer-overflow: tune docsRoman Lebedev2018-07-301-2/+2
| | | | | | | | | | | | | Yes, i erroneously assumed that the "after" was meant, but i was wrong: > I really meant "performed before", for cases like 4u / -2, > where -2 is implicitly converted to UINT_MAX - 2 before > the computation. Conversions that are performed after > a computation aren't part of the computation at all, > so I think it's much clearer that they're not in scope > for this sanitizer. llvm-svn: 338306
* Avoid returning an invalid end source locStephen Kelly2018-07-302-3/+5
| | | | llvm-svn: 338301
* [DebugInfo][OpenCL] Generate correct block literal debug info for OpenCLScott Linder2018-07-302-36/+58
| | | | | | | | | OpenCL block literal structs have different fields which are now correctly identified in the debug info. Differential Revision: https://reviews.llvm.org/D49930 llvm-svn: 338299
* [OpenEmbedded] Fix lib paths for OpenEmbedded targetsMandeep Singh Grang2018-07-3016-3/+69
| | | | | | | | | | | | | | | | | | | | | Summary: The lib paths are not correctly picked up for OpenEmbedded sysroots (like arm-oe-linux-gnueabi) for 2 reasons: 1. OpenEmbedded sysroots are of the form <sysroot>/usr/lib/<triple>/x.y.z. This form is handled in clang but only for Freescale vendor. 2. 64-bit OpenEmbedded sysroots may not have a /usr/lib dir. So they cannot find /usr/lib64 as it is referenced as /usr/lib/../lib64 in clang. This is a follow-up to the llvm patch: D48861 Reviewers: dlj, rengolin, fedor.sergeev, javed.absar, hfinkel, rsmith Reviewed By: rsmith Subscribers: rsmith, kristof.beyls, cfe-commits Differential Revision: https://reviews.llvm.org/D48862 llvm-svn: 338294
* Remove trailing spaceFangrui Song2018-07-30432-7748/+7748
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* Make test/Driver/baremetal.cpp work with linkers other than lldDavid Greene2018-07-301-5/+5
| | | | | | | | This test fails if clang is configure with, for example, gold as the default linker. It does not appear that this test really relies on lld so make the checks accept ld, ld.gold and ld.bfd too. llvm-svn: 338290
* [clang][ubsan] Implicit Conversion Sanitizer - integer truncation - clang partRoman Lebedev2018-07-3011-37/+829
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: C and C++ are interesting languages. They are statically typed, but weakly. The implicit conversions are allowed. This is nice, allows to write code while balancing between getting drowned in everything being convertible, and nothing being convertible. As usual, this comes with a price: ``` unsigned char store = 0; bool consume(unsigned int val); void test(unsigned long val) { if (consume(val)) { // the 'val' is `unsigned long`, but `consume()` takes `unsigned int`. // If their bit widths are different on this platform, the implicit // truncation happens. And if that `unsigned long` had a value bigger // than UINT_MAX, then you may or may not have a bug. // Similarly, integer addition happens on `int`s, so `store` will // be promoted to an `int`, the sum calculated (0+768=768), // and the result demoted to `unsigned char`, and stored to `store`. // In this case, the `store` will still be 0. Again, not always intended. store = store + 768; // before addition, 'store' was promoted to int. } // But yes, sometimes this is intentional. // You can either make the conversion explicit (void)consume((unsigned int)val); // or mask the value so no bits will be *implicitly* lost. (void)consume((~((unsigned int)0)) & val); } ``` Yes, there is a `-Wconversion`` diagnostic group, but first, it is kinda noisy, since it warns on everything (unlike sanitizers, warning on an actual issues), and second, there are cases where it does **not** warn. So a Sanitizer is needed. I don't have any motivational numbers, but i know i had this kind of problem 10-20 times, and it was never easy to track down. The logic to detect whether an truncation has happened is pretty simple if you think about it - https://godbolt.org/g/NEzXbb - basically, just extend (using the new, not original!, signedness) the 'truncated' value back to it's original width, and equality-compare it with the original value. The most non-trivial thing here is the logic to detect whether this `ImplicitCastExpr` AST node is **actually** an implicit conversion, //or// part of an explicit cast. Because the explicit casts are modeled as an outer `ExplicitCastExpr` with some `ImplicitCastExpr`'s as **direct** children. https://godbolt.org/g/eE1GkJ Nowadays, we can just use the new `part_of_explicit_cast` flag, which is set on all the implicitly-added `ImplicitCastExpr`'s of an `ExplicitCastExpr`. So if that flag is **not** set, then it is an actual implicit conversion. As you may have noted, this isn't just named `-fsanitize=implicit-integer-truncation`. There are potentially some more implicit conversions to be warned about. Namely, implicit conversions that result in sign change; implicit conversion between different floating point types, or between fp and an integer, when again, that conversion is lossy. One thing i know isn't handled is bitfields. This is a clang part. The compiler-rt part is D48959. Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=21530 | PR21530 ]], [[ https://bugs.llvm.org/show_bug.cgi?id=37552 | PR37552 ]], [[ https://bugs.llvm.org/show_bug.cgi?id=35409 | PR35409 ]]. Partially fixes [[ https://bugs.llvm.org/show_bug.cgi?id=9821 | PR9821 ]]. Fixes https://github.com/google/sanitizers/issues/940. (other than sign-changing implicit conversions) Reviewers: rjmccall, rsmith, samsonov, pcc, vsk, eugenis, efriedma, kcc, erichkeane Reviewed By: rsmith, vsk, erichkeane Subscribers: erichkeane, klimek, #sanitizers, aaron.ballman, RKSimon, dtzWill, filcab, danielaustin, ygribov, dvyukov, milianw, mclow.lists, cfe-commits, regehr Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D48958 llvm-svn: 338288
* [analyzer] Store ValueDecl in DeclRegionGeorge Karpenkov2018-07-301-3/+3
| | | | | | | | | All use cases of DeclRegion actually have ValueDecl there, and getting the name from declaration comes in very handy. Differential Revision: https://reviews.llvm.org/D49998 llvm-svn: 338286
* Delete some unreachable AST printing code.Richard Smith2018-07-301-30/+0
| | | | llvm-svn: 338282
* [ARM, AArch64]: Use unadjusted alignment when passing composites as argumentsMomchil Velikov2018-07-309-17/+350
| | | | | | | | | | | | | | | | | | The "Procedure Call Procedure Call Standard for the ARM® Architecture" (https://static.docs.arm.com/ihi0042/f/IHI0042F_aapcs.pdf), specifies that composite types are passed according to their "natural alignment", i.e. the alignment before alignment adjustment on the entire composite is applied. The same applies for AArch64 ABI. Clang, however, used the adjusted alignment. GCC already implements the ABI correctly. With this patch Clang becomes compatible with GCC and passes such arguments in accordance with AAPCS. Differential Revision: https://reviews.llvm.org/D46013 llvm-svn: 338279
* [analyzer] Add missing state transition in IteratorChecker.Reka Kovacs2018-07-301-0/+2
| | | | | | | | | After cleaning up program state maps in `checkDeadSymbols()`, a transition should be added to generate the new state. Differential Revision: https://reviews.llvm.org/D47417 llvm-svn: 338263
* [analyzer] Add support for more invalidating functions in InnerPointerChecker.Reka Kovacs2018-07-303-71/+214
| | | | | | | | | | | | According to the standard, pointers referring to the elements of a `basic_string` may be invalidated if they are used as an argument to any standard library function taking a reference to non-const `basic_string` as an argument. This patch makes InnerPointerChecker warn for these cases. Differential Revision: https://reviews.llvm.org/D49656 llvm-svn: 338259
* [CodeComplete] Fix the crash in code completion on access checkingIlya Biryukov2018-07-302-28/+15
| | | | | | | | | Started crashing in r337453. See the added test case for the crash repro. The fix reverts part of r337453 that causes the crash and does not actually break anything when reverted. llvm-svn: 338255
* [OPENMP] Modify the info about OpenMP support in UsersManual, NFC.Alexey Bataev2018-07-301-7/+2
| | | | llvm-svn: 338252
* [mips64][clang] Adjust tests to account for changes in r338239Stefan Maksimovic2018-07-303-7/+11
| | | | llvm-svn: 338246
* [clang-format] Silence -Wdocumentation warningsKrasimir Georgiev2018-07-301-6/+8
| | | | | | introduced in r338232 llvm-svn: 338245
* [mips64][clang] Provide the signext attribute for i32 return valuesStefan Maksimovic2018-07-301-2/+8
| | | | | | | | Additional info: see r338019. Differential Revision: https://reviews.llvm.org/D49289 llvm-svn: 338239
* Fix -Wdocumentation warning. NFCI.Simon Pilgrim2018-07-301-1/+0
| | | | llvm-svn: 338238
* [Analyzer] Iterator Checker Hotfix: Defer deletion of container data until ↵Adam Balogh2018-07-301-1/+22
| | | | | | | | | | | | | | its last iterator is cleaned up The analyzer may consider a container region as dead while it still has live iterators. We must defer deletion of the data belonging to such containers until all its iterators are dead as well to be able to compare the iterator to the begin and the end of the container which is stored in the container data. Differential Revision: https://reviews.llvm.org/D48427 llvm-svn: 338234
* [clang-format] Indent after breaking Javadoc annotated lineKrasimir Georgiev2018-07-306-46/+242
| | | | | | | | | | | | | | | | Summary: This patch makes clang-format indent the subsequent lines created by breaking a long javadoc annotated line. Reviewers: mprobst Reviewed By: mprobst Subscribers: acoomans, cfe-commits Differential Revision: https://reviews.llvm.org/D49797 llvm-svn: 338232
* PR38355 Prevent infinite recursion when checking initializer lifetime ifRichard Smith2018-07-302-1/+8
| | | | | | an initializer is self-referential. llvm-svn: 338230
* Revert r337456: [CodeGen] Disable aggressive structor optimizations at -O0, ↵Chandler Carruth2018-07-293-48/+13
| | | | | | | | | | | | | | | | | | | | | | | | take 3 This commit increases the number of sections and overall output size of .o files by 10% and sometimes a bit more. This alone is challenging for some users, but it also appears to trigger an as-yet unexplained behavior in the Gold linker where the memory usage increases considerably more than 10% (we think). The increase is also frustrating because in many (if not all) cases we end up with almost all of the growth coming from the ELF overhead of -ffunction-sections and such, not from actual extra code being emitted. Richard Smith and Eric Christopher are both going to investigate this and try to get to the bottom of what is triggering this and whether the kinds of increases here are sustainable or what options we might have to minimize the impact they have. However, this is currently breaking a pretty large number of our users' builds so reverting it while we sort out how to make progress here. I've seen a longer and more detailed update to the commit thread. llvm-svn: 338209
* [UBSan] Strengthen pointer checks in 'new' expressionsSerge Pavlov2018-07-285-26/+215
| | | | | | | | | | | | | | | | | | | | With this change compiler generates alignment checks for wider range of types. Previously such checks were generated only for the record types with non-trivial default constructor. So the types like: struct alignas(32) S2 { int x; }; typedef __attribute__((ext_vector_type(2), aligned(32))) float float32x2_t; did not get checks when allocated by 'new' expression. This change also optimizes the checks generated for the arrays created in 'new' expressions. Previously the check was generated for each invocation of type constructor. Now the check is generated only once for entire array. Differential Revision: https://reviews.llvm.org/D49589 llvm-svn: 338199
* [Sema][ObjC] Warn when a method declared in a protocol takes aAkira Hatanaka2018-07-283-7/+82
| | | | | | | | | | | non-escaping parameter but the implementation's method takes an escaping parameter. rdar://problem/39548196 Differential Revision: https://reviews.llvm.org/D49119 llvm-svn: 338189
* [CUDA][HIP] Allow function-scope static const variableYaxun Liu2018-07-285-13/+40
| | | | | | | | | | | | | | | | | | | | | | CUDA 8.0 E.3.9.4 says: Within the body of a __device__ or __global__ function, only __shared__ variables or variables without any device memory qualifiers may be declared with static storage class. It is unclear how a function-scope non-const static variable without device memory qualifier is implemented, therefore only static const variable without device memory qualifier is allowed, which can be emitted as a global variable in constant address space. Currently clang only allows function-scope static variable with __shared__ qualifier. This patch also allows function-scope static const variable without device memory qualifier and emits it as a global variable in constant address space. Differential Revision: https://reviews.llvm.org/D49931 llvm-svn: 338188
* [AST] Add a convenient getter from QualType to RecordDeclGeorge Karpenkov2018-07-286-12/+14
| | | | | | Differential Revision: https://reviews.llvm.org/D49951 llvm-svn: 338187
* Compile SemaTemplate.cpp with /bigobj on MSVCErik Pilkington2018-07-281-0/+1
| | | | | | This should fix some bot failures introduced by r338165. llvm-svn: 338186
* [CFG] Remove duplicate function/class names at the beginning of commentsFangrui Song2018-07-284-74/+67
| | | | | | | | Some functions/classes have renamed while the comments still use the old names. Delete them per coding style. Also some whitespace cleanup. llvm-svn: 338183
* Parse a possible trailing postfix expression suffix after a fold expressionNicolas Lesser2018-07-273-5/+42
| | | | | | | | | | | | | | | | | Summary: This patch allows the parsing of a postfix expression involving a fold expression, which is legal as a fold-expression is a primary-expression. See also https://llvm.org/pr38282 Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D49848 llvm-svn: 338170
* [Sema] Use a TreeTransform to extract deduction guide parameter typesErik Pilkington2018-07-272-15/+54
| | | | | | | | | | | | | | | Previously, we just canonicalized the type, but this lead to crashes with parameter types that referred to ParmVarDecls of the constructor. There may be more cases that this TreeTransform needs to handle though, such as a constructor parameter type referring to a member in an unevaluated context. Canonicalization doesn't address these cases either though, so we can address them as-needed in follow-up commits. rdar://41330135 Differential revision: https://reviews.llvm.org/D49439 llvm-svn: 338165
* [DEBUG_INFO] Fix tests, NFC.Alexey Bataev2018-07-272-0/+2
| | | | llvm-svn: 338158
* [DEBUGINFO] Disable unsupported debug info options for NVPTX target.Alexey Bataev2018-07-2710-80/+201
| | | | | | | | | | | | | | | | | | Summary: Some targets support only default set of the debug options and do not support additional debug options, like NVPTX target. Patch introduced virtual function supportsDebugInfoOptions() that can be overloaded by the toolchain, checks if the target supports some debug options and emits warning when an unsupported debug option is found. Reviewers: echristo Subscribers: aprantl, JDevlieghere, cfe-commits Differential Revision: https://reviews.llvm.org/D49148 llvm-svn: 338155
* [analyzer] Extend NoStoreFuncVisitor to insert a note on IVarsGeorge Karpenkov2018-07-273-17/+100
| | | | | | | | | | | | | | The note is added in the following situation: - We are throwing a nullability-related warning on an IVar - The path goes through a method which *could have* (syntactically determined) written into that IVar, but did not rdar://42444460 Differential Revision: https://reviews.llvm.org/D49689 llvm-svn: 338149
* Fix typos in comment.Richard Smith2018-07-271-2/+2
| | | | llvm-svn: 338141
* [ASTMatchers] Introduce a matcher for `ObjCIvarExpr`, support getting it's ↵George Karpenkov2018-07-271-0/+1
| | | | | | | | | | | | | declaration ObjCIvarExpr is *not* a subclass of MemberExpr, and a separate matcher is required to support it. Adding a hasDeclaration support as well, as it's not very useful without it. Differential Revision: https://reviews.llvm.org/D49701 llvm-svn: 338140
* [OPENMP] Static variables on device must be externally visible.Alexey Bataev2018-07-273-3/+27
| | | | | | | Do not mark static variable as internal on the device as they must be visible from the host to be mapped correctly. llvm-svn: 338139
* [ASTMatchers] Introduce a matcher for `ObjCIvarExpr`, support getting it's ↵George Karpenkov2018-07-276-1/+66
| | | | | | | | | | | | | declaration. ObjCIvarExpr is *not* a subclass of MemberExpr, and a separate matcher is required to support it. Adding a hasDeclaration support as well, as it's not very useful without it. Differential Revision: https://reviews.llvm.org/D49701 llvm-svn: 338137
* Add missing temporary materialization conversion on left-hand side of .Richard Smith2018-07-2711-279/+325
| | | | | | | | | in some member function calls. Specifically, when calling a conversion function, we would fail to create the AST node representing materialization of the class object. llvm-svn: 338135
* [AST] Sink 'part of explicit cast' down into ImplicitCastExprRoman Lebedev2018-07-276-13/+17
| | | | | | | | | | | | | | | | | | | | | | | Summary: As discussed in IRC with @rsmith, it is slightly not good to keep that in the `CastExpr` itself: Given the explicit cast, which is represented in AST as an `ExplicitCastExpr` + `ImplicitCastExpr`'s, only the `ImplicitCastExpr`'s will be marked as `PartOfExplicitCast`, but not the `ExplicitCastExpr` itself. Thus, it is only ever `true` for `ImplicitCastExpr`'s, so we don't need to write/read/dump it for `ExplicitCastExpr`'s. We don't need to worry that we write the `PartOfExplicitCast` in PCH after `CastExpr::path_iterator`, since the `ExprImplicitCastAbbrev` is only used when the `NumBaseSpecs == 0`, i.e. there is no 'path'. Reviewers: rsmith, rjmccall, erichkeane, aaron.ballman Reviewed By: rsmith, erichkeane Subscribers: vsk, cfe-commits, rsmith Tags: #clang Differential Revision: https://reviews.llvm.org/D49838 llvm-svn: 338108
OpenPOWER on IntegriCloud