summaryrefslogtreecommitdiffstats
path: root/clang/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* [CFG] Provide construction contexts for temporaries in conditional operators.Artem Dergachev2018-02-241-0/+3
| | | | | | | | | | | | | When a lifetime-extended temporary is on a branch of a conditional operator, materialization of such temporary occurs after the condition is resolved. This change allows us to understand, by including the MaterializeTemporaryExpr in the construction context, the target for temporary materialization in such cases. Differential Revision: https://reviews.llvm.org/D43483 llvm-svn: 326019
* [CFG] Provide construction contexts for temporaries bound to const references.Artem Dergachev2018-02-241-0/+3
| | | | | | | | | | In order to bind a temporary to a const lvalue reference, a no-op cast is added to make the temporary itself const, and only then the reference is taken (materialized). Skip the no-op cast when looking for the construction context. Differential Revision: https://reviews.llvm.org/D43481 llvm-svn: 326016
* [CFG] Provide construction contexts for functional cast-like constructors.Artem Dergachev2018-02-241-0/+2
| | | | | | | | | | When a constructor of a temporary with a single argument is treated as a functional cast expression, skip the functional cast expression and provide the correct construction context for the temporary. Differential Revision: https://reviews.llvm.org/D43480 llvm-svn: 326015
* [CFG] Provide construction contexts for lifetime-extended temporaries.Artem Dergachev2018-02-241-1/+24
| | | | | | | | | | | | | | When constructing a temporary that is going to be lifetime-extended through a MaterializeTemporaryExpr later, CFG elements for the respective constructor can now be queried to obtain the reference to that MaterializeTemporaryExpr and therefore gain information about lifetime extension. This may produce multi-layered construction contexts when information about both temporary destruction and lifetime extension is available. Differential Revision: https://reviews.llvm.org/D43477 llvm-svn: 326014
* [ExprConstant] Fix crash when initialize an indirect field with another field.Volodymyr Sapsai2018-02-231-4/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | When indirect field is initialized with another field, you have MemberExpr with CXXThisExpr that corresponds to the field's immediate anonymous parent. But 'this' was referring to the non-anonymous parent. So when we were building LValue Designator, it was incorrect as it had wrong starting point. Usage of such designator would cause unexpected APValue changes and crashes. The fix is in adjusting 'this' for indirect fields from non-anonymous parent to the field's immediate parent. Discovered by OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=4985 rdar://problem/36359187 Reviewers: rsmith, efriedma Reviewed By: rsmith Subscribers: cfe-commits, jkorous-apple Differential Revision: https://reviews.llvm.org/D42498 llvm-svn: 325997
* bpf: Hook target feature "alu32" with LLVMYonghong Song2018-02-231-1/+8
| | | | | | | | | | | | | | LLVM has supported a new target feature "alu32" which could be enabled or disabled by "-mattr=[+|-]alu32" when using llc. This patch link Clang with it, so it could be also done by passing related options to Clang, for example: -Xclang -target-feature -Xclang +alu32 Signed-off-by: Jiong Wang <jiong.wang@netronome.com> Reviewed-by: Yonghong Song <yhs@fb.com> llvm-svn: 325996
* [Sema][ObjC] Process category attributes before checking protocol usesAlex Lorenz2018-02-231-4/+7
| | | | | | | | | This ensures that any availability attributes are attached to the category before the availability for the referenced protocols is checked. rdar://37829755 llvm-svn: 325994
* [CFG] Try to narrow down MSVC compiler crash via binary search.Artem Dergachev2018-02-231-11/+17
| | | | | | | | | | Split the presumably offending function in two to see which part of it causes the crash to occur. The crash was introduced in r325966. r325969 did not help. llvm-svn: 325978
* [analyzer] Relax the assert used when traversing the node graph.George Karpenkov2018-02-231-1/+5
| | | | | | | | | | | | | | The assertion gets exposed when changing the exploration order. This is a quick hacky fix, but the intention is that if the nodes do merge, it should not matter which predecessor should be traverse. A proper fix would be not to traverse predecessors at all, as all information relevant for any decision should be avilable locally. rdar://37540480 Differential Revision: https://reviews.llvm.org/D42773 llvm-svn: 325977
* [analyzer] mark returns of functions where the region passed as parameter ↵George Karpenkov2018-02-231-0/+272
| | | | | | | | | | | | | | | | | | was not initialized In the wild, many cases of null pointer dereference, or uninitialized value read occur because the value was meant to be initialized by the inlined function, but did not, most often due to error condition in the inlined function. This change highlights the return branch taken by the inlined function, in order to help user understand the error report and see why the value was uninitialized. rdar://36287652 Differential Revision: https://reviews.llvm.org/D41848 llvm-svn: 325976
* [analyzer] Consider switch- and goto- labels when constructing the set of ↵George Karpenkov2018-02-231-6/+24
| | | | | | | | | | | | executed lines When viewing the report in the collapsed mode the label signifying where did the execution go is often necessary for properly understanding the context. Differential Revision: https://reviews.llvm.org/D43145 llvm-svn: 325975
* [CFG] NFC: Speculative attempt to fix MSVC internal compiler error on buildbot.Artem Dergachev2018-02-231-3/+6
| | | | | | Don't use fancy initialization and member access in a DenseMap. llvm-svn: 325969
* [CFG] [analyzer] NFC: Allow more complicated construction contexts.Artem Dergachev2018-02-231-24/+50
| | | | | | | | | | | | | | ConstructionContexts introduced in D42672 are an additional piece of information included with CFGConstructor elements that help the client of the CFG (such as the Static Analyzer) understand where the newly constructed object is stored. The patch refactors the ConstructionContext class to prepare for including multi-layered contexts that are being constructed gradually, layer-by-layer, as the AST is traversed. Differential Revision: https://reviews.llvm.org/D43428 llvm-svn: 325966
* Set Module Metadata "RtLibUseGOT" when fno-plt is used.Sriraman Tallam2018-02-231-0/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D42217 llvm-svn: 325961
* [Driver] Make -fno-common default for FuchsiaPetr Hosek2018-02-231-0/+2
| | | | | | | | We never want to generate common symbols on Fuchsia. Differential Revision: https://reviews.llvm.org/D43545 llvm-svn: 325945
* Bring r325915 back.Rafael Espindola2018-02-234-3/+20
| | | | | | | | | | | | | | | The tests that failed on a windows host have been fixed. Original message: Start setting dso_local for COFF. With this there are still some GVs where we don't set dso_local because setGVProperties is never called. I intend to fix that in followup commits. This is just the bare minimum to teach shouldAssumeDSOLocal what it should do for COFF. llvm-svn: 325940
* Revert "Start setting dso_local for COFF."Rafael Espindola2018-02-234-20/+3
| | | | | | | | This reverts commit r325915. It will take some time to fix the failures on a windows host. llvm-svn: 325929
* Start setting dso_local for COFF.Rafael Espindola2018-02-234-3/+20
| | | | | | | | | With this there are still some GVs where we don't set dso_local because setGVProperties is never called. I intend to fix that in followup commits. This is just the bare minimum to teach shouldAssumeDSOLocal what it should do for COFF. llvm-svn: 325915
* Support for the mno-stack-arg-probe flagHans Wennborg2018-02-233-10/+15
| | | | | | | | | | | | Adds support for this flag. There is also another piece for llvm (separate review). More info: https://bugs.llvm.org/show_bug.cgi?id=36221 By Ruslan Nikolaev! Differential Revision: https://reviews.llvm.org/D43108 llvm-svn: 325901
* [mips] Revert r325872Stefan Maksimovic2018-02-231-8/+0
| | | | | | | There are still outstanding issues with byVal arguments that prevent this from being committed. Revert for now. llvm-svn: 325899
* [mips] Reland r310704Stefan Maksimovic2018-02-231-0/+8
| | | | | | | | Recommit this change which was previously reverted for the 5.0.0 release since the failures identified were dealt with in r325782. llvm-svn: 325872
* Simplify setting dso_local. NFC.Rafael Espindola2018-02-233-12/+12
| | | | | | | | | | | The value of dso_local can be computed from just IR properties and global information (object file type, command line options, etc). With this patch we no longer pass in the Decl. It was almost unused and making it fully unused guarantees that dso_local is consistent with the rest of the IR. llvm-svn: 325846
* [Sema] Fix some Clang-tidy modernize and Include What You Use warnings; ↵Eugene Zelenko2018-02-221-28/+71
| | | | | | other minor fixes (NFC). llvm-svn: 325834
* [OpenMP] Limit reduction support for pragma 'distribute' when combined with ↵Carlo Bertolli2018-02-221-19/+23
| | | | | | | | | | | pragma 'simd' Differential Revision: https://reviews.llvm.org/D43513 This is a bug fix that removes the emission of reduction support for pragma 'distribute' when found alone or in combinations without simd. Pragma 'distribute' does not have a reduction clause, but when combined with pragma 'simd' we need to emit the support for simd's reduction clause as part of code generation for distribute. This guard is similar to the one used for reduction support earlier in the same code gen function. llvm-svn: 325822
* [CUDA] Added missing functions.Artem Belevich2018-02-221-0/+22
| | | | | | | | | Initial commit missed sincos(float), llabs() and few atomics that we used to pull in from device_functions.hpp, which we no longer include. Differential Revision: https://reviews.llvm.org/D43602 llvm-svn: 325814
* [OPENMP] Require valid SourceLocation in function call, NFC.Alexey Bataev2018-02-222-8/+7
| | | | | | | Removed default empty SourceLocation argument from `emitCall` function and require valid location. llvm-svn: 325812
* [OpenCL] Add '-cl-uniform-work-group-size' compile optionAlexey Sotkin2018-02-223-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: OpenCL 2.0 specification defines '-cl-uniform-work-group-size' option, which requires that the global work-size be a multiple of the work-group size specified to clEnqueueNDRangeKernel and allows optimizations that are made possible by this restriction. The patch introduces the support of this option. To keep information about whether an OpenCL kernel has uniform work group size or not, clang generates 'uniform-work-group-size' function attribute for every kernel: - "uniform-work-group-size"="true" for OpenCL 1.2 and lower, - "uniform-work-group-size"="true" for OpenCL 2.0 and higher if '-cl-uniform-work-group-size' option was specified, - "uniform-work-group-size"="false" for OpenCL 2.0 and higher if no '-cl-uniform-work-group-size' options was specified. If the function is not an OpenCL kernel, 'uniform-work-group-size' attribute isn't generated. Patch by: krisb Reviewers: yaxunl, Anastasia, b-sumner Reviewed By: yaxunl, Anastasia Subscribers: nhaehnle, yaxunl, Anastasia, cfe-commits Differential Revision: https://reviews.llvm.org/D43570 llvm-svn: 325771
* FreeBSD driver / Xray flags moving pthread to compile flags.Kamil Rytarowski2018-02-222-4/+10
| | | | | | | | | | | | | | | | | | Summary: - Using -lpthread instead, with -pthread the linkage does not work. -Warning about the -fxray-instrument usage outside of the working cases. Patch by: David CARLIER Reviewers: krytarowski, vitalybuka, dberris, emaste Reviewed By: krytarowski, emaste Subscribers: srhines, emaste, cfe-commits Differential Revision: https://reviews.llvm.org/D43378 llvm-svn: 325746
* [ODRHash] Fix hashing for friend functions.Richard Trieu2018-02-222-3/+6
| | | | | | | When hashing a templated function, use the hash of the function it was instantiated from. llvm-svn: 325742
* [ODRHash] Handle some template weirdness.Richard Trieu2018-02-222-19/+43
| | | | | | | | Build the index off of DeclarationName instead of Decl pointers. When finding an UnresolvedLookupExprClass, hash it as if it were a DeclRefExpr. This will allow methods to be hashed. llvm-svn: 325741
* [Driver] Generate .eh_frame_hdr for static executables too.Dan Albert2018-02-211-3/+1
| | | | | | | | | | | | | | Summary: libgcc won't unwind without an .eh_frame_hdr section. Reviewers: srhines, chandlerc Reviewed By: chandlerc Subscribers: chandlerc, cfe-commits Differential Revision: https://reviews.llvm.org/D43203 llvm-svn: 325733
* CodeGen: handle blocks correctly when inalloca'edSaleem Abdulrasool2018-02-211-2/+5
| | | | | | | | | | When using blocks with C++ on Windows x86, it is possible to have the block literal be pushed into the inalloca'ed parameters. Teach IRGen to handle the case properly by extracting the block literal from the inalloca parameter. This fixes the use of blocks with C++ on Windows x86. llvm-svn: 325724
* [clang-format] Fix regression when getStyle() called with empty filenameBen Hamilton2018-02-211-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: D43522 caused an assertion failure when getStyle() was called with an empty filename: P8065 This adds a test to reproduce the failure and fixes the issue by ensuring we never pass an empty filename to Environment::CreateVirtualEnvironment(). Test Plan: New test added. Ran test with: % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests Before diff, test failed with P8065. Now, test passes. Reviewers: vsapsai, jolesiak, krasimir Reviewed By: vsapsai Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D43590 llvm-svn: 325722
* Replace incorrect usage of isInvalidDecl with intended setInvalidDecl Erich Keane2018-02-211-1/+1
| | | | | | | This typo would cause an attempt to multiversion 'main' to issue an error, but not mark the function as invalid. This patch fixes it. llvm-svn: 325716
* [analyzer] Prevent AnalyzerStatsChecker from crashPeter Szecsi2018-02-211-0/+2
| | | | | | | | | | | | The checker marks the locations where the analyzer creates sinks. However, it can happen that the sink was created because of a loop which does not contain condition statement, only breaks in the body. The exhausted block is the block which should contain the condition but empty, in this case. This change only emits this marking in order to avoid the undefined behavior. Differential Revision: https://reviews.llvm.org/D42266 llvm-svn: 325693
* [clang-format] New API guessLanguage()Ben Hamilton2018-02-211-11/+20
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: For clients which don't have a filesystem, calling getStyle() doesn't make much sense (there's no .clang-format files to search for). In this diff, I hoist out the language-guessing logic from getStyle() and move it into a new API guessLanguage(). I also added support for guessing the language of files which have no extension (they could be C++ or ObjC). Test Plan: New tests added. Ran tests with: % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests Reviewers: jolesiak, krasimir Reviewed By: jolesiak, krasimir Subscribers: klimek, cfe-commits, sammccall Differential Revision: https://reviews.llvm.org/D43522 llvm-svn: 325691
* [Sema] Classify conversions from enum to float as narrowingMikhail Maltsev2018-02-211-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: According to [dcl.init.list]p7: A narrowing conversion is an implicit conversion - ... - from an integer type or unscoped enumeration type to a floating-point type, except where the source is a constant expression and the actual value after conversion will fit into the target type and will produce the original value when converted back to the original type, or - ... Currently clang does not handle the 'unscoped enumeration' case. This patch fixes the corresponding check. Reviewers: faisalv, rsmith, rogfer01 Reviewed By: rogfer01 Subscribers: rogfer01, cfe-commits Differential Revision: https://reviews.llvm.org/D42545 llvm-svn: 325668
* In C++14 onwards, it is permitted to read mutable members in constantRichard Smith2018-02-211-10/+22
| | | | | | | | | expressions, if their lifetime began during the evaluation of the expression. This is technically not allowed in C++11, though we could consider permitting it there too, as an extension. llvm-svn: 325663
* Clean up use of C allocation functionsSerge Pavlov2018-02-214-7/+8
| | | | | | | | | | | | | | | | If the value returned by `malloc`, `calloc` or `realloc` is not checked for null pointer, this change replaces them for `safe_malloc`, `safe_calloc` or `safe_realloc`, which are defined in the namespace `llvm`. These function report fatal error on out of memory. In the plain C files, assertion statements are added to ensure that memory is successfully allocated. The aim of this change is to get better diagnostics of OOM on Windows. Differential Revision: https://reviews.llvm.org/D43017 llvm-svn: 325661
* [Sema] Fix some Clang-tidy modernize and Include What You Use warnings; ↵Eugene Zelenko2018-02-212-19/+26
| | | | | | other minor fixes (NFC). llvm-svn: 325659
* [X86] Disable CLWB in Cannon LakeCraig Topper2018-02-211-1/+2
| | | | | | | | | | | Cannon Lake does not support CLWB, therefore it does not include all features listed under SKX. Patch by Gabor Buella Differential Revision: https://reviews.llvm.org/D43459 llvm-svn: 325655
* [mips] Spectre variant two mitigation for MIPSR2Simon Dardis2018-02-213-1/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch provides mitigation for CVE-2017-5715, Spectre variant two, which affects the P5600 and P6600. It provides the option -mindirect-jump=hazard, which instructs the LLVM backend to replace indirect branches with their hazard barrier variants. This option is accepted when targeting MIPS revision two or later. The migitation strategy suggested by MIPS for these processors is to use two hazard barrier instructions. 'jalr.hb' and 'jr.hb' are hazard barrier variants of the 'jalr' and 'jr' instructions respectively. These instructions impede the execution of instruction stream until architecturally defined hazards (changes to the instruction stream, privileged registers which may affect execution) are cleared. These instructions in MIPS' designs are not speculated past. These instructions are used with the option -mindirect-jump=hazard when branching indirectly and for indirect function calls. These instructions are defined by the MIPS32R2 ISA, so this mitigation method is not compatible with processors which implement an earlier revision of the MIPS ISA. Implementation note: I've opted to provide this as an -mindirect-jump={hazard,...} style option in case alternative mitigation methods are required for other implementations of the MIPS ISA in future, e.g. retpoline style solutions. Reviewers: atanasyan Differential Revision: https://reviews.llvm.org/D43487 llvm-svn: 325651
* Fix assert when template argument deduction's original call arg checking ↵Richard Smith2018-02-201-1/+1
| | | | | | triggers class template instantiation. llvm-svn: 325646
* When multiple sanitizers are enabled (ubsan + something else), use all ↵Richard Smith2018-02-201-30/+23
| | | | | | | | | | relevant blacklists. Ideally, we'd only use the ubsan blacklist for ubsan sanitizers, and only use the other-sanitizer blacklist for its sanitizers, but this at least enables the intended suppressions. llvm-svn: 325640
* [NFC] In Multiversion Check function, switch to return DiagErich Keane2018-02-201-67/+47
| | | | | | | | This function did a lot of 'Diag, return true' stuff. This resulted in needing to introduce scopes in quite a few places. This patch replaces useages of a single "S.Diag" followed by return true with simply "return S.Diag". llvm-svn: 325633
* [CUDA] Added missing __threadfence_system() function for CUDA9.Artem Belevich2018-02-201-0/+1
| | | | llvm-svn: 325626
* Correct multiversion unsupported target behavior, add a test.Erich Keane2018-02-201-0/+2
| | | | | | | | | | Multiversioning SEMA failed to set the declaration as invalid on unsupported targets. This patch does that. Additionally, I noticed that there is no test to validate this error message. This patch adds one, and uses 'mips' as the test architecture. llvm-svn: 325610
* Stop linking sanitized applications with -lutil and -lkvm on NetBSDKamil Rytarowski2018-02-201-6/+0
| | | | | | | | | The proper approach is to rebuild libutil and libkvm with a desired sanitizer. An alternative approach to reimplement these functions (and other ones like curses(3), editline(3) etc) does not scale and enforces linkage every single binary with these libraries. llvm-svn: 325593
* Revert r325375 "[MS] Make constexpr static data members implicitly inline"Hans Wennborg2018-02-201-1/+1
| | | | | | | | | | | | | | | | This broke Clang bootstrap on Windows, PR36453. > This handles them exactly the same way that we handle const integral > static data members with inline definitions, which is what MSVC does. > > As a follow-up, now that we have a way to mark variables inline in the > AST, we should consider marking them implicitly inline there instead of > only treating them as inline in CodeGen. Unfortunately, this breaks a > lot of dllimport test cases, so that is future work for now. > > Fixes PR36125. llvm-svn: 325576
* [CodeGen] Fix generation of TBAA tags for may-alias accessesIvan A. Kosarev2018-02-203-7/+20
| | | | | | | | | | | This patch fixes creating TBAA access descriptors for may_alias-marked access types. Currently, for such types we generate ordinary descriptors with char as its access type. The patch changes this to produce proper may-alias descriptors. Differential Revision: https://reviews.llvm.org/D42366 llvm-svn: 325575
OpenPOWER on IntegriCloud