Douglas Gregor [Fri, 18 Jan 2013 04:34:14 +0000 (04:34 +0000)]
Revert Clang r172620 and r172629, which caused a hang when building
complicated modules (<rdar://problem/13038265>). Unfortunately, this
un-fixes <rdar://problem/13016031>.
Douglas Gregor [Fri, 18 Jan 2013 01:41:40 +0000 (01:41 +0000)]
When checking the parameter types of an Objective-C method, don't
decay the parameter type immediately; let CheckParameter() do its
job. Fixes <rdar://problem/12071218>.
Douglas Gregor [Thu, 17 Jan 2013 23:59:28 +0000 (23:59 +0000)]
One can override an Objective-C ARC ownership qualifier that came from
a template parameter; make that also include one that came from
'auto'. Fixes <rdar://problem/12078752>.
Douglas Gregor [Thu, 17 Jan 2013 23:36:45 +0000 (23:36 +0000)]
In Objective-C ARC, completely ignore ownership qualifiers on the
return type of a function by canonicalizing them away. They are
useless anyway, and conflict with our rules for template argument
deduction and __strong. Fixes <rdar://problem/12367446>.
Richard Smith [Thu, 17 Jan 2013 22:06:26 +0000 (22:06 +0000)]
-Wunsequenced: if the LHS of an &&, || or ?: is not constant, check for
unsequenced operations in the RHS. We don't compare the RHS with the rest of
the expression yet; such checks will need care to avoid diagnosing unsequenced
operations which are both in conditionally-evaluated subexpressions which
actually can't occur together, such as in '(b && ++x) + (!b && ++x)'.
Kevin Enderby [Thu, 17 Jan 2013 21:38:06 +0000 (21:38 +0000)]
We want the dwarf AT_producer for assembly source files to match clang's
AT_producer. Which includes clang's version information so we can tell
which version of the compiler was used.
This is second of the two steps to allow us to do this. The first was a
change to llvm-mc with revision 172630 to provide a method to set the
AT_producer string. This second step has the clang driver passing the value
of getClangFullVersion() via the new flag -dwarf-debug-producer when invoking
the integrated assembler on assembly source files. Then using the new
setDwarfDebugProducer() method to set the AT_producer string.
Do not pass -pie flag to linker if -shared specified. This matches
the gcc driver and makes it possible to add -pie to $CC or similar and
have it apply in the right places.
Nico Weber [Thu, 17 Jan 2013 17:17:19 +0000 (17:17 +0000)]
Formatter: Get bit tests in ifs right.
It's generally not possible to know if 'a' '*' 'b' is a multiplication
expression or a variable declaration with a purely lexer-based approach. The
formatter currently uses a heuristic that classifies this token sequence as a
multiplication in rhs contexts (after '=' or 'return') and as a declaration
else.
Because of this, it gets bit tests in ifs, such as "if (a & b)" wrong. However,
declarations in ifs always have to be followed by '=', so this patch changes
the formatter to classify '&' as an operator if it's at the start of an if
statement.
Chandler Carruth [Thu, 17 Jan 2013 13:19:29 +0000 (13:19 +0000)]
Add initial rough support for synthesizing linker options when passed
-fopenmp in the link step on Linux. There is probably more tweaking that
will need to take place to get good support for linking the relevant
libraries on all Linux distributions and/or on other platforms, but this
get's the ball moving and allows Clang to build programs which contain
OpenMP pragmas that can be safely ignored by a compiler that doesn't
implement them, and yet makes direct calls into the OpenMP runtime.
Nico Weber [Thu, 17 Jan 2013 06:14:50 +0000 (06:14 +0000)]
Revert most of r172140.
r172140 changed the formatter to produce "-(id) foo" instead of "- (id)foo"
in google style, with a link to
http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml#Method_Declarations_and_Definitions
as reference. But now that I look at that link again, it seems I didn't
read it very carefully the first time round.
Suppress all -Wunused-value warnings from macro body expansions.
This is inspired by a number of false positives in real code, including
PR14968. I've added test cases reduced from these false positives to
test/Sema/unused-expr.c, as well as corresponding test cases that pass the
offending expressions as arguments to a no-op macro to ensure that we do warn
there.
This also removes my previous tweak from r166522/r166534, so that we warn on
unused cast expressions in macro arguments.
There were several test cases that were using -Wunused-value to test general
diagnostic emission features; I changed those to use other warnings or warn on
a macro argument expression. I stared at the test case for PR14399 for a while
with Richard Smith and we believe the new test case exercises the same
codepaths as before.
Richard Smith [Thu, 17 Jan 2013 01:30:42 +0000 (01:30 +0000)]
Implement C++11 semantics for [[noreturn]] attribute. This required splitting
it apart from [[gnu::noreturn]] / __attribute__((noreturn)), since their
semantics are not equivalent (for instance, we treat [[gnu::noreturn]] as
affecting the function type, whereas [[noreturn]] does not).
Richard Smith [Thu, 17 Jan 2013 01:17:56 +0000 (01:17 +0000)]
Add -Wunsequenced (with compatibility alias -Wsequence-point) to warn on
expressions which have undefined behavior due to multiple unsequenced
modifications or an unsequenced modification and use of a variable.
Douglas Gregor [Thu, 17 Jan 2013 00:38:46 +0000 (00:38 +0000)]
Treat hidden Objective-C protocol definitions as if they were
undefined, and don't find methods or protocols within those protocol
definitions. This completes <rdar://problem/10634711>.
Rafael Espindola [Wed, 16 Jan 2013 23:11:15 +0000 (23:11 +0000)]
Check for internal weak decls after merging.
This fixes pr14946. The problem was that the linkage computation was done too
early, so things like "extern int a;" would be given external linkage, even if
a previous declaration was static.
David Blaikie [Wed, 16 Jan 2013 23:08:36 +0000 (23:08 +0000)]
PR14964: intrinsic headers using non-reserved identifiers
Several of the intrinsic headers were using plain non-reserved identifiers.
C++11 17.6.4.3.2 [global.names] p1 reservers names containing a double
begining with an underscore followed by an uppercase letter for any use.
I think I got them all, but open to being corrected. For the most part I
didn't bother updating function-like macro parameter names because I don't
believe they're subject to any such collission - though some function-like
macros already follow this convention (I didn't update them in part because
the churn was more significant as several function-like macros use the double
underscore prefixed version of the same name as a parameter in their
implementation)
Douglas Gregor [Wed, 16 Jan 2013 23:00:23 +0000 (23:00 +0000)]
Rework the traversal of Objective-C categories and extensions to
consider (sub)module visibility.
The bulk of this change replaces myriad hand-rolled loops over the
linked list of Objective-C categories/extensions attached to an
interface declaration with loops using one of the four new category
iterator kinds:
visible_categories_iterator: Iterates over all visible categories
and extensions, hiding any that have their "hidden" bit set. This is
by far the most commonly used iterator.
known_categories_iterator: Iterates over all categories and
extensions, ignoring the "hidden" bit. This tends to be used for
redeclaration-like traversals.
visible_extensions_iterator: Iterates over all visible extensions,
hiding any that have their "hidden" bit set.
known_extensions_iterator: Iterates over all extensions, whether
they are visible to normal name lookup or not.
The effect of this change is that any uses of the visible_ iterators
will respect module-import visibility. See the new tests for examples.
Note that the old accessors for categories and extensions are gone;
there are *Raw() forms for some of them, for those (few) areas of the
compiler that have to manipulate the linked list of categories
directly. This is generally discouraged.
Douglas Gregor [Wed, 16 Jan 2013 18:47:38 +0000 (18:47 +0000)]
Teach global selector lookup to ignore hidden methods, which occur
when the methods are declared in a submodule that has not yet been
imported. Part of <rdar://problem/10634711>.
[PCH/Modules] The iterator may become invalidated because a new macro can be added
while deserializing a macro, make sure to copy/move what we need from it.
Due to an l_paren being followed by a colon, we assumed it to be part of
a constructor initializer. Thus, we never found the colon belonging to
the conditional expression, marked the line as bing incorrect and did
not format it.
[PCH/Modules] Change how macro [re]definitions are de/serialized.
Previously we would serialize the macro redefinitions as a list, part of
the identifier, and try to chain them together across modules individually
without having the info that they were already chained at definition time.
Change this by serializing the macro redefinition chain and then try
to synthesize the chain parts across modules. This allows us to correctly
pinpoint when 2 different definitions are ambiguous because they came from
unrelated modules.
Fixes bogus "ambiguous expansion of macro" warning when a macro in a PCH
is redefined without undef'ing it first.
Daniel Jasper [Wed, 16 Jan 2013 14:59:02 +0000 (14:59 +0000)]
Add option to avoid "bin-packing" of parameters.
"Bin-packing" here means allowing multiple parameters on one line, if a
function call/declaration is spread over multiple lines.
This is required by the Chromium style guide and probably desired for
the Google style guide. Not making changes to LLVM style as I don't have
enough data.
Manuel Klimek [Wed, 16 Jan 2013 12:31:12 +0000 (12:31 +0000)]
Use standard llvm Debug.h support for debugging output.
Leave a quick "// Uncomment this." hint to enable the debug output in
tests. FIXME: figure out whether we want to enable debug command line
handling for all tests.
Daniel Jasper [Wed, 16 Jan 2013 09:10:19 +0000 (09:10 +0000)]
Change the datastructure for UnwrappedLines.
It was quite convoluted leading to us accidentally introducing O(N^2)
complexity while copying from UnwrappedLine to AnnotatedLine. We might
still want to improve the datastructure in AnnotatedLine (most
importantly not put them in a vector where they need to be copied on
vector resizing but that will be done as a follow-up.
This fixes most of the regression in llvm.org/PR14959.
Douglas Gregor [Wed, 16 Jan 2013 00:52:15 +0000 (00:52 +0000)]
Apply adjustment to function- and array-typed non-type template
parameters (per C++ [temp.param]p8) when computing the type of a
reference to a non-type template parameter. Fixes <rdar://problem/13000548>.
Douglas Gregor [Tue, 15 Jan 2013 22:43:08 +0000 (22:43 +0000)]
When checking availability attributes for consistency between an
overriding and overridden method, allow the overridden method to have
a narrower contract (introduced earlier, deprecated/obsoleted later)
than the overriding method. Fixes <rdar://problem/12992023>.