Commit Graph

4956 Commits

Author SHA1 Message Date
Nick Lewycky fe71238b8d Add a workaround for PR7947, a crash trying to recover from invalid C++ code.
llvm-svn: 111675
2010-08-20 20:54:15 +00:00
John McCall 8b0666cf79 Another step in the process of making the parser depend on Sema:
- move DeclSpec &c into the Sema library
  - move ParseAST into the Parse library
Reflect this change in a thousand different includes.
Reflect this change in the link orders.

llvm-svn: 111667
2010-08-20 18:27:03 +00:00
Douglas Gregor 5be1eb8daf Revert r111609, which is failing its new test.
llvm-svn: 111611
2010-08-20 03:26:10 +00:00
John McCall a189f2eb0a Detect efforts to declare a template member friend and explicitly ignore them.
Avoids a crash.

llvm-svn: 111609
2010-08-20 01:40:01 +00:00
John McCall b3774b5c1e Regularize the API for accessing explicit template arguments.
llvm-svn: 111584
2010-08-19 23:49:38 +00:00
John McCall 13d031593e Correctly instantiate templates with non-type template arguments that
are local externs.  Fixes <rdar://problem/8302138>.

llvm-svn: 111570
2010-08-19 23:06:02 +00:00
Douglas Gregor 086cae6c1f Fix the source range of an anonymous namespace, from Jan Bierbaum
llvm-svn: 111561
2010-08-19 20:55:47 +00:00
Douglas Gregor c0afc67608 We don't actually need to check the implicit object argument's
conversion a second time for a conversion candidate (with the real
acting context), because the only problems we would find are access or
ambiguity issues that won't be diagnosed until we pick this
candidate. Add a test case to prove it to myself.

llvm-svn: 111526
2010-08-19 17:02:01 +00:00
Douglas Gregor c9ed4681a8 Properly implement the part of C++ [over.match.funcs]p4 that treats
conversion functions as if their acting context were the class that
we're converting from (the implicit object argument's
type). Retroactively tweaking the implicit conversion sequence, as we
were trying to do before, breaks the invariants of that implicit
conversion sequence (e.g., the types and conversions don't match
up). Fixes <rdar://problem/8018274>.

llvm-svn: 111520
2010-08-19 15:57:50 +00:00
Douglas Gregor 6affc78f1b Include a proper citation for the wacky hijinks involving conversion functions and the implicit object parameter type. No functionality change.
llvm-svn: 111519
2010-08-19 15:37:02 +00:00
Charles Davis 6bcb07ad71 Add some enum goodness as requested by Chris. Now instead of storing the
active C++ ABI as a raw string, we store it as an enum. This should improve
performance somewhat.

And yes, this time, I started from a clean build directory, and
all the tests passed. :)

llvm-svn: 111507
2010-08-19 02:18:14 +00:00
John McCall 5cf48cd17c On second thought, don't warn about reinterpret_casts under -Wcast-align.
llvm-svn: 111497
2010-08-19 01:19:08 +00:00
Ted Kremenek 50e0105f1c Add warning for functions/blocks that have attribute 'noreturn' but return a non-void result. (<rdar://problem/7562925>)
llvm-svn: 111492
2010-08-19 00:52:13 +00:00
Ted Kremenek 5295ce8120 HandleCommonNoReturnAttr() now only has a single caller. Move that logic to HandleAnalyzerNoReturnAttr.
llvm-svn: 111491
2010-08-19 00:51:58 +00:00
John McCall f733268e7a When deducing the element type of an array, ignore qualifiers if
the context allows us to ignore qualifiers on the array type itself.

llvm-svn: 111486
2010-08-19 00:20:19 +00:00
Sebastian Redl d44cd6adba More PCH -> AST renaming.
llvm-svn: 111472
2010-08-18 23:57:06 +00:00
Sebastian Redl 2c499f6561 Rename PCHReader to ASTReader.
llvm-svn: 111467
2010-08-18 23:56:43 +00:00
Alexis Hunt dcfba7b35b Generate Attr subclasses with TableGen.
Now all classes derived from Attr are generated from TableGen.
Additionally, Attr* is no longer its own linked list; SmallVectors or
Attr* are used. The accompanying LLVM commit contains the updates to
TableGen necessary for this.

Some other notes about newly-generated attribute classes:

 - The constructor arguments are a SourceLocation and a Context&,
   followed by the attributes arguments in the order that they were
   defined in Attr.td

 - Every argument in Attr.td has an appropriate accessor named getFoo,
   and there are sometimes a few extra ones (such as to get the length
   of a variadic argument).

Additionally, specific_attr_iterator has been introduced, which will
iterate over an AttrVec, but only over attributes of a certain type. It
can be accessed through either Decl::specific_attr_begin/end or
the global functions of the same name.

llvm-svn: 111455
2010-08-18 23:23:40 +00:00
Douglas Gregor fb640869ed There is no pointer conversion between to similar types (i.e., same
type ignoring cv-qualifiers). These are qualification
conversions. Fixes PR7934.

llvm-svn: 111428
2010-08-18 21:25:30 +00:00
Chris Lattner 396639db95 zap dead code.
llvm-svn: 111365
2010-08-18 16:09:06 +00:00
Douglas Gregor c1a42fdd53 Make sure to add MallocAttr to explicitly-declared operator new/new[]
when -fassume-sane-operator-new. Patch by Tom Jablin!

llvm-svn: 111363
2010-08-18 15:06:25 +00:00
John McCall 02db245d5e Rip out the existing retroactive abstract-class usage checker,
which in a fit of zeal wanted to walk the entire translation unit,
and replace it with a new checker that walks the types of declarations
nested within the class.  Also, look into templates when doing this.

llvm-svn: 111357
2010-08-18 09:41:07 +00:00
Chris Lattner e876fcd77a zap a big dead method.
llvm-svn: 111346
2010-08-18 02:44:19 +00:00
Douglas Gregor caa1bf434d Emit an error if an array is too large. We're slightly more strict
than GCC 4.2 here when building 32-bit (where GCC will allow
allocation of an array for which we can't get a valid past-the-end
pointer), and emulate its odd behavior in 64-bit where it only allows
63 bits worth of storage in the array. The former is a correctness
issue; the latter is harmless in practice (you wouldn't be able to use
such an array anyway) and helps us pass a GCC DejaGNU test.

Fixes <rdar://problem/8212293>.

llvm-svn: 111338
2010-08-18 00:39:00 +00:00
Daniel Dunbar 56df97761d StringRef'ication of lots stuff, patch by Peter Davies!
llvm-svn: 111314
2010-08-17 22:39:59 +00:00
Argyrios Kyrtzidis beb71b315a Rename -Wunused-method -> -Wunused-member-function.
llvm-svn: 111305
2010-08-17 22:06:44 +00:00
Argyrios Kyrtzidis cad715fb9b Introduce -Wunused-method option for warning on unused class methods in anonymous namespace.
This option is not part of the Unused diagnostic group until the warnings on llvm codebase are fixed
and we are ready to turn it on. Suggestion by Daniel.

llvm-svn: 111298
2010-08-17 21:43:11 +00:00
Fariborz Jahanian 798f83239c Diagnose use of iboutletcollection on ivar/property
of non-object types. Radar 8308053.

llvm-svn: 111296
2010-08-17 21:39:27 +00:00
John McCall 815039af77 Implicit decl ref expressions might not have name locations; don't silently
fail to instantiate them.

llvm-svn: 111293
2010-08-17 21:27:17 +00:00
Fariborz Jahanian b5d59b66c2 Patch to add type parameter support for attribute iboutletcollection.
Radar 8308053.

llvm-svn: 111275
2010-08-17 20:23:12 +00:00
Douglas Gregor 7116a8c19a When generating code completion patterns for method declarations, give
the resulting pattern the appropriate cursor kind of an instance or
class method declaration.

llvm-svn: 111237
2010-08-17 16:06:07 +00:00
Douglas Gregor b0ce9b79ba 1 != I. Fix the formulation of code-completion patterns for
Objective-C method declarations with > 2 parameters.

llvm-svn: 111233
2010-08-17 15:53:35 +00:00
Benjamin Kramer 35b077e674 Convert all uses of StringLiteral::getStrData() to StringLiteral::getString()
and remove getStrData().  Patch by Peter Davies (with some tweaks).

llvm-svn: 111229
2010-08-17 12:54:38 +00:00
John McCall 3696dcb171 Don't try to initialize a reference with a constructed temporary if either
of the classes is invalid.  A class is invalid if a base is invalid.

llvm-svn: 111227
2010-08-17 07:23:57 +00:00
John McCall 2677e10732 A field of incomplete type is sufficiently disruptive that we should mark
the record invalid.

llvm-svn: 111211
2010-08-16 23:42:35 +00:00
Douglas Gregor 59cab5564f Implement support for cached code completions for
nested-name-specifiers. Also includes fixes to the generation of
nested-name-specifier result in the non-cached case; we were producing
lame results for namespaces and namespace aliases, which (1) didn't
always have nested-name-specifiers when we want them, and (2) did not
have the necessary "::" as part of the completion.

llvm-svn: 111203
2010-08-16 23:05:20 +00:00
Fariborz Jahanian 99311ba1a8 Diagnose assiging to an interface object in
non-fragile abi mode as sizes are not statically known.
Fixes radar 8315734.

llvm-svn: 111191
2010-08-16 21:51:12 +00:00
Argyrios Kyrtzidis a3ae3eb690 Fix initialization for members of anonymous struct in a union.
llvm-svn: 111159
2010-08-16 17:27:13 +00:00
Argyrios Kyrtzidis 33aee3934a Emit diagnostic error when the field of an anonymous struct is non trivial.
llvm-svn: 111158
2010-08-16 17:27:08 +00:00
Douglas Gregor 6e24033bd2 When caching global completion results, keep track of the simplified
type class, so that we can adjust priorities appropriately when the
preferred type for the context and the actual type of the completion
are similar.

This gets us one step closer to parity of the cached completion
results with the non-cached completion results.

llvm-svn: 111139
2010-08-16 16:18:59 +00:00
Charles Davis ebab1ed5d3 Error out if reinterpret_casting between member pointers of two different
sizes.

llvm-svn: 111119
2010-08-16 05:30:44 +00:00
Charles Davis 2d3694297d Err on incomplete class types in member pointers when compiling for the
Microsoft C++ ABI, for now.

llvm-svn: 111118
2010-08-16 04:01:50 +00:00
Argyrios Kyrtzidis 04c7fa09e4 Don't warn for the common pattern of disallowing copying:
class S {
  S(const S&); // DO NOT IMPLEMENT
  void operator=(const S&); // DO NOT IMPLEMENT
};

llvm-svn: 111100
2010-08-15 10:17:33 +00:00
Douglas Gregor 3998219789 Extend the code-completion caching infrastructure to include global
declarations (in addition to macros). Each kind of declaration maps to
a certain set of completion contexts, and the ASTUnit completion logic
introduces the completion strings for those declarations if the actual
code-completion occurs in one of the contexts where it matters. 

There are a few new code-completion-context kinds. Without these,
certain completions (e.g., after "using namespace") would need to
suppress all global completions, which would be unfortunate.

Note that we don't get the priorities right for global completions,
because we don't have enough type information. We'll need a way to
compare types in an ASTContext-agnostic way before this can be
implemented.

llvm-svn: 111093
2010-08-15 06:18:01 +00:00
Eli Friedman f8d9817f4b Use Enumerators.data() instead of &Enumerators[0] to fix a potential
assertion failure.

llvm-svn: 111092
2010-08-15 02:27:09 +00:00
Argyrios Kyrtzidis 1cec2cc798 Remove dead code, caught by unused function warnings.
llvm-svn: 111091
2010-08-15 01:15:58 +00:00
Argyrios Kyrtzidis 1b30d9c0f0 Commit improved version of 111026 & 111027.
Unused warnings for functions:
-static functions
-functions in anonymous namespace
-class methods in anonymous namespace
-class method specializations in anonymous namespace
-function specializations in anonymous namespace

Unused warnings for variables:
-static variables
-variables in anonymous namespace
-static data members in anonymous namespace
-static data members specializations in anonymous namespace

Reveals lots of opportunities for dead code removal in llvm codebase that will
interest my esteemed colleagues.

llvm-svn: 111086
2010-08-15 01:15:20 +00:00
Eli Friedman df2392572e PR3344: Downgrade "too many braces around scalar initializer" to a warning.
llvm-svn: 111067
2010-08-14 03:14:53 +00:00
Douglas Gregor b14904c4a8 Implement caching of code-completion results for macro definitions
when the CXTranslationUnit_CacheCompletionResults option is given to
clang_parseTranslationUnit(). Essentially, we compute code-completion
results for macro definitions after we have parsed the file, then
store an ASTContext-agnostic version of those results (completion
string, cursor kind, priority, and active contexts) in the
ASTUnit. When performing code completion in that ASTUnit, we splice 
the macro definition results into the results provided by the actual
code-completion (which has had macros turned off) before libclang gets
those results. We use completion context information to only splice in
those results that make sense for that context.

With a completion involving all of the macros from Cocoa.h and a few other
system libraries (totally ~8500 macro definitions) living in a
precompiled header, we get about a 9% performance improvement from
code completion, since we no longer have to deserialize all of the
macro definitions from the precompiled header. 

Note that macro definitions are merely the canary; the cache is
designed to also support other top-level declarations, which should be
a bigger performance win. That optimization will be next.

Note also that there is no mechanism for determining when to throw
away the cache and recompute its contents.

llvm-svn: 111051
2010-08-13 22:48:40 +00:00
Argyrios Kyrtzidis 98703d3883 Revert 111026 & 111027, build breakage.
llvm-svn: 111036
2010-08-13 20:13:06 +00:00