Commit Graph

184 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis d2c0abad2b [arcmt] Copy the diagnostics so we don't have to worry about invaliding iterators from the diagnostic list.
Should fix http://llvm.org/PR15500

llvm-svn: 178500
2013-04-01 21:12:30 +00:00
Rafael Espindola 45b620aab5 Add a hasExternalLinkage helper. No functionality change.
llvm-svn: 176607
2013-03-07 02:00:27 +00:00
Argyrios Kyrtzidis fead64be9b [preprocessor] Use MacroDirective in the preprocessor callbacks to make available the
full information about the macro (e.g if it was imported and where).

llvm-svn: 175978
2013-02-24 00:05:14 +00:00
David Blaikie 05785d1622 Include llvm::Optional in clang/Basic/LLVM.h
Post-commit CR feedback from Jordan Rose regarding r175594.

llvm-svn: 175679
2013-02-20 22:23:23 +00:00
David Blaikie 6adc78e0df Replace TypeLoc llvm::cast support to be well-defined.
The TypeLoc hierarchy used the llvm::cast machinery to perform undefined
behavior by casting pointers/references to TypeLoc objects to derived types
and then using the derived copy constructors (or even returning pointers to
derived types that actually point to the original TypeLoc object).

Some context is in this thread:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-December/056804.html
Though it's spread over a few months which can be hard to read in the mail
archive.

llvm-svn: 175462
2013-02-18 22:06:02 +00:00
Argyrios Kyrtzidis d07fabf034 [arcmt] Make sure the function has an associated parameter for the argument
before checking for its attributes.

rdar://13192395

llvm-svn: 175184
2013-02-14 17:29:16 +00:00
Argyrios Kyrtzidis 88c0d3b1ae [arcmt] Make sure the objc migrators work fine when used with a PCH.
rdar://13140508

llvm-svn: 174386
2013-02-05 16:37:00 +00:00
Chandler Carruth 4b41745e05 Re-sort all the headers. Lots of regressions have crept in here.
Manually fix the order of UnwrappedLineParser.cpp as that one didn't
have its associated header as the first header.

This also uncovered a subtle inclusion order dependency as CLog.h didn't
include LLVM.h to pick up using declarations it relied upon.

llvm-svn: 172892
2013-01-19 08:09:44 +00:00
Argyrios Kyrtzidis 6b4f341ecd [objcmt] Rewrite a NSDictionary dictionaryWithObjects:forKeys: to a dictionary literal
if we can see the elements of the arrays.

for example:

 NSDictionary *dict = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"1", @"2", nil] forKeys:[NSArray arrayWithObjects:@"A", @"B", nil]];

-->

 NSDictionary *dict = @{ @"A" : @"1", @"B" : @"2" };

rdar://12428166

llvm-svn: 172679
2013-01-16 23:54:48 +00:00
Douglas Gregor 048fbfa302 Rework the traversal of Objective-C categories and extensions to
consider (sub)module visibility.

The bulk of this change replaces myriad hand-rolled loops over the
linked list of Objective-C categories/extensions attached to an
interface declaration with loops using one of the four new category
iterator kinds:

  visible_categories_iterator: Iterates over all visible categories
  and extensions, hiding any that have their "hidden" bit set. This is
  by far the most commonly used iterator.

  known_categories_iterator: Iterates over all categories and
  extensions, ignoring the "hidden" bit. This tends to be used for
  redeclaration-like traversals.

  visible_extensions_iterator: Iterates over all visible extensions,
  hiding any that have their "hidden" bit set.

  known_extensions_iterator: Iterates over all extensions, whether
  they are visible to normal name lookup or not.

The effect of this change is that any uses of the visible_ iterators
will respect module-import visibility. See the new tests for examples.

Note that the old accessors for categories and extensions are gone;
there are *Raw() forms for some of them, for those (few) areas of the
compiler that have to manipulate the linked list of categories
directly. This is generally discouraged.

Part two of <rdar://problem/10634711>.
 

llvm-svn: 172665
2013-01-16 23:00:23 +00:00
Dmitri Gribenko f857950d39 Remove useless 'llvm::' qualifier from names like StringRef and others that are
brought into 'clang' namespace by clang/Basic/LLVM.h

llvm-svn: 172323
2013-01-12 19:30:44 +00:00
Argyrios Kyrtzidis 08281fa337 [arcmt] Follow-up for r171484; make sure when adding brackets enclosing case statements,
that the case does not "contain" a declaration that is referenced "outside" of it,
otherwise we will emit un-compilable code.

llvm-svn: 171828
2013-01-08 00:58:25 +00:00
Ted Kremenek 3d1464caee Update CMakeLists.txt
llvm-svn: 171505
2013-01-04 19:04:47 +00:00
Filipe Cabecinhas c18708ee6e Add file added in r171484 to CMakelists.txt.
llvm-svn: 171494
2013-01-04 18:52:29 +00:00
Argyrios Kyrtzidis d12c332905 [arcmt] Allow removing an -autorelease of a variable initialized in the previous statement.
rdar://11074996

llvm-svn: 171485
2013-01-04 18:30:11 +00:00
Argyrios Kyrtzidis 03fbe3ef81 [arcmt] Adds brackets in case statements that "contain" initialization of retaining
variable, thus emitting the "switch case is in protected scope" error.

rdar://12952016

llvm-svn: 171484
2013-01-04 18:30:08 +00:00
Argyrios Kyrtzidis b7b89b5ebc [arcmt] Don't error if an autoreleased variable is returned after the -autorelease.
rdar://12952025

llvm-svn: 171482
2013-01-04 18:29:59 +00:00
Argyrios Kyrtzidis 6ba7afb8e1 [arcmt] Rewrite uses of Block_copy/Block_release macros.
c = Block_copy(b);
  Block_release(c);
 ---->
  c = [b copy];
  <removed>

rdar://9408211

llvm-svn: 171454
2013-01-03 03:17:17 +00:00
Argyrios Kyrtzidis 1f7321677c [arcmt] When capturing ARC errors, have a sanity check to make sure
the diagnostic has a valid location.

llvm-svn: 170040
2012-12-12 22:48:28 +00:00
Argyrios Kyrtzidis f5b993f7b1 [objc] For the ARC error that is emitted when a synthesized property implementation
has inconsistent ownership with the backing ivar, point the error location to the
ivar.

Pointing to the ivar (instead of the @synthesize) is better since this is where a fix is needed.
Also provide the location of @synthesize via a note.

This also fixes the problem where an auto-synthesized property would emit an error without
any location.

llvm-svn: 170039
2012-12-12 22:48:25 +00:00
Chandler Carruth 3a02247dc9 Sort all of Clang's files under 'lib', and fix up the broken headers
uncovered.

This required manually correcting all of the incorrect main-module
headers I could find, and running the new llvm/utils/sort_includes.py
script over the files.

I also manually added quite a few missing headers that were uncovered by
shuffling the order or moving headers up to be main-module-headers.

llvm-svn: 169237
2012-12-04 09:13:33 +00:00
Argyrios Kyrtzidis f3d587ea7c Refactor recording the preprocessor conditional directive regions out of
PreprocessingRecord and into its own class, PPConditionalDirectiveRecord.

Decoupling allows a client to use the functionality of PPConditionalDirectiveRecord
without needing a PreprocessingRecord.

llvm-svn: 169229
2012-12-04 07:27:05 +00:00
Benjamin Kramer d7d2b1fe45 Don't include Type.h in DeclarationName.h.
Recursively prune some includes.

llvm-svn: 169094
2012-12-01 16:35:25 +00:00
Benjamin Kramer ea70eb30a0 Pull the Attr iteration parts out of Attr.h, so including DeclBase.h doesn't pull in all the generated Attr code.
Required to pull some functions out of line, but this shouldn't have a perf impact.
No functionality change.

llvm-svn: 169092
2012-12-01 15:09:41 +00:00
Benjamin Kramer d81108f0bc s/tranform/transform/
llvm-svn: 167929
2012-11-14 15:08:31 +00:00
Bob Wilson 5ad5a9511c Remove old driver code to grab the iOS simulator version from the -D option.
We can now rely on the -mios-simulator-version-min command line option
and remove the awful hack. <rdar://problem/10304510>

llvm-svn: 167603
2012-11-09 01:59:30 +00:00
Douglas Gregor e81699d938 Move PreprocessorOptions into the Lex library, and make it intrusively
reference-counted.

llvm-svn: 166587
2012-10-24 17:01:35 +00:00
Douglas Gregor 7959178eb0 Use a .def file for most of the diagnostic options.
llvm-svn: 166520
2012-10-23 23:11:23 +00:00
Douglas Gregor 811db4eac4 Make DiagnosticOptions intrusively reference-counted, and make sure
the various stakeholders bump up the reference count. In particular,
the diagnostics engine now keeps the DiagnosticOptions object alive.

llvm-svn: 166508
2012-10-23 22:26:28 +00:00
Ted Kremenek cdf814900d Split library clangRewrite into clangRewriteCore and clangRewriteFrontend.
This is similar to how we divide up the StaticAnalyzer libraries to separate
core functionality to what is clearly associated with Frontend actions.

llvm-svn: 163050
2012-09-01 05:09:24 +00:00
Joao Matos 0e167f7368 Fixed invalid iterators. Since the iterator is invalidated after the erase() call, we need to replace it with the new one returned. This was triggering an assert under MSVC 2012 and making all the ARCMT/ tests fail.
llvm-svn: 163007
2012-08-31 17:28:09 +00:00
Richard Smith 802c4b7015 Fix undefined behavior: member function calls where 'this' is a null pointer.
llvm-svn: 162430
2012-08-23 06:16:52 +00:00
John McCall 3deb1ad40c Screw around with ObjCRuntime some more, changing the
diagnostics for bad deployment targets and adding a few
more predicates.  Includes a patch by Jonathan Schleifer
to enable ARC for ObjFW.

llvm-svn: 162252
2012-08-21 02:47:43 +00:00
Jordan Rose b00073db80 Update VerifyDiagnosticConsumer to only get directives during parsing.
The old behavior was to re-scan any files (like modules) where we may have
directives but won't actually be parsing during the -verify invocation.
Now, we keep the old behavior in Debug builds as a sanity check (though
modules are a known entity), and expect all legitimate directives to come
from comments seen by the preprocessor.

This also affects the ARC migration tool, which captures diagnostics in
order to filter some out. This change adds an explicit cleanup to
CaptureDiagnosticsConsumer in order to let its sub-consumer handle the
real end of diagnostics.

This was originally split into four patches, but the tests do not run
cleanly without all four, so I've combined them into one commit.

Patches by Andy Gibbs, with slight modifications from me.

llvm-svn: 161650
2012-08-10 01:06:16 +00:00
NAKAMURA Takumi 836926dbdf clang/lib: [CMake] Update tblgen'd dependencies.
llvm-svn: 160851
2012-07-27 06:18:33 +00:00
NAKAMURA Takumi 075c89bc06 clang/lib: [CMake] Reformat, alphabetize lists.
llvm-svn: 160850
2012-07-27 06:18:12 +00:00
Sylvestre Ledru 830885ca64 Fix a typo (the the => the)
llvm-svn: 160622
2012-07-23 08:59:39 +00:00
Dmitri Gribenko ec92531c29 Implement AST classes for comments, a real parser for Doxygen comments and a
very simple semantic analysis that just builds the AST; minor changes for lexer
to pick up source locations I didn't think about before.

Comments AST is modelled along the ideas of HTML AST: block and inline content.

* Block content is a paragraph or a command that has a paragraph as an argument
  or verbatim command.
* Inline content is placed within some block.  Inline content includes plain
  text, inline commands and HTML as tag soup.

llvm-svn: 159790
2012-07-06 00:28:32 +00:00
Benjamin Kramer 4ab984e74b Drop the ASTContext.h include from DeclFriend.h and DeclTemplate.h.
llvm-svn: 159723
2012-07-04 20:19:54 +00:00
Benjamin Kramer 1ea8e092be Drop the ASTContext.h include from Stmt.h and fix up transitive users.
This required moving the ctors for IntegerLiteral and FloatingLiteral out of
line which shouldn't change anything as they are usually called through Create
methods that are already out of line.

ASTContext::Deallocate has been a nop for a long time, drop it from ASTVector
and make it independent from ASTContext.h

Pass the StorageAllocator directly to AccessedEntity so it doesn't need to
have a definition of ASTContext around.

llvm-svn: 159718
2012-07-04 17:04:04 +00:00
Chandler Carruth 28969b4139 Remove a goofy CMake hack and use the standard CMake facilities to
express library-level dependencies within Clang.

This is no more verbose really, and plays nicer with the rest of the
CMake facilities. It should also have no change in functionality.

llvm-svn: 158888
2012-06-21 01:30:21 +00:00
Argyrios Kyrtzidis aa38f695ad [arcmt]
-Disable -pedantic-errors when migrating per Jordan's suggestion.
-Use llvm_move() per John's suggestion.

llvm-svn: 158785
2012-06-20 01:46:26 +00:00
Argyrios Kyrtzidis 692bf8cb64 [arcmt] When migrating to ARC disable -Werror so as to only block migration
for "hard" ARC errors, not warnings.

rdar://11691437

llvm-svn: 158781
2012-06-20 01:10:40 +00:00
Dmitri Gribenko aab8383a2b Structured comment parsing, first step.
* Retain comments in the AST
* Serialize/deserialize comments
* Find comments attached to a certain Decl
* Expose raw comment text and SourceRange via libclang

llvm-svn: 158771
2012-06-20 00:34:58 +00:00
Jordan Rose 288c421b3d Insert a space if necessary when suggesting CFBridgingRetain/Release.
This was a problem for people who write 'return(result);'

Also fix ARCMT's corresponding code, though there's no test case for this
because implicit casts like this are rejected by the migrator for being
ambiguous, and explicit casts have no problem.

<rdar://problem/11577346>

llvm-svn: 158130
2012-06-07 01:10:31 +00:00
Argyrios Kyrtzidis b03cc793a9 [arcmt] At an unbridged cast error, if we're returning a load-of-ivar from a +0 method,
automatically insert a __bridge cast.

radar://11560638

llvm-svn: 158127
2012-06-07 00:44:06 +00:00
David Blaikie 40ed29730b Revert Decl's iterators back to pointer value_type rather than reference value_type
In addition, I've made the pointer and reference typedef 'void' rather than T*
just so they can't get misused. I would've omitted them entirely but
std::distance likes them to be there even if it doesn't use them.

This rolls back r155808 and r155869.

Review by Doug Gregor incorporating feedback from Chandler Carruth.

llvm-svn: 158104
2012-06-06 20:45:41 +00:00
Benjamin Kramer 972a96aede Remove the last dead private member in clang.
llvm-svn: 158100
2012-06-06 20:15:08 +00:00
Benjamin Kramer d1d76b2da7 Remove unused private member variables found by clang's new -Wunused-private-field.
llvm-svn: 158086
2012-06-06 17:32:50 +00:00
Argyrios Kyrtzidis 273c7c40b2 [arcmt] Use CFBridgingRetain/CFBridgingRelease instead of __bridge_retained/__bridge_transfer
when migrating.

rdar://11569198

llvm-svn: 157785
2012-06-01 00:10:47 +00:00