Commit Graph

25913 Commits

Author SHA1 Message Date
Fariborz Jahanian 914faaf78a objc: tweak my last patch to warn if class extension
has not overridden the property. // rdar://11656982

llvm-svn: 158871
2012-06-20 23:18:57 +00:00
Fariborz Jahanian 876cc65a3f objective-c: Normally, a property cannot be both 'readonly' and having a
"write" attribute (copy/retain/etc.). But, property declaration in 
primary class and protcols are tentative as they may be overridden 
into a 'readwrite' property in class extensions. Postpone diagnosing 
such warnings until the class implementation is seen. 
// rdar://11656982

llvm-svn: 158869
2012-06-20 22:57:42 +00:00
John McCall 18ac1632f0 Introduce ObjCRuntime::hasWeakClassImport() and use it in the appropriate
places.  I've turned this off for the GNU runtimes --- I don't know if
they support weak class import, but it's easy enough for them to opt in.

Also tweak a comment per review by Jordan.

llvm-svn: 158860
2012-06-20 21:58:02 +00:00
Anna Zaks 9050ffd57c [analyzer] Malloc: cleanup, disallow free on relinquished memory.
This commits sets the grounds for more aggressive use after free
checking. We will use the Relinquished sate to denote that someone
else is now responsible for releasing the memory.

llvm-svn: 158850
2012-06-20 20:57:46 +00:00
Dmitri Gribenko 93b9ecba9b Remove unused ASTContext& arg in RawCommentList::addComment, as pointed out by Chandler in commit message for r158807.
llvm-svn: 158845
2012-06-20 20:39:04 +00:00
Nico Weber df7dffb34b Allow unqualified lookup of non-dependent member functions
in microsoft mode. Fixes PR12701.

The code for this was already in 2 of the 3 branches of a
conditional and missing in the 3rd branch, so lift it above
the conditional.

llvm-svn: 158842
2012-06-20 20:21:42 +00:00
Chad Rosier cc6a908c39 Whitespace.
llvm-svn: 158837
2012-06-20 18:51:04 +00:00
Jordan Rose de9e976468 Remove -Winternal-linkage-in-inline in C++.
It's very easy for anonymous external linkage to propagate in C++ through
return types and parameter types. Likewise, it's possible that a template
containing an inline function is only used with parameters that have internal
linkage. Actually diagnosing where the internal linkage comes from is fairly
difficult (both to locate and then to print nicely). Finally, since we only
have one translation unit available, we can't even prove that any of this
violates the ODR.

This warning needs better-defined behavior in C++ before it can really go in.

Rewording of the C warning (which /is/ specified by C99) coming shortly.

llvm-svn: 158836
2012-06-20 18:50:06 +00:00
Chad Rosier 43b7c021b3 [ms-style asm] Change the fatal error to an extension warning. Apparently, this
error was asserting on anything that included Windows.h.  MS-style inline asm is
still dropped, but at least now we're not completely silent about it.

llvm-svn: 158833
2012-06-20 18:28:37 +00:00
Benjamin Kramer e6dcf106b2 Don't circumvent the debug info type cache when emitting info for EnumConstantDecl.
CreateEnumType doesn't participate in caching so the descriptor for the enum
gets recomputed for every reference of an element of an enum, only to get
discarded when it gets turned into an MDNode.

No functionality change except performance.

llvm-svn: 158832
2012-06-20 18:11:18 +00:00
Chad Rosier bebf146dd6 Whitespace.
llvm-svn: 158830
2012-06-20 17:43:05 +00:00
Fariborz Jahanian edc2971c4d objc: improved diagnostic when property autosynthesis may cause
change in behavior. // rdar://11671080

llvm-svn: 158828
2012-06-20 17:18:31 +00:00
Chandler Carruth 39a3e7544a Fix a big layering violation introduced by r158771.
That commit added a new library just to hold the RawCommentList. I've
started a discussion on the commit thread about whether that is really
meritted -- it certainly doesn't seem necessary at this stage.

However, the immediate problem is that the AST library has a hard
dependency on the Comment library, but the dependencies were set up
completely backward. In addition to the layering violation, this had an
unfortunate effect if scattering the Comments library dependency
throughout the build system, but inconsistently so -- several parts of
the CMake dependencies were missing and only showed up due to transitive
deps or the fact that the target wasn't being built by tho bots.

It turns out that the Comments library can't (currently) be a well
formed layer *below* the AST library either, as it has an API that
accepts an ASTContext. That parameter is currently unused, so maybe that
was a mistake?

Anyways, it really seems like this is logically part of the AST --
that's the whole point of the ASTContext providing access to it as far
as I can tell -- so I've merged it into the AST library to solve the
immediate layering violation problems and remove some of the churn from
our library dependencies.

llvm-svn: 158807
2012-06-20 09:53:52 +00:00
Ted Kremenek c26328afa6 Revert "Provide a -no-pedantic to cancel out -pedantic." This needs to be designed
a bit further.  We may wish to just have -Wno flags to silence warnings, and not have a -no-pedantic.

llvm-svn: 158796
2012-06-20 07:03:37 +00:00
Chandler Carruth 029ea4ad29 Fix a warning on a fully covered switch with a default:
../tools/clang/lib/Serialization/ASTReader.cpp:6316:9: warning: default label in switch which covers all enumeration values [-Wcovered-switch-default]

Also fix the indentation here to match the coding conventions.

llvm-svn: 158794
2012-06-20 06:47:54 +00:00
John McCall 5fb5df9c83 Restructure how the driver communicates information about the
target Objective-C runtime down to the frontend:  break this
down into a single target runtime kind and version, and compute
all the relevant information from that.  This makes it
relatively painless to add support for new runtimes to the
compiler.  Make the new -cc1 flag, -fobjc-runtime=blah-x.y.z,
available at the driver level as a better and more general
alternative to -fgnu-runtime and -fnext-runtime.  This new
concept of an Objective-C runtime also encompasses what we
were previously separating out as the "Objective-C ABI", so
fragile vs. non-fragile runtimes are now really modelled as
different kinds of runtime, paving the way for better overall
differentiation.

As a sort of special case, continue to accept the -cc1 flag
-fobjc-runtime-has-weak, as a sop to PLCompatibilityWeak.

I won't go so far as to say "no functionality change", even
ignoring the new driver flag, but subtle changes in driver
semantics are almost certainly not intended.

llvm-svn: 158793
2012-06-20 06:18:46 +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
Jordan Rose 44320367ac [analyzer] Invalidate placement args; return the pointer given to placement new
The default global placement new just returns the pointer it is given.
Note that other custom 'new' implementations with placement args are not
guaranteed to do this.

In addition, we need to invalidate placement args, since they may be updated by
the allocator function. (Also, right now we don't properly handle the
constructor inside a CXXNewExpr, so we need to invalidate the placement args
just so that callers know something changed!)

This invalidation is not perfect because CallOrObjCMessage doesn't support
CXXNewExpr, and all of our invalidation callbacks expect that if there's no
CallOrObjCMessage, the invalidation is happening manually (e.g. by a direct
assignment) and shouldn't affect checker-specific metadata (like malloc state);
hence the malloc test case in new-fail.cpp. But region values are now
properly invalidated, at least.

The long-term solution to this problem is to rework CallOrObjCMessage into
something more general, rather than the morass of branches it is today.

<rdar://problem/11679031>

llvm-svn: 158784
2012-06-20 01:32:01 +00:00
Argyrios Kyrtzidis 927a437ac7 [objcmt] Have the modern objc migration warning change from:
[NSNumber numberWithDouble:cppb];
warning: converting to boxing syntax requires a cast

to something like:

[NSNumber numberWithDouble:cppb];
warning: converting to boxing syntax requires casting 'bool' to 'double'

This is way better to fully understand the warning.
rdar://11705106

llvm-svn: 158783
2012-06-20 01:28:32 +00:00
Rafael Espindola c757570032 Fix cmake build.
llvm-svn: 158782
2012-06-20 01:18:08 +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 17e147fa9d Unbreak GCC build: GCC doesn't like clang::Parser::CommentHandler and class clang::CommentHandler to have same name.
llvm-svn: 158780
2012-06-20 01:06:08 +00:00
James Dennett a02e11f31d Documentation cleanup: escape "::" to avoid a Doxygen warning
llvm-svn: 158778
2012-06-20 00:57:15 +00:00
Dmitri Gribenko b0ed34df15 Unbreak CMake build: remove not-yet-committed CommentLexer.cpp.
llvm-svn: 158777
2012-06-20 00:56:47 +00:00
James Dennett c07ab2c96a Documentation cleanup:
* Escaped # and < characters in Doxygen comments as needed;
* Removed a Doxygen comment in HeaderSearch.cpp that was redundant with
  the corresponding comment in the header file.

llvm-svn: 158776
2012-06-20 00:56:32 +00:00
Kaelyn Uhrain 272d718808 Add the PCH file name to the message about not being able to read the PCH.
Also add a couple of unit tests to check the invalid-PCH error messages
to satisfy PR4568 and for the assertion (introduced in r149918 and fixed
in r158769) that would cause clang to crash when given an empty PCH.

llvm-svn: 158772
2012-06-20 00:36:03 +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
Nico Weber 5f96883d44 Do a second lookup for type_info in the global namespace in microsoft mode. PR13153.
llvm-svn: 158768
2012-06-19 23:58:27 +00:00
Alexis Hunt 3bc72c1ec2 Reapply r158700 and fixup patches, minus one hunk that slipped through and
caused a crash in an obscure case. On the plus side, it caused me to catch
another bug by inspection.

llvm-svn: 158767
2012-06-19 23:57:03 +00:00
Alexis Hunt 78e2b91319 Do not crash when we dynamic cast a final type to void*.
llvm-svn: 158763
2012-06-19 23:44:55 +00:00
DeLesley Hutchins 312e742c99 Thread Safety Analysis: Move some warnings on thread safety
attributes into the ThreadSafetyAttributes group, where the other
warnings currently live.

llvm-svn: 158761
2012-06-19 23:25:19 +00:00
Tanya Lattner 4fdce3faa8 Extend the support for cl-std to include 1.2.
Add error checking for the static qualifier which is now allowed in certain situations for OpenCL 1.2. Use the CL version to turn on this feature.
Added test case for 1.2 static storage class feature.

llvm-svn: 158759
2012-06-19 23:09:52 +00:00
Fariborz Jahanian 63d40202fb objective-c: warn when autosynthesizing a property which has same
name as an existing ivar since this is common source of error
when people remove @synthesize to take advantage of autosynthesis. 
// rdar://11671080

llvm-svn: 158756
2012-06-19 22:51:22 +00:00
Aaron Ballman 478faed4b0 Reapplying the changes from r158717 as they were rolled back to avoid merge conflicts from a separate problematic patch.
llvm-svn: 158750
2012-06-19 22:09:27 +00:00
Jakob Stoklund Olesen e1c0ae6fda Revert r158700 and dependent patches r158716, r158717, and r158731.
The original r158700 caused crashes in the gcc test suite,
g++.abi/vtable3a.C among others. It also caused failures in the libc++
test suite.

llvm-svn: 158749
2012-06-19 21:48:43 +00:00
Richard Smith 72cd8ea5e5 Fix -Wc++11-narrowing warnings for narrowing negative values to larger unsigned
types to actually includes the value, rather than saying <uninitialized>.

llvm-svn: 158745
2012-06-19 21:28:35 +00:00
David Blaikie 9366d2b32d Enable -Wnull-conversion for non-integral target types (eg: double).
llvm-svn: 158744
2012-06-19 21:19:06 +00:00
James Dennett 51a8d8b8b5 Documentation cleanup: escape "::", and other minor reformatting
llvm-svn: 158741
2012-06-19 21:05:49 +00:00
James Dennett 99c193b3c0 Documentation cleanup: add \verbatim markup for grammar productions
llvm-svn: 158740
2012-06-19 21:04:25 +00:00
James Dennett e37835ef18 Documentation cleanup: fixing file headers to use Doxygen \file markup while
also being sufficiently conformant to LLVM's coding standards.

llvm-svn: 158739
2012-06-19 21:02:26 +00:00
Fariborz Jahanian a36cbeb464 objc-arc: captured block variable accessed in its block literal
initializer need be null initialized before initializer takes
hold, just like any other initialized retainable object pointer. 
// rdar://11016025

llvm-svn: 158738
2012-06-19 20:53:26 +00:00
Chad Rosier 103e2c9508 [driver] Per Bob's suggestion, emphasize the file dumps.
rdar://11684107

llvm-svn: 158734
2012-06-19 18:39:21 +00:00
Kaelyn Uhrain 33621a6977 Remove some debugging code that snuck into r158691.
llvm-svn: 158733
2012-06-19 18:38:00 +00:00
Meador Inge cdc0057e3c Revert predefined decl tracking.
r158085 added some logic to track predefined declarations.  The main reason we
had predefined declarations in the input was because the __builtin_va_list
declarations were injected into the preprocessor input.  As of r158592 we 
explicitly build the __builtin_va_list declarations.  Therefore the predefined
decl tracking is no longer needed.

llvm-svn: 158732
2012-06-19 18:17:30 +00:00
Chad Rosier 8179f11841 [driver] Print the compiler version before the diagnostic messages.
llvm-svn: 158729
2012-06-19 17:51:34 +00:00
Chad Rosier 47297636fd [driver] Make the crash diagnostic message more visable. Bug reports are being
filed, but still missing the preprocessed source and associated run script.
rdar://11684107

llvm-svn: 158727
2012-06-19 17:48:02 +00:00
Aaron Ballman 38c9ad9e72 Improves parsing and semantic analysis for MS __declspec attributes. This includes support for the align (which fixes PR12631).
llvm-svn: 158717
2012-06-19 13:49:26 +00:00
Anna Zaks 42908c7ac9 [analyzer] Allow pointers to escape into NSPointerArray.
(Fixes radar://11691035 PR13140)

llvm-svn: 158703
2012-06-19 05:10:32 +00:00
Alexis Hunt 7b28cdb3da Improve the specification of spellings in Attr.td.
Note that this is mostly a structural patch that handles the change from the old
spelling style to the new one. One consequence of this is that all AT_foo_bar
enum values have changed to not be based off of the first spelling, but rather
off of the class name, so they are now AT_FooBar and the like (a straw poll on
IRC showed support for this). Apologies for code churn.

Most attributes have GNU spellings as a temporary solution until everything else
is sorted out (such as a Keyword spelling, which I intend to add if someone else
doesn't beat me to it). This is definitely a WIP.

I've also killed BaseCheckAttr since it was unused, and I had to go through
every attribute anyway.

llvm-svn: 158700
2012-06-19 03:39:03 +00:00
Jordan Rose 8d63d5b8e6 Fix the location of the fixit for -Wnewline-eof.
It turns out SourceManager treating the "one-past-the-end" location as invalid,
but then failing to set the invalid flag properly.

llvm-svn: 158699
2012-06-19 03:09:38 +00:00
Argyrios Kyrtzidis a3fcbeb908 [objcmt] When checking whether the subscripting methods are declared use
ObjCInterfaceDec::lookupInstanceMethod to make sure we check categories as well
and update related tests.

rdar://11695288

llvm-svn: 158697
2012-06-19 02:22:02 +00:00
Rafael Espindola 66aa045fd9 Add a -fuse-init-array option to cc1 and map to the UseInitArray target
option. On the driver, check if we are using libraries from gcc 4.7 or newer
and if so pass -fuse-init-array to the frontend.
The crtbegin*.o files in gcc 4.7 no longer call the constructors listed in
.ctors, so we have to use .init_array.

llvm-svn: 158694
2012-06-19 01:26:10 +00:00
Kaelyn Uhrain 9ea8f7e6c5 Improve the error message when a function overload candidate is rejected
because it expects a reference and receives a non-l-value.

For example, given:

  int foo(int &);
  template<int x> void b() { foo(x); }

clang will now print "expects an l-value for 1st argument" instead of
"no known conversion from 'int' to 'int &' for 1st argument". The change
in wording (and associated code to detect the case) was prompted by
comment #5 in PR3104, and should be the last bit of work needed for the
bug.

llvm-svn: 158691
2012-06-19 00:37:47 +00:00
Ted Kremenek 9dcc0325de Sink definition of IBOutlet, IBOutletCollection, and IBAction into
the compiler predefines buffer.  These are essentially part of
the Objective-C language.

llvm-svn: 158690
2012-06-19 00:37:39 +00:00
Jordan Rose 8cea63c5cd Change -Winternal-linkage-in-inline from ExtWarn to Warning in C++.
Per post-commit review, it's not appropriate to use ExtWarn in C++, because
we can't prove that the inline function will actually be defined in more than
one place (and thus we can't prove that this violates the ODR).

This removes the warning entirely from uses in the main source file in C++.

llvm-svn: 158689
2012-06-18 23:58:49 +00:00
Tanya Lattner 794250474b Add language std for OpenCL 1.1 and 1.2.
llvm-svn: 158686
2012-06-18 22:55:02 +00:00
Jordan Rose 28cd12f265 Support -Winternal-linkage-in-inline in C++ code.
This includes treating anonymous namespaces like internal linkage, and allowing
const variables to be used even if internal. The whole thing's been broken out
into a separate function to avoid nested ifs.

llvm-svn: 158683
2012-06-18 22:09:19 +00:00
Jordan Rose 832c2134a9 [analyzer] Add a comment: why we treat array compound literals as lvalues.
llvm-svn: 158681
2012-06-18 21:31:27 +00:00
Matt Beaumont-Gay 50911a9d60 Move a few static functions from DiagnosticRenderer.cpp into SourceManager.
This simplifies the code a little bit, since these functions all took a
SourceManager parameter and called a bunch of methods on it, and makes
the functions available to other users.

llvm-svn: 158676
2012-06-18 20:12:05 +00:00
Jordan Rose edff020011 Allow internal decls in inline functions if the function is in the main file.
This handles the very common case of people writing inline functions in their
main source files and not tagging them as inline. These cases should still
behave as the user intended. (The diagnostic is still emitted as an extension.)

I'm reworking this code anyway to account for C++'s equivalent restriction in
[basic.def.odr]p6, but this should get some bots back to green.

llvm-svn: 158666
2012-06-18 17:49:58 +00:00
Michael J. Spencer e2f493604a [VS Toolchain] Correctly forward -l linker inputs to link.exe.
Patch by Nikola Smiljanic!

llvm-svn: 158664
2012-06-18 16:56:04 +00:00
Nuno Lopes e881ce2ef6 fix PR13071 / rdar://problem/11634669 :
crash on invalid function decl with alloc_size attribute

llvm-svn: 158663
2012-06-18 16:39:04 +00:00
Nuno Lopes e44e93aa6b alloc_size attribute: there's nothing wrong with alloc_size(1,1). It just means the function allocates x^2 bytes. GCC also accepts this syntax
llvm-svn: 158662
2012-06-18 16:27:56 +00:00
Alexis Hunt a0e54d453b Handle C++11 attribute namespaces automatically.
Now, as long as the 'Namespaces' variable is correct inside Attr.td, the
generated code will correctly admit a C++11 attribute only when it has the
appropriate namespace(s).

llvm-svn: 158661
2012-06-18 16:13:52 +00:00
Michael J. Spencer f97bd8c9cb [MSExtensions] Add support for __forceinline.
__forceinline is a combination of the inline keyword and __attribute__((always_inline))

llvm-svn: 158653
2012-06-18 07:00:48 +00:00
Richard Smith 7b3f322517 Extend the error recovery for a template-argument-list terminated by '>>' to
also deal with '>>>' (in CUDA), '>=', and '>>='. Fix the FixItHints logic to
deal with cases where the token is followed by an adjacent '=', '==', '>=',
'>>=', or '>>>' token, where a naive fix-it would result in a differing token
stream on a re-lex.

llvm-svn: 158652
2012-06-18 06:11:04 +00:00
Joerg Sonnenberger 5c98e1fb24 Don't warn about address-to-member used as part of initialisation, if
the member expression is in parentheses.

llvm-svn: 158651
2012-06-17 23:10:39 +00:00
James Dennett f124387119 Documentation cleanup: fix two typos, rief -> brief and Descripts -> Describes
llvm-svn: 158630
2012-06-17 05:33:25 +00:00
James Dennett 3d5e4593de Documentation cleanup:
* Added \file, \brief and \verbatim...\endverbatim markup, particularly around
  documentation of subset of the grammars that are being parsed.

llvm-svn: 158628
2012-06-17 04:36:28 +00:00
James Dennett 6deb84137c Documentation cleanup: Use \brief for summaries, and escape # characters.
llvm-svn: 158619
2012-06-17 03:41:54 +00:00
James Dennett f442d2455b Documentation cleanup:
* Removed docs for Lexer::makeFileCharRange from Lexer.cpp, as they're in
  the header file;
* Reworked the documentation for SkipBlockComment so that it doesn't confuse
  Doxygen's comment parsing;
* Added another summary with \brief markup.

llvm-svn: 158618
2012-06-17 03:40:43 +00:00
James Dennett 3dc736da32 Documentation cleanup: fixing a typo from my previous 'fix'.
llvm-svn: 158617
2012-06-17 03:36:08 +00:00
James Dennett 1cc2203286 Documentation cleanup: added \verbatim...\verbatim markup to fix the
formatting of Doxygen's output for StringLiteralParser::StringLiteralParser.

llvm-svn: 158616
2012-06-17 03:34:42 +00:00
James Dennett 18a6d793e7 Documentation cleanup:
* Escaped #pragma (as \#pragma) in Doxygen comments;
* Added \code...\endcode annotations around code examples in doc comments.

llvm-svn: 158615
2012-06-17 03:26:26 +00:00
James Dennett 87a2acf1eb Documentation cleanup: escaped # characters in Doxygen comments.
llvm-svn: 158614
2012-06-17 03:22:59 +00:00
Richard Smith a8d4f229a6 -Wuninitialized bugfix: when entering the scope of a variable with no
initializer, it is uninitialized, even if we may be coming from somewhere where
it was initialized.

llvm-svn: 158611
2012-06-16 23:34:14 +00:00
NAKAMURA Takumi 8bd8ee7648 clang/lib/Basic/FileManager.cpp: Detect the root directory with PathV2. It should be better fix for PR10331, or, "clang X:\foo.c" fails.
llvm-svn: 158596
2012-06-16 06:04:10 +00:00
Meador Inge 5d3fb22bac Explicitly build __builtin_va_list.
The target specific __builtin_va_list types are now explicitly built instead
of injecting strings into the preprocessor input.

llvm-svn: 158592
2012-06-16 03:34:49 +00:00
Eli Friedman 93ee5ca805 Fix Sema and IRGen for atomic compound assignment so it has the right semantics when promotions are involved.
(As far as I can tell, this only affects some edge cases.)

llvm-svn: 158591
2012-06-16 02:19:17 +00:00
Jordan Rose b4712d142a [analyzer] Array CompoundLiteralExprs need to be treated like lvalues.
llvm-svn: 158588
2012-06-16 01:28:03 +00:00
Jordan Rose e42412be39 [analyzer] Return an UnknownVal when we try to get the binding for a VLA.
This happens in C++ mode right at the declaration of a struct VLA;
MallocChecker sees a bind and tries to get see if it's an escaping bind.
It's likely that our handling of this is still incomplete, but it fixes a
crash on valid without disturbing anything else for now.

llvm-svn: 158587
2012-06-16 01:28:00 +00:00
Argyrios Kyrtzidis 33b4bfcef5 [AST/libclang] Fix the selector locations that are reported for a
method definition that has its '{' attached to the method name without
a space.

With a method like:

-(id)meth{
.....
}

the logic in ObjCMethodDecl that determined the selector locations got
confused because it was initialized based on an end location for '{' but
that end location changed to '}' after the method was finished.

Fix this by having an immutable end location for the declarator and
for getLocEnd() get the end location from the body itself.

Fixes rdar://11659739.

llvm-svn: 158583
2012-06-16 00:46:02 +00:00
Jordan Rose de409b6d5f [analyzer] Buffers passed to CGBitmapContextCreate can escape.
Specifically, although the bitmap context does not take ownership of the
buffer (unlike CGBitmapContextCreateWithData), the data buffer can be extracted
out of the created CGContextRef. Thus the buffer is not leaked even if its
original pointer goes out of scope, as long as
- the context escapes, or
- it is retrieved via CGBitmapContextGetData and freed.

Actually implementing that logic is beyond the current scope of MallocChecker,
so for now CGBitmapContextCreate goes on our system function exception list.

llvm-svn: 158579
2012-06-16 00:09:20 +00:00
Eli Friedman 13ffdd86b9 Make the ".*" operator work correctly when the base is a prvalue and the field has a non-trivial copy constructor. PR13097.
llvm-svn: 158578
2012-06-15 23:51:06 +00:00
Kaelyn Uhrain b5b17fe9fc Recover when correcting an unknown type name to a keyword like "struct".
llvm-svn: 158573
2012-06-15 23:45:58 +00:00
Kaelyn Uhrain 237c7d33b9 Move isCXXSimpleTypeSpecifier from Parser to Sema and tweak it for wider use.
llvm-svn: 158572
2012-06-15 23:45:51 +00:00
Jordan Rose 127f6eef7e [-E] Emit a rewritten _Pragma on its own line.
1. Teach Lexer that pragma lexers are like macro expansions at EOF.
2. Treat pragmas like #define/#undef when printing.
3. If we just printed a directive, add a newline before any more tokens.
(4. Miscellaneous cleanup in PrintPreprocessedOutput.cpp)

PR10594 and <rdar://problem/11562490> (two separate related problems)

llvm-svn: 158571
2012-06-15 23:33:51 +00:00
James Dennett a2449fea5b Documentation cleanup: Escaped backslashes in Doxygen comments.
llvm-svn: 158567
2012-06-15 22:33:08 +00:00
James Dennett 1bc5f0c7ef Documentation cleanup: fix a type, LocatioinE -> LocationE
llvm-svn: 158566
2012-06-15 22:32:14 +00:00
James Dennett 5207a1c728 Documentation cleanup: escape Objective-C @keywords in Doxygen comments.
llvm-svn: 158565
2012-06-15 22:30:14 +00:00
James Dennett b5d5f8191f Documentation cleanup: Made a parameter name in a \param command match the code
llvm-svn: 158564
2012-06-15 22:28:09 +00:00
James Dennett f14a6e5f13 Documentation cleanup:
* Escaped "::" and "<" as needed in Doxygen comments;
* Marked up code examples with \code...\endcode;
* Documented a \param that is current, instead of a few that aren't;
* Fixed up some \file and \brief comments.

llvm-svn: 158562
2012-06-15 22:23:43 +00:00
James Dennett be30245442 Documentation cleanup:
* Escaped Objective-C @keywords in Doxygen comments;
* Documented more accurate \params;
* Exposed some more summaries using \brief.

llvm-svn: 158559
2012-06-15 22:10:14 +00:00
James Dennett c423c533da Documentation cleanup: escape # in a Doxygen comment.
llvm-svn: 158554
2012-06-15 21:48:19 +00:00
James Dennett ff3c995624 Documentation cleanup: escape backslashes in Doxygen comments.
llvm-svn: 158552
2012-06-15 21:36:54 +00:00
James Dennett 523af827de Documentation cleanup: delete doc comments from source files where they are
broken duplicates of comments that are in the corresponding header files.

llvm-svn: 158550
2012-06-15 21:30:06 +00:00
James Dennett 88b71e4121 Documentation cleanup: escape # in a Doxygen comment.
llvm-svn: 158549
2012-06-15 21:28:23 +00:00
James Dennett 0d8a3f8fb1 Documentation cleanup: escape @ in a Doxygen comment.
llvm-svn: 158548
2012-06-15 21:27:44 +00:00
Alexis Hunt 2178f14c10 Stop referring to functions as methods in per-function fallthrough-checking.
llvm-svn: 158545
2012-06-15 21:22:05 +00:00
Jordan Rose 9da05858b4 [completion] Add completions for @"..." and @(...), and tidy up @[] and @{}.
Specifically, @[] and @{} didn't have a type associated with them; we now
use "NSArray *" and "NSDictionary *", respectively. @"" has the type
"NSString *". @(), unfortunately, has type "id", since it (currently) may
be either an NSNumber or an NSString.

Add a test for all the Objective-C at-expression completions.

<rdar://problem/11507708&11507668&11507711>

llvm-svn: 158533
2012-06-15 18:19:56 +00:00
Jordan Rose 95dfae824e [analyzer] RetainCount: don't track objects init'd with a delegate
We already didn't track objects that have delegates or callbacks or
objects that are passed through void * "context pointers". It's a
not-uncommon pattern to release the object in its callback, and so
the leak message we give is not very helpful.

llvm-svn: 158532
2012-06-15 18:19:52 +00:00
Jordan Rose 2684c68ddc Warn when a static variable is referenced in a non-static inline function.
This is explicitly forbidden in C99 6.7.4p3. This is /not/ forbidden in C++,
probably because by default file-scope const/constexpr variables have internal
linkage, while functions have external linkage. There's also the issue of
anonymous namespaces to consider. Nevertheless, there should probably be a
similar warning, since the semantics of inlining a function that references
a variable with internal linkage do not seem well-defined.

<rdar://problem/11577619>

llvm-svn: 158531
2012-06-15 18:19:48 +00:00
Douglas Gregor 7efd007cfb Check the parameter lists and return type of both blocks and lambdas
for unexpanded parameter packs. Fixes the crash-on-invalid in
PR13117.

llvm-svn: 158525
2012-06-15 16:59:29 +00:00
NAKAMURA Takumi f500be025a Headers/xopintrin.h: Try to fix r158492. Did you mean, mm256?
llvm-svn: 158521
2012-06-15 13:37:44 +00:00
James Dennett 9426c6c6d3 Documentation fix: made the name given to \param match the code.
llvm-svn: 158511
2012-06-15 09:02:08 +00:00
James Dennett a0ae493c1d Documentation cleanup: eliminated Doxygen warnings by deleting a doc comment
on ASTContext::CreateTypeSourceInfo that duplicated information from the
(more complete) version in ASTContext.h.

llvm-svn: 158504
2012-06-15 08:02:32 +00:00
James Dennett 845619a285 Documentation cleanup:
* Add \brief to produce a summary in the Doxygen output;
* Add missing parameter names to \param commands;
* Fix mismatched parameter names for \param commands;
* Add a parameter name so that the \param has a target.

llvm-svn: 158503
2012-06-15 07:41:35 +00:00
James Dennett 6e5cffb617 Documentation fixes: Added \brief markup and fixed some formatting.
llvm-svn: 158501
2012-06-15 07:35:42 +00:00
James Dennett 2a4d13c5cf Documentation cleanup:
* Removed \param comments for parameters that no longer exist;
* Fixed a "\para" typo to "\param";
* Escaped @, # and \ symbols as needed in Doxygen comments;
* Added use of \brief to output short summaries.

llvm-svn: 158498
2012-06-15 07:13:21 +00:00
James Dennett f44874fb21 Documentation cleanup: escape Objective-C @ symbols in Doxygen comments.
llvm-svn: 158495
2012-06-15 06:52:33 +00:00
Craig Topper 9e28bf9345 Add XOP frcz instrinsics.
llvm-svn: 158492
2012-06-15 06:33:42 +00:00
John McCall d8d00be632 It turns out that implementing the rethrow-on-fallthrough
semantics of a ctor/dtor function-try-block catch handler
by pushing a normal cleanup is not just overkill but actually
actively wrong when the handler contains an explicit return
(which is only legal in a dtor).  Just emit the rethrow as
ordinary code at the fallthrough point.  Fixes PR13102.

llvm-svn: 158488
2012-06-15 05:27:05 +00:00
Richard Smith e6799ddae8 PR12717: Clang supports hexadecimal floating-point literals in all language
modes. For languages other than C99/C11, this isn't quite a conforming
extension, and for C++11, it breaks some reasonable code containing
user-defined literals.

In languages which don't officially have hexfloats, pare back this extension
to only apply in cases where the token starts 0x and does not contain an
underscore. The extension is still not quite conforming, but it's a lot closer
now.

llvm-svn: 158487
2012-06-15 05:07:49 +00:00
David Blaikie 2af2b3071d Fix PR13065.
This condition (added in r158093) was overly conservative.

llvm-svn: 158483
2012-06-15 00:47:13 +00:00
Richard Trieu 7cdfe8fa04 Fix T* p to T *p
llvm-svn: 158478
2012-06-14 23:18:09 +00:00
Richard Trieu 4fc853681f Use a proper visitor to recursively check for uninitialized use in constructors.
llvm-svn: 158477
2012-06-14 23:11:34 +00:00
James Dennett 634962f3e1 Still more Doxygen documentation fixes:
* Escape #, < and @ symbols where Doxygen would try to interpret them;
* Fix several function param documentation where names had got out of sync;
* Delete param documentation referring to parameters that no longer exist.

llvm-svn: 158472
2012-06-14 21:40:34 +00:00
Daniel Jasper e99c2bf8aa Look at incomplete FunctionTemplateDecls in order to determine whether
a CXXRecordDecl is complete. Fixes Bug 13086.

llvm-svn: 158469
2012-06-14 20:56:06 +00:00
David Blaikie 690f21e25c Support -f[no-]rewrite-includes from the driver.
Review by Chandler Carruth.

llvm-svn: 158463
2012-06-14 18:55:27 +00:00
David Blaikie e993e4cd9b Support -frewrite-includes as an option while preprocessing.
llvm-svn: 158460
2012-06-14 17:36:09 +00:00
David Blaikie 76cae518cf Fix crash on missing header in -rewrite-includes.
llvm-svn: 158459
2012-06-14 17:36:05 +00:00
David Blaikie 619117a31d Rename -rewrite-includes to -frewrite-includes.
llvm-svn: 158458
2012-06-14 17:36:01 +00:00
James Dennett 596e475725 This makes SemaCodeComplete.cpp more Doxygen-friendly by changing the
OBJC_AT_KEYWORD_NAME take a string literal argument where previously
its second argument was an unquoted token; macro invocations such as
OBJC_AT_KEYWORD_NAME(NeedAt,{) confuse Doxygen's parser.

While I'm wary of changing code (rather than just comments) to work
around Doxygen's limitations, in this case the change makes the code
more readable for human beings as well, and the macro derived no
benefit from using the preprocessor's stringification operator, as
it never has need of the unquoted token.

I've also included a couple of trivial drive-by fixes to doc comments.

llvm-svn: 158440
2012-06-14 03:11:41 +00:00
James Dennett b9199ee5c1 More doxygen/documentation cleanups.
This reduces the number of warnings generated by Doxygen by about 100
(roughly 10%).  Issues addressed:
(1) Primarily, backslash-escaped "@foo" and "#bah" in Doxygen comments
when they're not supposed to be Doxygen commands or links, and
similarly for "<baz>" when it's not intended as as HTML tag;
(2) Changed some \t commands (which don't exist) to \c ("to refer to a
word of code", as the Doxygen manual says);
(3) \precondition becomes \pre;
(4) When touching comments, deleted a couple of spurious spaces in them;
(5) Changed some \n and \r to \\n and \\r;
(6) Fixed one tiny typo: #pragms -> #pragma.

This patch touches documentation/comments only.

llvm-svn: 158422
2012-06-13 22:07:09 +00:00
Richard Trieu 871f5f320c Rename a loop variable to silence a gcc warning.
llvm-svn: 158420
2012-06-13 20:52:36 +00:00
Richard Smith 8acadcb84b Add -isystem-prefix and -ino-system-prefix arguments, which can be used to
override whether headers are system headers by checking for prefixes of the
header name specified in the #include directive.

This allows warnings to be disabled for third-party code which is found in
specific subdirectories of include paths.

llvm-svn: 158418
2012-06-13 20:27:03 +00:00
Richard Trieu dc3559106b Moved the StringLiteral printing code from StmtPrinter into the StringLiteral
class and have StmtPrinter and StmtDumper refer to it.  This fixes an
assertion failure when dumping wchar string literals.

llvm-svn: 158417
2012-06-13 20:25:24 +00:00
John McCall 7dd1783c5e Provide a -no-pedantic to cancel out -pedantic.
llvm-svn: 158416
2012-06-13 19:48:01 +00:00
Richard Smith a60742a3d0 Fix issue where a token paste which forms a /* or // would discard the rest of
the input: token-pasting was producing a tok::eof.

Patch by Andy Gibbs!

llvm-svn: 158412
2012-06-13 19:02:56 +00:00
Daniel Jasper 429c134d5d Allow __attribute__((unused)) for fields and make it silence
-Wunused-private-field.

llvm-svn: 158411
2012-06-13 18:31:09 +00:00
Kaelyn Uhrain c1244ae6a0 Remove the trailing backslash from the comment to remove the warning about
a multi-line comment, fixing builds with e.g. -Werror=comment enabled.

llvm-svn: 158406
2012-06-13 17:05:13 +00:00
Richard Smith 0948d93b7f Fix off-by-one error in UTF-16 encoding: don't try to use a surrogate pair for U+FFFF.
llvm-svn: 158391
2012-06-13 05:41:29 +00:00
Richard Smith 4060f77462 PR13099: Teach -Wformat about raw string literals, UTF-8 strings and Unicode escape sequences.
llvm-svn: 158390
2012-06-13 05:37:23 +00:00
Richard Smith 25a80d424b Add missing narrowing check: converting from a signed integral type to a wider
unsigned type is narrowing if the source is non-constant or negative.

llvm-svn: 158377
2012-06-13 01:07:41 +00:00
Charles Davis a81618db44 Grab bag of Microsoft Mangler fixes:
- Support mangling virtual function tables (base tables need work on the
  ManglerContext interface).
- Correct mangling of local scopes (i.e. functions and C++ methods).
- Replace every llvm_unreachable() for actually-reachable code with a
  diagnostic.

llvm-svn: 158376
2012-06-13 00:18:14 +00:00
Chad Rosier 075608ecfc [ms-inline-asm] The __asm keyword is a statement separator, so multiple asm
statements are allowed on the same line.

llvm-svn: 158372
2012-06-12 20:30:26 +00:00
Chad Rosier 0764e0bb30 [ms-inline-asm] Cleanup MS style inline assembly parsing.
Specifically, improve the handling of whitespace, stop saving tokens that are
in comments and fix the case where we have a comment followed by a closing brace
on the next line.

Unfortunately, there's no easy way of testing this code.

llvm-svn: 158367
2012-06-12 19:03:42 +00:00
Douglas Gregor 9b4f370095 When code completion walks the members of a protocol or interface,
make sure that we walk the definition. Fixes <rdar://problem/11427742>.

llvm-svn: 158357
2012-06-12 13:44:08 +00:00
Bill Wendling d4da16c193 Remove unused variable.
llvm-svn: 158353
2012-06-12 06:53:25 +00:00
Craig Topper db0fbf0a50 Add XOP permute intrinsics.
llvm-svn: 158351
2012-06-12 06:03:35 +00:00
Richard Smith 700537cddf If parsing a trailing-return-type fails, don't pretend we didn't have one at
all. Suppresses follow-on errors mentioned in PR13074.

llvm-svn: 158348
2012-06-12 01:51:59 +00:00
Dmitri Gribenko 4425368365 Remove unused variable.
llvm-svn: 158343
2012-06-12 00:43:19 +00:00
Jordan Rose 2fdc07ee89 Revert "[analyzer] Treat LValueBitCasts like regular pointer bit casts."
This does not actually give us the right behavior for reinterpret_cast
of references. Reverting so I can think about it some more.

This reverts commit 50a75a6e26a49011150067adac556ef978639fe6.

llvm-svn: 158341
2012-06-12 00:20:22 +00:00
Jordan Rose ca00b28a47 [analyzer] Treat LValueBitCasts like regular pointer bit casts.
These casts only appear in very well-defined circumstances, in which the
target of a reinterpret_cast or a function formal parameter is an lvalue
reference. According to the C++ standard, the following are equivalent:

 reinterpret_cast<T&>( x)
*reinterpret_cast<T*>(&x)

[expr.reinterpret.cast]p11

llvm-svn: 158338
2012-06-11 23:20:52 +00:00
Hal Finkel 8eb5928514 Add PPC support for translating gcc-style -mcpu options into LLVM -target-cpu options.
This functionality is based on what is done on ARM, and enables selecting PPC CPUs
in a way compatible with gcc's driver. Also, mirroring gcc (and what is done on x86),
-mcpu=native support was added. This uses the host cpu detection from LLVM
(which will also soon be updated by refactoring code currently in backend).

In order for this to work, the target needs a list of valid CPUs -- we now accept all CPUs accepted by LLVM.
A few preprocessor defines for common CPU types have been added.

llvm-svn: 158334
2012-06-11 22:35:19 +00:00
Chad Rosier 175b507f5e Make CodeGenFunction::EmitMSAsmStmt throw a fatal error as MS-style inline
assembly is completely untested and unsupported.

llvm-svn: 158329
2012-06-11 21:52:25 +00:00
Chad Rosier 32503020a4 Etch out the code path for MS-style inline assembly.
llvm-svn: 158325
2012-06-11 20:47:18 +00:00
Jordan Rose efef760214 [analyzer] Add ObjCLoopChecker: objects from NSArray et al are non-nil.
While collections containing nil elements can still be iterated over in an
Objective-C for-in loop, the most common Cocoa collections -- NSArray,
NSDictionary, and NSSet -- cannot contain nil elements. This checker adds
that assumption to the analyzer state.

This was the cause of some minor false positives concerning CFRelease calls
on objects in an NSArray.

llvm-svn: 158319
2012-06-11 16:40:41 +00:00
Jordan Rose 3ba8ae3fd9 [analyzer] When looking for a known class, only traverse the hierarchy once.
This has a small hit in the case where only one class is interesting
(NilArgChecker) but is a big improvement when looking for one of several
interesting classes (VariadicMethodTypeChecker), in which the most common
case is that there is no match.

llvm-svn: 158318
2012-06-11 16:40:37 +00:00
Rafael Espindola a486f48e5b We were computing the visibility and linkage of template parameters, but
only using the linkage.

Use and test both, documenting that considering the visibility and linkage
of template parameters is a difference from gcc.

llvm-svn: 158309
2012-06-11 14:29:58 +00:00
Craig Topper ce8dbaadb6 Add XOP shift and compare intrinsics.
llvm-svn: 158300
2012-06-11 07:01:43 +00:00
James Dennett 1355bd17c6 Documentation cleanup, fixing Doxygen markup. Mostly this avoids common terms
such as "protocol" and "expression" being implicitly turned into links to
mistakenly-generated Doxygen pages:
- Escaping @ symbols when Doxygen would otherwise incorrectly interpret them;
- Escaping # symbols when they're not intended as explicit Doxygen link 
  requests, such as when discussing preprocessor directives;
- In one odd case, unescaping @ in @__experimental_modules_import, because
  Doxygen wrote '\@' to the output in that case, causing the example in the
  description of ImportDecl to be wrong; and
- Fixing a typo: @breif -> @brief.

llvm-svn: 158299
2012-06-11 06:19:40 +00:00
Argyrios Kyrtzidis ff32674d3a Const'ify CompilerInvocation::toArgs().
llvm-svn: 158298
2012-06-11 03:34:26 +00:00
Richard Smith 521ecc1f97 PR12964: __int128 and unsigned __int128 are promoted integral types, be sure to
consider them when enumerating builtin operator candidates.

llvm-svn: 158293
2012-06-10 08:00:26 +00:00
Craig Topper a3c5fbf54b Add XOP vprot* instruction intrinsics
llvm-svn: 158292
2012-06-10 07:47:32 +00:00
Richard Smith 4086a13df8 Remove CXXRecordDecl flags which are unused after r158289.
We need an efficient mechanism to determine whether a defaulted default
constructor is constexpr, in order to determine whether a class is a literal
type, so keep the incrementally-built form on CXXRecordDecl. Remove the
on-demand computation of same, so that we only have one method for determining
whether a default constructor is constexpr. This doesn't affect correctness,
since default constructor lookup is much simpler than selecting a constructor
for copying or moving.

We don't need a corresponding mechanism for defaulted copy or move constructors,
since they can't affect whether a type is a literal type. Conversely, checking
whether such functions are constexpr can require non-trivial effort, so we defer
such checks until the copy or move constructor is required.

Thus we now only compute whether a copy or move constructor is constexpr on
demand, and only compute whether a default constructor is constexpr in advance.
This is unfortunate, but seems like the best solution.

llvm-svn: 158290
2012-06-10 07:07:24 +00:00
Richard Smith b58000950e Fix PR13052 properly, by performing special member lookup to determine whether
an explicitly-defaulted default constructor would be constexpr. This is
necessary in weird (but well-formed) cases where a class has more than one copy
or move constructor.

Cleanup of now-unused parts of CXXRecordDecl to follow.

llvm-svn: 158289
2012-06-10 05:43:50 +00:00
Richard Smith 2b013185f8 PR13064: Store whether an in-class initializer uses direct or copy
initialization, and use that information to produce the right kind of
initialization during template instantiation.

llvm-svn: 158288
2012-06-10 03:12:00 +00:00
Craig Topper 02b3d81a97 More XOP intrinsics
llvm-svn: 158287
2012-06-10 02:46:15 +00:00
Craig Topper 33b6d5e20b Begin adding XOP intrinsics
llvm-svn: 158286
2012-06-10 00:39:38 +00:00
Craig Topper f561a9562d Add XOP feature flag.
llvm-svn: 158284
2012-06-09 22:24:14 +00:00
Benjamin Kramer 7132638995 Replace a char counting helper function with std::count.
No functionality change.

llvm-svn: 158272
2012-06-09 13:18:14 +00:00
Michael J. Spencer d1e09a4282 [C++11 Compat] Fix breaking change in C++11 pair copyctor.
While this code is valid C++98, it is not valid C++11. The problem can be
reduced to:

class MDNode;

class DIType {
  operator MDNode*() const {return 0;}
};

class WeakVH {
  WeakVH(MDNode*) {}
};

int main() {
  DIType di;
  std::pair<void*, WeakVH> p(std::make_pair((void*)0, di)));
}

This was not detected by any of the bots we have because they either compile
C++98 with libstdc++ (which allows it), or C++11 with libc++ (which incorrectly
allows it). I ran into the problem when compiling with VS 2012 RC.

Thanks to Richard for explaining the issue.

llvm-svn: 158245
2012-06-08 23:47:12 +00:00
Dmitri Gribenko 702b732d6f Correct method name in comment: from LexRawToken to LexFromRawLexer, according
to a change done long ago in r57393.

llvm-svn: 158243
2012-06-08 23:19:37 +00:00
Dmitri Gribenko 4280e5cf97 Convert comments to proper Doxygen comments.
llvm-svn: 158241
2012-06-08 23:13:42 +00:00
Jordan Rose d8d5669435 Warn in ObjC++ when an 'auto' variable deduces type 'id'.
This could happen for cases like this:

- (NSArray *)getAllNames:(NSArray *)images {
  NSMutableArray *results = [NSMutableArray array];
  for (auto img in images) {
    [results addObject:img.name];
  }
  return results;
}

Here the property access will fail because 'img' has type 'id', rather than,
say, NSImage.

This warning will not fire in templated code, since the 'id' could have
come from a template parameter.

llvm-svn: 158239
2012-06-08 22:46:07 +00:00
Richard Smith b3a1df03a9 PR13051: Only suggest the 'template' and 'operator' keywords when performing
typo-correction after a scope specifier.

llvm-svn: 158231
2012-06-08 21:35:42 +00:00
Jordan Rose d49a33e86c Disallow using ObjC literals in direct comparisons (== and friends).
Objective-C literals conceptually always create new objects, but may be
optimized by the compiler or runtime (constant folding, singletons, etc).
Comparing addresses of these objects is relying on this optimization
behavior, which is really an implementation detail.

In the case of == and !=, offer a fixit to a call to -isEqual:, if the
method is available. This fixit is directly on the error so that it is
automatically applied.

Most of the time, this is really a newbie mistake, hence the fixit.

llvm-svn: 158230
2012-06-08 21:14:25 +00:00
Jordan Rose b5a94f45d2 If fixits appear to overlap, move the second one over in the output.
This occurs when you have two insertions and the first one is so long that the
second fixit's column is before the first fixit ends. The edits themselves
don't actually overlap, but our command-line preview does.

llvm-svn: 158229
2012-06-08 21:14:19 +00:00
Richard Smith 12f247f43f PR13051: If a constructor is explicitly defaulted, it isn't marked as being
constexpr until we get to the end of the class definition. When that happens,
be sure to remember that the class actually does have a constexpr constructor.

This is a stopgap solution, which still doesn't cover the case of a class with
multiple copy constructors (only some of which are constexpr). We should be
performing constructor lookup when implicitly defining a constructor in order
to determine whether all constructors it invokes are constexpr.

llvm-svn: 158228
2012-06-08 21:09:22 +00:00
Richard Trieu 10c9246682 Remove a commented out variable declaration. This was originally a debugging
variable which wasn't removed when the original patch was committed.

llvm-svn: 158225
2012-06-08 20:10:05 +00:00
Anna Zaks 528b14c5d9 [analyzer] MallocSizeofChecker false positive: when sizeof is argument
to addition.

We should not to warn in case the malloc size argument is an
addition containing 'sizeof' operator - it is common to use the pattern
to pack values of different sizes into a buffer. 

Ex:

uint8_t *buffer = (uint8_t*)malloc(dataSize + sizeof(length));

llvm-svn: 158219
2012-06-08 18:44:43 +00:00
Jordan Rose de1a29277e Disable _Pragma during HTML macro rewriting to keep from crashing.
The preprocessor's handling of diagnostic push/pops is stateful, so
encountering pragmas during a re-parse causes problems. HTMLRewrite
already filters out normal # directives including #pragma, so it's
clear it's not expected to be interpreting pragmas in this mode.

This fix adds a flag to Preprocessor to explicitly disable pragmas.
The "right" fix might be to separate pragma lexing from pragma
parsing so that we can throw away pragmas like we do preprocessor
directives, but right now it's important to get the fix in.

Note that this has nothing to do with the "hack" of re-using the
input preprocessor in HTMLRewrite. Even if we someday copy the
preprocessor instead of re-using it, the copy would (and should) include
the diagnostic level tables and have the same problems.

llvm-svn: 158214
2012-06-08 18:06:21 +00:00
Douglas Gregor 02c2dbf45e Switch LineTableInfo to use FileID instead of int for file references,
from Tom Honermann!

llvm-svn: 158211
2012-06-08 16:40:28 +00:00
Argyrios Kyrtzidis 1416e17c89 [libclang] Don't crash when saving a PCH from a prefix header
that does not exist.

rdar://11607033

llvm-svn: 158193
2012-06-08 05:48:06 +00:00
Argyrios Kyrtzidis 31afb956ae [libclang/AST]
AST: For auto-synthesized ivars give them the location of the related
property (previously they had no source location). This allows them
to be indexed by libclang.

libclang: Make sure synthesized ivars are indexed before the methods that
may reference them.

Fixes rdar://11607001.

llvm-svn: 158189
2012-06-08 02:16:11 +00:00
Richard Smith 337a5a1c3f Allow friend declarations of defaulted special member functions. Only
definitions of such members are prohibited, not mere declarations.

llvm-svn: 158186
2012-06-08 01:30:54 +00:00
Kaelyn Uhrain 055e9479eb Fix up the 'typename' suggestion logic introduced in r157085, based on
feedback from Doug Gregor.

llvm-svn: 158185
2012-06-08 01:07:26 +00:00
Richard Smith f76568591c PR13047: Fix various abuses of clang::Type in the MS mangler, to make it work
in the presence of type sugar.

llvm-svn: 158184
2012-06-08 00:37:04 +00:00
Anna Zaks b60908db3a [analyzer] Add experimental "issue hash" to the plist diagnostic.
CmpRuns.py can be used to compare issues from different analyzer runs.
Since it uses the issue line number to unique 2 issues, adding a new
line to the beginning of a file makes all issues in the file reported as
new. 

The hash will be an opaque value which could be used (along with the
function name) by CmpRuns to identify the same issues. This way, we only
fail to identify the same issue from two runs if the function it appears
in changes (not perfect, but much better than nothing).

llvm-svn: 158180
2012-06-08 00:04:43 +00:00
Kaelyn Uhrain 1dac08da4b Teach the FixIt in DiagnoseInvalidRedeclaration how to replace the written
nested name specifiers in addition to the function's identifier when the
correction has a different nested name specifier.

llvm-svn: 158178
2012-06-07 23:57:12 +00:00
Kaelyn Uhrain 389e9c2d7c Ignore corrections to functions with bodies when deciding which
correction to use for an invalid function redeclaration.

llvm-svn: 158177
2012-06-07 23:57:08 +00:00
Anna Zaks a7dcc996a9 [analyzer] Fixit for r158136.
I falsely assumed that the memory spaces are equal when we reach this
point, they might not be when memory space of one or more is stack or
Unknown. We don't want a region from Heap space alias something with
another memory space.

llvm-svn: 158165
2012-06-07 20:18:08 +00:00
Fariborz Jahanian 5d53fcda7c User better API for vla in compund literals.
// rdar://11485774

llvm-svn: 158157
2012-06-07 18:15:55 +00:00
Douglas Gregor fed6699dd9 Add ext_vector type code for builtins, from John Garvin!
llvm-svn: 158156
2012-06-07 18:08:25 +00:00
Fariborz Jahanian bbc5bbf4f1 When emitting compund literal of vla pointer elements, make
sure to emit vla size to prevent an irgen crash.
// rdar://11485774

llvm-svn: 158153
2012-06-07 17:07:15 +00:00
Benjamin Kramer 5d4cff72b4 Reuse APInt's getNumWords, which gets rounding right (my ad-hoc solution missed it).
llvm-svn: 158151
2012-06-07 15:54:03 +00:00
Benjamin Kramer 6003ad5848 Plug a long standing memory leak in TemplateArgument.
The integral APSInt value is now stored in a decomposed form and the backing
store for large values is allocated via the ASTContext. This way its not
leaked as TemplateArguments are never destructed when they are allocated in
the ASTContext. Since the integral data is immutable it is now shared between
instances, making copying TemplateArguments a trivial operation.

Currently getting the integral data out of a TemplateArgument requires creating
a new APSInt object. This is cheap when the value is small but can be expensive
if it's not. If this turns out to be an issue a more efficient accessor could
be added.

llvm-svn: 158150
2012-06-07 15:09:51 +00:00
Anna Zaks 3563fde6a0 [analyzer] Anti-aliasing: different heap allocations do not alias
Add a concept of symbolic memory region belonging to heap memory space.
When comparing symbolic regions allocated on the heap, assume that they
do not alias. 

Use symbolic heap region to suppress a common false positive pattern in
the malloc checker, in code that relies on malloc not returning the
memory aliased to other malloc allocations, stack.

llvm-svn: 158136
2012-06-07 03:57:32 +00:00
Jordan Rose aefcedae65 Attach fixits for CFBridgingRetain/Release outside any casts.
Before, the note showed the location where you could insert __bridge variants,
but the actual fixit edit came after the cast.

No functionality change.

llvm-svn: 158131
2012-06-07 01:10:35 +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
Fariborz Jahanian ff045dc040 reverse r158117.
llvm-svn: 158119
2012-06-06 23:21:58 +00:00
Fariborz Jahanian 67164852a7 When doing arithmatic on vla pointer, make sure
to emit vla size to prevent an irgen crash.
// rdar://11485774

llvm-svn: 158117
2012-06-06 22:58:50 +00:00
Argyrios Kyrtzidis 63aebfb4ae [objcmt] When in ARC mode, also convert "[[.. alloc] init]" messages to literals,
since the change from +1 to +0 will be handled fine by ARC.

rdar://11606358

llvm-svn: 158114
2012-06-06 22:23:12 +00:00
Douglas Gregor 91c25eadea Whenever we have a BalancedDelimiterTracker, we have a 'nested' scope
where '>' is going to behave as an operator (and not as a '>' closing
a template argument list).

llvm-svn: 158111
2012-06-06 21:18:07 +00:00
Kaelyn Uhrain 493ea635fe Allow CorrectTypo to add/modify nested name qualifiers to typos that
are otherwise too short to try to correct.

The TODOs added to two of the tests are for existing deficiencies in the
typo correction code that could be exposed by using longer identifiers.

llvm-svn: 158109
2012-06-06 20:54:51 +00:00
Jordan Rose 0da4e77880 [analyzer] Provide debug descriptions for all memory space regions.
Patch by Guillem Marpons!

llvm-svn: 158106
2012-06-06 20:47:00 +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
David Blaikie d5321247c4 Add a -rewrite-includes option, which is similar to -rewrite-macros, but only expands #include directives.
Patch contributed by Lubos Lunak (l.lunax@suse.cz).
Review by Matt Beaumont-Gay (matthewbg@google.com).

llvm-svn: 158093
2012-06-06 18:52:13 +00:00
David Blaikie 987bcf9462 Escape \n and \r in doxycomment.
llvm-svn: 158091
2012-06-06 18:43:20 +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
Jordan Rose ccf43ca05c Add pedantic warning -Wempty-translation-unit (C11 6.9p1).
In standard C since C89, a 'translation-unit' is syntactically defined to have
at least one "external-declaration", which is either a decl or a function
definition. In Clang the latter gives us a declaration as well.

The tricky bit about this warning is that our predefines can contain external
declarations (__builtin_va_list and the 128-bit integer types). Therefore our
AST parser now makes sure we have at least one declaration that doesn't come
from the predefines buffer.

Also, remove bogus warning about empty source files. This doesn't catch source
files that only contain comments, and never fired anyway because of our
predefines.

PR12665 and <rdar://problem/9165548>

llvm-svn: 158085
2012-06-06 17:25:21 +00:00
Francois Pichet b27ea02784 Zap the /Za compiler switch from MSVC projects, the option is considered harmful even by Microsoft people and clang won't build using the MSVC 2012 RC if not removed.
Only 1 minor code change was necessary: can't use cdecl as variable name anymore.

llvm-svn: 158063
2012-06-06 12:00:10 +00:00
Daniel Jasper 0baec549a3 Introduce -Wunused-private-field. If enabled, this warning detects
unused private fields of classes that are fully defined in the current
translation unit.

llvm-svn: 158054
2012-06-06 08:32:04 +00:00
Ted Kremenek f470a4c2ca Disable path pruning for UndefResultChecker. It turns out we usually want to see more of the path
to discover how a value was used uninitialized.

llvm-svn: 158048
2012-06-06 06:25:37 +00:00
Douglas Gregor c65e1598ad A non-explicit constructor template with a second parameter that is a
parameter pack is a converting constructor. Fixes PR13003.

llvm-svn: 158040
2012-06-05 23:44:51 +00:00
Ted Kremenek 54baf2e57d PlistDiagnostics: force the ranges for control-flow edges to be single locations, forcing
adjacent edges to have compatible ranges.  This simplifies the layout logic for some clients.

llvm-svn: 158028
2012-06-05 22:00:52 +00:00
Fariborz Jahanian 3da28f80e3 objective-c: merge deprecated/unavailable attributes to
the overriding deprecated/unavailable method.
// rdar://11475360

llvm-svn: 158022
2012-06-05 21:14:46 +00:00
Eli Friedman 7919beaaf2 Fix a bug with va_arg and vectors on Darwin x86-32. <rdar://problem/11592208>.
llvm-svn: 158017
2012-06-05 19:40:46 +00:00
Eric Christopher beafa44be8 Reapply "Only emit debug information for methods that are user defined, there's"
As the failing testcase has been fixed.

This reverts commit 0637f407e6ee7fdccde17fbf9a5fcc4853187b3e.

llvm-svn: 158009
2012-06-05 18:16:22 +00:00
Simon Atanasyan d3d173ddca Mips: Define __mips_hard_float macro additional to __mips_single_float
when single float ABI is selected.

llvm-svn: 157996
2012-06-05 13:06:56 +00:00
John McCall 65485d7694 Revert "Only emit debug information for methods that are user defined, there's"
This reverts r157970, which was not passing on
  clang-x86_64-darwin10-nobootstrap-RA

llvm-svn: 157983
2012-06-05 06:10:39 +00:00
Eric Christopher f5dad49a65 Only emit debug information for methods that are user defined, there's
not much reason to emit for constructors and destructors that aren't
user defined.

rdar://11593099

llvm-svn: 157970
2012-06-05 00:15:06 +00:00
Jordan Rose 97c6f2b9e5 Teach format string checking about compile-time CFString constants.
Within the guts of CheckFormatHandler, the IsObjCLiteral flag was being used in
two ways: to see if null bytes were allowed, and to see if the '%@' specifier
is allowed.* The former usage has been changed to an explicit test and the
latter pushed down to CheckPrintfHandler and renamed ObjCContext, since it
applies to CFStrings as well.

* This also changes how wide chars are interpreted; in OS X Foundation, the
wide character type is 'unichar', a typedef for short, rather than wchar_t.

llvm-svn: 157968
2012-06-04 23:52:23 +00:00
Jordan Rose 614e72bec7 Make suggestions for mismatched enum arguments to printf/scanf.
llvm-svn: 157962
2012-06-04 22:49:02 +00:00
Jordan Rose 98709985a6 Teach printf/scanf about enums with fixed underlying types.
llvm-svn: 157961
2012-06-04 22:48:57 +00:00
Richard Smith 50fba8f0a9 PR13022: cope with parenthesized function types in MS name mangling.
llvm-svn: 157959
2012-06-04 22:46:59 +00:00
Richard Smith eb3cad53e7 Add a warning for when an array-to-pointer decay is performed on an array
temporary or an array subobject of a class temporary, and the resulting value
is used to initialize a pointer which outlives the temporary. Such a pointer
is always left dangling after the initialization completes and the array's
lifetime ends.

In order to detect this situation, this change also adds an
LValueClassification of LV_ArrayTemporary for temporaries of array type which
aren't subobjects of class temporaries. These occur in C++11 T{...} and GNU C++
(T){...} expressions, when T is an array type. Previously we treated the former
as a generic prvalue and the latter as a class temporary.

llvm-svn: 157955
2012-06-04 22:27:30 +00:00
Argyrios Kyrtzidis 6310fdd982 [objcmt] Don't migrate to subscripting syntax if the required methods have not
been declared on NSArray/NSDictionary.

rdar://11581975

llvm-svn: 157951
2012-06-04 21:23:26 +00:00
Anna Zaks 4ff9097fcc [analyzer] Fix a diagnostics bug which lead to a crash on the buildbot.
This bug was triggered by r157851. It only happens in the case where we
don't perform optimal diagnostic pruning.

llvm-svn: 157950
2012-06-04 21:03:31 +00:00
Fariborz Jahanian 22535def43 objective-c: Handle more warning cases for when
message receiver is 'weak' property.
// rdar://10225276

llvm-svn: 157946
2012-06-04 19:16:34 +00:00
Alexander Kornienko 8388d24701 Fixed a problem related to resolution of built-in headers in case a path of tool's binary contains sym-links.
llvm-svn: 157944
2012-06-04 19:02:59 +00:00
Aaron Ballman f0b67b6f5c Removing the lambda extension warning concerning single return statements, as it no longer applies.
llvm-svn: 157943
2012-06-04 18:57:41 +00:00
Jordan Rose 88bf06584b Remove AST and Parse from Driver's dependencies.
llvm-svn: 157933
2012-06-04 16:57:53 +00:00
Evgeniy Stepanov ea155f0153 Require -pie when linking with ASan on Android.
llvm-svn: 157923
2012-06-04 11:15:05 +00:00
Craig Topper 2b1eda344a Add fma3 intrinsic header file.
llvm-svn: 157913
2012-06-04 03:42:47 +00:00
Douglas Gregor 5bee25884b When adding built-in operator candidates for overload resolution
involving 'restrict', place restrict on the pointer type rather than
on the pointee type. Also make sure that we gather restrict from the
pointer type. Fixes PR12854 and the major part of PR11093.

llvm-svn: 157910
2012-06-04 00:15:09 +00:00
Craig Topper 12c9df3a9d Make disabling SSE levels also disable AVX and FMA.
llvm-svn: 157907
2012-06-03 22:23:42 +00:00
Craig Topper 1e9e01fabf Make AES and PCLMUL features imply SSE2 as that's needed to get the right types defined.
llvm-svn: 157906
2012-06-03 21:56:22 +00:00
Craig Topper bba778bfd5 Add fma feature flag for Intel FMA instructions.
llvm-svn: 157904
2012-06-03 21:46:30 +00:00
Nico Weber cdfb1ae7f7 Improve fixit for comparison operator on lhs of bitwise operator.
Before:
test.cc:2:18: note: place parentheses around the == expression to silence this warning
  if (0 == flags & 0xdd)
                 ^
                   (   )

Now:
test.cc:2:18: note: place parentheses around the == expression to silence this warning
  if (0 == flags & 0xdd)
                 ^
      (         )

llvm-svn: 157897
2012-06-03 07:07:00 +00:00
Argyrios Kyrtzidis 3c9aaf1ab8 Initialize the non-target-dependent fields of the Preprocessor in its constructor
so we can destroy it even if it was constructed with "DelayInitialization = true",
and we didn't end up calling Preprocessor::Initialize.

Fixes crashes in rdar://11558355

llvm-svn: 157892
2012-06-02 18:08:09 +00:00
NAKAMURA Takumi 4de31654bb ToolInvocation::mapVirtualFile(): Tweak for Win32. Handle the key as native path.
llvm-svn: 157889
2012-06-02 15:34:21 +00:00
Simon Atanasyan 590ad8f515 MIPS: Factor out code selects the float ABI as determined by -msoft-float,
-mhard-float, and -mfloat-abi= to the new function getMipsFloatABI. That
simplifies reuse of this code.

llvm-svn: 157888
2012-06-02 15:06:29 +00:00
Benjamin Kramer 474261af7b Fix typos found by http://github.com/lyda/misspell-check
llvm-svn: 157886
2012-06-02 10:20:41 +00:00
Alexander Kornienko 06caf7d59f Implementation of a "soft opt-in" option for -Wimplicit-fallthrough diagnostics: -Wimplicit-fallthrough-per-method
llvm-svn: 157871
2012-06-02 01:01:07 +00:00
Anna Zaks 7ba2615047 [analyzer] Rely on canBeInlined utility instead of checking CallExpr
explicitly.

This will make it easier to add inlining support to more expressions.

llvm-svn: 157870
2012-06-02 00:40:52 +00:00
Anna Zaks bec49efdf2 [analyzer] Fix a spurious undef value warning.
When we timeout or exceed a max number of blocks within an inlined
function, we retry with no inlining starting from a node right before
the CallEnter node. We assume the state of that node is the state of the
program before we start evaluating the call. However, the node pruning
removes this node as unimportant. 

Teach the node pruning to keep the predecessors of the call enter nodes.

llvm-svn: 157860
2012-06-01 23:48:44 +00:00
Anna Zaks 1b37ea0a5f [analyzer] Fix lack of coverage after empty inlined function.
We should not stop exploring the path after we return from an empty
function.

llvm-svn: 157859
2012-06-01 23:48:40 +00:00
Ted Kremenek 5d6e7c3351 Disable diagnosic path pruning for ReturnUndefChecker.
llvm-svn: 157851
2012-06-01 23:04:04 +00:00
Ted Kremenek c3da376fbc static analyzer: add inlining support for directly called blocks.
llvm-svn: 157833
2012-06-01 20:04:04 +00:00
Kaelyn Uhrain ba896f17ae Don't allow multiple correction candidates that have the same identifier
but different nested name specifiers to quietly clobber each other so
only one remains if they do not refer to the same NamedDecl. Fixes
PR12951.

llvm-svn: 157823
2012-06-01 18:11:16 +00:00
Eric Christopher 31a1fc6654 Support C++11 enum forward declarations.
Part of rdar://11570854

llvm-svn: 157787
2012-06-01 00:22:57 +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
Aaron Ballman a0bc07262b Anonymous union members within a struct are now properly handled as an unevaluated field in C++11 mode. This fixes PR12866.
llvm-svn: 157784
2012-06-01 00:02:08 +00:00
Kaelyn Uhrain 34fab5598d In TypoCorrectionConsumer, BestResults to CorrectionResults to lessen
the confusion among all of the uses of Best* in relation to the set of
possible typo correction results. Also add a method to return the set of
typo corrections that have the single best edit distance--it returns the
second half of the first pair in TypoEditDistanceMap (with
getBestEditDistance already returning the first half).

llvm-svn: 157781
2012-05-31 23:32:58 +00:00
Fariborz Jahanian bebd0ba549 objc: properties of NSObject attribute must
have correct pointer type or issue error,
instead of crashing in IRGen. // rdar:// 11569860

llvm-svn: 157780
2012-05-31 23:18:32 +00:00
Tom Care 698daefb58 [analyzer] Fix BugType memory leak in IdempotentOperationChecker.
llvm-svn: 157772
2012-05-31 21:24:58 +00:00