Commit Graph

53692 Commits

Author SHA1 Message Date
Stephen Kelly d83fe89497 NFC: Move Decl node handling to TextNodeDumper
Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56643

llvm-svn: 351175
2019-01-15 09:35:52 +00:00
Stephen Kelly f08ca204ac [ASTDump] NFC: Move dump of type nodes to NodeDumper
Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56642

llvm-svn: 351172
2019-01-15 09:30:00 +00:00
Dan Gohman 055a6f0462 [WebAssembly] Support multilibs for wasm32 and add a wasm OS that uses it
This adds support for multilib paths for wasm32 targets, following
[Debian's Multiarch conventions], and also adds an experimental OS name in
order to test it. 

[Debian's Multiarch conventions]: https://wiki.debian.org/Multiarch/

Differential Revision: https://reviews.llvm.org/D56553

llvm-svn: 351164
2019-01-15 06:58:16 +00:00
Craig Topper 69aed7c364 [X86] Make _xgetbv/_xsetbv on non-windows platforms
Summary:
This patch attempts to redo what was tried in r278783, but was reverted.

These intrinsics should be available on non-windows platforms with "xsave" feature check. But on Windows platforms they shouldn't have feature check since that's how MSVC behaves.

To accomplish this I've added a MS builtin with no feature check. And a normal gcc builtin with a feature check. When _MSC_VER is not defined _xgetbv/_xsetbv will be macros pointing to the gcc builtin name.

I've moved the forward declarations from intrin.h to immintrin.h to match the MSDN documentation and used that as the header file for the MS builtin.

I'm not super happy with this implementation, and I'm open to suggestions for better ways to do it.

Reviewers: rnk, RKSimon, spatel

Reviewed By: rnk

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56686

llvm-svn: 351160
2019-01-15 05:03:18 +00:00
Vlad Tsyrklevich 86e68fda3b Revert alignment assumptions changes
Revert r351104-6, r351109, r351110, r351119, r351134, and r351153. These
changes fail on the sanitizer bots.

llvm-svn: 351159
2019-01-15 03:38:02 +00:00
Mandeep Singh Grang 1b9337f16b [COFF, ARM64] Add __byteswap intrinsics
Reviewers: rnk, efriedma, ssijaric, TomTan, haripul

Reviewed By: efriedma

Subscribers: javed.absar, cfe-commits, kristof.beyls

Differential Revision: https://reviews.llvm.org/D56685

llvm-svn: 351147
2019-01-15 01:26:26 +00:00
Mandeep Singh Grang 50dadaa4e2 [Sema] Change std::sort to llvm::sort
llvm-svn: 351137
2019-01-14 23:45:58 +00:00
Mandeep Singh Grang 0055f80b3f [COFF, ARM64] Add __nop intrinsic
Reviewers: rnk, efriedma, TomTan, haripul, ssijaric

Reviewed By: rnk, efriedma

Subscribers: javed.absar, kristof.beyls, cfe-commits

Differential Revision: https://reviews.llvm.org/D56671

llvm-svn: 351135
2019-01-14 23:26:01 +00:00
Stephen Kelly 58c6504543 [ASTDump] NFC: Move dumping of QualType node to TextNodeDumper
Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56641

llvm-svn: 351116
2019-01-14 20:15:29 +00:00
Stephen Kelly bc2438d014 [ASTDump] NFC: Canonicalize handling of TypeLocInfo
Summary: No need to avoid the Visit method.

Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56640

llvm-svn: 351115
2019-01-14 20:13:09 +00:00
Stephen Kelly 449fa76d05 [ASTDump] NFC: Move Type Visit implementation to TextNodeDumper
Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56639

llvm-svn: 351114
2019-01-14 20:11:02 +00:00
Stephen Kelly 4b5e7cd416 NFC: Fix nits I missed before
llvm-svn: 351112
2019-01-14 19:50:34 +00:00
Erik Pilkington 0535b0f387 Improve a -Wunguarded-availability note
Mention the deployment target, and don't say "partial" which doesn't
really mean anything to users.

rdar://problem/33601513

Differential revision: https://reviews.llvm.org/D56523

llvm-svn: 351108
2019-01-14 19:17:31 +00:00
Roman Lebedev 7892c37455 [clang][UBSan] Sanitization for alignment assumptions.
Summary:
UB isn't nice. It's cool and powerful, but not nice.
Having a way to detect it is nice though.
[[ https://wg21.link/p1007r3 | P1007R3: std::assume_aligned ]] / http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1007r2.pdf says:
```
We propose to add this functionality via a library function instead of a core language attribute.
...
If the pointer passed in is not aligned to at least N bytes, calling assume_aligned results in undefined behaviour.
```

This differential teaches clang to sanitize all the various variants of this assume-aligned attribute.

Requires D54588 for LLVM IRBuilder changes.
The compiler-rt part is D54590.

Reviewers: ABataev, craig.topper, vsk, rsmith, rnk, #sanitizers, erichkeane, filcab, rjmccall

Reviewed By: rjmccall

Subscribers: chandlerc, ldionne, EricWF, mclow.lists, cfe-commits, bkramer

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D54589

llvm-svn: 351105
2019-01-14 19:09:27 +00:00
George Karpenkov e2a8eec457 [analyzer] [PR39792] false positive on strcpy targeting struct members
Patch by Pierre van Houtryve.

Differential Revision: https://reviews.llvm.org/D55226

llvm-svn: 351097
2019-01-14 18:54:48 +00:00
George Karpenkov 704913f562 [analyzer] [NFC] Remove unused undefined method.
Wow, at no point the linker or compiler complaints about that!

llvm-svn: 351096
2019-01-14 18:54:35 +00:00
Dan Gohman 51532a524e [WebAssembly] Remove old builtins
This removes the old grow_memory and mem.grow-style builtins, leaving just
the memory.grow-style builtins.

Differential Revision: https://reviews.llvm.org/D56645

llvm-svn: 351089
2019-01-14 18:28:10 +00:00
Anastasia Stulova d1986d1b5a [OpenCL] Set generic addr space of 'this' in special class members.
Set address spaces of 'this' param correctly for implicit special
class members.

This also changes initialization conversion sequence to separate
address space conversion from other qualifiers in case of binding
reference to a temporary. In this case address space conversion  
should happen after the binding (unlike for other quals). This is
needed to materialize it correctly in the alloca address space.

Initial patch by Mikael Nilssoni!

Differential Revision: https://reviews.llvm.org/D56066

llvm-svn: 351053
2019-01-14 11:44:22 +00:00
Sam McCall e60151c915 [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.
Summary:
This fixes ASTContext's parent map for nodes in such classes (e.g. operator()).
https://bugs.llvm.org/show_bug.cgi?id=39949

This also changes the observed shape of the AST for implicit RAVs.
- this includes AST MatchFinder: cxxRecordDecl() now matches lambda classes,
functionDecl() matches the call operator, and the parent chain is body -> call
operator -> lambda class -> lambdaexpr rather than body -> lambdaexpr.
- this appears not to matter for the ASTImporterLookupTable builder
- this doesn't matter for the other RAVs in-tree.

In order to do this, we remove the TraverseLambdaBody hook. The problem is it's
hard/weird to ensure this hook is called when traversing via the implicit class.
There were just two users of this hook in-tree, who use it to skip bodies.
I replaced these with explicitly traversing the captures only. Another approach
would be recording the bodies when the lambda is visited, and then recognizing
them later.
I'd be open to suggestion on how to preserve this hook, instead.

Reviewers: aaron.ballman, JonasToth

Subscribers: cfe-commits, rsmith, jdennett

Differential Revision: https://reviews.llvm.org/D56444

llvm-svn: 351047
2019-01-14 10:31:42 +00:00
Craig Topper 49488407aa [X86] Remove mask parameter from avx512 pmultishiftqb intrinsics. Use select in IR instead.
Fixes PR40259

llvm-svn: 351036
2019-01-14 08:46:51 +00:00
Craig Topper 689b3b71af [X86] Remove mask parameter from vpshufbitqmb intrinsics. Change result to a vXi1 vector.
We'll do the scalar<->vXi1 conversions with bitcasts in IR.

Fixes PR40258

llvm-svn: 351029
2019-01-14 00:03:55 +00:00
Stephen Kelly 07b76d23b4 [ASTDump] NFC: Move dump of individual Stmts to TextNodeDumper
Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D55340

llvm-svn: 351014
2019-01-12 16:53:27 +00:00
Stephen Kelly 63a6f3acbd Implement TemplateArgument dumping in terms of Visitor
Summary: Split the output streaming from the traversal to other AST nodes.

Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D55491

llvm-svn: 351012
2019-01-12 16:35:37 +00:00
Stephen Kelly 9bc90a2829 [ASTDump] Change parameter to StringRef
llvm-svn: 351011
2019-01-12 15:45:05 +00:00
Benjamin Kramer 2fb9646762 [analyzer] Fix unused variable warnings in Release builds
This was just an inlined version of isa<CXXConstructExpr>. NFC.

llvm-svn: 351007
2019-01-12 12:43:53 +00:00
Michal Gorny 1f9fe82040 [NetBSD] Enable additional sanitizer types
Differential Revision: https://reviews.llvm.org/D56607

llvm-svn: 351002
2019-01-12 11:18:35 +00:00
Stephen Kelly de82b5bef1 NFC: Port loop to cxx_range_for
llvm-svn: 350984
2019-01-12 00:42:59 +00:00
George Karpenkov 5be959c88e [analyzer] Support for OSObjects out parameters in RetainCountChecker
rdar://46357478
rdar://47121327

Differential Revision: https://reviews.llvm.org/D56240

llvm-svn: 350982
2019-01-11 23:35:17 +00:00
George Karpenkov 9f3a279f2c [analyzer] Introduce a convenience method for getting a CallEvent from an arbitrary Stmt
Differential Revision: https://reviews.llvm.org/D56300

llvm-svn: 350981
2019-01-11 23:35:04 +00:00
Steven Wu c3399db63d [Darwin][Driver] Don't pass a file as object_path_lto during ThinLTO
Summary:
After r327851, Driver::GetTemporaryPath will create the file rather than
just create a potientially unqine filename. If clang driver pass the
file as parameter as -object_path_lto, ld64 will pass it back to libLTO
as GeneratedObjectsDirectory, which is going to cause a LLVM ERROR if it
is not a directory.
Now during thinLTO, pass a temp directory path to linker instread.

rdar://problem/47194182

Reviewers: arphaman, dexonsmith

Reviewed By: arphaman

Subscribers: mehdi_amini, inglorion, jkorous, cfe-commits

Differential Revision: https://reviews.llvm.org/D56608

llvm-svn: 350970
2019-01-11 21:16:04 +00:00
Stephen Kelly db8fac140e Implement Attr dumping in terms of visitors
Remove now-vestigial dumpType and dumpBareDeclRef methods. The old
tablegen generated code used to expect them to be present, but the new
generated code has no such requirement.

Reviewers: aaron.ballman

Subscribers: mgorny, cfe-commits

Differential Revision: https://reviews.llvm.org/D55492

llvm-svn: 350958
2019-01-11 19:16:01 +00:00
Stephen Kelly 0df805db73 [ASTDump] Add utility for dumping a label with child nodes
Summary:
Use it to add optional label nodes to Stmt dumps.  This preserves
behavior of InitExprList dump:

// CHECK-NEXT: `-InitListExpr {{.+}} <col:13, col:15> 'U [3]'
// CHECK-NEXT:   |-array_filler: InitListExpr {{.+}} <col:15> 'U' field Field {{.+}} 'i' 'int'
// CHECK-NEXT:   `-InitListExpr {{.+}} <col:14> 'U' field Field {{.+}} 'i' 'int'
// CHECK-NEXT:     `-IntegerLiteral {{.+}} <col:14> 'int' 1

Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D55488

llvm-svn: 350957
2019-01-11 19:11:17 +00:00
Teresa Johnson 84cecfcb3d [LTO] Add option to enable LTOUnit splitting, and disable unless needed
Summary:
Adds a new -f[no]split-lto-unit flag that is disabled by default to
control module splitting during ThinLTO. It is automatically enabled
for -fsanitize=cfi and -fwhole-program-vtables.

The new EnableSplitLTOUnit codegen flag is passed down to llvm
via a new module flag of the same name.

Depends on D53890.

Reviewers: pcc

Subscribers: ormris, mehdi_amini, inglorion, eraman, steven_wu, dexonsmith, cfe-commits, llvm-commits

Differential Revision: https://reviews.llvm.org/D53891

llvm-svn: 350949
2019-01-11 18:32:07 +00:00
George Karpenkov 3a50a9fe74 [attributes] Extend os_returns_(not_?)_retained attributes to parameters
When applied to out-parameters, the attributes specify the expected lifetime of the written-into object.

Additionally, introduce OSReturnsRetainedOn(Non)Zero attributes, which
specify that an ownership transfer happens depending on a return code.

Differential Revision: https://reviews.llvm.org/D56292

llvm-svn: 350942
2019-01-11 18:02:08 +00:00
Erich Keane 473cfda1f4 Fix a pair of Wfallthrough warnings in ScanfFormatString.
Change-Id: Ia73a34fdd93fc974224583505f9e6432493cb0da
llvm-svn: 350941
2019-01-11 18:01:40 +00:00
Chris Kennelly 8dfa4ad981 Implementation Feature Test Macros for P0722R3
Summary:
P1353R0, adopted in San Diego, specified an implementation feature test macro for destroying delete (P0722R3).

The implementation of the feature (https://reviews.llvm.org/rL315662) is not guarded behind a flag, so the macro is not conditional on language version.

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D55741

llvm-svn: 350934
2019-01-11 17:09:22 +00:00
Akira Hatanaka 6c50e1fe0f [Sema] Make canPassInRegisters return true if the CXXRecordDecl passed
to it is a trivial_abi class.

A class that has all of its copy and move constructors deleted can still
be passed or returned in registers if the class is annotated with
trivial_abi.

This fixes PR39683.

llvm-svn: 350920
2019-01-11 07:06:38 +00:00
Akira Hatanaka d458ceda24 [Sema] If CheckPlaceholderExpr rewrites the initializer of an auto
variable during auto type deduction, use the rewritten initializer when
performing initialization of the variable.

This silences spurious -Warc-repeated-use-of-weak warnings that are
issued when the initializer uses a weak ObjC pointer.

Differential Revision: https://reviews.llvm.org/D55662

llvm-svn: 350917
2019-01-11 04:57:34 +00:00
Richard Smith 64095fc07c Remember to instantiate explicit template argument lists in a friend
function declaration.

We'd previously often just drop these on the floor, and friend
redeclaration matching would usually (but not always) figure out the
right redeclaration anyway.

Also, don't try to match a dependent friend function template
specialization to a template until instantiation, and don't forget to
reject qualified friend declarations in dependent contexts that don't
name an already-declared entity.

llvm-svn: 350915
2019-01-11 01:59:33 +00:00
Brian Gesiak 5488ab4ddd [AST] Remove ASTContext from getThisType (NFC)
Summary:
https://reviews.llvm.org/D54862 removed the usages of `ASTContext&` from
within the `CXXMethodDecl::getThisType` method. Remove the parameter
altogether, as well as all usages of it. This does not result in any
functional change because the parameter was unused since
https://reviews.llvm.org/D54862.

Test Plan: check-clang

Reviewers: akyrtzi, mikael

Reviewed By: mikael

Subscribers: mehdi_amini, dexonsmith, cfe-commits

Differential Revision: https://reviews.llvm.org/D56509

llvm-svn: 350914
2019-01-11 01:54:53 +00:00
Richard Trieu f8b8b39c60 Fix header issues.
Several headers would fail to compile if other headers were not previously
included.  The usual issue is that a class is forward declared, but the
full definition is needed.  The requirement for the definition is use of
isa/dyn_cast or calling functions of pointer-packed data types such as
DenseMap or PointerIntPair.  Add missing includes to these headers.

SVals.h required an out-of-line method definition in the .cpp file to avoid
circular inclusion of headers with BasicValueFactory.h

llvm-svn: 350913
2019-01-11 01:32:35 +00:00
Aaron Ballman 8047362129 Add an explicit initializer to silence a -Wmissing-field-initializers diagnostic; NFC.
llvm-svn: 350912
2019-01-11 00:13:57 +00:00
Thomas Lively b7b9fdc114 [WebAssembly] Add unimplemented-simd128 feature, gate builtins
Summary: Depends on D56501. Also adds a macro define
`__wasm_unimplemented_simd128__` for feature detection of
unimplemented SIMD builtins.

Reviewers: aheejin, dschuff

Subscribers: sbc100, jgravelle-google, sunfish, kristina, cfe-commits, rrwinterton
llvm-svn: 350909
2019-01-10 23:49:00 +00:00
Artem Dergachev fc72007f43 [analyzer] pr38838, pr39976: Fix crash on diagnosing before implicit destructor.
We need to be able to emit the diagnostic at PreImplicitCall,
and the patch implements this functionality.

However, for now the need for emitting such diagnostics is not all that great:
it is only necessary to not crash when emitting a false positive due to an
unrelated issue of having dead symbol collection not working properly.

Coming up with a non-false-positive test seems impossible with the current
set of checkers, though it is likely to be needed for good things as well
in the future.

Differential Revision: https://reviews.llvm.org/D56042

rdar://problem/46911462

llvm-svn: 350907
2019-01-10 23:44:44 +00:00
Sterling Augustine b6d0f85daf Properly support -shared-libgcc.
This revision was revied in D55016.

llvm-svn: 350900
2019-01-10 22:25:58 +00:00
Aaron Ballman 70bdcdf55d Correct the source range returned from preprocessor callbacks.
This adjusts the source range passed in to the preprocessor callbacks to only include the condition range itself, rather than all of the conditionally skipped tokens.

llvm-svn: 350891
2019-01-10 21:22:13 +00:00
Stephen Kelly 1224321623 NFC: Change case of identifiers
llvm-svn: 350890
2019-01-10 20:58:21 +00:00
Akira Hatanaka 0a84856431 [Sema] Call CheckPlaceholderExpr to resolve typeof or decltype
placeholder expressions while an unevaluated context is still on the
expression evaluation context stack.

This prevents recordUseOfWeek from being called when a weak variable is
used as an operand of a decltype or a typeof expression and fixes
spurious -Warc-repeated-use-of-weak warnings.

rdar://problem/45742525

Differential Revision: https://reviews.llvm.org/D55662

llvm-svn: 350887
2019-01-10 20:12:16 +00:00
Yaxun Liu 4fa83fca7e [HIP] Use nul instead of /dev/null when running on windows
When clang is running on windows, /dev/null is not available. Use nul as empty input file instead.

Differential Revision: https://reviews.llvm.org/D56225

llvm-svn: 350885
2019-01-10 20:09:52 +00:00
Nicolas Lesser 5610cd8b46 Fix false positive unsequenced access and modification warning in array subscript expression.
Summary: In the [expr.sub] p1, we can read that for a given E1[E2], E1 is sequenced before E2. 

Patch by Mateusz Janek.

Reviewers: rsmith, Rakete1111

Reviewed By: rsmith, Rakete1111

Subscribers: riccibruno, lebedev.ri, Rakete1111, hiraditya, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D50766

llvm-svn: 350874
2019-01-10 19:03:33 +00:00
George Karpenkov 3c1e066dca [analyzer] [hotfix] Fix the tests
The error must have crept during the cherry-pick.

llvm-svn: 350870
2019-01-10 18:28:10 +00:00
George Karpenkov 0bb17c4634 [analyzer] Update the category name for RetainCountChecker reports
..now that it includes OSObjects

rdar://46509986

Differential Revision: https://reviews.llvm.org/D56404

llvm-svn: 350869
2019-01-10 18:16:25 +00:00
George Karpenkov 42c6ac748e [analyzer] [NFC] [RetainCountChecker] Remove dead unused map
Differential Revision: https://reviews.llvm.org/D56402

llvm-svn: 350868
2019-01-10 18:16:10 +00:00
George Karpenkov 4f64b38f56 [analyzer] Quote the type of the leaked/problematic object in diagnostics for readability
Differential Revision: https://reviews.llvm.org/D56344

llvm-svn: 350867
2019-01-10 18:15:57 +00:00
George Karpenkov 7bac331b7e [analyzer] [NFC] Reduce redundancy in RetainSummaryManager by using a function
Differential Revision: https://reviews.llvm.org/D56282

llvm-svn: 350865
2019-01-10 18:15:30 +00:00
George Karpenkov 717c4c0e2b [analyzer] [RetainCountChecker] [NFC] Remove SummaryLog
The complicated machinery for passing the summary log around is actually
only used for one thing! To figure out whether the "dealloc" message was
sent.

Since I have tried to extend it for other uses and failed (it's actually
very hard to use), I think it's much better to simply use a tag and
remove the summary log altogether.

Differential Revision: https://reviews.llvm.org/D56228

llvm-svn: 350864
2019-01-10 18:15:17 +00:00
George Karpenkov c2d8f1235b [analyzer] [RetainCountChecker] [NFC] Another minor cleanup
Differential Revision: https://reviews.llvm.org/D56224

llvm-svn: 350863
2019-01-10 18:15:04 +00:00
George Karpenkov 371bfd7295 [analyzer] [RetainCountChecker] [NFC] Refactor the way attributes are handled
Make sure all checks for attributes go through a centralized function,
which checks whether attribute handling is enabled, and performs
validation.  The type of the attribute is returned.

Sadly, metaprogramming is required as attributes have no sensible static
getters.

Differential Revision: https://reviews.llvm.org/D56222

llvm-svn: 350862
2019-01-10 18:14:51 +00:00
George Karpenkov 4cb992e254 [analyzer] [RetainCountChecker] Remove redundant enum UnarySummaryKind
Differential Revision: https://reviews.llvm.org/D56072

llvm-svn: 350861
2019-01-10 18:14:38 +00:00
George Karpenkov 29e1ca83dd [analyzer] [RetainCountChecker] Remove obsolete "MakeCollectable" enum value
Differential Revision: https://reviews.llvm.org/D56071

llvm-svn: 350860
2019-01-10 18:14:25 +00:00
George Karpenkov 9cbcc21aed [analyzer] [RetainCountChecker] [NFC] Remove redundant enum items *Msg, as the object type is already communicated by a separate field
Differential Revision: https://reviews.llvm.org/D56070

llvm-svn: 350859
2019-01-10 18:14:12 +00:00
George Karpenkov 585a210e5f [analyzer] [NFC] Track object type with ArgEffect in RetainCountChecker.
This would be needed in the future.

https://reviews.llvm.org/D56040

llvm-svn: 350858
2019-01-10 18:13:59 +00:00
George Karpenkov 7e3016dec4 [analyzer] [NFC] Move ObjKind into a separate top-level enum in RetainSummaryManager.
Allows using it in future outside of RetEffect.

Differential Revision: https://reviews.llvm.org/D56039

llvm-svn: 350857
2019-01-10 18:13:46 +00:00
Rafael Stahl 8c48705a19 [analyzer][CrossTU][NFC] Generalize to external definitions instead of external functions
Summary: This is just changing naming and documentation to be general about external definitions that can be imported for cross translation unit analysis. There is at least a plan to add VarDecls: D46421

Reviewers: NoQ, xazax.hun, martong, a.sidorin, george.karpenkov, serge-sans-paille

Reviewed By: xazax.hun, martong

Subscribers: mgorny, whisperity, baloghadamsoftware, szepet, rnkovacs, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, cfe-commits

Differential Revision: https://reviews.llvm.org/D56441

llvm-svn: 350852
2019-01-10 17:44:04 +00:00
Aaron Ballman 2c49462725 Correct the spelling of helpURI to helpUri.
JSON is case sensitive and the SARIF spec uses the corrected spelling.

llvm-svn: 350817
2019-01-10 13:19:48 +00:00
Stanislav Mekhanoshin 6332f4d0d4 [AMDGPU] Separate feature dot-insts
Differential Revision: https://reviews.llvm.org/D56525

llvm-svn: 350794
2019-01-10 03:25:47 +00:00
Richard Smith 2f72a7521a In nothrow new-expressions, null-check the result if we're going to
apply sanitizers to it.

This avoids a sanitizer false positive that we are initializing a null
pointer.

llvm-svn: 350779
2019-01-10 00:03:29 +00:00
Nick Desaulniers 9b9fe4166f [Sema] Mark target of __attribute__((alias("target"))) used for C
Summary:
Prevents -Wunneeded-internal-delcaration warnings when the target has no
other references. This occurs frequently in device drivers in the Linux
kernel.

Sema would need to invoke the demangler on the target, since in C++ the
target name is mangled:

int f() { return 42; }
int g() __attribute__((alias("_Z1fv")));

Sema does not have the ability to demangle names at this time.

https://bugs.llvm.org/show_bug.cgi?id=39088
https://github.com/ClangBuiltLinux/linux/issues/232

Reviewers: rsmith, rjmccall

Reviewed By: rsmith

Subscribers: erik.pilkington, cfe-commits, pirama, srhines

Differential Revision: https://reviews.llvm.org/D54188

llvm-svn: 350776
2019-01-09 23:54:55 +00:00
Alex Lorenz 4e3c0bdf6f [ObjC] Allow the use of implemented unavailable methods from within
the @implementation context

In Objective-C, it's common for some frameworks to mark some methods like init
as unavailable in the @interface to prohibit their usage. However, these
frameworks then often implemented said method and refer to it in another method
that acts as a factory for that object. The recent change to how messages to
self are type checked in clang (r349841) introduced a regression which started
to prohibit this pattern with an X is unavailable error. This commit addresses
the aforementioned regression.

rdar://47134898

Differential Revision: https://reviews.llvm.org/D56469

llvm-svn: 350768
2019-01-09 22:31:37 +00:00
Gheorghe-Teodor Bercea 67796064c7 [OpenMP] Avoid remainder operations for loop index values on a collapsed loop nest.
Summary: Change the strategy for computing loop index variables after collapsing a loop nest via the collapse clause by replacing the expensive remainder operation with multiplications and additions.

Reviewers: ABataev, caomhin

Reviewed By: ABataev

Subscribers: guansong, arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D56413

llvm-svn: 350759
2019-01-09 20:45:26 +00:00
Gheorghe-Teodor Bercea a3afcf2445 [OpenMP] Add flag for preventing the extension to 64 bits for the collapse loop counter
Summary: Introduce a compiler flag for cases when the user knows that the collapsed loop counter can be safely represented using at most 32 bits. This will prevent the emission of expensive mathematical operations (such as the div operation) on the iteration variable using 64 bits where 32 bit operations are sufficient.

Reviewers: ABataev, caomhin

Reviewed By: ABataev

Subscribers: hfinkel, kkwli0, guansong, cfe-commits

Differential Revision: https://reviews.llvm.org/D55928

llvm-svn: 350758
2019-01-09 20:38:35 +00:00
Shoaib Meenai 39287e759f [CodeGen] Clarify comment about COFF common symbol alignment
After a discussion on the commit thread, it seems the 32 byte alignment
limitation is an MSVC toolchain artifact, not an inherent COFF
restriction. Clarify the comment accordingly, since saying COFF in the
comment but using isKnownWindowsMSVCEnvironment in the conditional is
confusing. Also add a newline before the comment, which is consistent
with the local style.

Differential Revision: https://reviews.llvm.org/D56466

llvm-svn: 350754
2019-01-09 20:05:16 +00:00
Bruno Ricci 4939165d7c [AST] Move back BasePathSize to the bit-fields of CastExpr
The number of trailing CXXBaseSpecifiers in CastExpr was moved from
CastExprBitfields to a trailing object in r338489 (D50050). At this time these
bit-fields classes were only 32 bits wide. However later r345459 widened these
bit-field classes to 64 bits.

The reason for this change was that on 64 bit archs alignment requirements
caused 4 bytes of padding after the Stmt sub-object in nearly all expression
classes. Reusing this padding yielded an >10% reduction in the size used by all
statement/expressions when parsing all of Boost (on a 64 bit arch). This
increased the size of statement/expressions for 32 bits archs, but this can be
mitigated by moving more data to the bit-fields of Stmt (and moreover most
people now care about 64 bits archs as a host).

Therefore move back the number of CXXBaseSpecifiers in CastExpr to the
bit-fields of Stmt. This in effect mostly revert r338489 while keeping the
added test.

Differential Revision: https://reviews.llvm.org/D56358

Reviewed By: lebedev.ri

Reviewers: lebedev.ri, rjmccall
llvm-svn: 350741
2019-01-09 16:41:33 +00:00
Alexey Bataev 7e6803e07b Incorrect implicit data-sharing for nested tasks
Summary:
There is a minor issue in how the implicit data-sharings for nested tasks are computed.

For the following example:
```
int x;
#pragma omp task shared(x)
#pragma omp task
x++;
```
We compute an implicit data-sharing of shared for `x` in the second task although I think that it should be firstprivate. Below you can find the part of the OpenMP spec that covers this example:
- // In a task generating construct, if no default clause is present, a variable for which the data-sharing attribute is not determined by the rules above and that in the enclosing context is determined to be shared by all implicit tasks bound to the current team is shared.//
- //In a task generating construct, if no default clause is present, a variable for which the data-sharing attribute is not determined by the rules above is firstprivate.//

Since each implicit-task has its own copy of `x`, we shouldn't apply the first rule.

Reviewers: ABataev

Reviewed By: ABataev

Subscribers: cfe-commits, rogfer01

Tags: #openmp

Differential Revision: https://reviews.llvm.org/D56430

llvm-svn: 350734
2019-01-09 15:58:05 +00:00
Bruno Ricci d7628d9993 [AST] Store the results in OverloadExpr in a trailing array
Use the newly available space in the bit-fields of Stmt to pack
OverloadExpr, UnresolvedLookupExpr and UnresolvedMemberExpr.

Additionally store the results in the overload set in a trailing array.
This saves 1 pointer + 8 bytes per UnresolvedLookupExpr and
UnresolvedMemberExpr.

Differential Revision: https://reviews.llvm.org/D56368

Reviewed By: rjmccall

llvm-svn: 350732
2019-01-09 15:43:19 +00:00
Florian Hahn 603467a9a4 Revert r350648: "Fix clang for r350647: Missed a function rename"
The related commit r350647 breaks thread sanitizer on some macOS builders, e.g.
http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/52725/

llvm-svn: 350718
2019-01-09 13:30:47 +00:00
Ilya Biryukov 87aaa56b42 [Driver] Fix libcxx detection on Darwin with clang run as ./clang
Summary:
By using '..' instead of fs::parent_path.

The intention of the code was to go from 'path/to/clang/bin' to
'path/to/clang/include'. In most cases parent_path works, however it
would fail when clang is run as './clang'.

This was noticed in Chromium's bug tracker, see
https://bugs.chromium.org/p/chromium/issues/detail?id=919761

Reviewers: arphaman, thakis, EricWF

Reviewed By: arphaman, thakis

Subscribers: christof, cfe-commits

Differential Revision: https://reviews.llvm.org/D56446

llvm-svn: 350714
2019-01-09 13:08:11 +00:00
Anastasia Stulova a9bc4bd814 Use DeclSpec for quals in DeclaratorChunk::FunctionTypeInfo.
Rather than duplicating data fields, use DeclSpec directly to store
the qualifiers for the functions/methods. This change doesn't handle
attributes yet and has to be extended further.

Differential revision: https://reviews.llvm.org/D55948

llvm-svn: 350703
2019-01-09 11:25:09 +00:00
Craig Topper bdbe5c7dc7 [X86] Make the pointer arguments to avx512 gather/scatter intrinsics 'void*' to match gcc and Intel's documentation.
The avx2 gather intrinsics are documented to use 'int', 'long long', 'float', or 'double' *. So I'm leaving those. This matches gcc.

llvm-svn: 350696
2019-01-09 07:36:01 +00:00
Stephen Kelly d186dbc041 [ASTDump] NFC: Move dumpDeclRef to NodeDumper
Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D55337

llvm-svn: 350677
2019-01-08 23:11:24 +00:00
Dan Albert dd14234b60 [Driver] Default to -fno-addrsig on Android.
Summary: The Android NDK still uses GNU binutils by default.

Reviewers: srhines, pirama

Reviewed By: srhines

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56456

llvm-svn: 350668
2019-01-08 22:33:59 +00:00
Stephen Kelly b6d674f6fe Implement the TreeStructure interface through the TextNodeDumper
Summary:
This way, when the generic ASTTraverser is extracted from ASTDumper,
there can't be any problem related to ordering of class members, a
concern that was raised in https://reviews.llvm.org/D55337.

This will also preserve the property that the generic traverser does not
enforce any coupling between the NodeDumper and the TreeStructure.

 https://godbolt.org/z/PEtT1_

Reviewers: aaron.ballman, erichkeane

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56407

llvm-svn: 350665
2019-01-08 22:32:48 +00:00
Dan Albert 706b1f3aeb Android is not GNU, so don't claim that it is.
Reviewers: pirama, srhines

Reviewed By: srhines

Subscribers: kristina, cfe-commits

Differential Revision: https://reviews.llvm.org/D55953

llvm-svn: 350664
2019-01-08 22:31:19 +00:00
Philip Pfaffe f341abba39 Fix clang for r350647: Missed a function rename
llvm-svn: 350648
2019-01-08 20:00:55 +00:00
Erich Keane 85c6224971 Limit COFF 'common' emission to <=32 alignment types.
As reported in PR33035, LLVM crashes if given a common object with an
alignment of greater than 32 bits. This is because the COFF file format
does not support these alignments, so emitting them is broken anyway.

This patch changes any global definitions greater than 32 bit alignment
to no longer be in 'common'.

https://bugs.llvm.org/show_bug.cgi?id=33035

Differential Revision: https://reviews.llvm.org/D56391

Change-Id: I48609289753b7f3b58c5e2bc1712756750fbd45a
llvm-svn: 350643
2019-01-08 18:44:22 +00:00
Alexander Kornienko 973fcc25fb Fix use-after-free bug in Tooling.
Summary:
`buildASTFromCodeWithArgs()` was creating a memory buffer referencing a
stack-allocated string.  This diff changes the implementation to copy the code
string into the memory buffer so that said buffer owns the memory.

Patch by Yitzhak Mandelbaum.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: cfe-commits, EricWF

Differential Revision: https://reviews.llvm.org/D55765

llvm-svn: 350638
2019-01-08 16:55:13 +00:00
Paul Robinson b1ce7c8c01 Don't emit DW_AT_enum_class unless it's actually an 'enum class'.
Finishes off the functional part of PR36168.

Differential Revision: https://reviews.llvm.org/D56393

llvm-svn: 350636
2019-01-08 16:28:11 +00:00
Bruno Ricci 030dab4115 [AST][NFC] Pack CXXScalarValueInitExpr
Use the newly available space in the bit-fields of Stmt.
This saves one pointer per CXXScalarValueInitExpr. NFC.

llvm-svn: 350635
2019-01-08 16:08:54 +00:00
Alexey Bataev 185e88d997 [OPENMP]Fix PR40191: Do not allow orphaned cancellation constructs.
Prohibited use of the orphaned cancellation directives.

llvm-svn: 350634
2019-01-08 15:53:42 +00:00
Bruno Ricci d56edfe13a [AST][NFC] Pack CXXNoexceptExpr and SubstNonTypeTemplateParmExpr
Use the newly available space in the bit-fields of Stmt.
This saves one pointer per CXXNoexceptExpr/SubstNonTypeTemplateParmExpr.

Use this opportunity to run clang-format on these two classes and
fix some style issues. NFC overall.

llvm-svn: 350627
2019-01-08 14:44:34 +00:00
Bruno Ricci 2e6dc538be [AST] Pack CXXDependentScopeMemberExpr
Use the newly available space in the bit-fields of Stmt. Additionally store
FirstQualifierFoundInScope as a trailing object since it is most of the time
null (non-null for 2 of the 35446 CXXDependentScopeMemberExpr when parsing
all of Boost).

It would be possible to move the data for the nested-name-specifier to a
trailing object too to save another 2 pointers, however doing so did actually
regress the time taken to parse all of Boost slightly.

This saves 8 bytes + 1 pointer per CXXDependentScopeMemberExpr in the vast
majority of cases.

Differential Revision: https://reviews.llvm.org/D56367

Reviewed By: rjmccall

llvm-svn: 350625
2019-01-08 14:17:00 +00:00
Bruno Ricci f605e82521 [Sema] Diagnose array access preceding the array bounds even when the base type is incomplete.
When the type of the base expression after IgnoreParenCasts is incomplete,
it is still possible to diagnose an array access which precedes the array
bounds.

This is a follow-up on D55862 which added an early return when the type of
the base expression after IgnoreParenCasts was incomplete.

Differential Revision: https://reviews.llvm.org/D56050

Reviewed By: efriedma

llvm-svn: 350622
2019-01-08 13:52:54 +00:00
Sam McCall e72804066c [ASTMatchers] Improve assert message for broken parent map.
Summary:
This assert catches places where the AST (as seen by RecursiveASTVisitor)
becomes disconnected due to incomplete traversal.
Making it print the actual parent-less node is a lot more helpful - it's
possible to work out which part of the tree wasn't traversed.

Reviewers: ilya-biryukov

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56395

llvm-svn: 350612
2019-01-08 07:29:46 +00:00
Stephen Kelly 54272e5b66 NFC: Replace asserts with if() in SourceLocation accessors
Summary:
Nowhere else in the AST classes assert on these kinds of accessors.

This way, we can call the accessors and check the validity of the result
instead of externally duplicating the conditions.  This generality will
make it possible to introspect instances for source locations:

 http://ec2-18-191-7-3.us-east-2.compute.amazonaws.com:10240/z/iiaWhw

Reviewers: aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56354

llvm-svn: 350573
2019-01-07 21:57:30 +00:00
Alexey Bataev 7bb3353f6a [OPENMP]Add call to __kmpc_push_target_tripcount() function.
Each we create the target regions with the teams distribute inner
region, we can better estimate number of the teams required to execute
the target region. Function __kmpc_push_target_tripcount() is used for
purpose, which accepts device_id and the number of the iterations,
performed by the associated loop.

llvm-svn: 350571
2019-01-07 21:30:43 +00:00
Craig Topper cd9e232a4d Recommit r350555 "[X86] Use funnel shift intrinsics for the VBMI2 vshld/vshrd builtins."
The MSVC limit hit in AutoUpgrade.cpp has been worked around for now.

llvm-svn: 350568
2019-01-07 21:00:41 +00:00
Craig Topper 33c9088783 Revert r350555 "[X86] Use funnel shift intrinsics for the VBMI2 vshld/vshrd builtins."
Had to revert the LLVM patch this depends on to fix a MSVC compiler limit in AutoUpgrade.cpp

llvm-svn: 350563
2019-01-07 19:39:25 +00:00
Craig Topper e34f2bb807 [X86] Use funnel shift intrinsics for the VBMI2 vshld/vshrd builtins.
Differential Revision: https://reviews.llvm.org/D56365

llvm-svn: 350555
2019-01-07 19:10:22 +00:00
Alexey Bataev 25d3de8a0a [OPENMP][NVPTX]Reduce number of barriers in reductions.
After the fix for the syncthreads we don't need to generate extra
barriers for the parallel reductions.

llvm-svn: 350530
2019-01-07 15:45:09 +00:00
Benjamin Kramer 27429d8786 [Sema] Fix unused variable warning in Release builds
llvm-svn: 350529
2019-01-07 15:22:08 +00:00
Rafael Stahl cc19f921b5 [analyzer] Pass the correct loc Expr from VisitIncDecOp to evalStore
Summary: The LocationE parameter of evalStore is documented as "The location expression that is stored to". When storing from an increment / decrement operator this was not satisfied. In user code this causes an inconsistency between the SVal and Stmt parameters of checkLocation.

Reviewers: NoQ, dcoughlin, george.karpenkov

Reviewed By: NoQ

Subscribers: xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, cfe-commits

Differential Revision: https://reviews.llvm.org/D55701

llvm-svn: 350528
2019-01-07 15:07:01 +00:00
Bruno Ricci 9b6dfac5ad [AST] Store some data of CXXNewExpr as trailing objects
Store the optional array size expression, optional initialization expression
and optional placement new arguments in a trailing array. Additionally store
the range for the parenthesized type-id in a trailing object if needed since
in the vast majority of cases the type is not parenthesized (not a single new
expression in the translation unit of SemaDecl.cpp has a parenthesized type-id).

This saves 2 pointers per CXXNewExpr in all cases, and 2 pointers + 8 bytes
per CXXNewExpr in the common case where the type is not parenthesized.

Differential Revision: https://reviews.llvm.org/D56134

Reviewed By: rjmccall

llvm-svn: 350527
2019-01-07 15:04:45 +00:00
Bruno Ricci 49ee964e19 [AST][NFC] Pack DependentScopeDeclRefExpr and CXXUnresolvedConstructExpr
Use the newly available space in the bit-fields of Stmt.
This saves 1 pointer per DependentScopeDeclRefExpr/CXXUnresolvedConstructExpr.

Additionally rename "TypeSourceInfo *Type;" to "TypeSourceInfo *TSI;"
as was done in D56022 (r350003) (but this is an internal detail anyway),
and clang-format both classes. NFC.

llvm-svn: 350525
2019-01-07 14:27:04 +00:00
Hyrum Wright 2cd40c0170 [clang] Add AST matcher for initializer list members
Summary:
Much like hasArg for various call expressions, this allows LibTooling users to
match against a member of an initializer list.

This is currently being used as part of the abseil-duration-scale clang-tidy
check.

Differential Revision: https://reviews.llvm.org/D56090

llvm-svn: 350523
2019-01-07 14:14:36 +00:00
Gabor Marton 3081690c84 [CTU] Make loadExternalAST return with non nullptr on success
Summary:
In loadExternalAST we return with either an error or with a valid
ASTUnit pointer which should not be a nullptr.
This prevents in the call site any superfluous check for being a nullptr.

Reviewers: xazax.hun, a_sidorin, Szelethus, balazske

Subscribers: rnkovacs, dkrupp, gamesh411, cfe-commits

Differential Revision: https://reviews.llvm.org/D55280

llvm-svn: 350521
2019-01-07 14:05:19 +00:00
Bruno Ricci 76ab9d4589 [AST][NFC] Pack OpaqueValueExpr
Use the newly available space in the bit-fields of Stmt.
This saves 1 pointer per OpaqueValueExpr. NFC.

llvm-svn: 350519
2019-01-07 13:39:26 +00:00
Martin Probst 55b6d4b9f9 clang-format: [JS] support goog.requireType.
Summary:
It's a new primitive for importing symbols, and should be treated like
the (previously handled) `goog.require` and `goog.forwardDeclare`.

Reviewers: krasimir

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56385

llvm-svn: 350516
2019-01-07 13:12:50 +00:00
Richard Smith 8ce732b46f DR674, PR38883, PR40238: Qualified friend lookup should look for a
template specialization if there is no matching non-template function.

This exposed a couple of related bugs:
 - we would sometimes substitute into a friend template instead of a
   suitable non-friend declaration; this would now crash because we'd
   decide the specialization of the friend is a redeclaration of itself
 - ADL failed to properly handle the case where an invisible local
   extern declaration redeclares an invisible friend

Both are fixed herein: in particular, we now never make invisible
friends or local extern declarations visible to name lookup unless
they are the only declaration of the entity. (We already mostly did
this for local extern declarations.)

llvm-svn: 350505
2019-01-07 06:00:46 +00:00
Brian Gesiak 7dda73a223 [SemaCXX] Fix ICE for unexpanded parameter pack
Summary:
The documentation for RecursiveASTVisitor::TraverseDecl states that the
Decl being traversed may be null. In fact, this is the case when a
CXXCatchStmt with no exception decl is traversed. Because the visitor
for diagnosing unexpanded parameter packs does not check for null, it
ends up crashing when it attempts to call the Decl::isParameterPack
method on a null Decl pointer.

Add a null check to prevent an ICE, and a test case that would crash
otherwise. Also, because the test requires C++ exceptions and C++14,
change the test parameters for the entire test file. (Alternatively, I
thought about adding a new test file, but went with this approach for my
own convenience.)

Co-authored-by: Andreas Molzer <andreas.molzer@gmx.de>
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D56271

llvm-svn: 350501
2019-01-07 03:25:59 +00:00
Saleem Abdulrasool 175890e1eb CodeGen: fix autolink emission on ELF
The autolinking extension for ELF uses a slightly different format for
encoding the autolink information compared to COFF and MachO.  Account
for this in the CGM to ensure that we do not assert when emitting
assembly or an object file.

llvm-svn: 350476
2019-01-05 19:27:12 +00:00
Saleem Abdulrasool da32d7f147 CodeGen: switch iteration to range based for loop (NFC)
Change a loop to range based instead while working on cleaning up some
modules autolinking issues on Linux.  NFC.

llvm-svn: 350472
2019-01-05 18:39:32 +00:00
Nico Weber b215d0731a Let new test from r350340 still pass even after r350451.
llvm-svn: 350453
2019-01-05 01:19:14 +00:00
Nico Weber 9f0c21c1e0 Move -add-plugin validation after -load was executed.
Moves the code added in r350340 around a bit, to hopefully make the existing
plugin tests pass when clang is built with examples enabled.

llvm-svn: 350451
2019-01-05 01:10:20 +00:00
Joel E. Denny bae586fb0a [OpenMP] Refactor const restriction for linear
As discussed in D56113, this patch refactors the implementation of the
const restriction for linear to reuse a function introduced by D56113.
A side effect is that, if a variable has mutable members, this
diagnostic is now skipped, and the diagnostic for the variable not
being an integer or pointer is reported instead.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D56299

llvm-svn: 350441
2019-01-04 22:12:13 +00:00
Joel E. Denny d2649292ef [OpenMP] Refactor const restriction for reductions
As discussed in D56113, this patch refactors the implementation of the
const restriction for reductions to reuse a function introduced by
D56113.  A side effect is that diagnostics sometimes now say
"variable" instead of "list item" when a list item is a variable.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D56298

llvm-svn: 350440
2019-01-04 22:11:56 +00:00
Joel E. Denny e6234d1429 [OpenMP] Replace predetermined shared for const variable
The following appears in OpenMP 3.1 sec. 2.9.1.1 as a predetermined
data-sharing attribute:

> Variables with const-qualified type having no mutable member are
> shared.

It does not appear in OpenmP 4.0, 4.5, or 5.0.  This patch removes the
implementation of that attribute when the requested OpenMP version is
greater than 3.1.

One effect of that removal is that `default(none)` affects const
variables without mutable members.

Also, without this patch, if a const variable without mutable members
was explicitly lastprivate or private, it was an error because it was
predetermined shared.  Now, clang instead complains that it's const
without mutable fields, which is a more intelligible diagnostic.  That
should be fine for all of the above versions because they all have
something like the following, which is quoted from OpenMP 5.0
sec. 2.19.3:

> A variable that is privatized must not have a const-qualified type
> unless it is of class type with a mutable member. This restriction does
> not apply to the firstprivate clause.

reduction and linear clauses already have separate checks for const
variables.  Future patches will merge the implementations.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D56113

llvm-svn: 350439
2019-01-04 22:11:31 +00:00
Peter Collingbourne 87f477b5e4 hwasan: Implement lazy thread initialization for the interceptor ABI.
The problem is similar to D55986 but for threads: a process with the
interceptor hwasan library loaded might have some threads started by
instrumented libraries and some by uninstrumented libraries, and we
need to be able to run instrumented code on the latter.

The solution is to perform per-thread initialization lazily. If a
function needs to access shadow memory or add itself to the per-thread
ring buffer its prologue checks to see whether the value in the
sanitizer TLS slot is null, and if so it calls __hwasan_thread_enter
and reloads from the TLS slot. The runtime does the same thing if it
needs to access this data structure.

This change means that the code generator needs to know whether we
are targeting the interceptor runtime, since we don't want to pay
the cost of lazy initialization when targeting a platform with native
hwasan support. A flag -fsanitize-hwaddress-abi={interceptor,platform}
has been introduced for selecting the runtime ABI to target. The
default ABI is set to interceptor since it's assumed that it will
be more common that users will be compiling application code than
platform code.

Because we can no longer assume that the TLS slot is initialized,
the pthread_create interceptor is no longer necessary, so it has
been removed.

Ideally, lazy initialization should only cost one instruction in the
hot path, but at present the call may cause us to spill arguments
to the stack, which means more instructions in the hot path (or
theoretically in the cold path if the spills are moved with shrink
wrapping). With an appropriately chosen calling convention for
the per-thread initialization function (TODO) the hot path should
always need just one instruction and the cold path should need two
instructions with no spilling required.

Differential Revision: https://reviews.llvm.org/D56038

llvm-svn: 350429
2019-01-04 19:27:04 +00:00
Aaron Enye Shi bea57bb5a4 [HIP][DRIVER][OFFLOAD] Do not unbundle unsupported file types
The offload bundler action should not unbundle the input file types that does not match the action type. This fixes an issue where .so files are unbundled when the action type is object files.

llvm-svn: 350425
2019-01-04 19:05:41 +00:00
Teresa Johnson 6ed7913c98 [ThinLTO] Clang changes to utilize new pass to handle chains of aliases
Summary:
As with NameAnonGlobals, invoke the new CanonicalizeAliases via clang
when using the new PM.

Depends on D54507.

Reviewers: pcc, davidxl

Subscribers: mehdi_amini, inglorion, steven_wu, dexonsmith, cfe-commits

Differential Revision: https://reviews.llvm.org/D55620

llvm-svn: 350424
2019-01-04 19:05:01 +00:00
Erik Pilkington 1e36882b52 [ObjCARC] Add an new attribute, objc_externally_retained
This attribute, called "objc_externally_retained", exposes clang's
notion of pseudo-__strong variables in ARC. Pseudo-strong variables
"borrow" their initializer, meaning that they don't retain/release
it, instead assuming that someone else is keeping their value alive.

If a function is annotated with this attribute, implicitly strong
parameters of that function aren't implicitly retained/released in
the function body, and are implicitly const. This is useful to expose
for performance reasons, most functions don't need the extra safety
of the retain/release, so programmers can opt out as needed.

This attribute can also apply to declarations of local variables,
with similar effect.

Differential revision: https://reviews.llvm.org/D55865

llvm-svn: 350422
2019-01-04 18:33:06 +00:00
Alexey Bataev 8e009036c9 [OPENMP][NVPTX]Use new functions from the runtime library.
Updated codegen to use the new functions from the runtime library.

llvm-svn: 350415
2019-01-04 17:25:09 +00:00
Aaron Ballman 9bdf515c74 Add two new pragmas for controlling software pipelining optimizations.
This patch adds #pragma clang loop pipeline and #pragma clang loop pipeline_initiation_interval for debugging or reducing compile time purposes. It is possible to disable SWP for concrete loops to save compilation time or to find bugs by not doing SWP to certain loops. It is possible to set value of initiation interval to concrete number to save compilation time by not doing extra pipeliner passes or to check created schedule for specific initiation interval.

Patch by Alexey Lapshin.

llvm-svn: 350414
2019-01-04 17:20:00 +00:00
Aaron Ballman fb6deeb984 Refactor the way we handle diagnosing unused expression results.
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-04 16:58:14 +00:00
Erich Keane 414ff52d09 Prevent unreachable when checking invalid multiversion decls.
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 15:24:06 +00:00
Anastasia Stulova 4cebc9db04 [Basic] Extend DiagnosticEngine to store and format Qualifiers.
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-04 11:50:36 +00:00
Daniel Dunbar a39bab36c6 Adopt SwiftABIInfo for WebAssembly.
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-03 23:24:50 +00:00
Nico Weber ca27a2b037 Validate -add-plugin arguments.
-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-03 18:26:06 +00:00
Arnaud Bienner 57fc9582f9 Make -Wstring-plus-int warns even if when the result is not out of bounds
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 17:45:28 +00:00
Alexey Bataev a3924b517e [OPENMP][NVPTX]Use __kmpc_barrier_simple_spmd(nullptr, 0) instead of
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-03 16:25:35 +00:00
Aaron Ballman d23e9bc5af Diagnose an unused result from a call through a function pointer whose 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 14:24:31 +00:00
Philip Pfaffe b39a97c8f6 [NewPM] Port Msan
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-03 13:42:44 +00:00
Patrick Lyster e13b1e3299 [OpenMP] Added support for explicit mapping of classes using 'this' pointer. Differential revision: https://reviews.llvm.org/D55982
llvm-svn: 350252
2019-01-02 19:28:48 +00:00
Pete Cooper de0a8d37a0 Only convert objc messages to alloc to objc_alloc if the receiver is a class.
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
2019-01-02 17:25:30 +00:00
Akira Hatanaka c7c7574ea3 [CodeGen] Replace '@' characters in block descriptors' symbol names with
'\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-29 17:28:30 +00:00
Richard Trieu b3e902f4c3 Add vtable anchor to classes.
llvm-svn: 350143
2018-12-29 02:02:30 +00:00
David Chisnall 386477a541 [objc-gnustep2] Fix a bug in category generation.
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 17:44:54 +00:00
Alexey Bataev db43f0696e [OPENMP]Fix processing of the clauses on target combined directives.
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-28 17:27:32 +00:00
David Chisnall ddd06821c4 [objc-gnustep] Fix a copy-and-paste error.
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-27 14:44:36 +00:00
Reid Kleckner a643e6449b [clang-cl] Treat inputs as C++ with /E, like MSVC
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 21:04:08 +00:00
Reid Kleckner 3ab5a9cd1c [MS] Mangle return adjusting thunks with the public access specifier
MSVC does this, so we should too.

Fixes PR40138

llvm-svn: 350071
2018-12-26 20:07:52 +00:00
Reid Kleckner 423b65333d Ignore ConstantExpr in IgnoreParens
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-26 17:44:40 +00:00
George Karpenkov b945db8afc [analyzer] [NFC] Clean up the mess of constructing argument effects in 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-24 18:45:18 +00:00
Michal Gorny dae01c352b [Driver] Disable -faddrsig on Gentoo by default
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 15:07:26 +00:00
Michal Gorny f241228a02 [Distro] Support detecting Gentoo
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-23 15:07:19 +00:00
Bruno Ricci ddb8f6b83a [AST] Store the arguments of CXXConstructExpr in a trailing array
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 14:39:30 +00:00
Artem Dergachev 02955afbb4 [analyzer] pr38668: Do not attempt to cast loaded integers to floats.
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 02:06:51 +00:00
Artem Belevich 9953577cb2 [CUDA] Treat extern global variable shadows same as regular extern vars.
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-22 01:11:09 +00:00
Aaron Ballman d914174d9b Switch from static_cast<> to cast<>, update identifier for coding conventions; NFC.
llvm-svn: 349955
2018-12-21 21:11:36 +00:00
Pete Cooper e5b64ea2b8 Convert some ObjC retain/release msgSends to runtime calls.
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 21:00:32 +00:00
Bruno Ricci d8c17673d7 [Sema][NFC] Fix a Wimplicit-fallthrough warning in CheckSpecializationInstantiationRedecl
All cases are covered so add an llvm_unreachable. NFC.

llvm-svn: 349949
2018-12-21 20:38:06 +00:00