Commit Graph

12971 Commits

Author SHA1 Message Date
Eli Friedman 7f21bd74b8 Don't crash with -Wlarge-by-value-copy and a dependent type. PR11726.
llvm-svn: 147812
2012-01-09 23:46:59 +00:00
Richard Smith c8a79033ba Extend the diagnostic for a ',' at the end of a declaration where a ';' was
intended to cover C++ class definitions.

llvm-svn: 147808
2012-01-09 22:31:44 +00:00
Nico Weber a8f80b31f9 Fix "note" of a duplicate explicit instantiation definition following a specialization.
llvm-svn: 147798
2012-01-09 19:52:25 +00:00
Akira Hatanaka 1632af603d Insert padding before unaligned long double arguments.
llvm-svn: 147791
2012-01-09 19:31:25 +00:00
Richard Smith 12ea3c56c3 Restore some parts of this test which were accidental reverted in r147649.
Thanks to David Blaikie for pointing this out.

llvm-svn: 147783
2012-01-09 18:30:34 +00:00
Douglas Gregor 540fd8135e When deserializing an anonymous namespace from a module, do not attach
the anonymous namespace to its parent. Semantically, this means that
the anonymous namespaces defined in one module are distinct from the
anonymous namespaces defined in another module.

llvm-svn: 147782
2012-01-09 18:07:24 +00:00
Douglas Gregor 9b47f94133 Implement merging of namespace-scope declarations across modules, so
that we can merge, for example, two occurrences of

  namespace N { void f(); }

in two disjoint modules.

llvm-svn: 147780
2012-01-09 17:38:47 +00:00
Douglas Gregor cfe7dc6b2f Implement redeclaration merging for namespaces defined in distinct
modules. Teach name lookup into namespaces to search in each of the
merged DeclContexts as well as the (now-primary) DeclContext. This
supports the common case where two different modules put something
into the same namespace.

llvm-svn: 147778
2012-01-09 17:30:44 +00:00
Douglas Gregor dbd93bfc2d Always allow redefinition of typedefs when modules are enabled. This
is important because it's fairly common for headers (especially system
headers) to want to provide only those typedefs needed for that
particular header, based on some guard macro, e.g.,

#ifndef _SIZE_T
#define _SIZE_T
typedef long size_t;
#endif

which is repeated in a number of headers. The guard macro protects
against duplicate definitions. However, this means that only the first
occurrence of this pattern actually defines size_t, so the submodule
corresponding to this header has the only visible definition. If a
user then imports a different submodule from the same module, size_t
will be known but not visible, and therefore cannot be used.

By allowing redefinition of typedefs, each header that wants to define
size_t can do so independently, so it will be available in the
corresponding submodules.

llvm-svn: 147775
2012-01-09 15:36:04 +00:00
Abramo Bagnara 1cd8368eb2 Fixed TypeofExpr AST and code generation.
llvm-svn: 147730
2012-01-07 10:52:36 +00:00
Douglas Gregor e57e752b71 Switch NamespaceDecl from its own hand-rolled redeclaration chain over
to Redeclarable<NamespaceDecl>, so that we benefit from the improveed
redeclaration deserialization and merging logic provided by
Redeclarable<T>. Otherwise, no functionality change.

As a drive-by fix, collapse the "inline" bit into the low bit of the
original namespace/anonymous namespace, saving 8 bytes per
NamespaceDecl on x86_64.

llvm-svn: 147729
2012-01-07 09:11:48 +00:00
Eli Friedman 73a040906d More lambda work: semantic analysis of capturing 'this'. It's a bit complicated, but we have to be careful about when exactly captures are marked given PotentiallyPotentiallyEvaluated contexts. (Actually, it's not 100% correct yet, but it's close enough for the moment.)
llvm-svn: 147723
2012-01-07 04:59:52 +00:00
Anna Zaks 126a2ef920 [analyzer] Add basic format string vulnerability checking.
We already have a more conservative check in the compiler (if the
format string is not a literal, we warn). Still adding it here for
completeness and since this check is stronger - only triggered if the
format string is tainted.

llvm-svn: 147714
2012-01-07 02:33:10 +00:00
Argyrios Kyrtzidis 10398a3789 [arcmt] Disable tests in mingw, no idea why they are failing there.
llvm-svn: 147713
2012-01-07 02:24:23 +00:00
Eli Friedman 44803326d4 Lambdas: semantic analysis of explicit captures.
This patch (and some of my other commits related to lambdas) is heavily based off of John Freeman's work-in-progress patches.

llvm-svn: 147706
2012-01-07 01:08:17 +00:00
Akira Hatanaka f64e1adcbb Add field PaddingType to ABIArgInfo which specifies the type of padding that
is inserted before the real argument. Padding is needed to ensure the backend
reads from or writes to the correct argument slots when the original alignment
of a byval structure is unavailable due to flattening.

llvm-svn: 147699
2012-01-07 00:25:33 +00:00
Matt Beaumont-Gay 7a57adab83 Suppress -Wunused-value within macros from system headers.
Along the way, move a helper function from SemaChecking.cpp to a more
accessible home in SourceManager.

llvm-svn: 147692
2012-01-06 22:43:58 +00:00
Fariborz Jahanian 7ff610b62d objc++: more code gen stuff for atomic property api,
currently turned off. // rdar://6137845
Also, fixes a test case which should be nonatomic under
new API.

llvm-svn: 147691
2012-01-06 22:33:54 +00:00
Eli Friedman df88c54f8d Revert r147655; it's breaking the compiler_rt build on OSX.
llvm-svn: 147677
2012-01-06 20:03:09 +00:00
DeLesley Hutchins 9d53033de6 Thread safety analysis: added support for trylock attribute.
llvm-svn: 147672
2012-01-06 19:16:50 +00:00
Douglas Gregor 224d8a74ae When inferring a submodule ID during module creation, look up the
include stack to find the first file that is known to be part of the
module. This copes with situations where the module map doesn't
completely specify all of the headers that are involved in the module,
which can come up when there are very strange #include_next chains
(e.g., with weird compiler/stdlib headers like stdarg.h or float.h).

llvm-svn: 147662
2012-01-06 17:19:32 +00:00
Richard Smith a8105bc9ce C++11 generalized constant expressions: implement checking and diagnostics for
pointer-arithmetic-related undefined behavior and unspecified results. We
continue to fold such values, but now notice they aren't constant expressions.

llvm-svn: 147659
2012-01-06 16:39:00 +00:00
David Chisnall 9217435a33 If we are compiling with -fno-builtin then don't do constant folding of
builtins.

This fixes PR11711.

llvm-svn: 147655
2012-01-06 12:20:19 +00:00
John McCall 8ba2f20bc0 Fix the mangling of class template arguments in a particular
dependent case.  Thanks to Jason Merrill for pointing this out.

llvm-svn: 147653
2012-01-06 05:06:35 +00:00
Rafael Espindola 7c23b0891b Improvements to the uninitialized variable warning: Check if the constructor
call is elidable or if the constructor is trivial instead of checking if it
is user declared.

llvm-svn: 147652
2012-01-06 04:54:01 +00:00
Richard Smith b3851f5ca1 David Blaikie and Chandler would like us to diagnose
int f();

in function scopes under -Wvexing-parse, so now we do.

llvm-svn: 147649
2012-01-06 02:30:50 +00:00
Richard Smith d069d2f6ac Tweak to r147599 for PR10828: Move the check from the parser into sema, and use
the Semantic Powers to only warn on class types (or dependent types), where the
constructor or destructor could do something interesting.

llvm-svn: 147642
2012-01-06 01:31:20 +00:00
Eli Friedman 5c5e3b7e84 Minor refactoring of sentinel warning on blocks. Add a test for this warning.
llvm-svn: 147641
2012-01-06 01:23:10 +00:00
Eli Friedman b1bc368ca7 Address Richard's review comments on r147561 (Evaluate support for address-of-label differences).
llvm-svn: 147631
2012-01-05 23:59:40 +00:00
Ted Kremenek 0c2c90b1ad After further discussion, rename attribute 'objc_disable_automatic_synthesis' to 'objc_requires_property_definitions'.
llvm-svn: 147622
2012-01-05 22:47:47 +00:00
Eli Friedman de30e523b4 Tweak the fix to PR8977: an empty expression-list represents value initialization, not default initialization. Fixes PR11712.
llvm-svn: 147620
2012-01-05 22:34:08 +00:00
Richard Smith 69f90dce49 PR10828: Produce a warning when a no-arguments function is declared in block
scope, when no other indication is provided that the user intended to declare a
function rather than a variable.

Remove some false positives from the existing 'parentheses disambiguated as a
function' warning by suppressing it when the declaration is marked as 'typedef'
or 'extern'.

Add a new warning group -Wvexing-parse containing both of these warnings.

The new warning is enabled by default; despite a number of false positives (and
one bug) in clang's test-suite, I have only found genuine bugs with it when
running it over a significant quantity of real C++ code.

llvm-svn: 147599
2012-01-05 04:12:21 +00:00
Eli Friedman 71c8055f8e More lambda work. Tweak the Sema interface slightly. Start adding the pieces to build the lambda class and its call operator. Create an actual scope for the lambda body.
llvm-svn: 147595
2012-01-05 03:35:19 +00:00
Chad Rosier 8fca6b268b [driver] Add support for passing -lazy_framework/-lazy_library to the linker.
rdar://10630328

llvm-svn: 147591
2012-01-05 01:56:11 +00:00
Douglas Gregor 5c193c7ed6 When we're performing name lookup for a tag, we still allow ourselves
to see hidden declarations because every tag lookup is effectively a
redeclaration lookup. For example, image that

  struct foo;

is declared in a submodule that is known but hasn't been imported. If
someone later writes

  struct foo *foo_p;

then "struct foo" is either a reference or a redeclaration. To keep
the redeclaration chains sound, we treat it like a redeclaration for
name-lookup purposes.

llvm-svn: 147588
2012-01-05 01:11:47 +00:00
John McCall a59dc2f8f0 The value of a const weak variable is not an integer constant.
llvm-svn: 147575
2012-01-05 00:13:19 +00:00
Fariborz Jahanian 088f1bc295 Fixes a code gen bug for setter code for a property of
c++ object reference type with trivial copy constructor.
This causes an assert crash and bad code gen. when assert 
is off. // rdar://6137845

llvm-svn: 147573
2012-01-05 00:10:16 +00:00
Douglas Gregor d2a8fe187d When generating includes for all of the headers we found in an
umbrella directory, skip includes for any headers that are part of an
unavailable module.

llvm-svn: 147572
2012-01-05 00:04:05 +00:00
Anna Zaks e04dadc248 [analyzer] Add another tests to taint tester.
llvm-svn: 147570
2012-01-04 23:54:04 +00:00
Anna Zaks 8158ef0dec [analyzer] Be less pessimistic about invalidation of global variables
as a result of a call.

Problem:
Global variables, which come in from system libraries should not be
invalidated by all calls. Also, non-system globals should not be
invalidated by system calls.

Solution:
The following solution to invalidation of globals seems flexible enough
for taint (does not invalidate stdin) and should not lead to too
many false positives. We split globals into 3 classes:

* immutable - values are preserved by calls (unless the specific
global is passed in as a parameter):
     A :  Most system globals and const scalars

* invalidated by functions defined in system headers:
     B: errno

* invalidated by all other functions (note, these functions may in
turn contain system calls):
     B: errno
     C: all other globals (which are not in A nor B)

llvm-svn: 147569
2012-01-04 23:54:01 +00:00
Ted Kremenek dec9d12fc4 Rename attribute 'objc_suppress_autosynthesis' to 'objc_disable_automatic_synthesis'.
llvm-svn: 147567
2012-01-04 23:51:09 +00:00
Eli Friedman 50c9d08fa5 Fix test on Release builds.
llvm-svn: 147565
2012-01-04 23:41:09 +00:00
Fariborz Jahanian f716839580 Test case for my previous patch.
llvm-svn: 147563
2012-01-04 23:16:48 +00:00
Eli Friedman fd5e54da2d Add an APValue representation for the difference between two address-of-label expressions. Add support to Evaluate and CGExprConstant for generating/handling them. Remove the special-case for such differences in Expr::isConstantInitializer.
With that done, remove a bunch of buggy code from CGExprConstant for handling scalar expressions which is no longer necessary.

Fixes PR11705.

llvm-svn: 147561
2012-01-04 23:13:47 +00:00
Chris Lattner 3ad9042456 fix test on -Asserts builds.
llvm-svn: 147558
2012-01-04 22:51:21 +00:00
Chris Lattner 36bc4f41bc implement rdar://10639962 by keeping track of increased alignment
information even in subscripting operations.

llvm-svn: 147557
2012-01-04 22:35:55 +00:00
Fariborz Jahanian a28a78ec2f Support __has_attribute for objc_suppress_autosynthesis
which is automatic with proper spelling :).

llvm-svn: 147555
2012-01-04 22:29:28 +00:00
Douglas Gregor 7f9abbdcc5 Add __has_feature(modules) to indicate when modules are available (in
any language variant), and restrict __has_feature(objc_modules) to
mean that we also have the Objective-C @import syntax. I anticipate
__has_feature(cxx_modules) and/or __has_feature(c_modules) for when we
nail down the module syntax for C/C++.

llvm-svn: 147548
2012-01-04 21:16:09 +00:00
Eli Friedman 2dd5d653f2 Fix test so it doesn't depend on the host's calling convention lowering code.
llvm-svn: 147545
2012-01-04 20:43:57 +00:00
Douglas Gregor b8c6f1e950 Implement declaration merging for variables in disjoint modules.
llvm-svn: 147535
2012-01-04 17:21:36 +00:00