Commit Graph

20618 Commits

Author SHA1 Message Date
Anders Carlsson cf5a882da1 Handle virtual bases in return adjustment types.
llvm-svn: 96119
2010-02-13 21:07:32 +00:00
Anders Carlsson f3f67846c8 Handle virtual bases in ComputeBaseOffset.
llvm-svn: 96117
2010-02-13 20:41:15 +00:00
Daniel Dunbar 9ced542c8a Add newline.
llvm-svn: 96116
2010-02-13 20:24:39 +00:00
Anders Carlsson 6a6cbfc55f More work on covariant return types. We now handle non-virtual adjustments fine.
llvm-svn: 96114
2010-02-13 20:11:51 +00:00
Chris Lattner ef538b52a3 add support for t Fedora 12 (February 2010), patch by
Dyachenko Dmitry.  Our system is "not so elegant" here.

llvm-svn: 96111
2010-02-13 19:18:26 +00:00
Daniel Dunbar ae4b77d99d 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

llvm-svn: 96107
2010-02-13 18:33:28 +00:00
Daniel Dunbar 43813bf023 cindex/Python: Add TranslationUnit.get_includes, patch by Andrew Sutton!
llvm-svn: 96106
2010-02-13 18:33:18 +00:00
Daniel Dunbar 2037d4e4ea cindex/Python: Update for clang_getDiagnosticRange... API changes.
llvm-svn: 96105
2010-02-13 18:33:03 +00:00
Charles Davis 4ea31ab369 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.

llvm-svn: 96100
2010-02-13 15:54:06 +00:00
Chandler Carruth a932bbca75 Fix think-o, attributes can't come *within* the type of the variable.
llvm-svn: 96099
2010-02-13 10:42:55 +00:00
Chandler Carruth 94eab4ad04 Silence unused variable warning in a build without assertions.
llvm-svn: 96098
2010-02-13 10:38:52 +00:00
Chandler Carruth 6b4756a224 Skip implicit instantiation of templated variables where a more recent
redeclaration provides an explicit instantiation or is invalid.

llvm-svn: 96097
2010-02-13 10:17:50 +00:00
Benjamin Kramer e047e11189 Remove dead {include, semicolon, variable}.
llvm-svn: 96087
2010-02-13 09:15:07 +00:00
Benjamin Kramer 02c673781d Use a different name for this iterator. MSVC and clang++ didn't like "I" in the same scope twice.
llvm-svn: 96086
2010-02-13 09:11:28 +00:00
Chandler Carruth dfe198b588 Silence a GCC warning about a possibly uninitialized variable. It's data flow
only flows so far it seems.

llvm-svn: 96085
2010-02-13 07:23:01 +00:00
Douglas Gregor 04922cbb46 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.

llvm-svn: 96084
2010-02-13 06:05:33 +00:00
Douglas Gregor af050cb73a Permit the use of typedefs of class template specializations in
qualified declarator-ids. This patch is actually due to Cornelius;
fixes PR6179.

llvm-svn: 96082
2010-02-13 05:23:25 +00:00
John McCall bb79b5f6f3 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.

llvm-svn: 96077
2010-02-13 03:50:24 +00:00
Anders Carlsson eee53d9c06 More work on return type adjustments in the new vtable builder.
llvm-svn: 96070
2010-02-13 02:02:03 +00:00
Ted Kremenek 1a6672a3d4 Enhance RegionStore::InvalidateRegions() to correctly invalidate bindings
by scanning through the values of LazyCompoundVals.

llvm-svn: 96067
2010-02-13 01:52:33 +00:00
John McCall ef3057c419 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.

llvm-svn: 96062
2010-02-13 01:04:05 +00:00
Ted Kremenek 7950b78430 Pull logic for visiting value bindings in InvalidateRegionsWorker into a separate method.
No functionality change.

llvm-svn: 96060
2010-02-13 00:54:03 +00:00
Eli Friedman d5c9399696 Fix for PR6274: teach constant folding to evaluate __builtin_expect.
llvm-svn: 96054
2010-02-13 00:10:10 +00:00
Eli Friedman 18c28f6cdc if-0 out printf.
llvm-svn: 96052
2010-02-13 00:03:21 +00:00
John McCall cfcb775b56 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

llvm-svn: 96046
2010-02-12 23:47:27 +00:00
Douglas Gregor 8cdbe64de4 Funnel changes to the ImportedDecls list in the ASTImporter through a
single Imported function, in preparation for fixing a serious design
flaw.

llvm-svn: 96044
2010-02-12 23:44:20 +00:00
Ted Kremenek 8bd0929d41 Fix bug I introduced with assinging a temporary to a StringRef.
llvm-svn: 96041
2010-02-12 23:31:14 +00:00
Ted Kremenek a3e657064b Make the following functions thread-safe but having them return an std::string that is reconstructed
every time they are called:

getClangRevision()
getClangFullRepositoryVersion()
getClangFullVersion()

llvm-svn: 96033
2010-02-12 22:54:40 +00:00
Douglas Gregor 98c1018337 Implement AST importing and merging for enumeration types and
enumerators, along with ImplicitCastExprs to make it work.

llvm-svn: 96024
2010-02-12 22:17:39 +00:00
Fariborz Jahanian 5ec502e35b Complain if block-literal expression's parameter name is
missing (in c/objc mode). Fixes radar 7528255.

llvm-svn: 96017
2010-02-12 21:53:14 +00:00
Ted Kremenek 8f8dcbaadd (1) Correctly format external Javascript link.
(2) Reformat "annotations" topics list to use a collapsable tree.

llvm-svn: 96013
2010-02-12 21:05:44 +00:00
Fariborz Jahanian e5c118f60d Don't error when setting a sub-structure variable via objc properties
in objective-c++ mode (do it for objective-c only).

llvm-svn: 96012
2010-02-12 21:02:28 +00:00
Chris Lattner 5647d3192c 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.

This fixes rdar://7597492, a crash on 255.vortex.

llvm-svn: 96004
2010-02-12 19:31:35 +00:00
Fariborz Jahanian dc68f9539c Patch to fix a warning which exposed a bug in building
a qualified objective-c pointer type. Fixes radar 7638810.
(Also removes a FIXME).

llvm-svn: 96003
2010-02-12 19:27:33 +00:00
Chris Lattner fc38aa7091 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.

llvm-svn: 95998
2010-02-12 18:52:52 +00:00
Anders Carlsson 0760481f26 Fix a refacto that broke the clang-on-clang build.
llvm-svn: 95994
2010-02-12 18:14:46 +00:00
Fariborz Jahanian a459c4453d Fixes a rewriter bug rewriting function decl.
with block-pointer-type as one or more of its
arguments. Fixes radar 7638400.

llvm-svn: 95992
2010-02-12 17:52:31 +00:00
Douglas Gregor 5089c769bb Improve representation of tag declarations first declared or defined
within the declarator of another declaration, from Enea Zaffanella!

llvm-svn: 95991
2010-02-12 17:40:34 +00:00
Anders Carlsson 5272c2574a Start stubbing out more of the covariant thunk support.
llvm-svn: 95990
2010-02-12 17:37:14 +00:00
Douglas Gregor 925df1b529 Improve documentation for DependentTypeOfExprType, DependentDecltypeType. No functionality change.
llvm-svn: 95989
2010-02-12 17:28:41 +00:00
Douglas Gregor 56521c5e8c Simplify incomplete-array merging code in the AST importer, thanks to
Daniel's suggestion.

llvm-svn: 95987
2010-02-12 17:23:39 +00:00
Douglas Gregor 8870a49310 Fix a latent bug found by Ahmed Charles, where we were calling
ASTContext::getFunctionType with the wrong set of arguments.

llvm-svn: 95986
2010-02-12 17:17:28 +00:00
Anders Carlsson 8e661e15f2 Keep track of whether a final overrider needs a return type adjustment.
llvm-svn: 95985
2010-02-12 17:13:23 +00:00
Anders Carlsson 136bd19224 Move overrider out into a separate struct.
llvm-svn: 95984
2010-02-12 16:55:34 +00:00
Chris Lattner aa1cccbbef 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.

llvm-svn: 95972
2010-02-12 08:03:27 +00:00
Anders Carlsson e8a9756e63 Keep track of the address points for all primary bases, and add the ability to dump multiple address points for a single offset.
llvm-svn: 95970
2010-02-12 07:43:48 +00:00
Douglas Gregor f40863caff 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.,  

  extern void *malloc (__SIZE_TYPE__ __size) throw () __attribute__
  ((__malloc__)) ;

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.

Ick.

llvm-svn: 95969
2010-02-12 07:32:17 +00:00
John McCall 84c416b9f6 Fix a bug causing an assertion when a covariant return type differed from
an overriden type only by reduced qualification.

llvm-svn: 95968
2010-02-12 06:15:07 +00:00
Douglas Gregor 87b4b4184c Improve a test slightly
llvm-svn: 95967
2010-02-12 06:08:51 +00:00
Douglas Gregor d3a5918742 In C++, allow builtins to be referred to via qualified name lookup, e.g.,
::__builtin_va_copy

Fixes one of the Firefox issues in PR5511.

llvm-svn: 95966
2010-02-12 05:48:04 +00:00
Anders Carlsson 65b4978f7f More work on vtable layout. We can now layout vtables with primary bases.
llvm-svn: 95965
2010-02-12 05:25:12 +00:00
John McCall 62d5d64ce9 Waste two bits in every clang::Type so that the type class can be read
in a single byte-load rather than some crazy bitmunging operation.

llvm-svn: 95964
2010-02-12 03:41:30 +00:00
Anders Carlsson 09da3372b6 When dumping vtables, dump whether a virtual member function is pure or not.
llvm-svn: 95963
2010-02-12 02:38:13 +00:00
Anders Carlsson 9fbf6d95f6 More work on the final overriders.
llvm-svn: 95954
2010-02-12 01:40:03 +00:00
Devang Patel f4df65cf60 Do not ignore anonymous records.
llvm-svn: 95953
2010-02-12 01:31:06 +00:00
Devang Patel e003dd1721 Cache new compile unit.
llvm-svn: 95952
2010-02-12 01:30:31 +00:00
Ted Kremenek e9711db487 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.

llvm-svn: 95943
2010-02-12 00:12:25 +00:00
Ted Kremenek 14015de619 Add comments.
llvm-svn: 95942
2010-02-12 00:10:34 +00:00
Douglas Gregor 2579105c4e Handle AST merges of incomplete class types.
llvm-svn: 95941
2010-02-12 00:09:27 +00:00
Tanya Lattner 90073804fb Implementing unused function warning.
llvm-svn: 95940
2010-02-12 00:07:30 +00:00
Charles Davis a90f7ca591 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.

llvm-svn: 95939
2010-02-11 23:57:08 +00:00
Fariborz Jahanian 4c4ca5a9d3 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

llvm-svn: 95936
2010-02-11 23:35:57 +00:00
Douglas Gregor 50dc219e8b 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.

llvm-svn: 95934
2010-02-11 22:55:30 +00:00
Ted Kremenek 9d6eb40ce7 Fix leak in CXXNewExpr where the SubExprs array would get allocated directly using 'new[]' instead of the allocator associated with ASTContext.
llvm-svn: 95933
2010-02-11 22:51:03 +00:00
John McCall 81472e34b2 Make this test not rely on the system <limits.h>. Hopefully fixes the
MSVC build.

llvm-svn: 95932
2010-02-11 22:45:16 +00:00
Ted Kremenek 9c8a6f5a8e Fix re-allocation in AttrWithString::ReplaceString() to use the allocator assosciated with ASTContext.
llvm-svn: 95931
2010-02-11 22:44:22 +00:00
Ted Kremenek 2c809308ca Allocate the SubExprs array in ObjCMessageExpr using the allocator associated with ASTContext. This fixes yet another leak (<rdar://problem/7639260>).
llvm-svn: 95930
2010-02-11 22:41:21 +00:00
Anders Carlsson e8ac42ad5c Stub out the final overriders class.
llvm-svn: 95922
2010-02-11 21:24:32 +00:00
Anders Carlsson dd27b5d7bb Use getAs instead of cast/dyn_cast on types. (I'm sure Doug will appreciate this).
llvm-svn: 95911
2010-02-11 19:45:15 +00:00
Anders Carlsson 727ffb14a1 Move two functions to the top. No functionality change.
llvm-svn: 95908
2010-02-11 19:39:49 +00:00
Ted Kremenek 23a26d244d Uncomment lines I never meant to have left commented in a commit.
llvm-svn: 95906
2010-02-11 19:37:25 +00:00
Douglas Gregor 7eeb59752a 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)

llvm-svn: 95900
2010-02-11 19:21:55 +00:00
Eli Friedman f5d476efb2 Add builtins from PR5255. Implementations coming soon.
llvm-svn: 95894
2010-02-11 19:02:42 +00:00
John McCall 739908faf6 Test case for warnings with carets inside macro instantiations.
llvm-svn: 95893
2010-02-11 18:52:49 +00:00
Anders Carlsson 48ea217fbf Add virtual operator= example.
llvm-svn: 95888
2010-02-11 18:21:49 +00:00
Anders Carlsson 5bd8d19291 More vtable layout dumper improvements. Handle destructors, dump the complete function type of the member functions (using PredefinedExpr::ComputeName.
llvm-svn: 95887
2010-02-11 18:20:28 +00:00
Douglas Gregor 69837bed2f Add missing test cases for AST merging of structures.
llvm-svn: 95886
2010-02-11 18:18:11 +00:00
Daniel Dunbar bcd554f908 Driver: Fix clang -ccc-no-clang -x c++-header foo.h on Darwin.
llvm-svn: 95876
2010-02-11 17:33:45 +00:00
Anders Carlsson 932c2f2a9a Keep track of, and dump, vtable address points.
llvm-svn: 95874
2010-02-11 17:18:51 +00:00
Benjamin Kramer 15d8225b59 Remove noisy semicolon.
llvm-svn: 95872
2010-02-11 11:33:47 +00:00
John McCall be089fa86b 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.

llvm-svn: 95870
2010-02-11 10:04:29 +00:00
Ted Kremenek d31b2637ab 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.

llvm-svn: 95869
2010-02-11 09:27:41 +00:00
Anders Carlsson 5d40c6f658 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.

llvm-svn: 95865
2010-02-11 08:02:13 +00:00
Ted Kremenek 50228be0f3 Attempt to always dispose of the CXIndex object in c-index-test.
llvm-svn: 95864
2010-02-11 07:41:25 +00:00
Ted Kremenek 510ee2594e Use the allocator associated with ASTContext to allocate the args
array associated with NonNullAttr.  This fixes yet another leak when
ASTContext uses a BumpPtrAllocator.

Fixes: <rdar://problem/7637150>
llvm-svn: 95863
2010-02-11 07:31:47 +00:00
Ted Kremenek da4e0d350c 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.

Fixes: <rdar://problem/7634755>
llvm-svn: 95861
2010-02-11 07:12:28 +00:00
Ted Kremenek 7f4945aa9c 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).

Fixes: <rdar://problem/7636765>
llvm-svn: 95853
2010-02-11 05:28:37 +00:00
Daniel Dunbar aeea8ac3d8 Driver: Add -rewrite-objc, which is an interface to clang -cc1 -rewrite-objc.
llvm-svn: 95849
2010-02-11 03:16:21 +00:00
Daniel Dunbar 84f22f9da1 Driver: Fix infinite loop and wrong message on invalid -ccc-clang-arch argument.
llvm-svn: 95848
2010-02-11 03:16:07 +00:00
Ted Kremenek c162e8e193 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.

This fixes <rdar://problem/7635046>.

llvm-svn: 95847
2010-02-11 02:19:13 +00:00
John McCall 4f7ced69ff Strip attributes and 'inline' off the "previous declaration" of a
template explicit specialization.  Complete an apparently stalled refactor
towards using CheckSpecializationInstantiationRedecl().

llvm-svn: 95845
2010-02-11 01:33:53 +00:00
Douglas Gregor 4a62bdfb2a Remove another redundant ASTContext parameter
llvm-svn: 95843
2010-02-11 01:30:34 +00:00
Douglas Gregor d505812422 Eliminate a bunch of unnecessary ASTContexts from members functions of
Decl subclasses. No functionality change.

llvm-svn: 95841
2010-02-11 01:19:42 +00:00
Fariborz Jahanian 13b9782cc0 Diagnose when user provided getter is being used as lvalue
using property dot-syntax. Fixes radar 7628953.

llvm-svn: 95838
2010-02-11 01:11:34 +00:00
Douglas Gregor 0a5a2216e2 Eliminate the ASTContext parameter from RecordDecl::getDefinition()
and CXXRecordDecl::getDefinition(); it's totally unnecessary. No
functionality change.

llvm-svn: 95836
2010-02-11 01:04:33 +00:00
Ted Kremenek da4abf11bf Allocate 'ObjCMethodList' objects (owned by Sema) using Sema's BumpPtrAllocator. Previously they were not getting freed. Fixes <rdar://problem/7635663>.
llvm-svn: 95834
2010-02-11 00:53:01 +00:00
Douglas Gregor 5c73e918c5 Implement basic AST merging for classes, structs, and unions in C.
llvm-svn: 95833
2010-02-11 00:48:18 +00:00
Fariborz Jahanian 989908fbac Generate the objc_read_weak API when calling
a __weak block. Fixes radar 7628591.

llvm-svn: 95822
2010-02-10 23:34:57 +00:00
Charles Davis 42b3842429 Fix a potential null-pointer use, and fix the style of my new function.
Thanks, Anton!

llvm-svn: 95821
2010-02-10 23:26:12 +00:00
Charles Davis bbc0aa5166 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.

llvm-svn: 95820
2010-02-10 23:06:52 +00:00