Daniel Dunbar [Sat, 13 Feb 2010 18:33:28 +0000 (18:33 +0000)]
cindex/Python: Fix cindex-{dump,includes} examples to just pass all args
directly to Index, instead of requiring the input file to be first. This makes
the examples behave more like 'clang'.
For example,
ddunbar@giles:tmp$ echo '#include <string>' | python ~/llvm/tools/clang/bindings/python/examples/cindex/cindex-includes.py -- -x c++ - | wc -l
114
ddunbar@giles:tmp$ echo '#include <stdio.h>' | python ~/llvm/tools/clang/bindings/python/examples/cindex/cindex-includes.py -- -x c - | wc -l
10
Charles Davis [Sat, 13 Feb 2010 15:54:06 +0000 (15:54 +0000)]
Emit the 'alignstack' LLVM function attribute when we encounter a function
marked 'force_align_arg_pointer'. Almost there; now all I need to do is finish
up the backend.
Douglas Gregor [Sat, 13 Feb 2010 06:05:33 +0000 (06:05 +0000)]
Fix a fiendinshly fun little type-canonicalization bug, where we were
rebuilding a typename type terminating in a template-id (with
dependent template name, naturally) as a TypenameType when, because
its context could be fully resolved, we should have been building it
as a QualifiedNameType. Fixes PR6268.
John McCall [Sat, 13 Feb 2010 03:50:24 +0000 (03:50 +0000)]
Raise the responsibility for passing -disable-llvm-verifier in NDEBUG builds
to the driver, and support it in CodeGenOptsToArgs(). Note that this changes
the default behavior of clang -cc1 to always run the verifier.
John McCall [Sat, 13 Feb 2010 01:04:05 +0000 (01:04 +0000)]
Switch the standard DeclarationName comparator to be a tri-valued comparator.
Use that while fixing a nasty misuse of qsort in vtable codegen which, somehow,
has not actually caused a crash.
John McCall [Fri, 12 Feb 2010 23:47:27 +0000 (23:47 +0000)]
Add an option to disable the LLVM verifier pass (which is still always
disabled in NDEBUG builds). The option applies only to -cc1 invocations and is:
-disable_llvm_verifier
Chris Lattner [Fri, 12 Feb 2010 19:31:35 +0000 (19:31 +0000)]
fix a bug in SourceManager::getInstantiationLocSlowCase, where
we'd add an offset from the spelling location space to the
instantiation location, which doesn't make sense and would
lead up to the text diagnostics crashing when presented with
non-sensical locations.
Chris Lattner [Fri, 12 Feb 2010 18:52:52 +0000 (18:52 +0000)]
restructure code a bit: there are two potential issues
worth asserting about in this code: 1) if the source range
is bogus (begin loc after end loc), and 2) if the client
is trying to highlight a range that is purely whitespace.
It is possible to just silently ignore #2, but it seems like
it is always a bug, so lets keep asserting on this condition,
but with a better assert message.
Chris Lattner [Fri, 12 Feb 2010 08:03:27 +0000 (08:03 +0000)]
Fix PR6282: the include guard optimization cannot happen if the
guard macro is already defined for the first occurrence of the
header. If it is, the body will be skipped and not be properly
analyzed for the include guard optimization.
Douglas Gregor [Fri, 12 Feb 2010 07:32:17 +0000 (07:32 +0000)]
Work around an annoying, non-standard optimization in the glibc
headers, where malloc (and many other libc functions) are declared
with empty throw specifications, e.g.,
The C++ standard doesn't seem to allow this, and redeclaring malloc as
the standard permits (as follows) resulted in Clang (rightfully!)
complaining about mis-matched exception specifications.
void *malloc(size_t size);
We work around this by silently propagating an empty throw
specification "throw()" from a function with C linkage declared in a
system header to a redeclaration that has no throw specifier.
Ted Kremenek [Fri, 12 Feb 2010 00:12:25 +0000 (00:12 +0000)]
Two changes to scan-build:
(1) When no 'clang' is found with 'scan-build', remember the one from
the path as scan-build sees it, not the build system. This prevents
us from finding different clangs during the build.
(2) Don't set LDPLUSPLUS when running xcodebuild; instead rely on the
clang driver to do the right thing.
Charles Davis [Thu, 11 Feb 2010 23:57:08 +0000 (23:57 +0000)]
Warn about using the new force_align_arg_pointer attribute on a function
pointer. If you don't like the new warning, you can turn it off with
-Wno-force-align-arg-pointer.
Fixes a rewriting bug where order of constructor expression arguments did not match
order of constructor arguments (all block API specific). This was exposed only in
a large block literal expression in a large file where PtrSet container size
execceded its limit and required reallocation. Fixes radar 7638294
Douglas Gregor [Thu, 11 Feb 2010 22:55:30 +0000 (22:55 +0000)]
When we have a dependent direct initializer but not a dependent
variable type, we can (and should) still check for completeness of the
variable's type. Do so, to work around an assertion that shows up in
Boost's shared_ptr.
Douglas Gregor [Thu, 11 Feb 2010 19:21:55 +0000 (19:21 +0000)]
When AST merging for record declarations fails, warn about the
incompatibility and show where the structural differences are. For
example:
struct1.c:36:8: warning: type 'struct S7' has incompatible definitions
in different translation units
struct S7 { int i : 8; unsigned j : 8; } x7;
^
struct1.c:36:33: note: bit-field 'j' with type 'unsigned int' and length 8 here
struct S7 { int i : 8; unsigned j : 8; } x7;
^
struct2.c:33:33: note: bit-field 'j' with type 'unsigned int' and length 16 here
struct S7 { int i : 8; unsigned j : 16; } x7;
^
There are a few changes to make this work:
- ASTImporter now has only a single Diagnostic object, not multiple
diagnostic objects. Otherwise, having a warning/error printed via
one Diagnostic and its note printed on the other Diagnostic could
cause the note to be suppressed.
- Implemented import functionality for IntegerLiteral (along with
general support for statements and expressions)
Anders Carlsson [Thu, 11 Feb 2010 18:20:28 +0000 (18:20 +0000)]
More vtable layout dumper improvements. Handle destructors, dump the complete function type of the member functions (using PredefinedExpr::ComputeName.
John McCall [Thu, 11 Feb 2010 10:04:29 +0000 (10:04 +0000)]
Suppress warnings if their instantiation location is in a system header, not
their spelling location. This prevents warnings from being swallowed just
because the caret is on the first parenthesis in, say, NULL.
This is an experiment; the risk is that there might be a substantial number
of system headers which #define symbols to expressions which inherently cause
warnings. My theory is that that's rare enough that it can be worked
around case-by-case, and that producing useful warnings around NULL is worth
it. But I'm willing to accept that I might be empirically wrong.
Ted Kremenek [Thu, 11 Feb 2010 09:27:41 +0000 (09:27 +0000)]
Patch by Cristian Draghici:
Enhance the printf format string checking when using the format
specifier flags ' ', '0', '+' with the 'p' or 's' conversions (since
they are nonsensical and undefined). This is similar to GCC's
checking.
Also warning when a precision is used with the 'p' conversin
specifier, since it has no meaning.
Anders Carlsson [Thu, 11 Feb 2010 08:02:13 +0000 (08:02 +0000)]
Check in the beginnings of my new vtable layout builder idea.
Right now, it's off by default but can be tested by passing -fdump-vtable-layouts to clang -cc1. This option will cause all vtables that will normally be emitted as part of codegen to also be dumped using the new layout code.
I've also added a very simple new vtable layout test case.
Ted Kremenek [Thu, 11 Feb 2010 07:31:47 +0000 (07:31 +0000)]
Use the allocator associated with ASTContext to allocate the args
array associated with NonNullAttr. This fixes yet another leak when
ASTContext uses a BumpPtrAllocator.
Ted Kremenek [Thu, 11 Feb 2010 07:12:28 +0000 (07:12 +0000)]
Have ~ASTContext() delete StoredDeclsMap (internal to DeclContext) by
storing the set of StoredDeclsMaps in an internal vector of void*.
This isn't an ideal solution, but for the time being this fixes a
major memory leak with these DenseMaps not being freed.
Ted Kremenek [Thu, 11 Feb 2010 05:28:37 +0000 (05:28 +0000)]
Remove use of 'std::string' from Attr objects, using instead a byte
array allocated using the allocator in ASTContext. This addresses
these strings getting leaked when using a BumpPtrAllocator (in
ASTContext).
Ted Kremenek [Thu, 11 Feb 2010 02:19:13 +0000 (02:19 +0000)]
Clean up ownership of 'AttributeList' objects in Parser. Apparently
we would just leak them all over the place, with no clear ownership of
these objects at all. AttributeList objects would get leaked on both
error and non-error paths.
Note: I introduced the usage of llvm::OwningPtr<AttributeList> to
manage these objects, which is particularly useful for methods with
multiple return sites. In at least one method I used them even when
they weren't strictly necessary because it clarified the ownership
semantics and made the code easier to read. Should the excessive
'take()' and 'reset()' calls become a performance issue we can always
re-evaluate.
Note+1: I believe I have not introduced any double-frees, but it would
be nice for someone to review this.
John McCall [Thu, 11 Feb 2010 01:33:53 +0000 (01:33 +0000)]
Strip attributes and 'inline' off the "previous declaration" of a
template explicit specialization. Complete an apparently stalled refactor
towards using CheckSpecializationInstantiationRedecl().