Commit Graph

37127 Commits

Author SHA1 Message Date
Alexey Samsonov 2c0aac2591 Fix member function call on null pointer in Sema::FindInstantiatedDecl.
This bug was reported by UBSan.

llvm-svn: 217059
2014-09-03 18:45:45 +00:00
Rafael Espindola efde5a7740 Update for LLVM api change.
llvm-svn: 217050
2014-09-03 17:31:52 +00:00
Eli Bendersky 7325e56c10 Split off CUDA-specific Sema parts to a new file
In line with SemaOpenMP.cpp, etc. CUDA-specific semantic analysis code goes into
a separate file. This is in anticipation of adding extra functionality here in
the near future.

No change in functionality.

Review: http://reviews.llvm.org/D5160
llvm-svn: 217043
2014-09-03 15:27:03 +00:00
Tom Stellard c4e0c1075b CGBuiltin: Use @llvm.fabs rather than fabs libcall when emitting builtins
Using the intrinsic allows the SelectionDAGBuilder to turn this call
into the FABS Node and also the intrinsic is something the vectorizer knows
how to vectorize.

This patch also sets the readnone attribute on this call, which should
enable additional optmizations.

llvm-svn: 217042
2014-09-03 15:24:29 +00:00
Benjamin Kramer 7ab8476c15 ASTMatchers: Add a matcher to detect whether a decl or stmt is inside a template instantiation.
This is hoisted from clang-tidy where it's used everywhere. The implementation
is not particularly efficient right now, but there is no easy fix for that.

Differential Revision: http://reviews.llvm.org/D5085

llvm-svn: 217029
2014-09-03 12:08:14 +00:00
Benjamin Kramer a39beb9dd6 Parse: Replace polymorphic functor objects with lambdas and llvm::function_ref.
No change in functionality.

llvm-svn: 217025
2014-09-03 11:06:10 +00:00
Daniel Jasper db986eb6bb clang-format: Add an option 'SpaceAfterCStyleCast'.
This permits to add a space after closing parenthesis of a C-style cast.
Defaults to false to preserve old behavior.

Fixes llvm.org/PR19982.

Before:
  (int)i;

After:
  (int) i;

Patch by Marek Kurdej.

llvm-svn: 217022
2014-09-03 07:37:29 +00:00
Ed Schouten ca98874943 Allow a scoped lockable object to acquire/release multiple locks.
Scoped lockable objects (mutex guards) are implemented as if it is a
lock itself that is acquired upon construction and unlocked upon
destruction. As it if course needs to be used to actually lock down
something else (a mutex), it keeps track of this knowledge through its
underlying mutex field in its FactEntry.

The problem with this approach is that this only allows us to lock down
a single mutex, so extend the code to use a vector of underlying
mutexes. This, however, makes the code a bit more complex than
necessary, so subclass FactEntry into LockableFactEntry and
ScopedLockableFactEntry and move all the logic that differs between
regular locks and scoped lockables into member functions.

llvm-svn: 217016
2014-09-03 06:00:11 +00:00
Richard Smith 73b21d8fa1 [modules] Use DeclContext::equals rather than == on DeclContext* when
determining whether a declaration is out of line, instead of assuming
that the semantic and lexical DeclContext will be the same declaration
whenever they're the same entity.

This fixes behavior of declarations within merged classes and enums.

llvm-svn: 217008
2014-09-03 02:33:22 +00:00
Eli Bendersky 838600482a Fix up formatting.
llvm-svn: 216976
2014-09-02 22:00:06 +00:00
Rafael Espindola 9efb728920 Don't indent inside a namespace.
llvm-svn: 216937
2014-09-02 19:37:08 +00:00
Richard Trieu b292604553 Don't allow lambdas to capture invalid decls during template instantiations.
Fixes PR20731.

llvm-svn: 216936
2014-09-02 19:32:44 +00:00
David Blaikie 86b9464e01 Fix for LLVM API change to SpecialCaseList::create
llvm-svn: 216926
2014-09-02 18:13:58 +00:00
David Majnemer 9676a2bc47 Frontend: Reindent Opts.CoverageFile
No functional change intended.

llvm-svn: 216888
2014-09-01 18:50:05 +00:00
David Majnemer ca32f9342b MS ABI: Reindent MicrosoftCXXABI::GetVirtualBaseClassOffset
No functional change intended.

llvm-svn: 216887
2014-09-01 18:50:02 +00:00
Alexander Potapenko c8e749a5fd Typo fix, no functionality change.
llvm-svn: 216876
2014-09-01 12:35:57 +00:00
Craig Topper bf3e32705a Fix some cases where StringRef was being passed by const reference. Remove const from some other StringRefs since its implicitly const already.
llvm-svn: 216825
2014-08-30 16:55:52 +00:00
Craig Topper 8c2a2a0f82 Use llvm::makeArrayRef instead of explicitly calling ArrayRef constructor and mentioning the type. This works now that we have a conversion from ArrayRef<T*> to ArrayRef<const T*>.
llvm-svn: 216824
2014-08-30 16:55:39 +00:00
Richard Smith 70d5850955 [modules] Fix deserialization cycle when loading a tag declaration with a typedef name for linkage purposes. When loading the type, delay loading its typedef until we've finished loading and merging the type. In its place, save out the name of the typedef, which we need for merging purposes.
llvm-svn: 216806
2014-08-30 00:04:23 +00:00
Adrian Prantl 21361fb308 Debug info: Only emit C++ accessibility specifiers when they are diverging
from the default for the containing type.

rdar://problem/18154959

llvm-svn: 216800
2014-08-29 22:44:27 +00:00
David Blaikie 02118cedd5 unique_ptrify PTHManager's PerIDCache using the newly added llvm::FreeDeleter
llvm-svn: 216786
2014-08-29 22:04:45 +00:00
David Blaikie 60e836ba99 unique_ptrify some parameters to PTHManager::PTHManager
A couple of these arguments were passed by void* as a rather extreme
example of pimpling. Adjusting this to a more classic form of the idiom
(involving forward declarations) makes this more legible and allows
explicit passing of ownership via std::unique_ptr.

llvm-svn: 216785
2014-08-29 22:04:40 +00:00
Reid Kleckner c34735148f Make all virtual member pointers use variadic musttail calls
This avoids encoding information about the function prototype into the
thunk at the cost of some function prototype bitcast gymnastics.

Fixes PR20653.

llvm-svn: 216782
2014-08-29 21:43:29 +00:00
Larisse Voufo 2e84650768 Fix for PR20660, where unexpanded parameter pack in function parameter clause causes clang to crash.
llvm-svn: 216778
2014-08-29 21:08:16 +00:00
Nico Weber ce069f11f9 Add a comment, no functional change.
llvm-svn: 216777
2014-08-29 21:05:44 +00:00
Fariborz Jahanian 3b23008987 Objective-C [qoi]. If property is going to be implemented
in the super class, do not issue the warning about property
in current class's protocol will not be auto synthesized.
// rdar://18179833

llvm-svn: 216769
2014-08-29 20:29:31 +00:00
David Blaikie eb62b822e3 unique_ptrify the raw_ostream argument to clang::serialized_diags::create
llvm-svn: 216767
2014-08-29 20:17:13 +00:00
David Blaikie 53dd8fea69 unique_ptrify clang::ento::createCheckerManager
llvm-svn: 216765
2014-08-29 20:11:03 +00:00
David Blaikie c9950cb1dd unique_ptrify PathDiagnosticConsumer::HandlePathDiagnostic
FoldingSet, another intrusive data structure that could use some
unique_ptr love on its interfaces. Eventually.

llvm-svn: 216764
2014-08-29 20:06:10 +00:00
Anna Zaks d5478fdd8f Add an option to silence all analyzer warnings.
People have been incorrectly using "-analyzer-disable-checker" to
silence analyzer warnings on a file, when analyzing a project. Add
the "-analyzer-disable-all-checks" option, which would allow the
suppression and suggest it as part of the error message for
"-analyzer-disable-checker". The idea here is to compose this with
"--analyze" so that users can selectively opt out specific files from
static analysis.

llvm-svn: 216763
2014-08-29 20:01:38 +00:00
David Blaikie 43e3717bdb unique_ptrify thep passing of BugReports to BugReportEquivClass
I suspect llvm::ilist should take elements by unique_ptr, since it does
take ownership of the element (by stitching it into the linked list) -
one day.

llvm-svn: 216761
2014-08-29 19:57:52 +00:00
David Blaikie 09844adc41 unique_ptrify HeaderMap::FileBuffer
llvm-svn: 216758
2014-08-29 19:51:32 +00:00
David Blaikie 6d5038c19c unique_ptrify Preprocessor's TokenLexerCache
llvm-svn: 216756
2014-08-29 19:36:52 +00:00
David Blaikie e90195c09b unique_ptrify the result of CFG::buildCFG/CFGBuilder::buildCFG
llvm-svn: 216755
2014-08-29 18:53:26 +00:00
Fariborz Jahanian c9b771560a Objective-C. Tweak diagnosing properties that are not auto-synthesized.
Do not warn when property declared in class's protocol will be auto-synthesized
by its uper class implementation because super class has also declared this
property while this class has not. Continue to warn if current class
has declared the property also (because this declaration will not result
in a 2nd synthesis).
rdar://18152478

llvm-svn: 216753
2014-08-29 18:31:16 +00:00
David Blaikie 8d05190e1d unique_ptrify PathDiagnostic::setEndOfPath's argument
Again, if shared ownership is the right model here (I assume it is,
given graph algorithms & such) this could be tidied up (the 'release'
call removed in favor of something safer) by having
IntrunsiveRefCntPointer constructible from a unique_ptr.

(& honestly I'd probably favor taking a page out of shared_ptr's book,
allowing implicit construction from a unique_ptr rvalue, and only allow
explicit from a raw pointer - currently IntrusiveRefCntPointer can
implicitly own from a raw pointer, which seems unsafe)

llvm-svn: 216752
2014-08-29 18:18:47 +00:00
David Blaikie d15481ccea unique_ptr-ify PathDiagnosticPiece ownership
llvm-svn: 216751
2014-08-29 18:18:43 +00:00
David Blaikie a97eaa1bc0 Provide a BuryPointer for unique_ptrs.
In theory, it'd be nice if we could move to a case where all buried
pointers were buried via unique_ptr to demonstrate that the program had
finished with the value (that we could really have cleanly deallocated
it) but instead chose to bury it.

I think the main reason that's not possible right now is the various
IntrusiveRefCntPtrs in the Frontend, sharing ownership for a variety of
compiler bits (see the various similar
"CompilerInstance::releaseAndLeak*" functions). I have yet to figure out
their correct ownership semantics - but perhaps, even if the
intrusiveness can be removed, the shared ownership may yet remain and
that would lead to a non-unique burying as is there today. (though we
could model that a little better - by passing in a shared_ptr, etc -
rather than needing the two step that's currently used in those other
releaseAndLeak* functions)

This might be a bit more robust if BuryPointer took the boolean:

BuryPointer(bool, unique_ptr<T>)

and the choice to bury was made internally - that way, even when
DisableFree was not set, the unique_ptr would still be null in the
caller and there'd be no chance of accidentally having a different
codepath where the value is used after burial in !DisableFree, but it
becomes null only in DisableFree, etc...

llvm-svn: 216742
2014-08-29 16:53:14 +00:00
David Blaikie 93106514a9 unique_ptrify Directives in VerifyDiagnosticConsumer
llvm-svn: 216740
2014-08-29 16:30:23 +00:00
Daniel Jasper 73e171f76d clang-format: Fix unary operator detection in corner case.
Before:
  decltype(* ::std::declval<const T &>()) void F();

After:
  decltype(*::std::declval<const T &>()) void F();

llvm-svn: 216724
2014-08-29 12:54:38 +00:00
Benjamin Kramer d9c9162bb9 ASTMatchers: Replace some copies of the bound nodes tree builder with moves.
But don't move if all we do is clearing the thing. The move method is too large
to be inlined and performs a ton of unnecessary checking when the RHS is empty.

No functionality change.

llvm-svn: 216723
2014-08-29 11:22:47 +00:00
James Molloy 90d6101410 Use store size instead of alloc size when coercing.
Previously, EnterStructPointerForCoercedAccess used Alloc size when determining how to convert. This was problematic, because there were situations were the alloc size was larger than the store size. For example, if the first element of a structure were i24 and the destination type were i32, the old code would generate a GEP and a load i24. The code should compare store sizes to ensure the whole object is loaded. I have attached a test case.

This patch modifies the output of arm64-be-bitfield.c test case, but the new IR seems to be equivalent, and after -O3, the compiler generates identical ARM assembly. (asr x0, x0, #54)

Patch by Thomas Jablin!

llvm-svn: 216722
2014-08-29 10:17:52 +00:00
David Blaikie 50a5f97e82 unique_ptrify SourceManager::createFileID
llvm-svn: 216715
2014-08-29 07:59:55 +00:00
David Majnemer 0392cf892f CodeGen: Don't completely mess-up optimized atomic libcalls
Summary:
We did a great job getting this wrong:
- We messed up which LLVM IR types to use for arguments and return values.
  The optimized libcalls use integer types for values.

  Clang attempted to use the IR type which corresponds to the value
  passed in instead of using an appropriately sized integer type.  This
  would result in violations of the ABI for, as an example, floating
  point types.
- We didn't bother recording the result of the atomic libcall in the
  destination memory.

Instead, call the functions with arguments matching the type of the
libcall prototype's parameters.

This fixes PR20780.

Differential Revision: http://reviews.llvm.org/D5098

llvm-svn: 216714
2014-08-29 07:27:49 +00:00
David Blaikie 486f440cf1 unique_ptrify Driver Action handling
It hits a limit when we reach ActionList, which is used for dynamic
conditional ownership, so we lose type safety there.

This did expose at least one caller "lying" about ownership (passing
ownership to an Action, then updating the Action to specify that it
doesn't actually own the thing that was passed) - changing this to
unique_ptr just makes that oddity more obvious.

llvm-svn: 216713
2014-08-29 07:25:23 +00:00
David Blaikie d6902a1403 Improve unique_ptr-y ownership in ASTUnit::ComputePreamble
Rather than having a pair of pairs and a reference out parameter, build
a structure with everything together and named. A raw pointer and a
unique_ptr, rather than a raw pointer and a boolean, are used to
communicate ownership transfer.

It's possible one day we'll end up with a conditional pointer (probably
represented by a raw pointer and a boolean) abstraction to use in places
like this. Conditional ownership seems to be coming up more often than
I'd hoped...

llvm-svn: 216712
2014-08-29 06:34:53 +00:00
Craig Topper f78d849a55 Use llvm::makeArrayRef instead of explicitly calling ArrayRef constructor and mentioning the type. This works now that we have a conversion from ArrayRef<T*> to ArrayRef<const T*>.
llvm-svn: 216710
2014-08-29 06:05:01 +00:00
David Blaikie 780dd3b71a unique_ptrify clang::BackendConsumer::takeModule
llvm-svn: 216707
2014-08-29 05:08:19 +00:00
Kostya Serebryany 4a9187a810 call __asan_load_cxx_array_cookie when loading array cookie in asan mode.
Summary:
The current implementation of asan cookie is incorrect:
we add nosanitize metadata to the cookie load, but the metadata may be lost
and we will instrument the load from poisoned memory.
This change replaces the load with a call to __asan_load_cxx_array_cookie (r216692)

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D5111

llvm-svn: 216702
2014-08-29 01:01:32 +00:00
Hans Wennborg 0a20f5417c Better codegen support for DLL attributes being dropped after the first declaration (PR20792)
For the following code:

  __declspec(dllimport) int f(int x);
  int user(int x) {
    return f(x);
  }
  int f(int x) { return 1; }

Clang will drop the dllimport attribute in the AST, but CodeGen would have
already put it on the LLVM::Function, and that would never get updated.
(The same thing happens for global variables.)

This makes Clang check dropped DLL attribute case each time the LLVM object
is referenced.

This isn't perfect, because we will still get it wrong if the function is
never referenced by codegen after the attribute is dropped, but this handles
the common cases and makes us not fail in the verifier.

llvm-svn: 216699
2014-08-29 00:16:06 +00:00