Commit Graph

12971 Commits

Author SHA1 Message Date
Richard Smith 300237f00c Add a warning flag for ext_embedded_directive. gcc considers this undefined
behaviour to be an error, so it's useful to be able to make it an error in clang
too.

llvm-svn: 146755
2011-12-16 20:58:01 +00:00
Richard Smith 13f6718b42 PR11594: Don't blindly build a UnaryOperator UO_Minus on an expression which
might not be an rvalue when checking array accesses. Instead, pass through a
flag indicating the array index is negated.

llvm-svn: 146753
2011-12-16 19:31:14 +00:00
Richard Smith f6f003af6a C++11 constexpr: Add note stacks containing backtraces if constant evaluation
fails within a call to a constexpr function. Add -fconstexpr-backtrace-limit
argument to driver and frontend, to control the maximum number of notes so
produced (default 10). Fix APValue printing to be able to pretty-print all
APValue types, and move the testing for this functionality from a unittest to
a -verify test now that it's visible in clang's output.

llvm-svn: 146749
2011-12-16 19:06:07 +00:00
Anna Zaks e48ee50324 [analyzer] Better stdin support.
llvm-svn: 146748
2011-12-16 18:28:50 +00:00
Devang Patel fbfd303dc4 Update tests to match r146744.
llvm-svn: 146745
2011-12-16 17:56:38 +00:00
David Blaikie 1d578782fa Support decltype in pseudo destructors and dependent destructor calls.
Reviewed by Eli Friedman.

llvm-svn: 146738
2011-12-16 16:03:09 +00:00
Fariborz Jahanian 21c2484454 objc: after issuing the warning on direct use of __attribute__((NSObject))
on properties, prevent consequential error  diagnostics. // rdar://10591336

llvm-svn: 146737
2011-12-16 15:54:29 +00:00
Douglas Gregor ab1ec82e04 Fix chaining of ObjCInterfaceDecl redeclarations
llvm-svn: 146722
2011-12-16 03:12:41 +00:00
Douglas Gregor 95ab186240 When name lookup finds a module-private Objective-C class declaration,
check whether any previous declarations of the class were visible.

llvm-svn: 146680
2011-12-15 20:36:27 +00:00
Douglas Gregor dc9166c8e1 Keep track of all declarations of an Objective-C class (both forward
declarations and definitions) as ObjCInterfaceDecls within the same
redeclaration chain. This new representation matches what we do for
C/C++ variables/functions/classes/templates/etc., and makes it
possible to answer the query "where are all of the declarations of
this class?"

llvm-svn: 146679
2011-12-15 20:29:51 +00:00
Devang Patel 40b88d6756 Update tests to match r146665.
llvm-svn: 146668
2011-12-15 18:03:43 +00:00
Douglas Gregor 843e978324 "Accidentally" fixed a bug with overloading of functions with
Objective-C objects as parameters in r146659. Add a test for it.

llvm-svn: 146660
2011-12-15 17:20:18 +00:00
Hans Wennborg 29b653413a Fix test/Sema/format-strings-scanf.c
llvm-svn: 146651
2011-12-15 11:43:45 +00:00
Hans Wennborg 23926bd2d7 Support the 'a' length modifier in scanf format strings as a C90
extension.

This fixes gcc.dg/format/c90-scanf-3.c and ext-4.c (test for excess
errors).

llvm-svn: 146649
2011-12-15 10:25:47 +00:00
Eli Friedman 8349dc1fd6 Enhance the -Wsign-compare handling to suppress the -Wsign-compare warning in the case of a shifted bitfield. PR11572.
llvm-svn: 146634
2011-12-15 02:41:52 +00:00
Anna Zaks a2510070ee Add support for matching one or more (aka regex +) diagnostic messages with -verify.
Ex:
// expected-warning + {{tainted}

llvm-svn: 146633
2011-12-15 02:28:16 +00:00
Anna Zaks 30373150a1 [analyzer] Ensure that the order in which checker callbacks are called
is deterministic.

Non-determinism was the reason for the test which caused the earlier
buildbot failures, so re-enable the test.

llvm-svn: 146628
2011-12-15 01:36:04 +00:00
Fariborz Jahanian 9e49b6a6ff objc: do not auto synthesize properties declared in
protocols; with a warning. // rdar://10567333

llvm-svn: 146626
2011-12-15 01:03:18 +00:00
Douglas Gregor 95715f9ecf In debugger support mode, if we have a top-level message send
expression with an unknown result type, assume that the result type is
'id'. Fixes <rdar://problem/10400663>.

llvm-svn: 146622
2011-12-15 00:53:32 +00:00
Richard Trieu 553b2b2e5d Modify how the -verify flag works. Currently, the verification string and
diagnostic message are compared.  If either is a substring of the other, then
no error is given.  This gives rise to an unexpected case:

  // expect-error{{candidate function has different number of parameters}}

will match the following error messages from Clang:

  candidate function has different number of parameters (expected 1 but has 2)
  candidate function has different number of parameters

It will also match these other error messages:

  candidate function
  function has different number of parameters
  number of parameters

This patch will change so that the verification string must be a substring of
the diagnostic message before accepting.  Also, all the failing tests from this
change have been corrected.  Some stats from this cleanup:

87 - removed extra spaces around verification strings
70 - wording updates to diagnostics
40 - extra leading or trailing characters (typos, unmatched parens or quotes)
35 - diagnostic level was included (error:, warning:, or note:)
18 - flag name put in the warning (-Wprotocol)

llvm-svn: 146619
2011-12-15 00:38:15 +00:00
Argyrios Kyrtzidis 41cfce25fe [libclang] Suppress indexing references for occurrences of the interface
in a superclass and the protocols in a protocol list.

llvm-svn: 146615
2011-12-15 00:04:56 +00:00
Richard Smith 902ca2138f Produce more detailed diagnostics when static_assert condition is not an ICE.
llvm-svn: 146607
2011-12-14 23:32:26 +00:00
Richard Smith 9af58d4426 Halve the constexpr recursion depth in this test in an attempt to make the
freebsd bots happy. In the longer term, we should have a mechanism for moving
constexpr recursion off the call stack, to support the default limit of 512
suggested by the standard.

llvm-svn: 146596
2011-12-14 21:55:23 +00:00
Douglas Gregor 7234103225 Don't consider an overloaded operator& when the expression is actually
going to be a pointer-to-member constant. Fixes <rdar://problem/10544564>.

llvm-svn: 146587
2011-12-14 21:23:13 +00:00
Rafael Espindola 224dd63fff Don't use the frame pointer on linux x86 and x86_64 if optimizing. This
matches gcc's behavior.

Fixes PR8186.

llvm-svn: 146586
2011-12-14 21:02:23 +00:00
Anna Zaks 93237e4808 [analyzer] Disable verification step on the failing test.
I need to keep the test itself in the repository since it's the only way I can currently reproduce the issue.

llvm-svn: 146582
2011-12-14 19:39:46 +00:00
DeLesley Hutchins 36f5d8518b Allow empty argument lists in thread safety attributes
llvm-svn: 146580
2011-12-14 19:36:06 +00:00
David Blaikie 96b4874b50 Move & comment the 'decltype in declarator-id' as suggested by Doug Gregor.
llvm-svn: 146576
2011-12-14 18:59:02 +00:00
Anna Zaks 72e90d54ae [analyzer] Re-enable the test which was failing on one of the bots.
I cannot reproduce the failures neither on my machine nor on the same buildbot machine (with the clang binary built on it). Let's see if it fails again..

llvm-svn: 146574
2011-12-14 18:34:17 +00:00
Douglas Gregor 4a814568b2 When name lookup comes across a declaration that is in a module that
is not visible, look for any previous declarations of that entity that
might be visible.

llvm-svn: 146563
2011-12-14 16:03:29 +00:00
Bob Wilson 721d4b858d Enable stack protectors by default for iOS. <rdar://problem/8836680>
llvm-svn: 146552
2011-12-14 06:08:25 +00:00
Eli Friedman 206dba0538 Switch test over to using -verify instead of using grep. PR11552.
llvm-svn: 146544
2011-12-14 02:16:13 +00:00
Anna Zaks 87ebe63542 [analyzer] Revert the taint test, which is failing on one of the bots for time being.
llvm-svn: 146541
2011-12-14 02:00:54 +00:00
Anna Zaks 099fe3fb28 [analyzer] Treat stdin as a source of taint.
Some of the test cases do not currently work because the analyzer core
does not seem to call checkers for pre/post DeclRefExpr visits.
(Opened radar://10573500. To be fixed later on.)

llvm-svn: 146536
2011-12-14 00:56:18 +00:00
Anna Zaks eefc0e9342 [analyzer] Mark output of fscanf and fopen as tainted.
llvm-svn: 146533
2011-12-14 00:56:02 +00:00
Anna Zaks d6bb3227de [analyzer] Mark getenv output as tainted.
Also, allow adding taint to a region (not only a symbolic value).

llvm-svn: 146532
2011-12-14 00:55:58 +00:00
Richard Trieu 96ed5b6b47 Make the diagnostic message more consistant. Update the type comparison to
handle non-pointer types.  This is for the extra info printed when function
types are compared.

llvm-svn: 146525
2011-12-13 23:19:45 +00:00
Fariborz Jahanian c17c86b56c objc: diagnose duplicate declaration of methods
in classes. // rdar://10535349

llvm-svn: 146504
2011-12-13 19:40:34 +00:00
Argyrios Kyrtzidis 25cb0ff3d8 [libclang] Indexing API: Fix indexing of missed references.
rdar://10567864&10567916

llvm-svn: 146497
2011-12-13 18:47:41 +00:00
Argyrios Kyrtzidis ccdf8276a3 [libclang] Indexing API: Fix suppressing of references in macros and suppress
@class forward references.

rdar://10568080&10568103&10568119

llvm-svn: 146496
2011-12-13 18:47:35 +00:00
David Blaikie 42b99e08e6 Disallow decltype in qualified declarator-ids.
llvm-svn: 146480
2011-12-13 08:03:36 +00:00
Richard Smith 357362d00b Add checks and diagnostics for many of the cases which C++11 considers to not
be constant expressions.

llvm-svn: 146479
2011-12-13 06:39:58 +00:00
Nick Lewycky f43e681ed7 Testcase for LLVM commit r146475.
llvm-svn: 146476
2011-12-13 05:09:22 +00:00
Nick Lewycky 304584f5a5 s/%clang-cc1/%clang_cc1/ for conformity.
llvm-svn: 146454
2011-12-13 00:32:15 +00:00
Francois Pichet 025131601d Implement the Microsoft __if_exists/if_not_exists extension in initializer-list.
Necessary to parse Microsoft ATL code.

Example: 
  int array[] = {
    0, 
    __if_exists(CLASS::Type) {2, }
    3
  };

will declare an array of 2 or 3 elements depending on if CLASS::Type exists or not.

llvm-svn: 146447
2011-12-12 23:24:39 +00:00
Fariborz Jahanian b989e6e50a objc-arc: better diagnostic when block is declared
inside a struct/union.

llvm-svn: 146444
2011-12-12 23:17:04 +00:00
Eli Friedman 3c840aad54 Make CGRecordLayoutBuilder correctly switch over to a packed class when a class has a base whose alignment will break the class layout. <rdar://problem/10551376>.
llvm-svn: 146443
2011-12-12 23:13:20 +00:00
Matt Beaumont-Gay 9d570c438c Suppress -Warray-bounds in certain cases involving macros from system headers.
The motivation here is a "clever" implementation of strncmp(), which peels the first few comparisons via chained conditional expressions which ensure that the input arrays are known at compile time to be sufficiently large.

llvm-svn: 146430
2011-12-12 22:35:02 +00:00
Fariborz Jahanian 0586df4a00 Fixes a bug in calculation of field offsets of ms_struct
fields by just following what comment says.
// rdar://10513599

llvm-svn: 146414
2011-12-12 21:16:36 +00:00
Richard Smith dcf1b2cc29 Further tweaking of diagnostic text for casts performing reinterpret_cast
conversions in constant expressions.

llvm-svn: 146406
2011-12-12 19:33:27 +00:00
Douglas Gregor c1aaf8cacb When we have an umbrella directory in a module map, recursively walk
the subdirectories to find headers in submodules.

llvm-svn: 146398
2011-12-12 19:13:53 +00:00
Richard Smith ff07af12df Clean up diagnostic wording for disallowed casts in C++11 constant expressions.
llvm-svn: 146395
2011-12-12 19:10:03 +00:00
Douglas Gregor a95387786d Don't mark include guard macros as implicitly private. This isn't
actually a terribly good heuristic, and the world is too horrible for
it to work.

llvm-svn: 146393
2011-12-12 18:47:39 +00:00
Hans Wennborg 4951c67875 Fix signature of vsscanf in Builtins.def
llvm-svn: 146392
2011-12-12 18:46:05 +00:00
Hans Wennborg 8d5a4093f5 Fix signature of sscanf in Builtins.def
llvm-svn: 146390
2011-12-12 18:33:02 +00:00
Richard Smith 6d6ecc34f8 Implement C++11 constant expression cast restrictions.
llvm-svn: 146371
2011-12-12 12:46:16 +00:00
Hans Wennborg bb4189db23 Make fscanf, vscanf, etc. be recognized as scanf-like functions.
llvm-svn: 146367
2011-12-12 10:34:18 +00:00
David Blaikie 08608f6744 Fix/test decltype dtor calls with invalid base expression.
llvm-svn: 146354
2011-12-12 04:13:55 +00:00
Anna Zaks 7c96b7db96 [analyzer] CStringChecker should not rely on the analyzer generating UndefOrUnknown value when it cannot reason about the expression.
We are now often generating expressions even if the solver is not known to be able to simplify it. This is another cleanup of the existing code, where the rest of the analyzer and checkers should not base their logic on knowing ahead of the time what the solver can reason about. 

In this case, CStringChecker is performing a check for overflow of 'left+right' operation. The overflow can be checked with either 'maxVal-left' or 'maxVal-right'. Previously, the decision was based on whether the expresion evaluated to undef or not. With this patch, we check if one of the arguments is a constant, in which case we know that 'maxVal-const' is easily simplified. (Another option is to use canReasonAbout() method of the solver here, however, it's currently is protected.)

This patch also contains 2 small bug fixes:
 - swap the order of operators inside SValBuilder::makeGenericVal.
 - handle a case when AddeVal is unknown in GenericTaintChecker::getPointedToSymbol.

llvm-svn: 146343
2011-12-11 18:43:40 +00:00
Hans Wennborg b1a5e09f6f Check that arguments to a scanf call match the format specifier,
and offer fixits when there is a mismatch.

llvm-svn: 146326
2011-12-10 13:20:11 +00:00
NAKAMURA Takumi 79451e68b2 test/Sema/attr-availability.c: Add explicit -triple x86_64-apple-darwin9, for now.
llvm-svn: 146321
2011-12-10 07:50:30 +00:00
Douglas Gregor 8ca0c6408e Make sure that we infer __strong, etc. when we instantiate variables
under ARC. Fixes <rdar://problem/10530209>.

llvm-svn: 146307
2011-12-10 01:22:52 +00:00
Fariborz Jahanian 88d510da9d Add ability to supply additional message to availability macros,
// rdar://10095131

llvm-svn: 146304
2011-12-10 00:28:41 +00:00
Douglas Gregor ddaae8e4e5 Use the right CHECK prefix so that we actually do this checking. Miraculously, this hasn't broken
llvm-svn: 146303
2011-12-10 00:28:18 +00:00
Douglas Gregor c7f46f20d1 When we manage to re-use an expression during tree transformation (=
template instantiation), and that expression might produce a
temporary, invoke MaybeBindToTemporary. Otherwise, we forget to
destroy objects, release objects, etc. Fixes <rdar://problem/10531073>.

llvm-svn: 146301
2011-12-10 00:23:21 +00:00
Eli Friedman de6a86b4f6 Make array new on a pointer to data member type work correctly. PR11523.
llvm-svn: 146291
2011-12-09 23:05:37 +00:00
Richard Smith 0765bec2ad Mechanically convert static_assert_fold to static_assert, now we implement the
C++11 ICE rules.

llvm-svn: 146290
2011-12-09 23:00:37 +00:00
Richard Smith f57d8cb131 C++11 constant expressions: Don't use CheckICE in C++11; instead, determine
whether an expression is a (core) constant expression as a side-effect of
evaluation. This takes us from accepting far too few expressions as ICEs to
accepting slightly too many -- fixes for the remaining cases are coming next.

The diagnostics produced when an expression is found to be non-constant are
currently quite poor (with generic wording but reasonable source locations),
and will be improved in subsequent commits.

llvm-svn: 146289
2011-12-09 22:58:01 +00:00
David Blaikie 10eb4b67d8 Add notes for suppressing and (if it's a zero-arg function returning bool) fixing the function-to-bool conversion warning.
llvm-svn: 146280
2011-12-09 21:42:37 +00:00
Fariborz Jahanian e283346d0b objc-arc: diagnose synthesis of a 'weak unavailable' property.
// rdar://10535245

llvm-svn: 146272
2011-12-09 19:55:11 +00:00
David Blaikie 72b61203f4 Provide a separate warning for weak vtables in explicit template instantiations. There's no (current) way to fix such templates to emit strong symbols/vtables, but perhaps users want to know about the cost being incurred anyway.
llvm-svn: 146265
2011-12-09 18:32:50 +00:00
Hans Wennborg a5b1aa99c7 Make printf warnings refer to wint_t and wchar_t by name
in addition to underlying type.

llvm-svn: 146254
2011-12-09 12:22:12 +00:00
Hans Wennborg 2027de3be9 fix format specifier fixit for printf("%ld", "foo");
It should reset the length modifier (unless it's a wchar_t string).

llvm-svn: 146252
2011-12-09 10:51:29 +00:00
Anna Zaks 6af472aa3b [analyzer] Fix inconsistency on when SValBuilder assumes that 2
types are equivalent.

+ A taint test which tests bitwise operations and which was
triggering an assertion due to presence of the integer to integer cast.

llvm-svn: 146240
2011-12-09 03:34:02 +00:00
Richard Smith 10c7c9090e Replace the implementation of __builtin_constant_p (which was based on the GCC
documentation) with one based on what GCC's __builtin_constant_p is actually
intended to do (discovered by asking a friendly GCC developer).

In particular, an expression which folds to a pointer is now only considered to
be a "constant" by this builtin if it refers to the first character in a string
literal.

This fixes a rather subtle wrong-code issue when building with glibc. Given:

const char cs[4] = "abcd";
int f(const char *p) { return strncmp(p, cs, 4); }

... the macro magic for strncmp produces a (potentially crashing) call to
strlen(cs), because it expands to an expression starting with:

  __builtin_constant_p(cs) && strlen(cs) < 4 ? /* ... */

Under the secret true meaning of __builtin_constant_p, this is guaranteed to be
safe!

llvm-svn: 146236
2011-12-09 02:04:48 +00:00
Douglas Gregor 7033127b4e Implement the notion of umbrella directories, which implicity cover
all of the headers below that particular directory. Use umbrella
directories as a clean way to deal with (1) directories/frameworks
that don't have an umbrella header, but don't want to enumerate all of
their headers, and (2) PrivateHeaders, which we never want to
enumerate and want to keep separate from the main umbrella header. 

This also eliminates a little more of the "magic" for private headers,
and frameworks in general.

llvm-svn: 146235
2011-12-09 02:04:43 +00:00
Fariborz Jahanian 329b351807 deprecated enum should not warn when used initializing another deprecated enumerator.
// rdar://10535640

llvm-svn: 146218
2011-12-09 01:15:54 +00:00
Argyrios Kyrtzidis c5dbeeadc1 [arcmt] Un-XFAIL a test.
llvm-svn: 146210
2011-12-09 00:17:47 +00:00
Anna Zaks 394256cc0d [analyzer] If memory region is tainted mark data as tainted.
+ random comments

llvm-svn: 146199
2011-12-08 22:38:43 +00:00
Eli Friedman 516c2ad731 Fix an edge case in IRGen for conditionals. PR11509.
llvm-svn: 146189
2011-12-08 22:01:56 +00:00
Hal Finkel 6b89a10b45 add tree test for suse on ppc64 (r146142)
llvm-svn: 146176
2011-12-08 20:36:19 +00:00
DeLesley Hutchins f7faa6a69b This patch extends thread safety analysis with support for the scoped_lockable attribute.
llvm-svn: 146174
2011-12-08 20:23:06 +00:00
Lang Hames 34792a8250 Added missing testcase from r145849. Thanks to Dave Blaikie for catching this.
llvm-svn: 146169
2011-12-08 19:26:24 +00:00
Douglas Gregor 524e33e1f8 Implement umbrella directories for modules, which are similar to
umbrella headers in the sense that all of the headers within that
directory (and eventually its subdirectories) are considered to be
part of the module with that umbrella directory. However, unlike
umbrella headers, which are expected to include all of the headers
within their subdirectories, Clang will automatically include all of
the headers it finds in the named subdirectory.

The intent here is to allow a module map to trivially turn a
subdirectory into a module, where the module's structure can mimic the
directory structure.

llvm-svn: 146165
2011-12-08 19:11:24 +00:00
Douglas Gregor 322f633c1c Tweak the syntax of umbrella headers, so that "umbrella" is treated as
a modifier for a header declarartion, e.g.,

  umbrella header "headername"

Collapse the umbrella-handling code in the parser into the
header-handling code, so we don't duplicate the header-search logic.

llvm-svn: 146159
2011-12-08 18:00:48 +00:00
Douglas Gregor 2537a36483 Keep track of import dependencies between submodules within the module
that's currently being built. This is important for supporting
transitive dependencies ("export *" in the module map) completely.

llvm-svn: 146156
2011-12-08 17:01:29 +00:00
David Blaikie ecd8a94acf Decltype in non-pseudo (& non-dependent) dtor calls.
llvm-svn: 146155
2011-12-08 16:13:53 +00:00
Hans Wennborg 70a1324428 Only do typo correction for implicit function decls when
they are treated as errors.

Doing typo correction when these are just warnings slows down the
compilation of source which deliberately uses implicit function
declarations.

llvm-svn: 146153
2011-12-08 15:56:07 +00:00
Erik Verbruggen f988785dc0 Fix: allow @protocol forward declarations inside @implementation-s.
llvm-svn: 146147
2011-12-08 09:58:43 +00:00
Peter Collingbourne 266e3dda17 Add an experimental MallocSizeofChecker, which reports inconsistencies
between the casted type of the return value of a malloc/calloc/realloc
call and the operand of any sizeof expressions contained within
its argument(s).

llvm-svn: 146144
2011-12-08 08:31:14 +00:00
Douglas Gregor 9458f82df7 Implement inference for the "Private" submodule corresponding to
private headers in a framework.

llvm-svn: 146082
2011-12-07 22:05:21 +00:00
Douglas Gregor 8030677b70 Make sure we pick up module_private.map when loading a module.map file.
llvm-svn: 146074
2011-12-07 21:25:07 +00:00
Hans Wennborg 772e9270f6 Make printf warnings refer to intmax_t et al. by name
in addition to underlying type.

For example, the warning for printf("%zu", 42.0);
changes from "conversion specifies type 'unsigned long'" to "conversion
specifies type 'size_t' (aka 'unsigned long')"

(This is a second attempt after r145697, which got reverted.)

llvm-svn: 146032
2011-12-07 10:33:11 +00:00
Argyrios Kyrtzidis 7910d7b72a Make changes to SDiagsWriter to make it work in combination with the ARC migrator:
-Allow it to be used with multiple BeginSourceFile/EndSourceFile calls; for this introduce
 a "finish" callback method in the DiagnosticConsumer. SDiagsWriter finishes up the serialization
 file inside this method.
-Make it independent of any particular DiagnosticsEngine; make it use the SourceManager of the
 Diagnostic object.
-Ignore null source ranges.

llvm-svn: 146020
2011-12-07 05:52:12 +00:00
Douglas Gregor e7ab36693b Implement basic support for private headers in frameworks. In essence,
when we load a module map (module.map) from a directory, also load a
private module map (module_private.map) for that directory, if
present. That private module map can inject a new submodule that
captures private headers.

llvm-svn: 146012
2011-12-07 02:23:45 +00:00
Ted Kremenek 9c9e81085f Tweak serialized diagnostics to support errors with no categories. Fixes <rdar://problem/10538300>.
llvm-svn: 146011
2011-12-07 02:08:00 +00:00
Eli Friedman dae858aca3 Make sure we correctly zero-initialize unions containing a pointer to data member as the first field. PR11487.
llvm-svn: 146009
2011-12-07 01:30:11 +00:00
Anna Zaks b86fdbe7e3 [analyzer] Propagate taint through MemRegions.
SVal can be not only a symbol, but a MemRegion. Add support for such
cases.

llvm-svn: 146006
2011-12-07 01:09:52 +00:00
Richard Smith 42d3af9d95 When folding the size of a global scope VLA to a constant, require the array
bound to not have side effects(!). Add constant-folding support for expressions
of void type, to ensure that we can still fold ((void)0, 1) as an array bound.

llvm-svn: 146000
2011-12-07 00:43:50 +00:00
Fariborz Jahanian 6bdeb14d5d objc: issue deprecated/unavailable diagnostic when
methods with these attributes are sent to receivers
of 'id' type too. // rdar://10459930

llvm-svn: 145999
2011-12-07 00:30:00 +00:00
Anna Zaks c25efccc8b [analyzer] Propagate taint through NonLoc to NonLoc casts.
- Created a new SymExpr type - SymbolCast.
 - SymbolCast is created when we don't know how to simplify a NonLoc to
NonLoc casts.
 - A bit of code refactoring: introduced dispatchCast to have better
code reuse, remove a goto.
 - Updated the test case to showcase the new taint flow.

llvm-svn: 145985
2011-12-06 23:12:27 +00:00
Richard Smith 161f09abd7 Move vector bitcast handling in constant expressions from the expression
evaluator into constant initializer handling / IRGen. The practical consequence
of this is that the bitcast now lives in the constant's definition, rather than
in its uses.

The code in the constant expression evaluator was producing vectors of the wrong
type and size (and possibly of the wrong value for a big-endian int-to-vector
bitcast). We were getting away with this only because we don't yet support
constant-folding of any expressions which inspect vector values.

llvm-svn: 145981
2011-12-06 22:44:34 +00:00
Argyrios Kyrtzidis 66f433a746 [libclang] API enhancements by Joe Groff!
- Exposes a CXType_Vector type kind for vector types.
- Adds generalized versions of the clang_getArrayElementType and clang_getArraySize functions, named clang_getElementType and clang_getNumElements, which work on array, vector, or complex types.
- Adds additional functions for querying function types. clang_isFunctionTypeVariadic returns true if a function type is variadic. clang_getFunctionCallingConv returns an enumeration value indicating the calling convention of the function type. clang_getNumArgTypes returns the number of static argument types, and clang_getArgType gets the type of an argument.
- Adds a clang_getTypedefDeclUnderlyingType function to get the underlying type from a TypedefDecl cursor.
- Adds a clang_getEnumDeclIntegerType function to get the integer type from an EnumDecl cursor.
- Adds clang_getEnumConstantDeclValue and clang_getEnumConstantDeclUnsignedValue functions to get the value of an EnumConstantDecl as a signed or unsigned long long, respectively.
- Exposes a CXCursor_AsmLabelAttr cursor kind for __asm__("label") attributes.
- Alters clang_getCursorSpelling to return the label value for AsmLabelAttr-kind cursors.

llvm-svn: 145972
2011-12-06 22:05:01 +00:00
Douglas Gregor 158764bbe2 Rename Objective-C-only tests to .m
llvm-svn: 145959
2011-12-06 20:51:42 +00:00
Douglas Gregor e89dbc1d98 When inferring a module map for a framework, infer subframework
modules for each of its subframeworks.

llvm-svn: 145957
2011-12-06 19:39:29 +00:00
Douglas Gregor dd005f69f0 Allow inferred submodules for any (sub)module that has an umbrella header
llvm-svn: 145945
2011-12-06 17:34:58 +00:00
Douglas Gregor 356f3d4b53 When suggesting a module import for a #include or #import, suggest the
most specific (sub)module based on the actual file we find, rather
than always importing the top-level module. This means
that #include'ing <Foo/Blah.h> should give us the submodule Foo.Blah.

llvm-svn: 145942
2011-12-06 17:31:28 +00:00
Douglas Gregor f2161a70aa Implement modules support for subframeworks (aka embedded
frameworks). A submodule can now be labeled as a "framework", and
header search will look into the appropriate Headers/PrivateHeaders
subdirectories for named headers.

llvm-svn: 145941
2011-12-06 17:16:41 +00:00
Douglas Gregor e5626c4119 When building the main file to parse given a module map, don't skip
explicit submodules or umbrella headers from submodules. Instead,
build the entire module at once, and let the name-hiding mechanisms
hide the contents of explicit submodules at load time.

llvm-svn: 145940
2011-12-06 17:15:11 +00:00
Daniel Dunbar e946e361ab Headers: wmmintrin.h only needs xmmintrin.h.
- Fixes <rdar://problem/10261246> clang -maes option is not sufficient to
   include <wmmintrin.h>

llvm-svn: 145939
2011-12-06 16:17:54 +00:00
Hans Wennborg 2fb8b91f6f Suggest typo corrections for implicit function declarations.
A mistyped function call becomes an inmplicit function declaration in C.
Suggest typo correction when one can be found.

llvm-svn: 145930
2011-12-06 09:46:12 +00:00
Erik Verbruggen c6c8d9356d Extend warnings for missing '@end'.
Fixes PR2709.

llvm-svn: 145928
2011-12-06 09:25:23 +00:00
Richard Trieu 5f623229ec Switch a cast to a dyn_cast and check the pointer before using. Fixes a crash
in the following code:

void test4(bool (&x)(void)) {
  while (x);
}

llvm-svn: 145918
2011-12-06 04:48:01 +00:00
Nick Lewycky 32275b9739 Fix test for unrelated changes.
llvm-svn: 145915
2011-12-06 03:46:28 +00:00
Nick Lewycky f4d3f7a0b9 Stack realignment is a tristate. Add -mno-stackrealign to turn off all stack
realignment, even with locals with alignment exceeding the ABI guarantee.

llvm-svn: 145909
2011-12-06 03:33:03 +00:00
John McCall e5e1b88bbc Fix an extremely stupid bug causing terrible miscompilations
of &= on pseudo-objects.

llvm-svn: 145904
2011-12-06 02:56:18 +00:00
Douglas Gregor a89c5ac4a6 Implement inferred submodules support, which (when requested)
implicitly generates submodules corresponding to the headers that fall
within a module.

llvm-svn: 145887
2011-12-06 01:10:29 +00:00
Eli Friedman 7c6515a653 Make sure we perform lvalue-to-rvalue conversions for enum initializers. PR11484.
llvm-svn: 145874
2011-12-06 00:10:34 +00:00
Fariborz Jahanian 56f326e7f2 objc: put out more coherent warning when method definition
attributes don't match its declaration. // rdar://10529259.

llvm-svn: 145872
2011-12-06 00:02:41 +00:00
Douglas Gregor 734410916a Parse inferred submodules in module maps, track their contents in
Module, and (de-)serialize this information. Semantics of inferred
submodules to follow.

llvm-svn: 145864
2011-12-05 22:27:44 +00:00
Eli Friedman 6d694a38fd Make EmitAggregateCopy take an alignment argument. Make EmitFinalDestCopy pass in the correct alignment when known.
The test includes a FIXME for a related case involving calls; it's a bit more complicated to fix because the RValue class doesn't keep track of alignment.

<rdar://problem/10463337>
  

llvm-svn: 145862
2011-12-05 22:23:28 +00:00
Anna Zaks d624f60a89 [analyzer] Simplify the expected-warning statement.
llvm-svn: 145855
2011-12-05 21:32:58 +00:00
Lang Hames df5c121f8e Add a warning for implicit conversion from function literals (and static
methods) to bool. E.g.

void foo() {}
if (f) { ... // <- Warns here.
}

Only applies to non-weak functions, and does not apply if the function address
is taken explicitly with the addr-of operator.

llvm-svn: 145849
2011-12-05 20:49:50 +00:00
Anna Zaks 004695b56e [analyzer] Add a missing taint tester warning.
llvm-svn: 145834
2011-12-05 18:58:33 +00:00
Anna Zaks a636fbe73f [analyzer] Remove all uses of ConstraintManager::canResonAbout() from
ExprEngine.

Teach SimpleConstraintManager::assumeSymRel() to propagate constraints
to symbolic expressions.

+ One extra warning (real bug) is now generated due to enhanced
assumeSymRel().

llvm-svn: 145832
2011-12-05 18:58:25 +00:00
Anna Zaks 1c215d0a11 [analyzer] Add a debug checker to test for tainted data.
llvm-svn: 145827
2011-12-05 18:58:01 +00:00
Douglas Gregor d8bd7537ec Inferred framework modules automatically export anything they import
(i.e., 'export *'), to better match the semantics of headers.

llvm-svn: 145813
2011-12-05 17:40:25 +00:00
Douglas Gregor f5eedd05db Implement support for wildcard exports in modules, allowing a module
to re-export anything that it imports. This opt-in feature makes a
module behave more like a header, because it can be used to re-export
the transitive closure of a (sub)module's dependencies.

llvm-svn: 145811
2011-12-05 17:28:06 +00:00
David Blaikie 15a430a368 Support decltype in nested-name-specifiers.
llvm-svn: 145785
2011-12-04 05:04:18 +00:00
Fariborz Jahanian 5c12ca8a25 Move block return type inference diagnostic to a common place where
Function or array lvalue conversions happens.

llvm-svn: 145782
2011-12-03 23:53:56 +00:00
Douglas Gregor fb9968d6f1 Fix mangling substitutions for address-space-qualified class
types. Patch from Dmitri Rubinstein!

llvm-svn: 145776
2011-12-03 18:24:43 +00:00
Douglas Gregor dca70af22f Implement support for the __is_final type trait, to determine whether
a class is marked 'final', from Alberto Ganesh Barbati! Fixes
PR11462.

llvm-svn: 145775
2011-12-03 18:14:24 +00:00
Fariborz Jahanian dd5eb9df0c If block literal return type is not specified, return type of the block is
inferred from return types. All the return statements have to agree about the type.
// rdar://10466373

llvm-svn: 145774
2011-12-03 17:47:53 +00:00
Francois Pichet 9c39113fdb In Microsoft mode, don't perform typo correction in a template member function dependent context because it interferes with the "lookup into dependent bases of class templates" feature.
Basically typo correction will try to offer a correction instead of looking into type dependent base classes.

I found this problem while parsing Microsoft ATL code with clang.

llvm-svn: 145772
2011-12-03 15:55:29 +00:00
Sebastian Redl df88864273 Implement overload resolution for reference-typed parameters supplied with initializer lists.
llvm-svn: 145769
2011-12-03 14:54:30 +00:00
Argyrios Kyrtzidis b2b0795c9f [PCH] Make sure that the SourceExpr of a OpaqueValueExpr is always initialized
when deserialized, fixing random crashes in libclang.

Also simplifies how OpaqueValueExprs are [de]serialized.
The reader/writer automatically retains pointer equality of sub-statements (when a
statement node is referenced in multiple nodes), so no need to manually handle it.

llvm-svn: 145752
2011-12-03 03:49:52 +00:00
Argyrios Kyrtzidis 0042b6f925 [libclang] Fix infinite loop when doing visitation of an OpaqueValueExpr.
llvm-svn: 145751
2011-12-03 03:49:47 +00:00
Argyrios Kyrtzidis 0fd8fae0a6 [libclang] Allow indexing/get-cursor/etc. for the exception variable in a C++ catch.
llvm-svn: 145750
2011-12-03 03:49:44 +00:00
Douglas Gregor 0a8391362e Implement support for precompiled headers, preambles, and serialized
"main" files that import modules. When loading any of these kinds of
AST files, we make the modules that were imported visible into the
translation unit that loaded the PCH file or preamble.

llvm-svn: 145737
2011-12-03 00:59:55 +00:00
Nick Lewycky 45ccba64ab Revert r145697 and dependent patch r145702. It added a dependency from
lib/Analysis to lib/Sema which is cyclical.

llvm-svn: 145724
2011-12-02 23:21:43 +00:00
Douglas Gregor 282d70c410 Add missing test header
llvm-svn: 145710
2011-12-02 21:59:41 +00:00
Douglas Gregor dac7f9a57e Only perform checking of the predefines buffer when loading a
precompiled header. Previously, we were trying to gather predefines
buffers from all kinds of AST files (which doesn't make sense) and
were performing some validation when AST files were loaded as main
files. 

With these tweaks, using PCH files that import modules no longer fails
immediately (due to mismatched predefines buffers). However, module
visibility is lost, so this feature does not yet work.

llvm-svn: 145709
2011-12-02 21:56:05 +00:00
Hans Wennborg 4d99c7a6dd Make r145697 actually work.
Use the canonical type of the typedef to compare with the underlying type.

llvm-svn: 145702
2011-12-02 20:32:01 +00:00
Douglas Gregor 2a5d14898a Make sure that name lookup in C checks whether a name is hidden.
llvm-svn: 145700
2011-12-02 20:08:44 +00:00
Hans Wennborg 70f7213d2c Make conversion specifier warning refer to typedef if possible.
For example, the warning for printf("%zu", 42.0);
changes from "conversion specifies type 'unsigned long'" to "conversion
specifies type 'size_t' (aka 'unsigned long')"

llvm-svn: 145697
2011-12-02 19:22:15 +00:00
Douglas Gregor 541392832f When making a module visible, also make any of its exported modules
visible, allowing one to create modules that import (and then
re-export) other modules.

llvm-svn: 145696
2011-12-02 19:11:09 +00:00
Douglas Gregor 7b8e4bc83f Implement name hiding for macro definitions within modules, such that
only the macro definitions from visible (sub)modules will actually be
visible. This provides the same behavior for macros that r145640
provided for declarations.

llvm-svn: 145683
2011-12-02 15:45:10 +00:00
Eli Friedman a91d38a435 Fix bitfield handling for record layout with #pragma pack. <rdar://problem/10494810> and PR9560.
llvm-svn: 145673
2011-12-02 02:38:48 +00:00
Eric Christopher af6431077c Add support for AVX registers to clang inline asm. Add a small testcase
and update the Sema testcase with a register that we won't hit for a while
I hope.

Fixes rdar://10510405

llvm-svn: 145671
2011-12-02 02:12:16 +00:00
Eric Christopher 5037249cc3 Clean up some oddly gratuitous vertical whitespace.
llvm-svn: 145670
2011-12-02 02:12:12 +00:00
Eric Christopher 86e6c07a0c Rename function.
llvm-svn: 145669
2011-12-02 02:12:09 +00:00
Douglas Gregor 2b82c2a59e Implementing parsing and resolution of module export declarations
within module maps, which will (eventually) be used to re-export a
module from another module. There are still some pieces missing,
however.

llvm-svn: 145665
2011-12-02 01:47:07 +00:00
Ted Kremenek 65cdbf58a7 Diagnose use of wide string literal in 'asm' instead of crashing. Fixes <rdar://problem/10465079>.
llvm-svn: 145656
2011-12-02 00:35:46 +00:00
Richard Smith d572f82e49 Fix wrong-code bug when a const automatic variable of struct type has both a
mutable member and a constant initializer. We'd previously promoted such
variables to global constants, resulting in nasal demons if the mutable member
was modified.

This is only a temporary fix. The subtle interplay between isConstantInitializer
and CGExprConstant is very bug-prone; there are some other issues in this area
which I will be addressing in subsequent, more major reworking of this code.

llvm-svn: 145654
2011-12-02 00:30:33 +00:00
Eli Friedman bfd5addf4c When we're passing a vector with an illegal type through memory on x86-64, use byval so we're sure the backend does the right thing. Fixes va_arg with illegal vectors and an obscure ABI mismatch with __m64 vectors.
llvm-svn: 145652
2011-12-02 00:11:43 +00:00
Douglas Gregor cf68c58afe Implement name hiding for declarations deserialized from a non-visible
module. When that module becomes visible, so do those declarations.

llvm-svn: 145640
2011-12-01 22:20:10 +00:00
Anna Zaks 719051e1c6 [analyzer] Make KeychainAPI checker less aggressive. radar://10508828
We trigger an error if free is called after a possibly failed allocation. Do not trigger the error if we know that the buffer is not null.

llvm-svn: 145584
2011-12-01 16:41:58 +00:00
Douglas Gregor 11bb308457 When typo-correction an Objective-C superclass name, don't
typo-correct to ourselves.

llvm-svn: 145583
2011-12-01 15:37:53 +00:00
Michael J. Spencer 0567b8ec58 Add Microsoft mangling of constructors and destructors. Patch by Dmitry!
llvm-svn: 145581
2011-12-01 09:55:00 +00:00
Francois Pichet d3b986df5d Change the Microsoft __interface keyword to be an alias for struct (not class) since members are public by default.
llvm-svn: 145580
2011-12-01 08:30:47 +00:00
Ted Kremenek dc6fb77d35 Fix typo.
llvm-svn: 145577
2011-12-01 07:39:23 +00:00
Ted Kremenek 24fc93a940 When analyzing a C++ method (without a specific caller), assume 'this' is non-null. Fixes <rdar://problem/10508787>.
llvm-svn: 145575
2011-12-01 05:29:42 +00:00
Eli Friedman f37bd2f2f1 Don't use a varargs convention for calls unprototyped functions where one of the arguments is an AVX vector.
llvm-svn: 145574
2011-12-01 04:53:19 +00:00
Douglas Gregor d8fb1e30eb When sending a message to a receiver that has "unknown any" type,
force the unknown any type to "id" so that the message send can be
completed without requiring a case. Fixes <rdar://problem/10506646>.

llvm-svn: 145552
2011-12-01 01:37:36 +00:00
Argyrios Kyrtzidis 79d0428046 ParmVarDecls have no linkage. Previously we would report that parameters
in type signatures have external linkage.

Fixes rdar://10058317.

llvm-svn: 145551
2011-12-01 01:28:21 +00:00
Ted Kremenek 764d63ad94 Specially whitelist the selector 'addOperationWithBlock:' for the retain-cycle checking in -Warc-retain-cycles. This commonly
is hit by users using NSOperationQueue.  Fixes <rdar://problem/10465721>.

llvm-svn: 145548
2011-12-01 00:59:21 +00:00
Ted Kremenek 85825aebc9 Further tweak -Wurneachable-code and templates by allowing the warning to run on
explicit template specializations (which represent actual functions somebody wrote).

Along the way, refactor some other code which similarly cares about whether or
not they are looking at a template instantiation.

llvm-svn: 145547
2011-12-01 00:59:17 +00:00
Eli Friedman 83a1258342 Fix MSVC class layout for empty classes. Patch by Dmitry Sokolov.
llvm-svn: 145544
2011-12-01 00:37:01 +00:00
Richard Smith b3041feaf7 Revert most of r145372 for now. Lookahead beyond the ';' in a function
declaration tickles a bug in the way we handle visibility pragmas.

The improvement to error recovery for template function definitions declared
with the 'typedef' specifier in r145372 is unrelated and not reverted here.

llvm-svn: 145541
2011-11-30 23:45:35 +00:00
Argyrios Kyrtzidis b9e53ed4e2 [PCH] In ASTReader::FinishedDeserializing, after we do PassInterestingDeclsToConsumer
we may end up having added more pending stuff to do, so go in a loop until everything
is cleared out.

This fixes the error in rdar://10278815 which has a certain David Lynch-esque quality..

  error: unknown type name 'BOOL'; did you mean 'BOOL'?

llvm-svn: 145536
2011-11-30 23:18:26 +00:00
Lang Hames d8bcb2b808 Test case for fix committed in r145441.
llvm-svn: 145534
2011-11-30 23:03:25 +00:00
Ted Kremenek f551f326fc Per an offline conversation with John McCall, have StmtPrinter actually print out the source expression for OpaqueValueExpr.
llvm-svn: 145524
2011-11-30 22:08:08 +00:00
Ted Kremenek 7f770032c7 Don't run -Wunreachable-code on template instantiations. Different instantiations may produce different unreachable code results, and it is very difficult for us to prove that ALL instantiations of a template have specific unreachable code. If we come up with a better solution, then we can revisit this, but this approach will at least greatly reduce the noise of this warning for code that makes use of templates.
llvm-svn: 145520
2011-11-30 21:22:09 +00:00
Douglas Gregor 41e115a81a Introduce an opt-in warning indicating when the compiler is treating
an #include/#import as a module import.

llvm-svn: 145500
2011-11-30 18:02:36 +00:00
Douglas Gregor 36b7f115e4 Add preprocessor-only test for submodule imports
llvm-svn: 145490
2011-11-30 14:57:39 +00:00
John McCall e929082806 Fix the instantiation of pseudo-object expressions. This is a
really bad way to go about this, but I'm not sure there's a better
choice without substantial changes to TreeTransform --- most
notably, preserving implicit semantic nodes instead of discarding
and rebuilding them.

llvm-svn: 145480
2011-11-30 04:42:31 +00:00
Douglas Gregor 5196bc6b39 When loading a module that involves submodules (e.g., std.vector),
check whether the named submodules themselves are actually
valid, and drill down to the named submodule (although we don't do
anything with it yet). Perform typo correction on the submodule names
when possible.

llvm-svn: 145477
2011-11-30 04:03:44 +00:00
Eric Christopher 607fb70750 Make sure that forward declarations are marked as such in the debug info
for the structure type.

rdar://10499337

llvm-svn: 145461
2011-11-29 23:57:40 +00:00
Richard Smith 507840dbff Revert r145244. It causes us to create broken ASTs with missing type information
for some cast expressions.

Original commit message:

Removed useless ImplicitCast nodes in explicit cstyle and static casts

llvm-svn: 145447
2011-11-29 22:48:16 +00:00
Matt Beaumont-Gay c93b489138 Suppress -Warray-bounds for classes (not just structs) where the last field is
a 1-length character array.

llvm-svn: 145445
2011-11-29 22:43:53 +00:00
Douglas Gregor 70db54f18d Eliminate the -emit-module option, which emitted a module by parsing a
source file (e.g., a header). Immediately steal this useful option
name for building modules from a module map file.

llvm-svn: 145444
2011-11-29 22:42:06 +00:00
Ted Kremenek cfe4ff9725 Relax RegionStore to allow loads from CodeTextRegions. Apparently you can actually write code that does this. This seems worthy of a checker, but the StoreManager should handle the memory abstraction without crashing. Fixes PR 11450.
llvm-svn: 145424
2011-11-29 19:39:29 +00:00
Matt Beaumont-Gay b2339826e6 Merge branch 'yo-dawg-i-herd-u-like-arrays'
llvm-svn: 145421
2011-11-29 19:27:11 +00:00
Ted Kremenek 7623347f83 Place "use @dynamic or provide a method implementation" warnings under a -W flag.
llvm-svn: 145418
2011-11-29 19:18:47 +00:00
Douglas Gregor 514b636ada Teach the module import mechanism how to rebuild modules expressed via
module map, rather than assuming that there is an umbrella
header. This allows us to automatically build umbrella-less modules. 

llvm-svn: 145415
2011-11-29 19:06:37 +00:00
Richard Smith 53711607a0 Add fix-it to remove 'typedef' from function template definitions. Such a token
was probably meant to be 'typename', which we will have already suggested if it
is appropriate.

llvm-svn: 145395
2011-11-29 09:09:06 +00:00
Argyrios Kyrtzidis c36d6a1696 [libclang] Make the test portable.
llvm-svn: 145377
2011-11-29 05:48:01 +00:00
Richard Smith 675ea99a2a PR10101: Recover better from a common copy-paste error: if a function
declaration at namespace scope is followed by a semicolon and an open-brace
(or in C++, a 'try', ':' or '='), then the error is probably a function
definition with a spurious ';', rather than a mysterious '{'.

llvm-svn: 145372
2011-11-29 05:27:40 +00:00
Argyrios Kyrtzidis 1ddb97ec86 [libclang] Make clang_findReferencesInFile also work on macros (find all expansions/definition
of a macro in a file).

As a bonus, also make searching for declarations more efficient by ignoring
preprocessing entities when we know that we are looking for a declaration.

Fixes rdar://10427411.

llvm-svn: 145369
2011-11-29 03:14:11 +00:00
Fariborz Jahanian a45495a9f2 objc: warn if NSObject attribute appears other than in a typedef.
// rdar://10453342

llvm-svn: 145358
2011-11-29 01:48:40 +00:00
Ted Kremenek 6cdff0a82b Fix serialized diagnostics to handle FixIts that only remove text. Fixes <rdar://problem/10473903>.
llvm-svn: 145339
2011-11-29 00:30:52 +00:00
Tanya Lattner 71f1b2dcd4 Correct the code generation for function arguments of vec3 types on x86_64 when they are greater than 128 bits. This was incorrectly coercing things like long3 into a double2.
Add test case.

llvm-svn: 145312
2011-11-28 23:18:11 +00:00
Anna Zaks ff029b6953 [analyzer] Add more simple taint tests.
llvm-svn: 145275
2011-11-28 20:43:40 +00:00
Douglas Gregor 7db3e95b0d When synthesizing an implicitly-defined copy or move constructor, or
when computing the exception specification of a copy or move constructor,
ignore non-static data member initializers. Fixes PR11418 /
<rdar://problem/10478642>.

llvm-svn: 145269
2011-11-28 20:03:15 +00:00
Fariborz Jahanian 25d09c2209 pinpoint name/location of deprecated/unavailable enumerator
whose enum has been made deprecated/unavailable in the warning.
// rdar://10201690

llvm-svn: 145264
2011-11-28 19:45:58 +00:00
Fariborz Jahanian 22b405c7aa objc: turn warning for property type mismatch in
primary and its continuation class into error.
// rdar://10142679

llvm-svn: 145255
2011-11-28 18:38:27 +00:00
Douglas Gregor 7372248a98 When checking a call to a builtin atomic operation, be sure to
consider the _<width> variants as well, which we'll see if we're
performing the type checking in a template instantiation where the
call expression itself was originally not type-dependent. Fixes
PR11411.

llvm-svn: 145248
2011-11-28 16:30:08 +00:00
Nicola Gigante 13b6a2ae04 Removed useless ImplicitCast nodes in explicit cstyle and static casts
llvm-svn: 145244
2011-11-28 12:21:57 +00:00
NAKAMURA Takumi cd9c3d6647 test/lit.cfg: Enhance getRegisteredTargets() to retrieve +Asserts.
- s/getRegisteredTargets/get_llc_props/g
  - get_llc_props() returns dict {"set_of_targets", "enable_assertions"}
  - Enable the feature "asserts".
    test/Driver/darwin-verify-debug.c had expected it.

llvm-svn: 145231
2011-11-28 05:09:42 +00:00
Argyrios Kyrtzidis eca1f36a54 [arcmt] Integrate GC __weak into property attributes even when we don't have
the implementation.

llvm-svn: 145224
2011-11-28 02:04:36 +00:00
Argyrios Kyrtzidis 3fc3dcd80f [arcmt] Don't add __weak if there is already a GC __weak and make sure to clear
__weak from a readonly property.

llvm-svn: 145210
2011-11-28 00:23:12 +00:00
Peter Collingbourne fbef4c8657 In Sema::MaybeBindToTemporary, create a CXXBindTemporaryExpr for an
array of objects with non-trivial destructors.  PR11365.

llvm-svn: 145203
2011-11-27 22:09:28 +00:00
Rafael Espindola a6416a7c73 Make our handling of MMX x SSE closer to what gcc does:
* Enabling sse enables mmx.
* Disabling (-mno-mmx) mmx, doesn't disable sse (we got this right already).
* The order in not important. -msse -mno-mmx is the same as -mno-mmx -msse.

llvm-svn: 145194
2011-11-27 20:00:43 +00:00
Rafael Espindola 32d8a275b9 Add inreg attributes to reference arguments.
llvm-svn: 145189
2011-11-27 18:35:39 +00:00
Sebastian Redl 29526f09ce Reference initialization with initializer lists.
This supports single-element initializer lists for references according to DR1288, as well as creating temporaries and binding to them for other initializer lists.

llvm-svn: 145186
2011-11-27 16:50:07 +00:00
Rafael Espindola 04268df8ed Set __OPTIMIZE_SIZE__ on -Os and -Oz. This matches gcc's behaviour on both OS X
and linux.

llvm-svn: 145142
2011-11-26 06:21:20 +00:00
Francois Pichet de232cb166 In Microsoft mode, make "Unqualified lookup into dependent bases of class templates" works inside a friend function definition at class scope.
Basically we have to look into the parent *lexical* DeclContext for friend functions at class scope. That's because calling GetParent() return the namespace or file DeclContext.

This fixes all remaining cases of "Unqualified lookup into dependent bases of class templates" when parsing MFC code with clang.

llvm-svn: 145127
2011-11-25 01:10:54 +00:00
Matt Beaumont-Gay 63be19122e Wordsmith the -Warray-bounds diagnostic text a bit
llvm-svn: 145116
2011-11-24 00:27:38 +00:00
Richard Trieu caff247882 Add feature to diagnostics that will provide more information on function
pointer mismatch.  Cases covered are: initialization, assignment, and function
arguments.  Additional text will give the extra information about the nature
of the mismatch: different classes for member functions, wrong number of
parameters, different parameter type, different return type, and function
qualifier mismatch.

llvm-svn: 145114
2011-11-23 22:32:32 +00:00
Argyrios Kyrtzidis a72450057b [PCH] Check for isTopLevelDeclInObjCContainer when picking abbreviations.
llvm-svn: 145110
2011-11-23 21:11:23 +00:00
Argyrios Kyrtzidis 8ad3bab505 [libclang] Fix operations (token annotation, getting cursor, etc.) with a file region
inside an objc container that "contains" other file-level declarations.

When getting the array of file-level declarations that overlap with a file region,
we failed to report that the region overlaps with an objc container, if
the container had other file-level declarations declared lexically inside it.

Fix this by marking such declarations as "isTopLevelDeclInObjCContainer" in the AST
and handling them appropriately.

llvm-svn: 145109
2011-11-23 20:27:36 +00:00
James Molloy c445be4b4b AAPCS compliance - 32-bit wchar_t should be unsigned for both aapcs and aapcs-linux.
Original behaviour of defining wchar_t as signed int has been kept for apcs-gnu as I don't have any spec for this to validate against.

llvm-svn: 145102
2011-11-23 13:35:08 +00:00
Richard Smith 514f7e9cb9 Don't check alignment, it's irrelevant to this test.
llvm-svn: 145093
2011-11-23 02:12:00 +00:00
Richard Smith 2d988f0f05 Use static storage duration for file-scope compound literals, even when they
appear in non-constant initializers in C++.

llvm-svn: 145087
2011-11-22 22:48:32 +00:00
Kostya Serebryany c3333e879f implement __has_feature(address_sanitizer); also use LangOpts.AddressSanitizer instead of CodeGenOpts.AddressSanitizer
llvm-svn: 145054
2011-11-22 01:28:36 +00:00
Peter Collingbourne 6e6e52b58a Un-XFAIL this test on Darwin, it reportedly passes now.
llvm-svn: 145052
2011-11-21 21:56:51 +00:00
Richard Smith 9a56882e53 Add driver arguments -ftemplate-depth=N and -fconstexpr-depth=N, with the same
semantics and defaults as the corresponding g++ arguments. The historical g++
argument -ftemplate-depth-N is kept for compatibility, but modern g++ versions
no longer document that option.

Add -cc1 argument -fconstexpr-depth N to implement the corresponding
functionality.

The -ftemplate-depth=N part of this fixes PR9890.

llvm-svn: 145045
2011-11-21 19:36:32 +00:00
Peter Collingbourne 0e7e3fc130 Delete the depfile if we could not open a header file. We cannot
generate any reasonable depfile if a header is missing.

llvm-svn: 145019
2011-11-21 00:01:14 +00:00
Peter Collingbourne 119cfaa595 Teach the driver about failure result files, which are compilation
output files that are valid regardless of whether the compilation
succeeded or failed (but not if we crash).  Add depfiles to the
failure result file list.

llvm-svn: 145018
2011-11-21 00:01:05 +00:00
Benjamin Kramer ddbb2b85ab CodeGen: allow __asm renaming on static local variables.
Fixes PR4777.

llvm-svn: 145015
2011-11-20 21:05:04 +00:00
Francois Pichet 6dc4c16417 Enable delayed template parsing for friend functions declared at template class scope.
llvm-svn: 144980
2011-11-18 23:47:17 +00:00
Eli Friedman f22fa9eaef Finish r144971, which was an incomplete commit.
llvm-svn: 144972
2011-11-18 04:01:36 +00:00
Eli Friedman 0b3f201b61 Fix the meaning of an "empty" record for the case of a zero-length array. Use isEmptyRecord for arguments on x86-32; there are structs of size 0 which don't count as empty.
llvm-svn: 144971
2011-11-18 03:47:20 +00:00
Eli Friedman a1748564b4 Make va_arg on x86-64 compute alignment the same way as argument passing.
Fixes <rdar://problem/10463281>.

llvm-svn: 144966
2011-11-18 02:44:19 +00:00
Anna Zaks 457c68726c [analyzer] Warn when non pointer arguments are passed to scanf (only when running taint checker).
There is an open radar to implement better scanf checking as a Sema warning. However, a bit of redundancy is fine in this case.

llvm-svn: 144964
2011-11-18 02:26:36 +00:00
Eli Friedman 1d7dd3b682 A bunch of fixes to argument passing and va_arg on Darwin x86-32 for structures containing an SSE vector.
llvm-svn: 144963
2011-11-18 02:12:09 +00:00
Eli Friedman e5c85622c9 Don't try to expand struct arguments containing holes on x86-32. From gcc struct layout tests.
llvm-svn: 144961
2011-11-18 01:32:26 +00:00
Eli Friedman ee94534662 Simplify code for returning a struct for Darwin x86-32 ABI. Use a better type for a function returning a struct containing only a pointer. Handle the edge case of a struct containing only a float or double plus some dead padding instead of asserting.
llvm-svn: 144960
2011-11-18 01:25:50 +00:00
Anna Zaks 1df54a8bc8 [analyzer] The compiler warning was disabling the analyzer in this test.
llvm-svn: 144946
2011-11-18 00:45:20 +00:00
Eli Friedman 9f061a37bb Ignore empty unions in argument lowering on x86-32. From gcc struct layout tests.
llvm-svn: 144944
2011-11-18 00:28:11 +00:00
Anna Zaks 040ddfedc0 [analyzer] Do not conjure a symbol when we need to propagate taint.
When the solver and SValBuilder cannot reason about symbolic expressions (ex: (x+1)*y ), the analyzer conjures a new symbol with no ties to the past. This helps it to recover some path-sensitivity. However, this breaks the taint propagation.

With this commit, we are going to construct the expression even if we cannot reason about it later on if an operand is tainted.

Also added some comments and asserts.

llvm-svn: 144932
2011-11-17 23:07:28 +00:00
Richard Smith 027bf11eb3 Constant expression evaluation: add support for evaluation of member pointers
and base-to-derived casts, and add proper handling of temporaries.

llvm-svn: 144926
2011-11-17 22:56:20 +00:00
Douglas Gregor 755b205519 Add the notion of "framework" modules to module maps. Framework
modules (obviously) describe frameworks, and understand the header
layout of frameworks.

llvm-svn: 144921
2011-11-17 22:09:43 +00:00
NAKAMURA Takumi 5dd3777633 test/Frontend/dependency-gen.c: Relax expressions for Win32 host (mingw msys).
llvm-svn: 144887
2011-11-17 07:21:33 +00:00
David Blaikie 0f65d59e52 Include named unions in union member init checking
llvm-svn: 144883
2011-11-17 06:01:57 +00:00
Francois Pichet 857f9d6e5e In Microsoft mode, make "Unqualified lookup into dependent bases of class templates" works inside default argument instantiation.
This is a little bit tricky because during default argument instantiation the CurContext points to a CXXMethodDecl but we can't use the keyword this or have an implicit member call generated.

This fixes 2 errors when parsing MFC code with clang.

llvm-svn: 144881
2011-11-17 03:44:24 +00:00
Douglas Gregor 56c6401306 When we're loading a framework header, first try to turn the framework
into a module. This module can either be loaded from a module map in
the framework directory (which isn't quite working yet) or inferred
from an umbrella header (which does work, and replaces the existing
hack).

llvm-svn: 144877
2011-11-17 01:41:17 +00:00
Daniel Dunbar e285a7d3f0 tests/Driver/darwin-ld.c: Get rid of the "splatter" test case. We have enough
other coverage that actually properly checks features such that this test is not
really adding value anymore.

llvm-svn: 144868
2011-11-17 00:36:53 +00:00
Douglas Gregor b2ac5517b5 Add missing header for modules test.
llvm-svn: 144862
2011-11-16 23:41:39 +00:00
Douglas Gregor b65dbfff52 A module with an umbrella header assumes that all of the headers in
the umbrella header's directory and its subdirectories are part of the
module (that's why it's an umbrella). Make sure that these headers are
considered to be part of the module for lookup purposes.

llvm-svn: 144859
2011-11-16 23:02:25 +00:00
Abramo Bagnara b0cf297654 Added missing ImplicitCastExpr around conversion operator call.
llvm-svn: 144850
2011-11-16 22:46:05 +00:00
Jim Goodnow II 8d21fc8239 Fixed crash with initializer lists and unnamed bitfields in the RegionStore
Manager. Added test to ensure proper binding of initialized values.
This patch fixes PR11249.

llvm-svn: 144831
2011-11-16 20:29:27 +00:00
Douglas Gregor 9dc3212f98 Implement (de-)serialization of the buffer contents for an overridden
file in the source manager. This allows us to properly create and use
modules described by module map files without umbrella headers (or
with incompletely umbrella headers). More generally, we can actually
build a PCH file that makes use of  file -> buffer remappings, which
could be useful in libclang in the future.

llvm-svn: 144830
2011-11-16 20:05:18 +00:00
Anna Zaks 20829c90be [analyzer] Catch the first taint propagation implied buffer overflow.
Change the ArrayBoundCheckerV2 to be more aggressive in reporting buffer overflows
when the offset is tainted. Previously, we did not report bugs when the state was
underconstrained (not enough information about the bound to determine if there is
an overflow) to avoid false positives. However, if we know that the buffer
offset is tainted - comes in from the user space and can be anything, we should
report it as a bug.

+ The very first example of us catching a taint related bug.
This is the only example we can currently handle. More to come...

llvm-svn: 144826
2011-11-16 19:58:17 +00:00
Richard Smith 10f4d06b81 PR11391: Don't try to evaluate the LHS of a _Complex assignment as an rvalue.
llvm-svn: 144799
2011-11-16 17:22:48 +00:00
Douglas Gregor 4332b32c5e When building a module from a module map that isn't simply an umbrella
header, create our own in-memory buffer to parse all of the
appropriate headers, and use that to build the module. This isn't
end-to-end testable yet; that's coming next.

llvm-svn: 144797
2011-11-16 17:04:00 +00:00
Douglas Gregor 4ba7c2abc2 Switch the remaining modules tests over to -emit-module-from-map.
llvm-svn: 144795
2011-11-16 15:22:03 +00:00
Argyrios Kyrtzidis 463741a5a2 [libclang] Make clang_annotateTokens use "file-targeted" deserialization and avoid
unnecessary deserializations.

llvm-svn: 144792
2011-11-16 08:58:57 +00:00
Argyrios Kyrtzidis c504eb3448 [libclang] Make clang_findReferencesInFile use "file-targeted" deserialization and avoid
unnecessary deserializations.

llvm-svn: 144791
2011-11-16 08:58:54 +00:00
Richard Smith cf74da76db Fix PR11385: A pointer constant expression which has been cast via an integer is
not safely derived. Don't allow lvalue-to-rvalue conversions on the result of
dereferencing such a pointer.

llvm-svn: 144783
2011-11-16 07:18:12 +00:00