Douglas Gregor [Mon, 14 Jan 2013 20:53:57 +0000 (20:53 +0000)]
Topologically sort the link options generated for modules based on
module-import dependencies, so we'll get the link order correct for
those silly linkers that need it.
Jordan Rose [Mon, 14 Jan 2013 18:58:33 +0000 (18:58 +0000)]
[analyzer] -drain is not an alias for -release.
This was previously added to support -[NSAutoreleasePool drain], which
behaves like -release under non-GC and "please collect" under GC. We're
not currently modeling the autorelease pool stack, though, so we can
just take this out entirely.
This conceptually moves the logic for figuring out the syntax the
linker will accept from LLVM into Clang. Moreover, it makes it easier
to support MSVC's
Douglas Gregor [Mon, 14 Jan 2013 17:57:51 +0000 (17:57 +0000)]
Infer "link" lines for top-level frameworks. Essentially, a framework
will have a shared library with the same name as its framework (and no
suffix!) within its .framework directory. Detect this both when
inferring the whole top-level framework and when parsing a module map.
Bill Schmidt [Mon, 14 Jan 2013 17:45:36 +0000 (17:45 +0000)]
This patch addresses varargs processing for small complex types under
the 64-bit PowerPC ELF ABI.
The ABI requires that the real and imaginary parts of a complex argument
each occupy their own doubleword. Arguments smaller than 8 bytes are
right-adjusted within the doubleword.
Clang expects EmitVAARG() to return a pointer to a structure in which
the real and imaginary parts are packed adjacently in memory. To accomplish
this, we generate code to load the code appropriately from the varargs
location and pack the values into a temporary variable in the form Clang
expects, returning a pointer to that structure.
The test case demonstrates correct code generation for all "small" complex
types on PPC64: int, short, char, and float.
Douglas Gregor [Mon, 14 Jan 2013 17:21:00 +0000 (17:21 +0000)]
Implement parsing, AST, (de-)serialization, and placeholder global
metadata for linking against the libraries/frameworks for imported
modules.
The module map language is extended with a new "link" directive that
specifies what library or framework to link against when a module is
imported, e.g.,
link "clangAST"
or
link framework "MyFramework"
Importing the corresponding module (or any of its submodules) will
eventually link against the named library/framework.
For now, I've added some placeholder global metadata that encodes the
imported libraries/frameworks, so that we can test that this
information gets through to the IR. The format of the data is still
under discussion.
Manuel Klimek [Mon, 14 Jan 2013 16:41:43 +0000 (16:41 +0000)]
Fixes formatting of nested brace initializers.
We now format this correctly:
Status::Rep Status::global_reps[3] = {
{ kGlobalRef, OK_CODE, NULL, NULL, NULL },
{ kGlobalRef, CANCELLED_CODE, NULL, NULL, NULL },
{ kGlobalRef, UNKNOWN_CODE, NULL, NULL, NULL }
};
- fixed a bug where BreakBeforeClosingBrace would be set on the wrong
state
- added penalties for breaking between = and {, and between { and any
other non-{ token
Dump comments in -ast-dump.
http://llvm-reviews.chandlerc.com/D269
"Added dumping of declaration comments in ASTDumper. This required moving the
comment dumping code from CommentDumper so that the indentation is correct."
Daniel Jasper [Mon, 14 Jan 2013 13:08:07 +0000 (13:08 +0000)]
Refactor datastructure used in clang-format.
Main difference, add an AnnotatedLine class to hold information about a
line while formatting. At the same time degrade the UnwrappedLine class
to a class solely used for communicating between the UnwrappedLineParser
and the Formatter.
Richard Smith [Mon, 14 Jan 2013 08:00:39 +0000 (08:00 +0000)]
Fix regression in r172376. Don't try to detect missing 'constexpr' specifiers
on redeclarations, since that makes us pick wrong prior declarations under
some circumstances.
Richard Smith [Mon, 14 Jan 2013 07:53:01 +0000 (07:53 +0000)]
Accept [[gnu::*]] for all __attribute__((*))s which are:
1) Supported by Clang, and
2) Supported by GCC, and
3) Documented in GCC's manual.
g++ allows its C++11-style attributes to appertain only to the entity being
declared, and never to a type (even for a type attribute), so we do the same.
Nico Weber [Mon, 14 Jan 2013 05:49:49 +0000 (05:49 +0000)]
Formatter: Add a test for bitfields.
They work fine, but this fifth use of colons (after labels, in ?:,
in initalizer lists in constructors, in objc method expressions, and in
bitfields) wasn't covered by tests yet.
Daniel Jasper [Sun, 13 Jan 2013 16:10:20 +0000 (16:10 +0000)]
Stronger respect the input codes line breaks wrt. comments.
clang-format should not change whether or not there is a line break
before a line comment as this strongly influences the percieved binding.
User input: void f(int a,
// b is awesome
int b);
void g(int a, // a is awesome
int b);
Before: void f(int a, // b is awesome
int b);
void g(int a, // a is awesome
int b);
After: <unchanged from input>
Daniel Jasper [Sun, 13 Jan 2013 14:39:04 +0000 (14:39 +0000)]
Format unions like structs and classes.
Note that I don't know whether we should put {} on a single line in this
case, but it is probably a theoretical issue as in practice such
structs, classes or unions won't be empty.
Chandler Carruth [Sun, 13 Jan 2013 11:46:33 +0000 (11:46 +0000)]
Refactor the x86 CPU name logic in the driver and pass -march and -mcpu
flag information down from the Clang driver into the Gold linker plugin
for LTO. This allows specifying -march on the linker commandline and
should hopefully have it pass all the way through to the LTO optimizer.
Nico Weber [Sat, 12 Jan 2013 07:05:25 +0000 (07:05 +0000)]
Formatter: Remove an always-false condition.
canBreakBefore() does not allow breaking after ':' for LT_ObjCMethodDecl lines,
so if Newline is true in addTokenToState() for ':' then LT_ObjCMethodDecl
cannot be set. No functionality change.
Rafael Espindola [Sat, 12 Jan 2013 06:42:30 +0000 (06:42 +0000)]
Disable caching of visibility.
The testcase in pr14929 shows that this is extremely hard to do. If we choose
to apply the attribute, that causes the visibility of some decls to change and
that can happen really late (during codegen).
Current gcc warns and ignores the attribute in this testcase with a warning.
This suggest that the correct solution is to find a point in the compilation
where we can compute the visibility and
* assert it was never computed before
* reject any attempts to compute it again in the future (with warnings).
Nico Weber [Sat, 12 Jan 2013 06:18:40 +0000 (06:18 +0000)]
Formatter: Initial support for formatting Objective-C method expressions.
This follows the approach suggested by djasper in PR14911: When a '[' is
seen that's at the start of a line, follows a binary operator, or follows one
of : [ ( return throw, that '[' and its closing ']' are marked as
TT_ObjCMethodExpr and every ':' in that range that isn't part of a ternary
?: is marked as TT_ObjCMethodExpr as well.
Update the layout routines to not output spaces around ':' tokens that are
marked TT_ObjCMethodExpr, and only allow breaking after such tokens, not
before.
Douglas Gregor [Sat, 12 Jan 2013 01:29:50 +0000 (01:29 +0000)]
Provide Decl::getOwningModule(), which determines the (sub)module in
which a particular declaration resides. Use this information to
customize the "definition of 'blah' must be imported from another
module" diagnostic with the module the user actually has to
import. Additionally, recover by importing that module, so we don't
complain about other names in that module.
Still TODO: coming up with decent Fix-Its for these cases, and expand
this recovery approach for other name lookup failures.
Fix -Wunused-comparison for comparisons in arguments to function-like macros.
Previously, -Wunused-comparison ignored comparisons in both macro bodies and
macro arguments, but we would still emit a -Wunused-value warning for either.
Now we correctly emit -Wunused-comparison for expressions in macro arguments.
Also, add isMacroBodyExpansion to SourceManager, to go along with
isMacroArgExpansion.
Sean Callanan [Fri, 11 Jan 2013 23:17:47 +0000 (23:17 +0000)]
Fixed a bug that caused the AST importer to erroneously
import incomplete definitions for RecordDecls and then
mark the resulting definition as complete.