Commit Graph

9616 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis 0a9ce3ec8f [analyzer] Migrate ArrayBoundCheckerV2 to CheckerV2.
Turns -analyzer-check-buffer-overflows into -analyzer-checker=core.experimental.Overflow

llvm-svn: 126609
2011-02-28 01:26:57 +00:00
Argyrios Kyrtzidis 560bbb1241 [analyzer] Turn -analyzer-stats into -analyzer-checker=debug.Stats
llvm-svn: 126608
2011-02-28 01:26:50 +00:00
Argyrios Kyrtzidis 21c9423ef4 [analyzer] Remove '-analyzer-experimental-checks' flag.
llvm-svn: 126607
2011-02-28 01:26:43 +00:00
Argyrios Kyrtzidis 183f0fb4cf [analyzer] Migrate MallocChecker to CheckerV2.
llvm-svn: 126606
2011-02-28 01:26:35 +00:00
Argyrios Kyrtzidis 4e23dbd0fd [analyzer] Have CheckerManager::registerChecker return a pointer to the checker object and
only allow a checker to be registered once.

llvm-svn: 126605
2011-02-28 01:26:28 +00:00
Anders Carlsson 6dc07d4e56 Get rid of the areExceptionsEnabled() getter from LangOptions.
llvm-svn: 126598
2011-02-28 00:33:03 +00:00
Chris Lattner 589b989713 add a const version of this accessor.
llvm-svn: 126594
2011-02-28 00:17:41 +00:00
Douglas Gregor 6e068014f0 When we encounter a dependent template name within a
nested-name-specifier, e.g., 

  T::template apply<U>::

represent the dependent template name specialization as a
DependentTemplateSpecializationType, rather than a
TemplateSpecializationType with a dependent TemplateName.

llvm-svn: 126593
2011-02-28 00:04:36 +00:00
Douglas Gregor b09518c551 Eliminate a silly little Parse/Sema dance when parsing typename
specifiers such as

  typename T::template apply<U>

Previously, we would turn T::template apply<U> into a
TemplateSpecializationType. Then, we'd reprocess that
TemplateSpecializationType and turn it into either a
TemplateSpecializationType wrapped in an ElaboratedType (when we could
resolve "apply" to a template declaration) or a
DependentTemplateSpecializationType. We now produce the same ASTs but
without generating the intermediate TemplateSpecializationType.

The end goal here is to avoid generating TemplateSpecializationTypes
with dependent template-names, ever. We're not there yet.

llvm-svn: 126589
2011-02-27 22:46:49 +00:00
Alexis Hunt c5575cced8 Implement delegating constructors partially.
This successfully performs constructor lookup and verifies that a
delegating initializer is the only initializer present.

This does not perform loop detection in the initialization, but it also
doesn't codegen delegating constructors at all, so this won't cause
runtime infinite loops yet.

llvm-svn: 126552
2011-02-26 19:13:13 +00:00
John McCall bebede4d33 Provide a bit saying that a builtin undergoes custom type-checking, then
don't let calls to such functions go down the normal type-checking path.
Test this out with __builtin_classify_type and __builtin_constant_p.

llvm-svn: 126539
2011-02-26 05:39:39 +00:00
Matt Beaumont-Gay 531c079de8 ASTStmtReader is already a friend of DependentScopeDeclRefExpr, and GCC
doesn't like re-friending.

llvm-svn: 126524
2011-02-25 22:36:42 +00:00
Fariborz Jahanian e6b127d7da Sprinkle optional text of the "unavailable' attribute
where ever such attribute causes an error diagnostic.

llvm-svn: 126509
2011-02-25 20:51:14 +00:00
Douglas Gregor 3a43fd645d Push nested-name-specifier source location information into
DependentScopeDeclRefExpr. Plus, give NestedNameSpecifierLoc == and !=
operators, since we're going to need 'em elsewhere.

llvm-svn: 126508
2011-02-25 20:49:16 +00:00
Chandler Carruth 301416380e Remove the FIXME I introduced last night, and pull the logic for
marking selected overloads into the callers. This allows a few callers
to skip it altogether (they would have anyways because they weren't
interested in successful overloads) or defer until after further checks
take place much like the check required for PR9323 to avoid marking
unused copy constructors.

llvm-svn: 126503
2011-02-25 19:41:05 +00:00
Fariborz Jahanian bff158dc67 Print optional message for attr(unavailable) in C++ mode.
// rdar://9046492

llvm-svn: 126499
2011-02-25 18:38:59 +00:00
Douglas Gregor a6ce608b97 Push nested-name-specifier source-location information into
pseudo-destructor expressions. Also, clean up some
template-instantiation and type-checking issues with
pseudo-destructors.

llvm-svn: 126498
2011-02-25 18:19:59 +00:00
Douglas Gregor c05ba2ef12 Push nested-name-specifier source location information into namespace
aliases.

llvm-svn: 126496
2011-02-25 17:08:07 +00:00
Douglas Gregor 12441b3bc5 Push nested-name-specifier source location information into using directives.
llvm-svn: 126489
2011-02-25 16:33:46 +00:00
Chandler Carruth a28097da4f Rough fix for PR9323 that prevents Clang from marking copy constructor
declarations as referenced when in fact we're not going to even form
a call in the AST. This is significant because we attempt to allow as an
extension classes with intentionally private and undefined copy
constructors to have temporaries bound to references, and so shouldn't
warn about the lack of definition for that copy constructor when the
class is internal.

Doug, John wasn't really satisfied with the presence of overloading at
all. This is a stop-gap and there may be a better solution. If you can
give me some hints for how you'd prefer to see this solved, I'll happily
switch things over.

llvm-svn: 126480
2011-02-25 08:52:25 +00:00
Chandler Carruth ebd3375ba2 Give this warning a flag that can be used to turn it off in old, crufty,
legacy code that contains dead code paths referring to such
declarations.

llvm-svn: 126478
2011-02-25 06:53:20 +00:00
Douglas Gregor 144548072d Use NestedNameSpecifierLoc within out-of-line variables, function, and
tag definitions. Also, add support for template instantiation of
NestedNameSpecifierLocs.

llvm-svn: 126470
2011-02-25 02:25:35 +00:00
Ted Kremenek b6f9ab6378 Teach TextDiagnosticPrinter to print out '-Werror' in addition to the warning flag for a warning mapped to an error.
For example:

t.c:7:9: error: using the result of an assignment as a condition without parentheses [-Werror,-Wparentheses]

llvm-svn: 126466
2011-02-25 01:28:26 +00:00
Douglas Gregor a9d87bc6ac Update UsingDecl, UnresolvedUsingTypenameDecl, and
UnresolvedUsingValueDecl to use NestedNameSpecifierLoc rather than the
extremely-lossy NestedNameSpecifier/SourceRange pair it used to use,
improving source-location information.

Various infrastructure updates to support NestedNameSpecifierLoc:
  - AST/PCH (de-)serialization
  - Recursive AST visitor
  - libclang traversal (including the first tests of this
    functionality)

llvm-svn: 126459
2011-02-25 00:36:19 +00:00
Argyrios Kyrtzidis 17bee3e70a Intoduce '-analyzer-checker-help' flag which outputs a list of all available static analyzer checkers.
This is pretty basic for now, eventually checkers should be grouped according to package, hidden checkers should be indicated etc.

llvm-svn: 126454
2011-02-25 00:09:51 +00:00
Argyrios Kyrtzidis b388f77ad9 [analyzer] Remove '-analyzer-experimental-internal-checks' flag, it doesn't have any checkers associated with it anymore.
llvm-svn: 126440
2011-02-24 21:43:08 +00:00
Douglas Gregor 869ad45f8f Retain complete source-location information for C++
nested-name-specifiers throughout the parser, and provide a new class
(NestedNameSpecifierLoc) that contains a nested-name-specifier along
with its type-source information.

Right now, this information is completely useless, because we don't
actually store the source-location information anywhere in the
AST. Call this Step 1/N.

llvm-svn: 126391
2011-02-24 17:54:50 +00:00
Chandler Carruth e721185799 Simplify messages as requested by Chris.
llvm-svn: 126389
2011-02-24 17:13:15 +00:00
Axel Naumann 016538ad2a From Vassil Vassilev:
Add an interface for last resort, unqualified lookup. It can provide results for unqualified lookup when Sema fails to find anything itself.

llvm-svn: 126387
2011-02-24 16:47:47 +00:00
Argyrios Kyrtzidis dd407f423b [analyzer] Migrate ArrayBoundChecker to CheckerV2.
llvm-svn: 126371
2011-02-24 08:42:12 +00:00
Argyrios Kyrtzidis 8f38c3843d [analyzer] Don't pass a GRState to CheckerManager::runCheckersForLocation, terrible mistake.
If the state is new, make sure an ExplodedNode is associated with it.

llvm-svn: 126370
2011-02-24 08:42:04 +00:00
Douglas Gregor 7b26ff912f Teach NestedNameSpecifier to keep track of namespace aliases the same
way it keeps track of namespaces. Previously, we would map from the
namespace alias to its underlying namespace when building a
nested-name-specifier, losing source information in the process.

llvm-svn: 126358
2011-02-24 02:36:08 +00:00
Argyrios Kyrtzidis 4769e9376e [analyzer] Remove unused functions from CheckerManager.
llvm-svn: 126352
2011-02-24 01:05:37 +00:00
Argyrios Kyrtzidis c26f15dbad [analyzer] Migrate CStringChecker to CheckerV2.
llvm-svn: 126350
2011-02-24 01:05:30 +00:00
Douglas Gregor 2ab3fee3f3 Tweak the CXXScopeSpec API a bit, so that we require the
nested-name-specifier and source range to be set at the same time.

llvm-svn: 126347
2011-02-24 00:49:34 +00:00
Douglas Gregor 90c9972fb2 Teach CXXScopeSpec to handle the extension of a nested-name-specifier
with another component in the nested-name-specifiers, updating its
representation (a NestedNameSpecifier) and source-location information
(currently a SourceRange) simultaneously. This is groundwork for
adding source-location information to nested-name-specifiers.

llvm-svn: 126346
2011-02-24 00:17:56 +00:00
Chandler Carruth 4c6fdca035 Implement a warning for known shift overflows on constant shift
expressions. Consider the code:

  int64_t i = 10 << 30;

This compiles fine, but most developers expect it to produce the value
for 10 gigs, not -2 gigs. This is actually undefined behavior because
the LHS is a signed integer type.

The warning is currently gated behind -Wshift-overflow.

There is a special case where only the sign bit is overridden that gets
a custom error message and is by default ignored. This case is much less
likely to cause observed buggy behavior, it's just undefined behavior
according to the spec. This warning can be enabled with
-Wshift-sign-overflow.

Original patch by Oleg Slezberg, with style tweaks and some correctness
fixes by me.

llvm-svn: 126342
2011-02-23 23:34:11 +00:00
Nick Lewycky 3607989847 Preserve what the user passed to -include when emitting .d files. Fixes PR8974!
llvm-svn: 126334
2011-02-23 21:16:44 +00:00
Argyrios Kyrtzidis 506220fef7 [analyzer] Migrate StackAddrLeakChecker to CheckerV2.
llvm-svn: 126333
2011-02-23 21:04:54 +00:00
Argyrios Kyrtzidis f1b5d1f01b [analyzer] Refactor EndOfFunctionNodeBuilder.
-Introduce EndOfFunctionNodeBuilder::withCheckerTag to allow it be "specialized" with a
 checker tag and not require the checkers to pass a tag.
-For EndOfFunctionNodeBuilder::generateNode, reverse the order of tag/P parameters since
 there are actual calls that assume the second parameter is ExplodedNode.

llvm-svn: 126332
2011-02-23 21:04:49 +00:00
Argyrios Kyrtzidis 68cab73ab9 [analyzer] const goodness.
llvm-svn: 126326
2011-02-23 19:38:45 +00:00
Argyrios Kyrtzidis da02a25ae6 [analyzer] Migrate ChrootChecker to CheckerV2.
llvm-svn: 126324
2011-02-23 19:38:39 +00:00
Matt Beaumont-Gay 5d2144602f fix typo
llvm-svn: 126323
2011-02-23 18:55:30 +00:00
Chandler Carruth e71b378dc7 Fix the behavior of -Wignored-qualifiers on return type qualifiers in
several ways. We now warn for more of the return types, and correctly
locate the ignored ones. Also adds fix-it hints to remove the ignored
qualifiers. Fixes much of PR9058, although not all of it.

Patch by Hans Wennborg, a couple of minor style tweaks from me.

llvm-svn: 126321
2011-02-23 18:51:59 +00:00
Douglas Gregor 4a4e0eb782 Mention libclang in the Doxygen documentation
llvm-svn: 126316
2011-02-23 17:45:25 +00:00
Argyrios Kyrtzidis bf61d97a98 [analyzer] Migrate UnreachableCodeChecker to CheckerV2.
llvm-svn: 126308
2011-02-23 07:19:23 +00:00
Argyrios Kyrtzidis 99ea46462a [analyzer] Add LangOptions in CheckerManager.
llvm-svn: 126306
2011-02-23 07:19:14 +00:00
Anders Carlsson 33e56a047f Add a -fcxx-exceptions flag to clang -cc1. This controls the newly added CXXExceptions flag.
llvm-svn: 126300
2011-02-23 03:16:42 +00:00
Anders Carlsson 6bbd268396 Add a CXXExceptions flag to LangOptions.
llvm-svn: 126299
2011-02-23 03:04:54 +00:00
Ted Kremenek 204f1d26d4 Add doxygen comments to Sema::DiagRuntimeBehavior().
llvm-svn: 126296
2011-02-23 02:26:43 +00:00
Peter Collingbourne 4b66c47a16 Sema: diagnose kernel calls to non-global functions
llvm-svn: 126292
2011-02-23 01:53:29 +00:00
Ted Kremenek 3427fac7c8 Enhance Sema::DiagRuntimeBehavior() to delay some diagnostics to see if the related code is reachable. This suppresses some
diagnostics that occur in unreachable code (e.g., -Warray-bound).

We only pay the cost of doing the reachability analysis when we issue one of these diagnostics.

llvm-svn: 126290
2011-02-23 01:52:04 +00:00
Ted Kremenek 80861ca9b5 Migrate CFGReachabilityAnalysis out of the IdempotentOperationsChecker and into its own analysis file.
llvm-svn: 126289
2011-02-23 01:51:59 +00:00
Ted Kremenek cc7f1f8c2e Have IdempotentOperationsChecker pull its CFGStmtMap from AnalysisContext.
llvm-svn: 126288
2011-02-23 01:51:53 +00:00
Ted Kremenek 1767a27b3e Issue AnalysisBasedWarnings as part of calling Sema::PopBlockOrFunctionScope(). No real functionality change.
llvm-svn: 126287
2011-02-23 01:51:48 +00:00
Ted Kremenek 55ae319a28 Update Sema::DiagRuntimeBehavior() to take an optional Stmt* to indicate the code the diagnostic is associated with.
This Stmt* is unused, but we will use it shortly for pruning diagnostics associated
with unreachable code.

llvm-svn: 126286
2011-02-23 01:51:43 +00:00
Chandler Carruth 1aef0c5621 Switch the VerifyDiagnosticsClient to use PresumedLocs now that they
exist. Cheat and do this by adding some wrappers around the PresumedLoc
machinery that directly return the line and column number.

llvm-svn: 126281
2011-02-23 00:47:48 +00:00
Richard Smith 2abf6767e3 Fix PR9276: We were missing the checks for auto deducing to different types in the same declaration group in the template instantiation case.
llvm-svn: 126279
2011-02-23 00:37:57 +00:00
Argyrios Kyrtzidis 9631dbe5ce Silence a MSVC warning.
llvm-svn: 126273
2011-02-23 00:16:04 +00:00
Argyrios Kyrtzidis a1540db6e4 [analyzer] Refactor BugTypes and their ownership model.
-In general, don't have the BugReporter deleting BugTypes, BugTypes will eventually become owned by checkers
 and outlive the BugReporter. In the meantime, there will be some leaks since some checkers assume that
 the BugTypes they create will be destroyed by the BugReporter.
-Have BugReporter::EmitBasicReport create BugTypes that are reused if the same name & category strings
 are passed to EmitBasicReport. These BugTypes are owned and destroyed by the BugReporter.
 This allows bugs reported through EmitBasicReport to be coalesced.
-Remove the llvm::FoldingSet<BugReportEquivClass> from BugType and move it into the BugReporter.
 For uniquing BugReportEquivClass also use the BugType* so that we can iterate over all of them using only one set.

llvm-svn: 126272
2011-02-23 00:16:01 +00:00
Richard Smith e97a53a446 DeclGroup's operator[] always returned the first Decl in the group.
llvm-svn: 126268
2011-02-23 00:09:59 +00:00
Matt Beaumont-Gay 06de2553f3 Clean up the error recovery at the bottom of Sema::LookupMemberExpr. This
mostly just shuffles various possibilities for recovery into a more
straightforward order, but also unifies a couple of diagnostics.

llvm-svn: 126266
2011-02-22 23:52:53 +00:00
Fariborz Jahanian bb6db56028 Provide Fixit warning when 'auto' is intended as storage
specifier in legacy code. Patch is reviewed offline by Doug.
// rdar://9036633.

llvm-svn: 126261
2011-02-22 23:17:49 +00:00
John McCall 147d021b75 Emit the structure layout of the block literal parameter to a block
invocation function into the debug info.  Rather than faking up a class,
which is tricky because of the custom layout we do, we just emit a struct
directly from the layout information we've already got.

Also, don't emit an unnecessarily parameter alloca for this "variable".

llvm-svn: 126255
2011-02-22 22:38:33 +00:00
John McCall 550d13aebb Give ImplicitParamDecl a public constructor so that it can be allocated on
the stack.

llvm-svn: 126254
2011-02-22 22:25:56 +00:00
John McCall b67608fe83 Provide a Decl::getNonClosureContext to look through any "closure" (i.e.
block and, eventually, C++ lambda) contexts.

llvm-svn: 126252
2011-02-22 22:25:23 +00:00
Douglas Gregor a1aec29a2d Enable enumeration types with a fixed underlying type, e.g.,
enum X : long { Value = 0x100000000 };

when in Microsoft-extension mode (-fms-extensions). This (now C++0x)
feature has been supported since Microsoft Visual Studio .NET 2003.

llvm-svn: 126243
2011-02-22 20:32:04 +00:00
Douglas Gregor e2f943b5cb Implement the GNU C extension which permits the initialization of an
array from a constant array compound literal. Fixes PR9261.

llvm-svn: 126230
2011-02-22 18:29:51 +00:00
Argyrios Kyrtzidis ed35cf271d [analyzer] Start moving the path-sensitive checkers to CheckerV2.
-Migrate ObjCSelfInitChecker to CheckerV2. In the process remove the 'preCallSelfFlags' field
 from the checker class and use GRState for storing that info.
-Get ExprEngine to start delegating checker running to CheckerManager.

llvm-svn: 126229
2011-02-22 17:30:38 +00:00
Argyrios Kyrtzidis 98e35dda03 [analyzer] Separate CheckerContext into its own include file. No functionality change.
llvm-svn: 126228
2011-02-22 17:30:32 +00:00
Argyrios Kyrtzidis b9eae65c63 [analyzer] Fix GRStatePartialTrait<bool> and introduce GRStatePartialTrait<unsigned>.
llvm-svn: 126227
2011-02-22 17:30:28 +00:00
Joerg Sonnenberger fe74286a48 Remove the storage for -cxx-system-include. Make libcxx toolchain
use -nostdinc++ and -cxx-isystem.

llvm-svn: 126223
2011-02-22 15:19:35 +00:00
Peter Collingbourne f29ce975ba Reimplement __pragma support using a TokenLexer
llvm-svn: 126221
2011-02-22 13:49:06 +00:00
Peter Collingbourne 2c9f966600 Make TokenLexer capable of storing preprocessor directive tokens
llvm-svn: 126220
2011-02-22 13:49:00 +00:00
Douglas Gregor 6cd5ae4dfa Fix a little bug in the handling of enumeration types with a fixed
underlying type: we weren't parsing unnamed enumeration types with a
fixed underlying type.

llvm-svn: 126184
2011-02-22 02:55:24 +00:00
Douglas Gregor a78f193e7e Warn about implicit conversions between values of different, named
enumeration types. Fixes <rdar://problem/8559831>.

llvm-svn: 126183
2011-02-22 02:45:07 +00:00
Anders Carlsson 3320e1575f Make clang -cc1 disable Objective-C exceptions by default, and add a -fobjc-exceptions flag to turn them on.
Update all tests accordingly.

llvm-svn: 126177
2011-02-22 01:52:06 +00:00
Richard Smith 23eb9f707b In Objective-C, there are no trailing return types, so don't produce diagnostics suggesting they are missing.
llvm-svn: 126174
2011-02-22 01:22:29 +00:00
Joerg Sonnenberger cc9c8eb837 Bug#8945: Add -cxx-isystem option to specify C++ system directories.
It works like -isystem and the search path keeps -isystem and
-cxx-isystem in order relative to each other. -cxx-isystem is only used
for C++ sources though. Drop the existing -cxx-system-include option for
cc1 as it is now redundant.

llvm-svn: 126167
2011-02-22 00:40:56 +00:00
Richard Smith 59006e4338 Fix a few auto-related issues:
* 'auto' was being rejected on abstract-declarators with trailing return
types and on typedefs with trailing return types. 'auto' is always
allowed in these cases. This was found while testing the fix for PR 9278.

 * A very poor diagnostic was being issued for auto (f() -> int): "return
type must be 'auto', not 'auto'". This is closely related to PR 9060.

 * Trailing return type handling was happening slightly too late,
resulting in the checks for functions returning arrays and functions
returning functions being missed.

llvm-svn: 126166
2011-02-22 00:36:53 +00:00
Fariborz Jahanian d7b0cb5388 Warn when type modifiers on objc method declarations in
protocols do not match with method implementation.
// rdar://7076235

llvm-svn: 126162
2011-02-21 23:49:15 +00:00
Richard Smith 27e39b11b1 C++0x's deduced auto is illegal in typedefs.
This actually rules out too much, since it also catches typedefs for pointers to functions with trailing return types:

  typedef auto (*F)() -> int;

Fix for that (and the same issue in all abstract-declarators) to follow shortly.

llvm-svn: 126153
2011-02-21 23:18:00 +00:00
Chris Lattner 93ede02045 add one more case of mismatched input/output constraints.
When the mismatch is due to a larger input operand that is
a constant, truncate it down to the size of the output.  This
allows us to accept some cases in the linux kernel and elsewhere.
Pedantically speaking, we generate different code than GCC, though
I can't imagine how it would matter:

Clang:
	movb	$-1, %al
	frob %al

GCC:

	movl	$255, %eax
	frob %al

llvm-svn: 126148
2011-02-21 22:09:29 +00:00
Richard Smith b2bc2e6752 Tweaks to C++0x deduced auto type support:
* Flag indicating 'we're parsing this auto typed variable's initializer' moved from VarDecl to Sema
 * Temporary template parameter list for auto deduction is now allocated on the stack.
 * Deduced 'auto' types are now uniqued.

llvm-svn: 126139
2011-02-21 20:05:19 +00:00
Fariborz Jahanian f5bfc46c95 Remove warning on future change in ivar lookup rule
when doing the property default synthesis.
// rdar://9027673.

llvm-svn: 126128
2011-02-21 17:31:28 +00:00
John McCall 701417a0ac Pseudo-revirtualize CallExpr::getSourceRange by making it follow the
logic from CXXMemberCallExpr and by making it check for
CXXOperatorCallExpr in order to defer.  This is not really an awesome solution,
but I don't have a better idea.

llvm-svn: 126114
2011-02-21 06:23:05 +00:00
Chandler Carruth 468b5cbd40 Allow -Wformat to be enabled without -Wformat-security. GCC gates
-Wformat-security on -Wformat, not vice-versa.

Fixes PR8486. Patch by Oleg Slezberg.

llvm-svn: 126096
2011-02-21 00:07:51 +00:00
Oscar Fuentes 6f72540e46 New function for tablegenning: clang_tablegen.
llvm-svn: 126093
2011-02-20 22:06:32 +00:00
Richard Smith 30482bc786 Implement the C++0x deduced 'auto' feature.
This fixes PR 8738, 9060 and 9132.

llvm-svn: 126069
2011-02-20 03:19:35 +00:00
Ken Dyck d24099de04 Add const qualifier to getTypeInfoInChars().
llvm-svn: 126064
2011-02-20 01:55:18 +00:00
Anders Carlsson 08ce5ed1b1 Add a LangOptions::areExceptionsEnabled and start using it.
llvm-svn: 126062
2011-02-20 00:20:27 +00:00
Anders Carlsson ce8dd3a5d4 Add a new ObjCExceptions member variable to LangOptions. This controls whether Objective-C exceptions are enabled or not (they are by default).
llvm-svn: 126061
2011-02-19 23:53:54 +00:00
Peter Collingbourne 8f5cf74c77 Re-instate r125819 and r125820 with no functionality change
llvm-svn: 126060
2011-02-19 23:03:58 +00:00
Rafael Espindola a6d2bff0c5 Revert 125820 and 125819 to fix PR9266.
llvm-svn: 126050
2011-02-19 21:39:31 +00:00
Douglas Gregor b491ed36b4 Handle the resolution of a reference to a function template (which
includes explicitly-specified template arguments) to a function
template specialization in cases where no deduction is performed or
deduction fails. Patch by Faisal Vali, fixes PR7505!

llvm-svn: 126048
2011-02-19 21:32:49 +00:00
Peter Collingbourne 5de2850efb Reimplement Token::isAnnotation() using TokenKinds.def. No functionality change.
llvm-svn: 126045
2011-02-19 20:06:59 +00:00
Anders Carlsson 68b36aff46 Disallow try/catch/throw when exceptions are disabled.
llvm-svn: 126039
2011-02-19 19:26:44 +00:00
Douglas Gregor b11aad8cba Revert all of my commits that devirtualized the Decl hierarchy, which
lead to a serious slowdown (4%) on parsing of Cocoa.h. This memory
optimization should be revisited later, when we have time to look at
the generated code.

llvm-svn: 126033
2011-02-19 18:51:44 +00:00
Daniel Dunbar 1094bb101b Driver/Darwin: Support -Wl, with -Xarch_. This doesn't work naturally because of
the special way we model "linker input" arguments.

llvm-svn: 126023
2011-02-19 05:33:51 +00:00
Ted Kremenek ff6fd0f4b0 Change 'StoreRef' back to 'Store' in GRState, shrinking the size of GRState back by one pointer.
llvm-svn: 126020
2011-02-19 03:56:19 +00:00
John McCall 8377967543 Warn about code that uses variables and functions with internal linkage
without defining them.  This should be an error, but I'm paranoid about
"uses" that end up not actually requiring a definition.  I'll revisit later.

Also, teach IR generation to not set internal linkage on variable
declarations, just for safety's sake.  Doing so produces an invalid module
if the variable is not ultimately defined.

Also, fix several places in the test suite where we were using internal
functions without definitions.

llvm-svn: 126016
2011-02-19 02:53:41 +00:00
Argyrios Kyrtzidis 21f347e729 [analyzer] Fix crash when analyzing C++ code.
llvm-svn: 126013
2011-02-19 01:59:41 +00:00
Ted Kremenek fda3687515 Add 'StoreRef' smart pointer to allow more fine-grain memory lifetime control of Store objects.
This yields a minor memory reduction (for larger functions) on Sqlite at the cost of slightly
higher memory usage on some functions because of the increased size of GRState (which can be optimized).

I expect the real memory savings from this enhancement will come when we aggressively
canabilize more of the ExplodedGraph.

llvm-svn: 126012
2011-02-19 01:59:33 +00:00
Chandler Carruth 98e3c568bf Fix PR8767, improve diagnostic wording when allocating an object of an
abstract class type.

Patch by Stephen Hines, with a wording tweak from Doug applied by me.

llvm-svn: 125996
2011-02-18 23:59:51 +00:00
Chandler Carruth a8bea4b90e Initial steps to improve diagnostics when there is a NULL and
a non-pointer on the two sides of a conditional expression.

Patch by Stephen Hines and Mihai Rusu.

llvm-svn: 125995
2011-02-18 23:54:50 +00:00
Chandler Carruth 241b31378d Check for NULL child expressions before visiting them, as the first
thing the visit does is dyn_cast<>, which leads to a nasty segfault.

llvm-svn: 125993
2011-02-18 23:42:00 +00:00
Douglas Gregor 3a69eafa88 When code-completing a case statement for a switch on a value of
enumeration type, prioritize the enumeration constants and don't
provide completions for any other expressions. Fixes <rdar://problem/7283668>.

llvm-svn: 125991
2011-02-18 23:30:37 +00:00
Douglas Gregor af2a6ae429 Selector::getIdentifierInfoForSlot() can return NULL values, a fact
that was ignored in a few places (most notably, code
completion). Introduce Selector::getNameForSlot() for the common case
where we only care about the name. Audit all uses of
getIdentifierInfoForSlot(), switching many over to getNameForSlot(),
fixing a few crashers.

Fixed <rdar://problem/8939352>, a code-completion crasher.

llvm-svn: 125977
2011-02-18 22:29:55 +00:00
Chris Lattner 9ba479bd2c fix rdar://9024687, a crash on invalid that we used to silently ignore.
llvm-svn: 125962
2011-02-18 21:16:39 +00:00
Argyrios Kyrtzidis 32d1040519 [analyzer] Fix a crash when analyzing C++ code.
llvm-svn: 125958
2011-02-18 20:55:19 +00:00
Argyrios Kyrtzidis 1bdd68871e Introduce ASTContext::getLogicalOperationType() to return bool or int, depending on language.
No functionality change.

llvm-svn: 125957
2011-02-18 20:55:15 +00:00
Peter Collingbourne 14a552b2d7 Move CompilerInstance::LLVMContext and LLVMContext ownership to CodeGenAction
This removes the final dependency edge from any lib outside of CodeGen
to core.  As a result we can, and do, trim the dependency on core
from libclang, PrintFunctionNames, the unit tests and c-index-test.
While at it, review and trim other unneeded dependencies.

llvm-svn: 125820
2011-02-18 02:25:12 +00:00
Peter Collingbourne 3ae6caaf1b Move TargetInfo::adjustInlineAsmType to TargetCodeGenInfo
llvm-svn: 125819
2011-02-18 02:24:56 +00:00
Chris Lattner 43e7f31f11 implement basic support for __label__. I wouldn't be shocked if there are
bugs from other clients that don't expect to see a LabelDecl in a DeclStmt,
but if so they should be easy to fix.

This implements most of PR3429 and rdar://8287027

llvm-svn: 125817
2011-02-18 02:08:43 +00:00
Argyrios Kyrtzidis 951e22e2c9 Handle UsingDecl in CFGRecStmtDeclVisitor.
llvm-svn: 125814
2011-02-18 01:44:17 +00:00
Chris Lattner ebb5c6c717 Switch labels over to using normal name lookup, instead of their
own weird little DenseMap.  Hey look, we now emit unused label
warnings deterministically, amazing.

llvm-svn: 125813
2011-02-18 01:27:55 +00:00
Francois Pichet f9e7f09c84 Unbreak the MSVC build
std::make_pair is unreliable under MSVC 2010.

Ref: http://stackoverflow.com/questions/2691680/why-does-visual-studio-2010-throw-this-error-with-boost-1-42-0
llvm-svn: 125811
2011-02-18 01:25:16 +00:00
Chris Lattner 60f844916c make block bodies handle undefined labels just like functions.
llvm-svn: 125799
2011-02-17 23:58:47 +00:00
Argyrios Kyrtzidis 57d736fd46 [analyzer] Use the new registration mechanism for the debugging info "checks".
The relative checker package is 'debug':

'-dump-live-variables' is replaced by '-analyzer-checker=debug.DumpLiveVars'
'-cfg-view' is replaced by '-analyzer-checker=debug.ViewCFG'
'-cfg-dump' is replaced by '-analyzer-checker=debug.DumpCFG'

llvm-svn: 125780
2011-02-17 21:39:39 +00:00
Argyrios Kyrtzidis af45aca670 [analyzer] Use the new registration mechanism on the non-path-sensitive-checkers:
DeadStoresChecker
  ObjCMethSigsChecker
  ObjCUnusedIvarsChecker
  SizeofPointerChecker
  ObjCDeallocChecker
  SecuritySyntaxChecker

llvm-svn: 125779
2011-02-17 21:39:33 +00:00
Argyrios Kyrtzidis 24ffc08f39 [analyzer]
-Introduce CheckerV2, a set of templates for convenient declaration & registration of checkers.
 Currently useful just for checkers working on the AST not the path-sensitive ones.
-Enhance CheckerManager to actually collect the checkers and turn it into the entry point for
 running the checkers.
-Use the new mechanism for the LLVMConventionsChecker.

llvm-svn: 125778
2011-02-17 21:39:24 +00:00
Argyrios Kyrtzidis 507ff53e39 [analyzer] Pass CheckerManager to the registration functions.
llvm-svn: 125777
2011-02-17 21:39:17 +00:00
Chandler Carruth 2a666fc2c7 Clean up the style of this function to match the conventions in the rest
of Clang, and reflows the code a bit to make it easier to read.

llvm-svn: 125773
2011-02-17 20:55:08 +00:00
Chris Lattner cab02a60d2 Step #2/N of __label__ support: keep pushing LabelDecl forward,
making them be template instantiated in a more normal way and 
make them handle attributes like other decls.

This fixes the used/unused label handling stuff, making it use
the same infrastructure as other decls.

llvm-svn: 125771
2011-02-17 20:34:02 +00:00
Chris Lattner 50c3c1316a Inline LocalInstantiationScope::getInstantiationOf into its one
client, making room for future hacking.

llvm-svn: 125770
2011-02-17 19:47:42 +00:00
Chris Lattner bdc1a42aef remove some dead overloads.
llvm-svn: 125768
2011-02-17 19:37:28 +00:00
Douglas Gregor d6f8124c9c Eliminate the internal command-line option for viewing inheritance in C++ classes, since it's only really worked for the trivial cases anyway due to lame pseudo-parsing of the class name. The viewInheritance() function is still available for use in the debugger, where this is far more useful
llvm-svn: 125762
2011-02-17 19:04:40 +00:00
Douglas Gregor 65f57fe6ea Replace a FIXME with a comment describing why we did what we did
llvm-svn: 125757
2011-02-17 18:32:37 +00:00
Douglas Gregor e5de7013c7 Remove the last virtual member function from the Decl hierarchy,
reducing the size of all declarations by one pointer. For a 64-bit
Clang parsing Cocoa.h, this saves ~630k of memory (about 3.5% of
ASTContext's memory usage for this header).

llvm-svn: 125756
2011-02-17 18:14:32 +00:00
Douglas Gregor b494173c93 Devirtualize TagDecl::completeDefinition().
llvm-svn: 125755
2011-02-17 18:06:05 +00:00
Douglas Gregor fe590dfa84 Devirtualize DeclaratorDecl::getInnerLocStart() and TagDecl::getInnerLocStart().
llvm-svn: 125754
2011-02-17 17:39:40 +00:00
Fariborz Jahanian 5fc74804a6 Improve diagnostics on missing property decl.
llvm-svn: 125752
2011-02-17 17:30:05 +00:00
Douglas Gregor a991f3a4e9 Devirtualize NamedDecl::getNameForDiagnostic().
llvm-svn: 125751
2011-02-17 17:23:19 +00:00
Douglas Gregor 0215459c37 Devirtualize RedeclarableTemplateDecl::newCommon().
llvm-svn: 125750
2011-02-17 17:10:20 +00:00
Chandler Carruth 22c7a79a1d Implement a sub-group of -Wconversion: -Wliteral-conversion. This
specifically targets literals which are implicitly converted, a those
are more often unintended and trivial to fix. This can be especially
helpful for diagnosing what makes 'const int x = 1e6' not an ICE.

Original patch authored by Jim Meehan with contributions from other
Googlers and a few cleanups from myself.

llvm-svn: 125745
2011-02-17 11:05:49 +00:00
John McCall c07a0c7e48 Change the representation of GNU ?: expressions to use a different expression
class and to bind the shared value using OpaqueValueExpr.  This fixes an
unnoticed problem with deserialization of these expressions where the
deserialized form would lose the vital pointer-equality trait;  or rather,
it fixes it because this patch also does the right thing for deserializing
OVEs.

Change OVEs to not be a "temporary object" in the sense that copy elision is
permitted.

This new representation is not totally unawkward to work with, but I think
that's really part and parcel with the semantics we're modelling here.  In
particular, it's much easier to fix things like the copy elision bug and to
make the CFG look right.

I've tried to update the analyzer to deal with this in at least some          
obvious cases, and I think we get a much better CFG out, but the printing
of OpaqueValueExprs probably needs some work.

llvm-svn: 125744
2011-02-17 10:25:35 +00:00
Douglas Gregor 133edddd82 Devirtualize Decl::getNextRedeclaration().
llvm-svn: 125740
2011-02-17 08:47:29 +00:00
Chandler Carruth 712563bba4 Implement -Wenum-compare, which warns when comparing two enums of
different types. We omit the warning when the enum types are anonymous.
Unlike GCC, this warning does not distinguish between C++ and C/ObjC for
controling whether it is on by default, it is always on by default.

Original patch contributed by Richard Trieu (@ Google), I fixed some
style issues, and cleaned it up for submission.

llvm-svn: 125739
2011-02-17 08:37:06 +00:00
Douglas Gregor 00716e8bd3 Devirtualize Decl::getSourceRange()
llvm-svn: 125736
2011-02-17 08:12:32 +00:00
Douglas Gregor 7edc20ac24 Devirtualize Decl::getCanonicalDecl().
llvm-svn: 125735
2011-02-17 07:58:36 +00:00
Chris Lattner c8e630e4db Step #1/N of implementing support for __label__: split labels into
LabelDecl and LabelStmt.  There is a 1-1 correspondence between the
two, but this simplifies a bunch of code by itself.  This is because
labels are the only place where we previously had references to random
other statements, causing grief for AST serialization and other stuff.

This does cause one regression (attr(unused) doesn't silence unused
label warnings) which I'll address next.

This does fix some minor bugs:
1. "The only valid attribute " diagnostic was capitalized.
2. Various diagnostics printed as ''labelname'' instead of 'labelname'
3. This reduces duplication of label checking between functions and blocks.

Review appreciated, particularly for the cindex and template bits.

llvm-svn: 125733
2011-02-17 07:39:24 +00:00
Douglas Gregor f7b2c93b2f Devirtualize Decl::getBody() and Decl::hasBody().
llvm-svn: 125731
2011-02-17 07:13:24 +00:00
Douglas Gregor a43942a48e De-virtualize Decl::isOutOfLine().
llvm-svn: 125730
2011-02-17 07:02:32 +00:00
Chris Lattner e281e99f76 tidy up
llvm-svn: 125723
2011-02-17 05:19:40 +00:00
Matt Beaumont-Gay 956fc1cb81 Fix PR9025 and add a diagnostic (and sometimes a fixit) for an overloaded
function name used as the base of a member expression. Early feedback from
Chandler Carruth, and code review from Nick Lewycky.

llvm-svn: 125714
2011-02-17 02:54:17 +00:00
Ted Kremenek 06e2474d51 Bump up IdentifierInfo::ObjCOrBuiltinID to use 11 bits instead of 10. Fixes PR 9231.
Apparently we can blow out the number of builtin IDs on FreeBSD with only 10 bits.

llvm-svn: 125713
2011-02-17 02:43:00 +00:00
Fariborz Jahanian 05d389f407 Improve diagnostics when property names an object type of
a forward class. // rdar://8851803

llvm-svn: 125699
2011-02-17 01:26:14 +00:00
Douglas Gregor 669a25aec3 Implement code completion results for the Objective-C Key-Value Coding
(KVC) and Key-Value Observing (KVO) protocols.

llvm-svn: 125696
2011-02-17 00:22:45 +00:00
Ted Kremenek 3a854f8ad2 Placate Doug and change capitalization of diagnostic note.
llvm-svn: 125688
2011-02-16 22:08:28 +00:00
Zhanyong Wan 85a203ebdd Makes most methods in SVals.h conform to the naming guide. Reviewed
by kremenek.

llvm-svn: 125687
2011-02-16 21:13:32 +00:00
Chandler Carruth 83ac424574 3000 Sema diagnostics should be enough for anyone.
llvm-svn: 125684
2011-02-16 19:41:58 +00:00
Douglas Gregor 162b712d38 Teach the CXCodeCompleteResults results structure, which stores
code-completion results accessed via libclang, to extend the lifetime
of the allocator used for cached global code-completion results at
least until these completion results are destroyed. Fixes
<rdar://problem/8997369>.

llvm-svn: 125678
2011-02-16 19:08:06 +00:00
Douglas Gregor df7a79a997 Improve the invalidation logic for the cache of global code
completions. We now compute a hash of the names of all top-level
declarations and macro definitions, and invalidate the cache when the
hash value changes.

llvm-svn: 125670
2011-02-16 18:16:54 +00:00
Douglas Gregor 012b69d5bb Teach PPChainedCallbacks to forward the InclusionDirective() callback.
llvm-svn: 125669
2011-02-16 18:15:35 +00:00
Argyrios Kyrtzidis d691ad1680 Warning -> ExtWarn
llvm-svn: 125664
2011-02-16 16:23:31 +00:00
John McCall 1bf5846abf Save a copy expression for non-trivial copy constructions of catch variables.
llvm-svn: 125661
2011-02-16 08:02:54 +00:00
Ted Kremenek 108b2d56bf Tweak -Warray-bounds diagnostics based on feedback from Chandler.
llvm-svn: 125649
2011-02-16 04:01:44 +00:00
Ted Kremenek 64699befcd Add trivial buffer overflow checking in Sema.
llvm-svn: 125640
2011-02-16 01:57:07 +00:00
Argyrios Kyrtzidis 9d4d4f9104 [analyzer] Use the new registration mechanism on the apple checkers:
NilArgChecker
  CFNumberCreateChecker
  NSAutoreleasePoolChecker
  CFRetainReleaseChecker
  ClassReleaseChecker

llvm-svn: 125636
2011-02-16 01:40:52 +00:00
Fariborz Jahanian 0c87d36d9d Fix typo (per Chris's comment).
llvm-svn: 125619
2011-02-16 00:14:11 +00:00
Argyrios Kyrtzidis c541ade850 Warn for missing terminating " or ' instead of error for gcc compatibility. Fixed rdar://8914293.
llvm-svn: 125616
2011-02-15 23:45:31 +00:00
Argyrios Kyrtzidis b2400924d9 [analyzer] Use the new registration mechanism on the IdempotentOperationChecker.
llvm-svn: 125611
2011-02-15 22:55:14 +00:00
Douglas Gregor f34a6f0fef Implement a special code-completion pattern for "IBAction". Fixes
<rdar://problem/8767704>.

llvm-svn: 125604
2011-02-15 22:19:42 +00:00
Argyrios Kyrtzidis f81ff04ba3 [analyzer] Remove ObjCSelfInitCheck from AnalyzerOptions.
llvm-svn: 125599
2011-02-15 21:25:07 +00:00
Douglas Gregor 8003924d10 When code-completing within a list of declaration specifiers,
separately handle the case of a local declaration-specifier list,
including all types in the set of options. Fixes
<rdar://problem/8790735> and <rdar://problem/8662831>.

llvm-svn: 125594
2011-02-15 20:33:25 +00:00
Peter Collingbourne 5df20e02af Serialization/deserialization support for floating point #pragma
options, enabled OpenCL extensions and default FP_CONTRACT setting.

llvm-svn: 125589
2011-02-15 19:46:30 +00:00
Peter Collingbourne e87167b7d8 OpenCL: semantic analysis support for cl_khr_fp64 extension
llvm-svn: 125588
2011-02-15 19:46:23 +00:00
Argyrios Kyrtzidis 10b2368e9f Allow resolving headers from a PCH even after headers+PCH were moved to another path.
Store in PCH the directory that the PCH was originally created in.
If a header file is not found at the path that we expect it to be and the PCH file
was moved from its original location, try to resolve the file by assuming that
header+PCH were moved together and the header is in the same place relative to the PCH.

llvm-svn: 125576
2011-02-15 17:54:22 +00:00
Argyrios Kyrtzidis 6fa0d20a6f Fix the clang-wpa example.
llvm-svn: 125565
2011-02-15 16:54:12 +00:00
Argyrios Kyrtzidis f2ec88ea54 Initialize InlineCall in AnalyzerOptions.
llvm-svn: 125564
2011-02-15 16:54:07 +00:00
Argyrios Kyrtzidis 4e52527c28 [analyzer] Reflect changes for tablegen'ing the checkers.
-Update tablegen files for checkers, use the tablegen class name for the checker class name.
-Update ClangSACheckersProvider to not look into hidden checker packages.

llvm-svn: 125560
2011-02-15 07:42:38 +00:00
Ken Dyck 7ad11e70b6 Convert RecordLayout::Alignment to CharUnits from bit units. No change in
functionality intended. 

llvm-svn: 125549
2011-02-15 02:32:40 +00:00
Fariborz Jahanian d33ab8c635 Warn if method for a deprecated method is implemented.
Warn if class for a deprecated class is implemented.
Warn if category for a deprecated class is implemented.
All under control of -Wdeprecated-implementations.
// rdar://8973810.

llvm-svn: 125545
2011-02-15 00:59:30 +00:00
Ted Kremenek 05e63e0e37 Put "incomplete implementation" warning under a flag.
llvm-svn: 125535
2011-02-14 23:59:16 +00:00
John McCall 909acf8209 Provide overload diagnostics when explicit casts involving class types fail.
PR8626.

llvm-svn: 125506
2011-02-14 18:34:10 +00:00
Argyrios Kyrtzidis 556c45e9c5 [analyzer] Overhauling of the checker registration mechanism.
-Checkers will be defined in the tablegen file 'Checkers.td'.
-Apart from checkers, we can define checker "packages" that will contain a collection of checkers.
-Checkers can be enabled with -analyzer-checker=<name> and disabled with -analyzer-disable-checker=<name> e.g:
	Enable checkers from 'cocoa' and 'corefoundation' packages except the self-initialization checker:
	-analyzer-checker=cocoa -analyzer-checker=corefoundation -analyzer-disable-checker=cocoa.SelfInit
-Introduces CheckerManager and CheckerProvider. CheckerProviders get the set of checker names to enable/disable and
 register them with the CheckerManager which will be the entry point for all checker-related functionality.

Currently only the self-initialization checker takes advantage of the new mechanism.

llvm-svn: 125503
2011-02-14 18:13:31 +00:00
Argyrios Kyrtzidis 4ec3cf9937 [analyzer] Remove ManagerRegistry which is not used. In the future we may load analyzer plugins dynamically but
registration through static constructors should be avoided.

llvm-svn: 125502
2011-02-14 18:13:17 +00:00
Argyrios Kyrtzidis 2ef5f3c1c5 [analyzer] Move include/clang/StaticAnalyzer/AnalysisConsumer.h -> lib/StaticAnalyzer/Frontend/AnalysisConsumer.h since
FrontendActions.cpp is the only user.

llvm-svn: 125501
2011-02-14 18:13:11 +00:00
Jeffrey Yasskin 9170c73d26 Add support for the builtins used in gcc 4.4's <cmath> and <complex>
headers in C++0x mode.  Fixes PR9138.

Patch by John Bytheway!

llvm-svn: 125492
2011-02-14 17:02:48 +00:00
Ted Kremenek 9909df3b3a Handle 'UsingDirective' in CFGRecStmtDeclVisitor.
llvm-svn: 125491
2011-02-14 17:00:16 +00:00
John McCall c146582e60 When parsing an out-of-line member function declaration, we must delay
access-control diagnostics which arise from the portion of the declarator
following the scope specifier, just in case access is granted by
friending the individual method.  This can also happen with in-line
member function declarations of class templates due to templated-scope
friend declarations.

We were really playing fast-and-loose before with this sort of thing,
and it turned out to work because *most* friend functions are in file
scope.  Making us delay regardless of context exposed several bugs with
how we were manipulating delay.  I ended up needing a concept of a
context that's independent of the declarations in which it appears,
and then I actually had to make some things save contexts correctly,
but delay should be much cleaner now.

I also encapsulated all the delayed-diagnostics machinery in a single
subobject of Sema;  this is a pattern we might want to consider rolling
out to other components of Sema.

llvm-svn: 125485
2011-02-14 07:13:47 +00:00
Peter Collingbourne cb26ef94d4 Add missing file
llvm-svn: 125478
2011-02-14 02:14:26 +00:00
Peter Collingbourne 7ce13fc940 OpenCL: add support for __kernel, kernel keywords and EXTENSION,
FP_CONTRACT pragmas.  Patch originally by ARM.

llvm-svn: 125475
2011-02-14 01:42:53 +00:00
Peter Collingbourne 564c0fa47a Move support for "#pragma STDC FP_CONTRACT" to Parser; add Sema actions
llvm-svn: 125474
2011-02-14 01:42:35 +00:00
Peter Collingbourne 3bffa52933 Make LexOnOffSwitch a Preprocessor member function
llvm-svn: 125473
2011-02-14 01:42:24 +00:00
John McCall 8322c3a197 Give some convenient idiomatic accessors to Stmt::child_range and
Stmt::const_child_range, then make a bunch of places use them instead
of the individual iterator accessors.

llvm-svn: 125450
2011-02-13 04:07:26 +00:00
John McCall 2b3c5538fa Look through array types when deciding whether a field requires non-trivial
destruction in the destructor-aliases logic.  Fixes PR 9197.

llvm-svn: 125447
2011-02-13 00:46:43 +00:00
Fariborz Jahanian 42455ea935 Implement objective-c++'s block pointer type matching involving
types which are contravariance in argument types and covariance
in return types. // rdar://8979379.

llvm-svn: 125445
2011-02-12 19:07:46 +00:00
Argyrios Kyrtzidis 9fdd25492c When reading the AST, delay loading of the redeclaration chain to avoid deeply nested calls.
Temporarily set the first (canonical) declaration as the previous one, which is the one that
matters, and mark the real previous DeclID to be loaded & attached later on.

Fixes rdar://8956193.

llvm-svn: 125434
2011-02-12 07:50:47 +00:00
Ted Kremenek 70aeefa17e Weaken the ObjCSelfInitChecker to only warn when one calls an 'init' method within an 'init' method. This is a temporary stop gap to avoid false positives while we investigate how to make it smarter.
llvm-svn: 125427
2011-02-12 03:03:54 +00:00
Ted Kremenek b1c392aa56 Don't emit a dead store for '++' operations unless it occurs with a return statement. We've never seen any other cases that were real bugs.
Fixes <rdar://problem/6962292>.

llvm-svn: 125419
2011-02-12 00:17:19 +00:00
Ted Kremenek 9865d7f0e6 Don't report dead stores on unreachable code paths. Fixes <rdar://problem/8405222>.
llvm-svn: 125415
2011-02-11 23:24:26 +00:00
Peter Collingbourne de32b20bdd Reject forbidden storage class specifiers in OpenCL. Patch by George Russell!
llvm-svn: 125399
2011-02-11 19:59:54 +00:00
Ted Kremenek eddeba0dae Rename 'InvalidateRegions()' to 'invalidateRegions()'.
llvm-svn: 125395
2011-02-11 19:48:15 +00:00
Douglas Gregor 46c50012ca Rename the operation that loads a preprocessed entity from a given offset to indicate that we're loading from an offset, not an index, lest one be confused. No functionality change.
llvm-svn: 125394
2011-02-11 19:46:30 +00:00
Zhanyong Wan e1dd3e2c31 Improves Clang's virtual file handling.
This patch contains:

- making some of the existing comments more accurate in the presence
of virtual files/directories.

- renaming some private data members of FileManager to match their roles better.

- creating 'DirectorEntry's for the parent directories of virtual
files, such that we can tell whether two virtual files are from the
same directory.  This is useful for injecting virtual files whose
directories don't exist in the real file system.

- minor clean-ups and adding comments for class
FileManager::UniqueDirContainer and FileManager::UniqueFileContainer.

- adding statistics on virtual files to FileManager::PrintStats().

- adding unit tests to verify the existing and new behavior of FileManager.

llvm-svn: 125384
2011-02-11 18:44:49 +00:00
Ted Kremenek 5662dfefad Allow the 'Eng' entry in GRStateManager to be a (possibly null) pointer instead of a reference.
llvm-svn: 125362
2011-02-11 04:20:16 +00:00
Rafael Espindola 3968cd0f7b For consistency, use llvm::raw_ostream in the rest of the mangle api.
llvm-svn: 125360
2011-02-11 02:52:17 +00:00
Ken Dyck d5090c16f8 Convert RecordLayout::DataSize to CharUnits from bits, eliminating two
unnecessary calls to RoundUpToAlignment. No changes to functionality
intended.

llvm-svn: 125356
2011-02-11 02:20:09 +00:00
Ken Dyck b0fcc59e19 Add a helper function, ASTContext::toBits(), that converts sizes in
CharUnits to sizes in bits, and use it to tidy up the places where the
conversion was done explicitly.

llvm-svn: 125332
2011-02-11 01:54:29 +00:00
Rafael Espindola a759d72d7b Use raw_ostream instead of raw_svector_ostream.
llvm-svn: 125330
2011-02-11 01:41:00 +00:00
Douglas Gregor 68051a74ec Implement AST/PCH chaining support for macro definitions. Previously,
we would deserialize all of the macro definitions we knew about while
serializing the macro definitions at the end of the AST/PCH file. Even
though we skipped most of them (since they were unchanged), it's still
a performance problem.

Now, we do the standard AST/PCH chaining trick: watch what identifiers
are deserialized as macro names, and consider only those identifiers
(along with macro definitions that have been deserialized/written in
the source) when serializing the preprocessor state.

llvm-svn: 125324
2011-02-11 00:26:14 +00:00
Rafael Espindola ac00f5dd4b Use raw_svector_ostream in more places in the mangler.
llvm-svn: 125321
2011-02-10 23:59:36 +00:00
Douglas Gregor 09b6989ef0 Implement two related optimizations that make de-serialization of
AST/PCH files more lazy:
  - Don't preload all of the file source-location entries when reading
  the AST file. Instead, load them lazily, when needed.
  - Only look up header-search information (whether a header was already
  #import'd, how many times it's been included, etc.) when it's needed
  by the preprocessor, rather than pre-populating it.

Previously, we would pre-load all of the file source-location entries,
which also populated the header-search information structure. This was
a relatively minor performance issue, since we would end up stat()'ing
all of the headers stored within a AST/PCH file when the AST/PCH file
was loaded. In the normal PCH use case, the stat()s were cached, so
the cost--of preloading ~860 source-location entries in the Cocoa.h
case---was relatively low.

However, the recent optimization that replaced stat+open with
open+fstat turned this into a major problem, since the preloading of
source-location entries would now end up opening those files. Worse,
those files wouldn't be closed until the file manager was destroyed,
so just opening a Cocoa.h PCH file would hold on to ~860 file
descriptors, and it was easy to blow through the process's limit on
the number of open file descriptors.

By eliminating the preloading of these files, we neither open nor stat
the headers stored in the PCH/AST file until they're actually needed
for something. Concretely, we went from

*** HeaderSearch Stats:
835 files tracked.
  364 #import/#pragma once files.
  823 included exactly once.
  6 max times a file is included.
  3 #include/#include_next/#import.
    0 #includes skipped due to the multi-include optimization.
1 framework lookups.
0 subframework lookups.

*** Source Manager Stats:
835 files mapped, 3 mem buffers mapped.
37460 SLocEntry's allocated, 11215575B of Sloc address space used.
62 bytes of files mapped, 0 files with line #'s computed.

with a trivial program that uses a chained PCH including a Cocoa PCH
to

*** HeaderSearch Stats:
4 files tracked.
  1 #import/#pragma once files.
  3 included exactly once.
  2 max times a file is included.
  3 #include/#include_next/#import.
    0 #includes skipped due to the multi-include optimization.
1 framework lookups.
0 subframework lookups.

*** Source Manager Stats:
3 files mapped, 3 mem buffers mapped.
37460 SLocEntry's allocated, 11215575B of Sloc address space used.
62 bytes of files mapped, 0 files with line #'s computed.

for the same program.

llvm-svn: 125286
2011-02-10 17:09:37 +00:00
Roman Divacky 178e0160b7 Implement mcount profiling, enabled via -pg.
llvm-svn: 125282
2011-02-10 16:52:03 +00:00
Ted Kremenek 75e4564140 static analyzer: Make GRStates reference counted, with reference counts managed by ExplodedNodes.
This reduces memory usage of the analyzer on sqlite by another 5%.

llvm-svn: 125260
2011-02-10 02:21:52 +00:00
Ted Kremenek f8cbac4b91 Split 'include/clang/StaticAnalyzer' into 'include/clang/StaticAnalyzer/Core' and 'include/clang/StaticAnalyzer/Checkers'.
This layout matches lib/StaticAnalyzer, which corresponds to two StaticAnalyzer libraries.

llvm-svn: 125251
2011-02-10 01:03:03 +00:00
Fariborz Jahanian ca3566fc20 Fix scoping of method declarations and issue
warning when same parameter name used multiple times.
// rdar://8877730

llvm-svn: 125229
2011-02-09 22:20:01 +00:00
Peter Collingbourne 5eec5f0422 Parse: add support for parsing CUDA kernel calls
llvm-svn: 125219
2011-02-09 21:12:02 +00:00
Peter Collingbourne c1270f51fa Lexer: add CUDA kernel call tokens
llvm-svn: 125218
2011-02-09 21:08:21 +00:00
Peter Collingbourne 41f8546233 AST, Sema, Serialization: add CUDAKernelCallExpr and related semantic actions
llvm-svn: 125217
2011-02-09 21:07:24 +00:00
Peter Collingbourne 9e2c81f00a AST, Sema, Serialization: keep track of cudaConfigureCall
llvm-svn: 125216
2011-02-09 21:04:32 +00:00
Daniel Dunbar 0bb0331d95 Driver/Frontend: Wire up -mregparm=.
llvm-svn: 125201
2011-02-09 17:54:19 +00:00
John McCall bd06678921 Remove vtables from the Stmt hierarchy; this was pretty easy as
there were only three virtual methods of any significance.

The primary way to grab child iterators now is with
  Stmt::child_range children();
  Stmt::const_child_range children() const;
where a child_range is just a std::pair of iterators suitable for
being llvm::tie'd to some locals.  I've left the old child_begin()
and child_end() accessors in place, but it's probably a substantial
penalty to grab the iterators individually now, since the
switch-based dispatch is kindof inherently slower than vtable
dispatch.  Grabbing them together is probably a slight win over the
status quo, although of course we could've achieved that with vtables, too.

I also reclassified SwitchCase (correctly) as an abstract Stmt
class, which (as the first such class that wasn't an Expr subclass)
required some fiddling in a few places.

There are somewhat gross metaprogramming hooks in place to ensure
that new statements/expressions continue to implement
getSourceRange() and children().  I had to work around a recent clang
bug;  dgregor actually fixed it already, but I didn't want to
introduce a selfhosting dependency on ToT.

llvm-svn: 125183
2011-02-09 08:16:59 +00:00
Ted Kremenek 435c80f5ea Initialize 'reclaimNodes'.
llvm-svn: 125179
2011-02-09 06:04:59 +00:00
Ken Dyck 48b0b2f762 Correct units in comments describing Size and getSize().
llvm-svn: 125158
2011-02-09 02:06:44 +00:00
Ken Dyck c8ae55050d Convert RecordLayout::Size to CharUnits from bits. No changes to
functionality intended.

llvm-svn: 125156
2011-02-09 01:59:34 +00:00
Ted Kremenek a40f8ebc83 static analyzer: Further reduce the analyzer's memory usage when analyzing sqlite3 by 7-10% by recylcing "uninteresting" ExplodedNodes.
The optimization involves eagerly pruning ExplodedNodes from the ExplodedGraph that contain
practically no difference between the predecessor and successor nodes.  For example, if
the state is different between a predecessor and a node, the node is left in.  Only for
the 'environment' component of the state do we not care if the ExplodedNodes are different.
This paves the way for future optimizations where we can reclaim the environment objects.

llvm-svn: 125154
2011-02-09 01:27:33 +00:00
Ted Kremenek a628225535 Make ProgramPoint::getTag() public.
llvm-svn: 125153
2011-02-09 01:27:27 +00:00
John McCall f4cd4f94d9 NonTypeTemplateParmDecl is just a DeclaratorDecl, not a VarDecl.
Also, reorganize and make very explicit the logic for determining
the value kind and type of a referenced declaration.

llvm-svn: 125150
2011-02-09 01:13:10 +00:00
John McCall 7a198cef04 When checking the 'weak' and 'weakref' attributes, look for non-external
linkage rather than the presence of the 'static' storage class specifier.
Fixes rdar://problem/8814626.

llvm-svn: 125126
2011-02-08 22:35:49 +00:00
Douglas Gregor 92a96f5c32 Split the serialized representation for the detailed preprocessing
record away from the core processor record. The tangling of these two
data structures led to some inefficiencies (e.g., deserializing all
of the detailed preprocessing record when we didn't need it, such as
while performing code completion) along with some unnecessary
ugliness.

llvm-svn: 125117
2011-02-08 21:58:10 +00:00
Peter Collingbourne 3a34725ed1 AST: support for pre-arg expressions on CallExpr subclasses
llvm-svn: 125115
2011-02-08 21:18:02 +00:00
Benjamin Kramer 1a648d1930 Allow multiple -B prefixes. Patch by Joerg Sonnenberger.
llvm-svn: 125111
2011-02-08 20:31:42 +00:00
John McCall d396b97c5a Clear the linkage cache recursively. Fixes PR8926.
llvm-svn: 125104
2011-02-08 19:01:05 +00:00
Fariborz Jahanian 87967425f9 Support for objextive-c++ use of property-dot syntax as receiver
in liu of a class method getter. 
// rdar://8962253

llvm-svn: 125094
2011-02-08 18:05:59 +00:00
Ken Dyck bec0285d7f Convert RecordLayout::NonVirtualAlign to CharUnits. No change in
functionality intended.

llvm-svn: 125069
2011-02-08 02:02:47 +00:00
Ted Kremenek e6a12a97d4 Move uninitialized variable checking back under -Wuninitialized-experimental. It is clear from user feedback that this warning is not quite ready.
llvm-svn: 125007
2011-02-07 17:38:38 +00:00
John McCall 351762cda2 A few more tweaks to the blocks AST representation:
- BlockDeclRefExprs always store VarDecls
  - BDREs no longer store copy expressions
  - BlockDecls now store a list of captured variables, information about
    how they're captured, and a copy expression if necessary
    
With that in hand, change IR generation to use the captures data in       
blocks instead of walking the block independently.        

Additionally, optimize block layout by emitting fields in descending
alignment order, with a heuristic for filling in words when alignment
of the end of the block header is insufficient for the most aligned
field.

llvm-svn: 125005
2011-02-07 10:33:21 +00:00
Chris Lattner 7031ae38bb add some missing builtins.
llvm-svn: 124981
2011-02-06 12:45:51 +00:00
Douglas Gregor 606c4ac325 Improve our uniquing of file entries when files are re-saved or are
overridden via remapping. Thus, when we create a "virtual" file in the
file manager, we still stat() the real file that lives behind it so
that we can provide proper uniquing based on inodes. This helps keep
the file manager much more consistent.

To take advantage of this when reparsing files in libclang, we disable
the use of the stat() cache when reparsing or performing code
completion, since the stat() cache is very likely to be out of date in
this use case.

llvm-svn: 124971
2011-02-05 19:42:43 +00:00
Sebastian Redl 0890502f44 Basic implementation of inherited constructors. Only generates declarations, and probably only works for very basic use cases.
llvm-svn: 124970
2011-02-05 19:23:19 +00:00
Argyrios Kyrtzidis 3d3208675f When the out-of-line definition differs from the declaration in the return type,
say "out-of-line definition differ from the declaration in the return type" instead of
the silly "functions that differ only in their return type cannot be overloaded".

Addresses rdar://7980179.

llvm-svn: 124939
2011-02-05 05:54:49 +00:00
Fariborz Jahanian c9b7c209bb -Wselector should warn on implemented selectors only
when selector metadata is generated, which is triggered 
by at least on class implementation. This is to match gcc's
behavior. // rdar://8851684.

llvm-svn: 124909
2011-02-04 23:19:27 +00:00
Douglas Gregor 125fa40c34 When calling a bound pointer to member function, check the
cv-qualifiers on the object against the cv-qualifiers on the member
function. Fixes PR8315.

llvm-svn: 124865
2011-02-04 12:57:49 +00:00
Douglas Gregor 87866ceda7 Implement proper (de-)serialization for explicit template argument
lists with zero template arguments. Fixes some seriously scary
crashers in C++ PCH.

llvm-svn: 124862
2011-02-04 12:01:24 +00:00
Ted Kremenek d68ec818c3 Downgrade error about attribute 'iboutlet' and 'ibaction' being applied to anything but a instance method to a warning.
llvm-svn: 124858
2011-02-04 06:54:16 +00:00
Douglas Gregor a99fb4c77d Tighten up the semantics of default template arguments, per C++0x
[temp.param]p9 and C++ DR226. Fixes PR8747.

llvm-svn: 124856
2011-02-04 04:20:44 +00:00
Douglas Gregor 8b481d8ac2 When a function template's template parameter has a default argument,
it's okay for the following template parameters to not have default
arguments (since those template parameters can still be
deduced). Also, downgrade the error about default template arguments
in function templates to an extension warning, since this is a
harmless C++0x extension.

llvm-svn: 124855
2011-02-04 03:57:22 +00:00
Daniel Dunbar 7aa71f9423 build: Add support for DISABLE_DEFAULT_STRICT_ALIASING, which does what one
might expect.

llvm-svn: 124848
2011-02-04 02:20:39 +00:00
Daniel Dunbar 5ad0d7edfa Fix 80-col violins.
llvm-svn: 124847
2011-02-04 02:20:34 +00:00
Fariborz Jahanian f7f04458b3 -fapple-kext cannot have 'weak' visibility in this
abi.

llvm-svn: 124834
2011-02-04 00:01:24 +00:00
Oscar Fuentes edeaf16f2c Moved here from LLVM Clang's configuration options and related macros.
llvm-svn: 124825
2011-02-03 22:48:20 +00:00
Argyrios Kyrtzidis 7272d9cf36 Implement -Woverloaded-virtual.
The difference with gcc is that it warns if you overload virtual methods only if
the method doesn't also override any method. This is to cut down on the number of warnings
and make it more useful like reported here: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20423.
If we want to warn that not all overloads are overriden we can have an additional
warning like -Wpartial-override.

-Woverloaded-virtual, unlike gcc, is added to -Wmost. Addresses rdar://8757630.

llvm-svn: 124805
2011-02-03 18:01:15 +00:00
Douglas Gregor e664276bcf Teach SourceManager::getLocation() how to cope with a source file
whose inode has changed since the file was first created and that is
being seen through a different path name (e.g., due to symlinks or
relative path elements), such that its FileEntry pointer doesn't match
a known FileEntry pointer. Since this requires a system call (to
stat()), we only perform this deeper checking if we can't find the
file by comparing FileEntry pointers.

Also, add a micro-optimization where we don't bother to compute line
numbers when given the location (1, 1). This improves the
efficiency of clang_getLocationForOffset().
 

llvm-svn: 124800
2011-02-03 17:17:35 +00:00
John McCall 5f2d556a92 Capture a few implicit references to 'self'.
llvm-svn: 124786
2011-02-03 09:00:02 +00:00
John McCall f3a8860ee1 More capturing of 'this': implicit member expressions. Getting that
right for anonymous struct/union members led to me discovering some
seemingly broken code in that area of Sema, which I fixed, partly by  
changing the representation of member pointer constants so that    
IndirectFieldDecls aren't expanded.  This led to assorted cleanups with   
member pointers in CodeGen, and while I was doing that I saw some random
other things to clean up.                   

llvm-svn: 124785
2011-02-03 08:15:49 +00:00
Ted Kremenek 436cc8ffe7 Reenable -Wuninitialized warning for captured block variables.
llvm-svn: 124782
2011-02-03 06:51:50 +00:00
Daniel Dunbar 9aa47fcb55 Frontend: Switch -header-include-file output to use unbuffered raw_ostreams with
the atomic writes option, since the intent is that this option be set for an
entire build, which may have any number of compiler instances writing to the
same output file.

llvm-svn: 124772
2011-02-03 03:45:00 +00:00
Francois Pichet 50a2e0e894 Fix Microsoft bit field problem. This resolves the Index\complete-exprs.c regression on Win32.
llvm-svn: 124767
2011-02-03 02:02:42 +00:00