summaryrefslogtreecommitdiffstats
path: root/clang/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix a doc typo; NFCGeorge Burgess IV2018-03-081-1/+1
| | | | llvm-svn: 326968
* [Sema] Make getCurFunction() return null outside function parsingReid Kleckner2018-03-088-95/+107
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Before this patch, Sema pre-allocated a FunctionScopeInfo and kept it in the first, always present element of the FunctionScopes stack. This meant that Sema::getCurFunction would return a pointer to this pre-allocated object when parsing code outside a function body. This is pretty much always a bug, so this patch moves the pre-allocated object into a separate unique_ptr. This should make bugs like PR36536 a lot more obvious. As you can see from this patch, there were a number of places that unconditionally assumed they were always called inside a function. However, there are also many places that null checked the result of getCurFunction(), so I think this is a reasonable direction. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D44039 llvm-svn: 326965
* [MS] Accept __unaligned as a qualifier on member function pointersReid Kleckner2018-03-071-1/+2
| | | | | | | | | | We need to treat __unaligned like the other 'cvr' qualifiers when it appears at the end of a function prototype. We weren't doing that in some tentative parsing. Fixes PR36638. llvm-svn: 326962
* Set dso_local on tls init functions.Rafael Espindola2018-03-071-1/+3
| | | | | | | We copy the visibility, so copying the dso_local flag seems the natural thing to do. llvm-svn: 326961
* [ms] Emit vtordisp initializers in a deterministic order.Nico Weber2018-03-071-5/+6
| | | | | | | | | | No effective behavior change, just for cleanliness. Analysis and typing by me, actual patch mostly by Reid. Fixes PR36159. https://reviews.llvm.org/D44223 llvm-svn: 326960
* Avoid including ScopeInfo.h from Sema.hReid Kleckner2018-03-079-34/+48
| | | | | | | | | | | | | | | | | Summary: This provides no measurable build speedup, but it reinstates an optimization from r112038 that was lost in r179618. It requires moving CapturedScopeInfo::Capture out to clang::sema, which might be too general since we have plenty of other Capture records in BlockDecl and other AST nodes. Reviewers: rjmccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D44221 llvm-svn: 326957
* [analyzer] [PointerArithChecker] do not warn on indexes into vector typesGeorge Karpenkov2018-03-071-0/+4
| | | | | | | | rdar://35041502 Differential Revision: https://reviews.llvm.org/D44172 llvm-svn: 326952
* [analyzer] Don't crash with assertion failure on structured bindingsGeorge Karpenkov2018-03-071-1/+6
| | | | | | | | | | | | Proper modeling still remains to be done. Note that BindingDecl#getHoldingVar() is almost always null, and this should probably be handled by dealing with DecompositionDecl beforehand. rdar://36852163 Differential Revision: https://reviews.llvm.org/D44183 llvm-svn: 326951
* [OpenMP] Remove implicit data sharing code gen that aims to use device ↵Gheorghe-Teodor Bercea2018-03-072-197/+26
| | | | | | | | | | | | | | | | shared memory Summary: Remove this scheme for now since it will be covered by another more generic scheme using global memory. This code will be worked into an optimization for the generic data sharing scheme. Removing this completely and then adding it via future patches will make all future data sharing patches cleaner. Reviewers: ABataev, carlo.bertolli, caomhin Reviewed By: ABataev Subscribers: jholewinski, guansong, cfe-commits Differential Revision: https://reviews.llvm.org/D43625 llvm-svn: 326948
* CodeGen: Fix address space of indirect function argumentYaxun Liu2018-03-0712-108/+201
| | | | | | | | | | | | | | | | | | | | | The indirect function argument is in alloca address space in LLVM IR. However, during Clang codegen for C++, the address space of indirect function argument should match its address space in the source code, i.e., default addr space, even for indirect argument. This is because destructor of the indirect argument may be called in the caller function, and address of the indirect argument may be taken, in either case the indirect function argument is expected to be in default addr space, not the alloca address space. Therefore, the indirect function argument should be mapped to the temp var casted to default address space. The caller will cast it to alloca addr space when passing it to the callee. In the callee, the argument is also casted to the default address space and used. CallArg is refactored to facilitate this fix. Differential Revision: https://reviews.llvm.org/D34367 llvm-svn: 326946
* [clang-format] Break consecutive string literals in text protosKrasimir Georgiev2018-03-071-1/+2
| | | | | | | | | | | | | | | | Summary: This patch fixes a bug where consecutive string literals in text protos were put on the same line. Reviewers: alexfh Reviewed By: alexfh Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D44204 llvm-svn: 326945
* Correct the alignment for the PS4 targetMatthew Voss2018-03-071-0/+1
| | | | | | https://reviews.llvm.org/D44218 llvm-svn: 326942
* [OpenCL] Remove block invoke function from emitted block literal structYaxun Liu2018-03-073-88/+68
| | | | | | | | | | | | | | | | | | | | | OpenCL runtime tracks the invoke function emitted for any block expression. Due to restrictions on blocks in OpenCL (v2.0 s6.12.5), it is always possible to know the block invoke function when emitting call of block expression or __enqueue_kernel builtin functions. Since __enqueu_kernel already has an argument for the invoke function, it is redundant to have invoke function member in the llvm block literal structure. This patch removes invoke function from the llvm block literal structure. It also removes the bitcast of block invoke function to the generic block literal type which is useless for OpenCL. This will save some space for the kernel argument, and also eliminate some store instructions. Differential Revision: https://reviews.llvm.org/D43783 llvm-svn: 326937
* [analyzer] [NFC] Minor refactoring of NonNullParamCheckerGeorge Karpenkov2018-03-071-68/+65
| | | | | | Differential Revision: https://reviews.llvm.org/D43917 llvm-svn: 326935
* Push a function scope when parsing function bodies without a declarationReid Kleckner2018-03-071-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is PR36536. There are a few ways to reach Sema::ActOnStartOfFunctionDef with a null Decl. Currently, the parser continues on to attempt to parse the statements in the function body without pushing a function scope or declaration context. However, lots of statement parsing logic relies on getCurFunction() returning something reasonable. It turns out that getCurFunction() will never return null today because of an optimization where Sema pre-allocates one FunctionScopeInfo and reuses it when possible. This goes wrong when something inside the function body causes us to push another function scope, such as requiring an implicit definition of a special member function. Reusing the state clears it out, which will lead to bugs. In PR36536, we found that the SwitchStack gets unbalanced, because we push a switch, clear out the stack, and then try to pop a switch that isn't there. As a follow-up, I plan to move the pre-allocated FunctionScopeInfo out of the FunctionScopes stack. This means the FunctionScopes stack will often be empty, and callers of getCurFunction() will need to check for null. Reviewers: thakis Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D43980 llvm-svn: 326926
* [OPENMP] Fix lifetime of the loop counters.Alexey Bataev2018-03-072-76/+102
| | | | | | | | We may emit incorrect lifetime info during codegen for loop counters in OpenMP constructs because of automatic scope cleanup when we needed temporarily locations for private loop counters. llvm-svn: 326922
* Reland r326766 (with a slightly modified test)George Burgess IV2018-03-071-1/+5
| | | | | | | | | The original revert was done in r326869, since reverting r326602 broke the test added by this. The new test should be less dependent on r326602. llvm-svn: 326872
* Revert 326766 too, after r326862 the test fails and I don't know how to fix.Nico Weber2018-03-071-5/+1
| | | | llvm-svn: 326869
* [analyzer] Fix the checker for the performance anti-pattern to accept messagesGeorge Karpenkov2018-03-071-11/+14
| | | | | | | | send to ObjC objects. Differential Revision: https://reviews.llvm.org/D44170 llvm-svn: 326868
* [Driver] Enable SafeStack by default on FuchsiaPetr Hosek2018-03-072-0/+9
| | | | | | | | This is already used throughout the entire system, so make it a default. Differential Revision: https://reviews.llvm.org/D44065 llvm-svn: 326867
* Revert r326602, it caused PR36620.Nico Weber2018-03-078-102/+125
| | | | llvm-svn: 326862
* [Driver] Automatically disable incompatible default sanitizersPetr Hosek2018-03-071-13/+23
| | | | | | | | | | When a sanitizer incompatible with one of the default sanitizers is explicitly enabled, automatically disable all the conflicting default sanitizers. Differential Revision: https://reviews.llvm.org/D44064 llvm-svn: 326860
* [StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use ↵Eugene Zelenko2018-03-072-188/+190
| | | | | | warnings; other minor fixes (NFC). llvm-svn: 326856
* [CodeGen] Don't emit lifetime.end without lifetime.startGeorge Burgess IV2018-03-061-3/+1
| | | | | | | | EmitLifetimeStart returns a non-null `size` pointer if it actually emits a lifetime.start. Later in this function, we use `tempSize`'s nullness to determine whether or not we should emit a lifetime.end. llvm-svn: 326844
* [FrontEnd] Allow overriding the default C/C++ -std via CMake varsMichal Gorny2018-03-061-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Provide two new CMake cache variables -- CLANG_DEFAULT_STD_C and CLANG_DEFAULT_STD_CXX -- that can be used to override the default C/ObjC and C++/ObjC++ standards appropriately. They can be set to one of the identifiers from LangStandards.def, or left unset (the default) to respect the current platform default. This option is mostly intended for compiler vendors that may wish to adjust the defaults their compilers are using. For example, Gentoo planned to use it to set clang and gcc to matching standards, so that we could maintain as much compatibility between different compilers as possible. The code relies on explicit identifiers rather than the string aliases for simplicity. This saves us from the necessity of parsing aliases at build-time or adding additional processing at runtime. For the latter case, it also adds trivial value check -- if incorrect value is passed, the code simply fails to compile through referencing an undefined constant. If the variable is used to redefine the default standard, the explicit value overrides the special case for PS4. It is done this way mostly following other kinds of variables where 'platform defaults' are redefined. Differential Revision: https://reviews.llvm.org/D34365 llvm-svn: 326836
* [OPENMP] Fix generation of the unique names for task reductionAlexey Bataev2018-03-062-16/+29
| | | | | | | | | | | variables. If the task has reduction construct and this construct for some variable requires unique threadprivate storage, we may generate different names for variables used in taskgroup task_reduction clause and in task in_reduction clause. Patch fixes this problem. llvm-svn: 326827
* [clang-format] Improve detection of ObjC for-in statementsBen Hamilton2018-03-061-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously, clang-format would detect the following as an Objective-C for-in statement: for (int x = in.value(); ...) {} because the logic only decided a for-loop was definitely *not* an Objective-C for-in loop after it saw a semicolon or a colon. To fix this, I delayed the decision of whether this was a for-in statement until after we found the matching right-paren, at which point we know if we've seen a semicolon or not. Test Plan: New tests added. Ran tests with: make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests Reviewers: krasimir, jolesiak Reviewed By: jolesiak Subscribers: djasper, cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D43904 llvm-svn: 326815
* [X86] Fix typo in cpuid.h, bit_AVX51SER->bit_AVX512ER.Craig Topper2018-03-061-1/+1
| | | | llvm-svn: 326807
* [clang-format] fix handling of consecutive unary operatorsKrasimir Georgiev2018-03-061-4/+2
| | | | | | | | | | | | | | | | | | | | | | Summary: Code that used to be formatted as `if (! + object) {` is now formatted as `if (!+object) {` (we have a particular object in our codebase where unary `operator+` is overloaded to return the underlying value, which in this case is a `bool`) We still preserve the TypeScript behavior where `!` is a trailing non-null operator. (This is already tested by an existing unit test in `FormatTestJS.cpp`) It doesn't appear like handling of consecutive unary operators are tested in general, so I added another test for completeness Patch contributed by @kevinl! Reviewers: krasimir Reviewed By: krasimir Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D43312 llvm-svn: 326792
* [analyzer] CStringChecker.cpp: Remove the duplicated check about null ↵Henry Wong2018-03-061-21/+0
| | | | | | | | | | | | | | | | dereference on dest-buffer or src-buffer. Summary: `CheckBufferAccess()` calls `CheckNonNull()`, so there are some calls to `CheckNonNull()` that are useless. Reviewers: dcoughlin, NoQ, xazax.hun, cfe-commits, george.karpenkov Reviewed By: NoQ Subscribers: szepet, rnkovacs, MTC, a.sidorin Differential Revision: https://reviews.llvm.org/D44075 llvm-svn: 326782
* [Analyzer] More accurate modeling about the increment operator of the ↵Henry Wong2018-03-061-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | operand with type bool. Summary: There is a problem with analyzer that a wrong value is given when modeling the increment operator of the operand with type bool. After `rL307604` is applied, a unsigned overflow may occur. Example: ``` void func() { bool b = true; // unsigned overflow occur, 2 -> 0 U1b b++; } ``` The use of an operand of type bool with the ++ operators is deprecated but valid untill C++17. And if the operand of the increment operator is of type bool, it is set to true. This patch includes two parts: - If the operand of the increment operator is of type bool or type _Bool, set to true. - Modify `BasicValueFactory::getTruthValue()`, use `getIntWidth()` instead `getTypeSize()` and use `unsigned` instead `signed`. Reviewers: alexshap, NoQ, dcoughlin, george.karpenkov Reviewed By: NoQ Subscribers: xazax.hun, szepet, a.sidorin, cfe-commits, MTC Differential Revision: https://reviews.llvm.org/D43741 llvm-svn: 326776
* Fix an unused variable warning; NFCGeorge Burgess IV2018-03-061-0/+1
| | | | llvm-svn: 326767
* [ExprConstant] Look through ExprWithCleanups for `allocsize`George Burgess IV2018-03-061-1/+5
| | | | llvm-svn: 326766
* [StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use ↵Eugene Zelenko2018-03-063-53/+84
| | | | | | warnings; other minor fixes (NFC). llvm-svn: 326757
* [analyzer] [quickfix] Prevent a crash in NamedDecl::getName()George Karpenkov2018-03-061-2/+4
| | | | llvm-svn: 326755
* [analyzer] AST-matching checker to detect global central dispatch ↵George Karpenkov2018-03-052-0/+155
| | | | | | | | | | | | | performance anti-pattern rdar://37312818 NB: The checker does not care about the ordering of callbacks, see the relevant FIXME in tests. Differential Revision: https://reviews.llvm.org/D44059 llvm-svn: 326746
* [msvc] Allow MSVC toolchain driver to find the aarch64 / arm64 cross-compiler.Reid Kleckner2018-03-051-0/+6
| | | | | | | | | | | | | | | Starting with the Fall Creators Update, Windows 10 Desktop can run on machines that are powered by aarch64 processors. Microsoft call the aarch64 architecture "arm64". This patch maps ArchType::aarch64 to "arm64" to allow the MSVC toolchain driver to find the aarch64 / arm64 cross-compiler. Patch by Chris January Differential Revision: https://reviews.llvm.org/D44087 llvm-svn: 326744
* Fix typo in comment.Richard Smith2018-03-051-1/+1
| | | | llvm-svn: 326741
* [AMDGPU] Clean up old address space mapping and fix constant address space valueYaxun Liu2018-03-052-93/+47
| | | | | | Differential Revision: https://reviews.llvm.org/D43911 llvm-svn: 326725
* [analyzer] Improves the logic of GenericTaintChecker identifying stdin.Henry Wong2018-03-051-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: GenericTaintChecker can't recognize stdin in some cases. The reason is that `if (PtrTy->getPointeeType() == C.getASTContext().getFILEType()` does not hold when stdin is encountered. My platform is ubuntu16.04 64bit, gcc 5.4.0, glibc 2.23. The definition of stdin is as follows: ``` __BEGIN_NAMESPACE_STD /* The opaque type of streams. This is the definition used elsewhere. */ typedef struct _IO_FILE FILE; ___END_NAMESPACE_STD ... /* The opaque type of streams. This is the definition used elsewhere. */ typedef struct _IO_FILE __FILE; ... /* Standard streams. */ extern struct _IO_FILE *stdin; /* Standard input stream. */ extern struct _IO_FILE *stdout; /* Standard output stream. */ extern struct _IO_FILE *stderr; /* Standard error output stream. */ ``` The type of stdin is as follows AST: ``` ElaboratedType 0xc911170'struct _IO_FILE'sugar `-RecordType 0xc911150'struct _IO_FILE' `-CXXRecord 0xc923ff0'_IO_FILE' ``` `C.getASTContext().GetFILEType()` is as follows AST: ``` TypedefType 0xc932710 'FILE' sugar |-Typedef 0xc9111c0 'FILE' `-ElaboratedType 0xc911170 'struct _IO_FILE' sugar `-RecordType 0xc911150 'struct _IO_FILE' `-CXXRecord 0xc923ff0 '_IO_FILE' ``` So I think it's better to use `getCanonicalType()`. Reviewers: zaks.anna, NoQ, george.karpenkov, a.sidorin Reviewed By: zaks.anna, a.sidorin Subscribers: a.sidorin, cfe-commits, xazax.hun, szepet, MTC Differential Revision: https://reviews.llvm.org/D39159 llvm-svn: 326709
* [x86][CET] Introduce _get_ssp, _inc_ssp intrinsicsAlexander Ivchenko2018-03-051-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The _get_ssp intrinsic can be used to retrieve the shadow stack pointer, independent of the current arch -- in contract with the rdsspd and the rdsspq intrinsics. Also, this intrinsic returns zero on CPUs which don't support CET. The rdssp[d|q] instruction is decoded as nop, essentially just returning the input operand, which is zero. Example result of compilation: ``` xorl %eax, %eax movl %eax, %ecx rdsspq %rcx # NOP when CET is not supported movq %rcx, %rax # return zero ``` Reviewers: craig.topper Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D43814 llvm-svn: 326689
* [Bash-autocompletion] Fixed formattingYuka Takahashi2018-03-051-3/+4
| | | | | | Fixed a trivial formatting and indent. llvm-svn: 326685
* [Bash-autocompletion] Pass all flags in shell command-line to ClangYuka Takahashi2018-03-051-19/+31
| | | | | | | | | | | | | | | | | | | | Previously, we passed "#" to --autocomplete to indicate to enable cc1 flags. For example, when -cc1 or -Xclang was passed to bash, bash executed `clang --autocomplete=#-<flag they want to complete>`. However, this was not a good implementation because it depends -Xclang and -cc1 parsing to shell. So I changed this to pass all flags shell has, so that Clang can handle them internally. I had to change many testcases because API spec changed quite a lot. Reviewers: teemperor, v.g.vassilev Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D39342 llvm-svn: 326684
* Replace the custom handling for several attributes; NFC.Aaron Ballman2018-03-041-64/+10
| | | | | | These attributes were only customized because of the need to check for attribute mutual exclusion, but we now have the handleSimpleAttributeWithExclusions() helper function to handle these scenarios. llvm-svn: 326675
* Create a subject list for the `used` attribute rather than use custom ↵Aaron Ballman2018-03-031-18/+1
| | | | | | | | checking logic. This changes the diagnostic wording somewhat, but otherwise intends no functional change to the attribute. llvm-svn: 326665
* OpenBSD Driver basic sanitiser supportKamil Rytarowski2018-03-032-1/+24
| | | | | | | | | | | | | | | | | | Summary: Basic support of Sanitiser to follow-up ubsan support in compiler-rt. Needs to use lld instead of base ld to be fully workable. Patch by: David CARLIER Reviewers: krytarowski, vitalybuka, kettenis Reviewed By: vitalybuka Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D43961 llvm-svn: 326648
* Better OpenBSD frontend supportKamil Rytarowski2018-03-033-3/+9
| | | | | | | | | | | | | | | | | | Summary: - Like other *BSD, conditioning certain flags to pass - To prepare future OpenBSD sanitisers. Patch by: David CARLIER Reviewers: dlj, krytarowski, vitalybuka Reviewed By: vitalybuka Subscribers: krytarowski, cfe-commits Differential Revision: https://reviews.llvm.org/D43818 llvm-svn: 326645
* Do not generate calls to fentry with __attribute__((no_instrument_function))Manoj Gupta2018-03-021-4/+6
| | | | | | | | | | | | | | | | | | | Summary: Currently only calls to mcount were suppressed with no_instrument_function attribute. Linux kernel requires that calls to fentry should also not be generated. This is an extended fix for PR PR33515. Reviewers: hfinkel, rengolin, srhines, rnk, rsmith, rjmccall, hans Reviewed By: rjmccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D43995 llvm-svn: 326639
* [StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use ↵Eugene Zelenko2018-03-023-136/+149
| | | | | | warnings; other minor fixes (NFC). llvm-svn: 326633
* PR36581: Support data recursion over Stmts in AST matchers.Richard Smith2018-03-021-11/+16
| | | | llvm-svn: 326624
OpenPOWER on IntegriCloud