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().
Douglas Gregor [Thu, 11 Feb 2010 01:04:33 +0000 (01:04 +0000)]
Eliminate the ASTContext parameter from RecordDecl::getDefinition()
and CXXRecordDecl::getDefinition(); it's totally unnecessary. No
functionality change.
Ted Kremenek [Thu, 11 Feb 2010 00:53:01 +0000 (00:53 +0000)]
Allocate 'ObjCMethodList' objects (owned by Sema) using Sema's BumpPtrAllocator. Previously they were not getting freed. Fixes <rdar://problem/7635663>.
Charles Davis [Wed, 10 Feb 2010 23:06:52 +0000 (23:06 +0000)]
Add support for the force_align_arg_pointer attribute. This is an x86-specific
attribute, so it uses Anton's new target-specific attribute support. It's
supposed to ensure that the stack is 16-byte aligned, but since necessary
support is lacking from LLVM, this is a no-op for now.
Daniel Dunbar [Wed, 10 Feb 2010 18:49:11 +0000 (18:49 +0000)]
Switch to using -fsjlj-exceptions instead of hard-coding it. Notably, this fixes
calls to the UnwindResumeOrRethrow function for C++/Obj-C exception handling,
for Darwin ARM.
Douglas Gregor [Wed, 10 Feb 2010 17:16:49 +0000 (17:16 +0000)]
Teach AST merging that variables with incomplete array types can be
merged with variables of constant array types. Also, make sure that we
call DiagnosticClient's BeginSourceFile/EndSourceFile, so that it has
a LangOptions to work with.
John McCall [Wed, 10 Feb 2010 09:31:12 +0000 (09:31 +0000)]
Improve access control diagnostics. Perform access control on member-pointer
conversions. Fix an access-control bug where privileges were not considered
at intermediate points along the inheritance path. Prepare for friends.
Douglas Gregor [Wed, 10 Feb 2010 00:15:17 +0000 (00:15 +0000)]
Implement basic support for importing source locations from one AST
into another AST, including their include history. Here's an example
error that involves a conflict merging a variable with different types
in two translation units (diagnosed in the third AST context into
which everything is merged).
/Volumes/Data/dgregor/Projects/llvm/tools/clang/test/ASTMerge/Inputs/var2.c:3:5:
error: external variable 'x2' declared with incompatible types in
different translation units ('int' vs. 'double')
int x2;
^
In file included from
/Volumes/Data/dgregor/Projects/llvm/tools/clang/test/ASTMerge/Inputs/var1.c:3:
/Volumes/Data/dgregor/Projects/llvm/tools/clang/test/ASTMerge/Inputs/var1.h:1:8:
note: declared here with type 'double'
double x2;
^
Although we maintain include history, we do not maintain macro
instantiation history across a merge. Instead, we map down to the
spelling location (for now!).
Douglas Gregor [Tue, 9 Feb 2010 22:26:47 +0000 (22:26 +0000)]
Move the diagnostic argument formatting function out of Sema and make
it available within the AST library, of which Sema is one client. No
functionality change.
Implement synthesizing properties by default.
This is a non-fragile-abi feature only. Since it
breaks existing code, it is currently placed under
-fobjc-nonfragile-abi2 option for test purposes only
until further notice. WIP.
Ted Kremenek [Tue, 9 Feb 2010 19:11:53 +0000 (19:11 +0000)]
Fix lookup of fields from lazy bindings to check if the region is
NULL, not the store, to determine if a lookup succeeded. The store
can be null if it contained no bindings. This fixes a false positive
reported to me by a user of the analyzer.