summaryrefslogtreecommitdiffstats
path: root/clang/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* [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
* [analyzer] Don't throw NSNumberObjectConversion warning on object ↵George Karpenkov2018-03-021-2/+4
| | | | | | | | | | | | | | | initialization in if-expression ``` if (NSNumber* x = ...) ``` is a reasonable pattern in objc++, we should not warn on it. rdar://35152234 Differential Revision: https://reviews.llvm.org/D44044 llvm-svn: 326619
* Range-ify a for loop. NFCGeorge Burgess IV2018-03-021-5/+2
| | | | llvm-svn: 326607
* [Attr] Fix parameter indexing for several attributesJoel E. Denny2018-03-028-125/+102
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The patch fixes a number of bugs related to parameter indexing in attributes: * Parameter indices in some attributes (argument_with_type_tag, pointer_with_type_tag, nonnull, ownership_takes, ownership_holds, and ownership_returns) are specified in source as one-origin including any C++ implicit this parameter, were stored as zero-origin excluding any this parameter, and were erroneously printing (-ast-print) and confusingly dumping (-ast-dump) as the stored values. * For alloc_size, the C++ implicit this parameter was not subtracted correctly in Sema, leading to assert failures or to silent failures of __builtin_object_size to compute a value. * For argument_with_type_tag, pointer_with_type_tag, and ownership_returns, the C++ implicit this parameter was not added back to parameter indices in some diagnostics. This patch fixes the above bugs and aims to prevent similar bugs in the future by introducing careful mechanisms for handling parameter indices in attributes. ParamIdx stores a parameter index and is designed to hide the stored encoding while providing accessors that require each use (such as printing) to make explicit the encoding that is needed. Attribute declarations declare parameter index arguments as [Variadic]ParamIdxArgument, which are exposed as ParamIdx[*]. This patch rewrites all attribute arguments that are processed by checkFunctionOrMethodParameterIndex in SemaDeclAttr.cpp to be declared as [Variadic]ParamIdxArgument. The only exception is xray_log_args's argument, which is encoded as a count not an index. Differential Revision: https://reviews.llvm.org/D43248 llvm-svn: 326602
* [OPENMP] Scan all redeclarations looking for `declare simd` attribute.Alexey Bataev2018-03-021-65/+69
| | | | | | | | | Patch fixes the problem with the functions marked as `declare simd`. If the canonical declaration does not have associated `declare simd` construct, we may not generate required code even if other redeclarations are marked as `declare simd`. llvm-svn: 326594
* [OPENMP] Treat local variables in CUDA mode as thread local.Alexey Bataev2018-03-021-15/+59
| | | | | | | | In CUDA mode all local variables are actually thread local|threadprivate, not private, and, thus, they cannot be shared between threads|lanes. llvm-svn: 326590
* Add possibility to specify output stream for CompilerInstanceAlexey Sotkin2018-03-021-1/+4
| | | | | | | | | | | | | | Patch by: krisb Reviewers: teemperor Reviewed By: teemperor Subscribers: klimek, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D43809 llvm-svn: 326566
* [Frontend] Avoid including default system header paths on FuchsiaPetr Hosek2018-03-021-0/+2
| | | | | | | | These paths aren't used and don't make sense on Fuchsia. Differential Revision: https://reviews.llvm.org/D43992 llvm-svn: 326542
* Remove debugging code I accidentally committed in r326530.Akira Hatanaka2018-03-021-1/+0
| | | | llvm-svn: 326531
* Add an option to disable tail-call optimization for escaping blocks.Akira Hatanaka2018-03-026-4/+30
| | | | | | | | | | | | | This makes it easier to debug crashes and hangs in block functions since users can easily find out where the block is called from. The option doesn't disable tail-calls from non-escaping blocks since non-escaping blocks are not as hard to debug as escaping blocks. rdar://problem/35758207 Differential Revision: https://reviews.llvm.org/D43841 llvm-svn: 326530
* Always set dso_local in CodeGenModule::setDSOLocal.Rafael Espindola2018-03-021-2/+7
| | | | | | | | | | | | | This shouldn't change any results for now, but is more consistent with how we set dllimport/dllexport and will make future changes easier. Since clang produces IR as it parses, it can find out mid file that something is dllimport. When that happens we have to drop dso_local. This is not a problem right now because CodeGenModule::setDSOLocal is called from relatively few places at the moment. llvm-svn: 326527
* [analyzer] Prevent crashing in NonNullParamCheckerGeorge Karpenkov2018-03-021-0/+2
| | | | | | | | | | | | | https://bugs.llvm.org/show_bug.cgi?id=36381 rdar://37543426 Turns out, the type passed for the lambda capture was incorrect. One more argument to abandon the getSVal overload which does not require the type information. Differential Revision: https://reviews.llvm.org/D43925 llvm-svn: 326520
* [StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use ↵Eugene Zelenko2018-03-021-203/+202
| | | | | | warnings; other minor fixes (NFC). llvm-svn: 326519
* [WebAssembly] Add exception handling optionHeejin Ahn2018-03-022-1/+11
| | | | | | | | | | | | Summary: Add exception handling option to clang. Reviewers: dschuff Subscribers: jfb, sbc100, jgravelle-google, sunfish, cfe-commits Differential Revision: https://reviews.llvm.org/D43681 llvm-svn: 326517
* [NFC] Move CommentOpts checks to the call sites that depend on it. ↵David L. Jones2018-03-024-17/+18
| | | | | | | | | | | | | | | | | | | | | | (Re-applying r326501.) When parsing comments, for example, for -Wdocumentation, slightly different behaviour occurs when -fparse-all-comments is specified. However, these differences are subtle: 1. All comments are saved during parsing, regardless of whether they are doc comments or not. 2. "Maybe-doc" comments, like <, !, etc, are saved as such, instead of marking them as ordinary comments. The maybe-doc type of comment is never saved otherwise. (Warning on these is the impetus of -Wdocumentation.) 3. All comments are treated as doc comments in ASTContext, even if they are ordinary. This change moves the logic for checking CommentOptions.ParseAllComments closer to where it has an effect. The overall logic is unchanged, but checks of the ParseAllComments flag are now done where the effect will be clearer. Subscribers: cfe-commits llvm-svn: 326512
* Revert r326501 due to buildbot breakage.David L. Jones2018-03-014-18/+17
| | | | | | | | | | | | | | | | | | | | Original change: [NFC] Move CommentOpts checks to the call sites that depend on it. When parsing comments, for example, for -Wdocumentation, slightly different behaviour occurs when -fparse-all-comments is specified. However, these differences are subtle: 1. All comments are saved during parsing, regardless of whether they are doc comments or not. 2. "Maybe-doc" comments, like //<, //!, etc, are saved as such, instead of marking them as ordinary comments. The maybe-doc type of comment is never saved otherwise. (Warning on these is the impetus of -Wdocumentation.) 3. All comments are treated as doc comments in ASTContext, even if they are ordinary. This change moves the logic for checking CommentOptions.ParseAllComments closer to where it has an effect. The overall logic is unchanged, but checks of the ParseAllComments flag are now done where the effect will be clearer. llvm-svn: 326508
* [NFC] Move CommentOpts checks to the call sites that depend on it.David L. Jones2018-03-014-17/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | When parsing comments, for example, for -Wdocumentation, slightly different behaviour occurs when -fparse-all-comments is specified. However, these differences are subtle: 1. All comments are saved during parsing, regardless of whether they are doc comments or not. 2. "Maybe-doc" comments, like //<, //!, etc, are saved as such, instead of marking them as ordinary comments. The maybe-doc type of comment is never saved otherwise. (Warning on these is the impetus of -Wdocumentation.) 3. All comments are treated as doc comments in ASTContext, even if they are ordinary. This change moves the logic for checking CommentOptions.ParseAllComments closer to where it has an effect. The overall logic is unchanged, but checks of the ParseAllComments flag are now done where the effect will be clearer. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D43663 llvm-svn: 326501
* [Driver] Pass -f[no-]emulated-tls and set up ExplicitEmulatedTLSChih-Hung Hsieh2018-03-013-9/+10
| | | | | | | | | | Since LLVM r326341, default EmulatedTLS mode is decided in backend according to target triple. Any front-end should pass -f[no]-emulated-tls to backend and set up ExplicitEmulatedTLS only when the flags are used. Differential Revision: https://reviews.llvm.org/D43965 llvm-svn: 326499
* [modules] Don't diagnose "redefinition" of a friend with a pending definitionRichard Smith2018-03-011-0/+9
| | | | | | if the other definition is a merged copy of the same function. llvm-svn: 326496
* [RecordLayout] Only assert that fundamental type sizes are power of two on MSVCMartin Storsjo2018-03-011-4/+26
| | | | | | | | | | Make types with sizes that aren't a power of two an error (that can be disabled) in structs with ms_struct layout, except on mingw where the situation is quite likely to occur and GCC handles it silently. Differential Revision: https://reviews.llvm.org/D43908 llvm-svn: 326476
* [analyzer] Enable cfg-temporary-dtors by default.Artem Dergachev2018-03-011-2/+2
| | | | | | | | | | | | Don't enable c++-temp-dtor-inlining by default yet, due to this reference counting pointe problem. Otherwise the new mode seems stable and allows us to incrementally fix C++ problems in much less hacky ways. Differential Revision: https://reviews.llvm.org/D43804 llvm-svn: 326461
* Resubmit [analyzer] Support for naive cross translation unit analysisIlya Biryukov2018-03-017-12/+77
| | | | | | | | | | | Originally submitted as r326323 and r326324. Reverted in r326432. Reverting the commit was a mistake. The breakage was due to invalid build files in our internal buildsystem, CMakeLists did not have any cyclic dependencies. llvm-svn: 326439
* Revert "[analyzer] Support for naive cross translation unit analysis"Ilya Biryukov2018-03-017-77/+12
| | | | | | | | | | Also revert "[analyzer] Fix a compiler warning" This reverts commits r326323 and r326324. Reason: the commits introduced a cyclic dependency in the build graph. This happens to work with cmake, but breaks out internal integrate. llvm-svn: 326432
* [clang-format] Add SpaceBeforeColon optionFrancois Ferrand2018-03-012-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: When disabled, this option allows removing the space before colon, making it act more like the semi-colon. When enabled (default), the current behavior is not affected. This mostly affects C++11 loop, initializer list, inheritance list and container literals: class Foo: Bar {} Foo::Foo(): a(a) {} for (auto i: myList) {} f({a: 1, b: 2, c: 3}); Reviewers: krasimir, djasper Reviewed By: djasper Subscribers: xvallspl, teemperor, karies, cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D32525 llvm-svn: 326426
* Function definition may have uninstantiated bodySerge Pavlov2018-03-012-41/+47
| | | | | | | | | | | | | | | | | | | | | | | | Current implementation of `FunctionDecl::isDefined` does not take into account redeclarations that do not have bodies, but the bodies can be instantiated from corresponding templated definition. This behavior does not allow to detect function redefinition in the cases where friend functions is defined in class templates. For instance, the code: ``` template<typename T> struct X { friend void f() {} }; X<int> xi; void f() {} ``` compiles successfully but must fail due to redefinition of `f`. The declaration of the friend `f` is created when the containing template `X` is instantiated, but it does not have a body as per 14.5.4p4 because `f` is not odr-used. With this change the function `Sema::CheckForFunctionRedefinition` considers functions with uninstantiated bodies as definitions. Differential Revision: https://reviews.llvm.org/D30170 llvm-svn: 326419
* Remove redundant casts. NFCGeorge Burgess IV2018-03-0148-170/+155
| | | | | | | | | | | | | | | | | | | So I wrote a clang-tidy check to lint out redundant `isa`, `cast`, and `dyn_cast`s for fun. This is a portion of what it found for clang; I plan to do similar cleanups in LLVM and other subprojects when I find time. Because of the volume of changes, I explicitly avoided making any change that wasn't highly local and obviously correct to me (e.g. we still have a number of foo(cast<Bar>(baz)) that I didn't touch, since overloading is a thing and the cast<Bar> did actually change the type -- just up the class hierarchy). I also tried to leave the types we were cast<>ing to somewhere nearby, in cases where it wasn't locally obvious what we were dealing with before. llvm-svn: 326416
* [analyzer] Add a checker for mmap()s which are both writable and executable.Artem Dergachev2018-03-012-0/+88
| | | | | | | | | | | | | | | | | | | This is a security check that warns when both PROT_WRITE and PROT_EXEC are set during mmap(). If mmap()ed memory is both writable and executable, it makes it easier for the attacker to execute arbitrary code when contents of this memory are compromised. Some applications require such mmap()s though, such as different sorts of JIT. Re-applied after a revert in r324167. Temporarily stays in the alpha package because it needs a better way of determining macro values that are not immediately available in the AST. Patch by David Carlier! Differential Revision: https://reviews.llvm.org/D42645 llvm-svn: 326405
* [CFG] [analyzer] Recall that we only skip NoOp casts in construction contexts.Artem Dergachev2018-03-011-1/+3
| | | | | | | | | | | | For now. We should also add support for ConstructorConversion casts as presented in the attached test case, but this requires more changes because AST around them seems different. The check was originally present but was accidentally lost during r326021. Differential Revision: https://reviews.llvm.org/D43840 llvm-svn: 326402
* Start setting dllimport/dllexport in setGVProperties.Rafael Espindola2018-03-0110-140/+81
| | | | | | | | | | This is the next step in setting dso_local for COFF. The patches changes setGVProperties to first set dllimport/dllexport and changes a few cases that were setting dllimport/dllexport manually. With this a few more GVs are marked dso_local. llvm-svn: 326397
* Pass a GlobalDecl to SetCommonAttributes. NFC.Rafael Espindola2018-03-012-6/+6
| | | | | | Part of D43900. llvm-svn: 326392
* Inline a trivial function. NFC.Rafael Espindola2018-03-013-10/+2
| | | | llvm-svn: 326391
* Pass a GlobalDecl to setNonAliasAttributes. NFC.Rafael Espindola2018-02-282-4/+5
| | | | | | Also part of D43900. llvm-svn: 326388
* Pass a GlobalDecl to SetInternalFunctionAttributes. NFC.Rafael Espindola2018-02-287-26/+27
| | | | | | | | This just reduces the noise in a followup patch. Part of D43900. llvm-svn: 326385
* [OpenMP] Extend NVPTX SPMD implementation of combined constructsCarlo Bertolli2018-02-284-21/+23
| | | | | | | | Differential Revision: https://reviews.llvm.org/D43852 This patch extends the SPMD implementation to all target constructs and guards this implementation under a new flag. llvm-svn: 326368
* [Hexagon] Add -ffixed-r19 driver option and translate it to +reserved-r19Krzysztof Parzyszek2018-02-281-5/+9
| | | | llvm-svn: 326366
* CodeGenObjCXX: handle inalloca appropriately for msgSend variantSaleem Abdulrasool2018-02-281-1/+2
| | | | | | | | | | | objc_msgSend_stret takes a hidden parameter for the returned structure's address for the construction. When the function signature is rewritten for the inalloca passing, the return type is no longer marked as indirect but rather inalloca stret. This enhances the test for the indirect return to check for that case as well. This fixes the incorrect return classification for Windows x86. llvm-svn: 326362
OpenPOWER on IntegriCloud