aboutsummaryrefslogtreecommitdiff
path: root/clang/lib
AgeCommit message (Collapse)AuthorFilesLines
2019-01-04Refactor the way we handle diagnosing unused expression results.Aaron Ballman12-97/+126
Rather than sprinkle calls to DiagnoseUnusedExprResult() around in places where we want diagnostics, we now diagnose unused expression statements and full expressions in a more generic way when acting on the final expression statement. This results in more appropriate diagnostics for [[nodiscard]] where we were previously lacking them, such as when the body of a for loop is not a compound statement. This patch fixes PR39837. llvm-svn: 350404
2019-01-04Prevent unreachable when checking invalid multiversion decls.Erich Keane1-0/+5
CPUSpecifc/CPUDispatch call resolution assumed that all declarations that would be passed are valid, however this was an invalid assumption. This patch deals with those situations by making the valid version take priority. Note that the checked ordering is arbitrary, since both are replaced by calls to the resolver later. Change-Id: I7ff2ec88c55a721d51bc1f39ea1a1fe242b4e45f llvm-svn: 350398
2019-01-04[Basic] Extend DiagnosticEngine to store and format Qualifiers.Anastasia Stulova3-5/+18
Qualifiers can now be streamed into the DiagnosticEngine using regular << operator. If Qualifiers are empty 'unqualified' will be printed in the diagnostic otherwise regular qual syntax is used. Differential Revision: https://reviews.llvm.org/D56198 llvm-svn: 350386
2019-01-03Adopt SwiftABIInfo for WebAssembly.Daniel Dunbar1-6/+17
Summary: - This adopts SwiftABIInfo as the base class for WebAssemblyABIInfo, which is in keeping with what is done for other targets for which Swift is supported. - This is a minimal patch to unblock exploration of WASM support for Swift (https://bugs.swift.org/browse/SR-9307) Reviewers: rjmccall, sunfish Reviewed By: rjmccall Subscribers: ahti, dschuff, sbc100, jgravelle-google, aheejin, cfe-commits Differential Revision: https://reviews.llvm.org/D56188 llvm-svn: 350372
2019-01-03Validate -add-plugin arguments.Nico Weber1-1/+15
-plugin already prints an error if the name of an unknown plugin is passed. -add-plugin used to silently ignore that, now it errors too. Differential Revision: https://reviews.llvm.org/D56273 llvm-svn: 350340
2019-01-03Make -Wstring-plus-int warns even if when the result is not out of boundsArnaud Bienner1-10/+0
Summary: Patch by Arnaud Bienner Reviewers: sylvestre.ledru, thakis, serge-sans-paille Reviewed By: thakis Subscribers: arphaman, dyung, anemet, llvm-commits, cfe-commits Differential Revision: https://reviews.llvm.org/D55382 llvm-svn: 350335
2019-01-03[OPENMP][NVPTX]Use __kmpc_barrier_simple_spmd(nullptr, 0) instead ofAlexey Bataev2-12/+32
nvvm_barrier0. Use runtime functions instead of the direct call to the nvvm intrinsics. It allows to prevent some dangerous LLVM optimizations, that breaks the code for the NVPTX target. llvm-svn: 350328
2019-01-03Diagnose an unused result from a call through a function pointer whose ↵Aaron Ballman3-25/+19
return type is marked [[nodiscard]]. When a function returns a type and that type was declared [[nodiscard]], we diagnose any unused results from that call as though the function were marked nodiscard. The same behavior should apply to calls through a function pointer. This addresses PR31526. llvm-svn: 350317
2019-01-03[NewPM] Port MsanPhilip Pfaffe1-1/+2
Summary: Keeping msan a function pass requires replacing the module level initialization: That means, don't define a ctor function which calls __msan_init, instead just declare the init function at the first access, and add that to the global ctors list. Changes: - Pull the actual sanitizer and the wrapper pass apart. - Add a newpm msan pass. The function pass inserts calls to runtime library functions, for which it inserts declarations as necessary. - Update tests. Caveats: - There is one test that I dropped, because it specifically tested the definition of the ctor. Reviewers: chandlerc, fedor.sergeev, leonardchan, vitalybuka Subscribers: sdardis, nemanjai, javed.absar, hiraditya, kbarton, bollu, atanasyan, jsji Differential Revision: https://reviews.llvm.org/D55647 llvm-svn: 350305
2019-01-02[OpenMP] Added support for explicit mapping of classes using 'this' pointer. ↵Patrick Lyster2-3/+80
Differential revision: https://reviews.llvm.org/D55982 llvm-svn: 350252
2019-01-02Only convert objc messages to alloc to objc_alloc if the receiver is a class.Pete Cooper1-3/+6
r348687 converted [Foo alloc] to objc_alloc(Foo). However the objc runtime method only takes a Class, not an arbitrary pointer. This makes sure we are messaging a class before we convert these messages. rdar://problem/46943703 llvm-svn: 350224
2018-12-29[CodeGen] Replace '@' characters in block descriptors' symbol names withAkira Hatanaka1-0/+3
'\1'. '@' can't be used in block descriptors' symbol names since it is reserved on ELF platforms as a separator between symbol names and symbol versions. See the discussion here: https://reviews.llvm.org/D50783. Differential Revision: https://reviews.llvm.org/D54539 llvm-svn: 350157
2018-12-29Add vtable anchor to classes.Richard Trieu3-0/+6
llvm-svn: 350143
2018-12-28[objc-gnustep2] Fix a bug in category generation.David Chisnall1-6/+20
We were not emitting a protocol definition while generating the category method list. This was fine in most cases, because something else in the library typically referenced any given protocol, but it caused linker failures if the category was the only reference to a given protocol. llvm-svn: 350130
2018-12-28[OPENMP]Fix processing of the clauses on target combined directives.Alexey Bataev1-4/+7
For constants with the predefined data-sharing clauses we may had troubles with the target combined directives. It may cause compiler crash in some corner cases. llvm-svn: 350127
2018-12-27[objc-gnustep] Fix a copy-and-paste error.David Chisnall1-1/+1
We were emitting the null class symbol in the wrong section, which meant that programs that contained no Objective-C classes would fail to link. llvm-svn: 350092
2018-12-26[clang-cl] Treat inputs as C++ with /E, like MSVCReid Kleckner1-1/+4
midl invokes the compiler on .idl files with /E. Before this change, we would treat unrecognized inputs as object files. Now we pre-process to stdout as expected. I checked that MSVC defines __cplusplus when invoked this way, so treating the input as C++ seems like the right thing to do. After this change, I was able to run midl like this with clang-cl: $ midl -cpp_cmd clang-cl.exe foo.idl Things worked for the example IDL file in the Microsoft documentation, but beyond that, I don't know if this will work well. Fixes PR40140 llvm-svn: 350072
2018-12-26[MS] Mangle return adjusting thunks with the public access specifierReid Kleckner1-6/+12
MSVC does this, so we should too. Fixes PR40138 llvm-svn: 350071
2018-12-26Ignore ConstantExpr in IgnoreParensReid Kleckner1-4/+4
Summary: This moves it up from IgnoreParenImpCasts to IgnoreParens, so that more helpers ignore it. For most clients, this ensures that these helpers behave the same with and without C++17 enabled, which is what appears to introduce these new expression nodes. Fixes PR39881 Reviewers: void, rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55853 llvm-svn: 350068
2018-12-24[analyzer] [NFC] Clean up the mess of constructing argument effects in ↵George Karpenkov1-60/+83
RetainCountChecker Previously, argument effects were stored in a method variable, which was effectively global. The global state was reset at each (hopefully) entrance point to the summary construction, and every function could modify it. Differential Revision: https://reviews.llvm.org/D56036 llvm-svn: 350057
2018-12-23[Driver] Disable -faddrsig on Gentoo by defaultMichal Gorny1-0/+2
Gentoo supports combining clang toolchain with GNU binutils, and many users actually do that. As -faddrsig is not supported by GNU strip, this results in a lot of warnings. Disable it by default and let users enable it explicitly if they want it; with the intent of reevaluating when the underlying feature becomes standarized. See also: https://bugs.gentoo.org/667854 Differential Revision: https://reviews.llvm.org/D56047 llvm-svn: 350028
2018-12-23[Distro] Support detecting GentooMichal Gorny1-0/+3
Add support for distinguishing plain Gentoo distribution, and a unit test for it. This is going to be used to introduce distro-specific customizations in the driver code; most notably, it is going to be used to disable -faddrsig. Differential Revision: https://reviews.llvm.org/D56024 llvm-svn: 350027
2018-12-22[AST] Store the arguments of CXXConstructExpr in a trailing arrayBruno Ricci5-95/+130
Store the arguments of CXXConstructExpr in a trailing array. This is very similar to the CallExpr case in D55771, with the exception that there is only one derived class (CXXTemporaryObjectExpr) and that we compute the offset to the trailing array instead of storing it. This saves one pointer per CXXConstructExpr and CXXTemporaryObjectExpr. Reviewed By: rjmccall Differential Revision: https://reviews.llvm.org/D56022 llvm-svn: 350003
2018-12-22[analyzer] pr38668: Do not attempt to cast loaded integers to floats.Artem Dergachev2-9/+31
This patch is a different approach to landing the reverted r349701. It is expected to have the same object (memory region) treated as if it has different types in different program points. The correct behavior for RegionStore when an object is stored as an object of type T1 but loaded as an object of type T2 is to store the object as if it has type T1 but cast it to T2 during load. Note that the cast here is some sort of a "reinterpret_cast" (even in C). For instance, if you store an integer and load a float, you won't get your integer represented as a float; instead, you will get garbage. Admit that we cannot perform the cast and return an unknown value. Differential Revision: https://reviews.llvm.org/D55875 rdar://problem/45062567 llvm-svn: 349984
2018-12-22[CUDA] Treat extern global variable shadows same as regular extern vars.Artem Belevich1-10/+5
This fixes compiler crash when we attempted to compile this code: extern __device__ int data; __device__ int data = 1; Differential Revision: https://reviews.llvm.org/D56033 llvm-svn: 349981
2018-12-21Switch from static_cast<> to cast<>, update identifier for coding ↵Aaron Ballman1-4/+2
conventions; NFC. llvm-svn: 349955
2018-12-21Convert some ObjC retain/release msgSends to runtime calls.Pete Cooper3-0/+94
It is faster to directly call the ObjC runtime for methods such as retain/release instead of sending a message to those functions. Differential Revision: https://reviews.llvm.org/D55869 Reviewed By: rjmccall llvm-svn: 349952
2018-12-21[Sema][NFC] Fix a Wimplicit-fallthrough warning in ↵Bruno Ricci1-0/+1
CheckSpecializationInstantiationRedecl All cases are covered so add an llvm_unreachable. NFC. llvm-svn: 349949
2018-12-21[AST][NFC] Remove stale comment in CXXRecordDecl::is(Virtually)DerivedFrom.Bruno Ricci1-2/+0
The "this" capture was removed in r291939. llvm-svn: 349948
2018-12-21Remove stat cache chaining as it's no longer needed after PTH support has beenAlex Lorenz3-45/+12
removed Stat cache chaining was implemented for a StatListener in the PTH writer so that it could write out the stat information to PTH. r348266 removed support for PTH, and it doesn't seem like there are other uses of stat cache chaining. We can remove the chaining support. Differential Revision: https://reviews.llvm.org/D55455 llvm-svn: 349942
2018-12-21Revert "Revert rL349876 from cfe/trunk: [analyzer] Perform escaping in ↵George Karpenkov1-23/+28
RetainCountChecker on type mismatch even for inlined functions" This reverts commit b44b33f6e020a2c369da2b0c1d53cd52975f2526. Revert the revert with the fix. llvm-svn: 349939
2018-12-21[analyzer] Correct the summary violation diagnostics for the retain count ↵George Karpenkov1-1/+1
checker It should be in the past tense. llvm-svn: 349938
2018-12-21[AST][NFC] Fix Wsign-compare warning introduced in CXXOperatorCallExprBruno Ricci1-2/+3
llvm-svn: 349934
2018-12-21[Sema][NFC] Fix Wimplicit-fallthrough warning in getCursorKindForDeclBruno Ricci1-0/+1
All cases are covered so add an llvm_unreachable. NFC. llvm-svn: 349933
2018-12-21[AST][NFC] Pack CXXOperatorCallExprBruno Ricci3-5/+10
Use the space available in the bit-fields of Stmt. This saves 8 bytes per CXXOperatorCallExpr. NFC. llvm-svn: 349924
2018-12-21[AST] Store the callee and argument expressions of CallExpr in a trailing array.Bruno Ricci13-217/+379
Since CallExpr::setNumArgs has been removed, it is now possible to store the callee expression and the argument expressions of CallExpr in a trailing array. This saves one pointer per CallExpr, CXXOperatorCallExpr, CXXMemberCallExpr, CUDAKernelCallExpr and UserDefinedLiteral. Given that CallExpr is used as a base of the above classes we cannot use llvm::TrailingObjects. Instead we store the offset in bytes from the this pointer to the start of the trailing objects and manually do the casts + arithmetic. Some notes: 1.) I did not try to fit the number of arguments in the bit-fields of Stmt. This leaves some space for future additions and avoid the discussion about whether x bits are sufficient to hold the number of arguments. 2.) It would be perfectly possible to recompute the offset to the trailing objects before accessing the trailing objects. However the trailing objects are frequently accessed and benchmarks show that it is slightly faster to just load the offset from the bit-fields. Additionally, because of 1), we have plenty of space in the bit-fields of Stmt. Differential Revision: https://reviews.llvm.org/D55771 Reviewed By: rjmccall llvm-svn: 349910
2018-12-21[Sema][NFC] Remove some unnecessary calls to getASTContext.Bruno Ricci4-13/+12
The AST context is already easily available. NFC. llvm-svn: 349904
2018-12-21[AST][NFC] Pass the AST context to one of the ctor of DeclRefExpr.Bruno Ricci17-187/+197
All of the other constructors already take a reference to the AST context. This avoids calling Decl::getASTContext in most cases. Additionally move the definition of the constructor from Expr.h to Expr.cpp since it is calling DeclRefExpr::computeDependence. NFC. llvm-svn: 349901
2018-12-21Revert rL349876 from cfe/trunk: [analyzer] Perform escaping in ↵Simon Pilgrim1-28/+23
RetainCountChecker on type mismatch even for inlined functions The fix done in D55465 did not previously apply when the function was inlined. rdar://46889541 Differential Revision: https://reviews.llvm.org/D55976 ........ Fixes broken buildbot: http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/14764 llvm-svn: 349894
2018-12-21[Sema] Produce diagnostics when C++17 aligned allocation/deallocationAkira Hatanaka3-20/+34
functions that are unavailable on Darwin are explicitly called or called from deleting destructors. rdar://problem/40736230 Differential Revision: https://reviews.llvm.org/D47757 llvm-svn: 349890
2018-12-21[analyzer] Perform escaping in RetainCountChecker on type mismatch even for ↵George Karpenkov1-23/+28
inlined functions The fix done in D55465 did not previously apply when the function was inlined. rdar://46889541 Differential Revision: https://reviews.llvm.org/D55976 llvm-svn: 349876
2018-12-21[analyzer] Fix a bug in RetainCountDiagnostics while printing a note on ↵George Karpenkov1-3/+2
mismatched summary in inlined functions Previously, we were not printing a note at all if at least one of the parameters was not annotated. rdar://46888422 Differential Revision: https://reviews.llvm.org/D55972 llvm-svn: 349875
2018-12-21[mingw] Don't mangle thiscall like fastcall etcReid Kleckner1-2/+8
GCC does not mangle it when it is not explicit in the source. The mangler as currently written cannot differentiate between explicit and implicit calling conventions, so we can't match GCC. Explicit thiscall conventions are rare, so mangle as if the convention was implicit to be as ABI compatible as possible. Also fixes some tests using %itanium_abi_triple in some configurations as a side effect. Fixes PR40107. llvm-svn: 349872
2018-12-21[driver] [analyzer] Fix --analyze -Xanalyzer after r349863.Artem Dergachev1-2/+13
If an -analyzer-config is passed through -Xanalyzer, it is not found while looking for -Xclang. Additionally, don't emit -analyzer-config-compatibility-mode for *every* -analyzer-config flag we encounter; one is enough. https://reviews.llvm.org/D55823 rdar://problem/46504165 llvm-svn: 349866
2018-12-21Revert "Revert "[driver] [analyzer] Fix a backward compatibility issue after ↵George Karpenkov1-3/+7
r348038."" This reverts commit 144927939587b790c0536f4ff08245043fc8d733. Fixes the bug in the original commit. llvm-svn: 349863
2018-12-21[analyzer] RetainCount: Suppress retain detection heuristic on some CM methods.Artem Dergachev1-0/+11
If it ends with "Retain" like CFRetain and returns a CFTypeRef like CFRetain, then it is not necessarily a CFRetain. But it is indeed true that these two return something retained. Differential Revision: https://reviews.llvm.org/D55907 rdar://problem/39390714 llvm-svn: 349862
2018-12-20[CodeGen] Fix assertion on emitting cleanup for object with inlined ↵Volodymyr Sapsai1-0/+1
inherited constructor and non-trivial destructor. Fixes assertion > Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file llvm/Support/Casting.h, line 255. It was triggered by trying to cast `FunctionDecl` to `CXXMethodDecl` as `CGF.CurCodeDecl` in `CallBaseDtor::Emit`. It was happening because cleanups were emitted in `ScalarExprEmitter::VisitExprWithCleanups` after destroying `InlinedInheritingConstructorScope`, so `CodeGenFunction.CurCodeDecl` didn't correspond to expected cleanup decl. Fix the assertion by emitting cleanups before leaving `InlinedInheritingConstructorScope` and changing `CurCodeDecl`. Test cases based on a patch by Shoaib Meenai. Fixes PR36748. rdar://problem/45805151 Reviewers: rsmith, rjmccall Reviewed By: rjmccall Subscribers: jkorous, dexonsmith, cfe-commits, smeenai, compnerd Differential Revision: https://reviews.llvm.org/D55543 llvm-svn: 349848
2018-12-20Add support for namespaces on #pragma clang attributeErik Pilkington2-17/+69
Namespaces are introduced by adding an "identifier." before a push/pop directive. Pop directives with namespaces can only pop a attribute group that was pushed with the same namespace. Push and pop directives that don't opt into namespaces have the same semantics. This is necessary to prevent a pitfall of using multiple #pragma clang attribute directives spread out in a large file, particularly when macros are involved. It isn't easy to see which pop corripsonds to which push, so its easy to inadvertently pop the wrong group. Differential revision: https://reviews.llvm.org/D55628 llvm-svn: 349845
2018-12-20Revert "[driver] [analyzer] Fix a backward compatibility issue after r348038."Artem Dergachev1-10/+3
This reverts commits r349824, r349828, r349835. More buildbot failures were noticed. Differential Revision: https://reviews.llvm.org/D55823 rdar://problem/46504165 llvm-svn: 349843
2018-12-20[ObjC] Messages to 'self' in class methods that return 'instancetype' shouldAlex Lorenz1-22/+43
use the pointer to the class as the result type of the message Prior to this commit, messages to self in class methods were treated as instance methods to a Class value. When these methods returned instancetype the compiler only saw id through the instancetype, and not the Interface *. This caused problems when that return value was a receiver in a message send, as the compiler couldn't select the right method declaration and had to rely on a selection from the global method pool. This commit modifies the semantics of such message sends and uses class messages that are dispatched to the interface that corresponds to the class that contains the class method. This ensures that instancetypes are correctly interpreted by the compiler. This change is safe under ARC (as self can't be reassigned), however, it also applies to MRR code as we are assuming that the user isn't doing anything unreasonable. rdar://20940997 Differential Revision: https://reviews.llvm.org/D36790 llvm-svn: 349841