Commit Graph

15575 Commits

Author SHA1 Message Date
Jordan Rose 92e1449b55 [analyzer] Track null/uninitialized C++ objects used in method calls.
llvm-svn: 161278
2012-08-03 23:08:49 +00:00
Jordan Rose 16fe35eb2b Enhance getImplicitObjectArgument to look through ->*.
This only applies in the case where ->* is not overloaded, since it
specifically looks for BinaryOperator and not CXXOperatorCallExpr.

llvm-svn: 161275
2012-08-03 23:08:39 +00:00
Jordan Rose 86bedb0de0 [analyzer] Add a test for copy-constructor inlining.
llvm-svn: 161274
2012-08-03 23:08:36 +00:00
Anna Zaks 150843b87e [analyzer] ObjC Inlining: Start tracking dynamic type info in the GDM
In the following code, find the type of the symbolic receiver by
following it and updating the dynamic type info in the state when we
cast the symbol from id to MyClass *.

  MyClass *a = [[self alloc] init];
  return 5/[a testSelf];

llvm-svn: 161264
2012-08-03 21:43:37 +00:00
Dmitri Gribenko 6430583017 Comment diagnostics: warn if \returns is used in a non-function comment or if
the function returns void.

llvm-svn: 161261
2012-08-03 21:15:32 +00:00
Richard Smith ed9430274e Fix crash if a literal operator template's template parameter pack is not a non-type template parameter pack. Patch by Andy Gibbs!
llvm-svn: 161260
2012-08-03 21:14:57 +00:00
Anna Zaks 52242a6677 [analyzer] Malloc: track non-allocated but freed memory
There is no reason why we should not track the memory which was not
allocated in the current function, but was freed there. This would
allow to catch more use-after-free and double free with no/limited IPA.

Also fix a realloc issue which surfaced as the result of this patch.

llvm-svn: 161248
2012-08-03 18:30:18 +00:00
Benjamin Kramer 4a9020839c Flesh out test for defaulted key functions a bit more.
llvm-svn: 161243
2012-08-03 15:43:22 +00:00
Benjamin Kramer 7555b54020 Reduce temp file pollution in some test cases.
llvm-svn: 161237
2012-08-03 10:35:06 +00:00
Benjamin Kramer 73d1be7c56 Fix failed to generate vtables in certain cases.
By C++ standard, the vtable should be generated if the first non-inline
virtual function is defined in the TU.  Current version of clang doesn't
generate vtable if the first virtual function is defaulted, because the
key function is regarded as the defaulted function.

Patch by Li Kan!

llvm-svn: 161236
2012-08-03 08:39:58 +00:00
Anna Zaks 4c03dfd4b1 [analyzer] Solve another source of non-determinism in the diagnostic
engine.

The code that was supposed to split the tie in a deterministic way is
not deterministic. Most likely one of the profile methods uses a
pointer. After this change we do finally get the consistent diagnostic
output. Testing this requires running the analyzer on large code bases
and diffing the results.

llvm-svn: 161224
2012-08-02 23:41:05 +00:00
Dmitri Gribenko baeb60e919 Comments: handle template paramter documentation in alias-declaration
templates.

llvm-svn: 161215
2012-08-02 21:36:57 +00:00
Jordan Rose 9a2eec3826 [analyzer] Add a simple check for initializing reference variables with null.
There's still more work to be done here; this doesn't catch reference
parameters or return values. But it's a step in the right direction.

Part of <rdar://problem/11212286>.

llvm-svn: 161214
2012-08-02 21:33:42 +00:00
Dmitri Gribenko 7f4b3773be Attaching comments to declarations: handle using-declaration.
llvm-svn: 161211
2012-08-02 20:49:51 +00:00
Fariborz Jahanian 9191865b2d objc-arc: Modify test for more prcecise fixit.
// rdar://11913153

llvm-svn: 161194
2012-08-02 18:38:41 +00:00
Fariborz Jahanian 9080491dbd objective-c arc: Patch to suggest bridge casting of CF
objects used as dictionary subscript objects.
// rdar://11913153

llvm-svn: 161187
2012-08-02 18:03:58 +00:00
Nuno Lopes c65c24b178 add a comment to explain this test case
llvm-svn: 161172
2012-08-02 12:12:26 +00:00
Hans Wennborg db7a78c211 test/Sema/tls.c: don't use -verify to check if TLS is supported
Use "%clang_cc1" vs "not %clang_cc1" instead.
Also use -fsyntax-only.

llvm-svn: 161165
2012-08-02 09:04:56 +00:00
Eli Friedman abab776039 Make sure we don't emit IR for unused EH cleanups. PR13359.
llvm-svn: 161148
2012-08-02 00:10:24 +00:00
Dmitri Gribenko 58e4131995 Comment to HTML conversion: correct typo in CSS class name: taram -> tparam
llvm-svn: 161145
2012-08-01 23:47:30 +00:00
Dmitri Gribenko b0ddb66a8d Comment diagnostics fixit tests: move exected-warning constructs from the
comment being tested.

llvm-svn: 161144
2012-08-01 23:29:52 +00:00
Dmitri Gribenko fae2e4ed0a Comment diagnostics: add tests for \tparam fixits.
llvm-svn: 161142
2012-08-01 23:27:13 +00:00
Eli Friedman 22be06a250 Fix an assertion failure instantiating a constexpr function from within a -dealloc method. PR13401.
llvm-svn: 161135
2012-08-01 21:02:59 +00:00
Hans Wennborg 1241731803 TLS is not supported on OpenBSD
This fixes PR13502 and adds a test to keep track of which
targets support TLS and which do not.

llvm-svn: 161124
2012-08-01 18:53:19 +00:00
Nuno Lopes 35b8c509c8 add test for PR13497
llvm-svn: 161119
2012-08-01 17:02:30 +00:00
Manuel Klimek 8c9a6bcae6 Fix typo.
llvm-svn: 161106
2012-08-01 08:48:27 +00:00
John McCall 13a39c6f54 When devirtualizing the conversion to a virtual base subobject,
don't explode if the offset we get is zero.  This can happen if
you have an empty virtual base class.

While I'm at it, remove an unnecessary block from the IR-generation
of the null-check, mark the eventual GEP as inbounds, and generally
prettify.

llvm-svn: 161100
2012-08-01 05:04:58 +00:00
Dmitri Gribenko 307cf89b19 Comment to HTML conversion: skip \tparam commands with whitespace paragraphs
llvm-svn: 161096
2012-08-01 00:48:00 +00:00
Dmitri Gribenko 7c0456f91b Comment to HTML conversion: escape HTML special characters in command arguments
llvm-svn: 161094
2012-08-01 00:21:12 +00:00
Aaron Ballman 899b9c6666 Explicitly defaulted constructors cannot be used for default initialization.
llvm-svn: 161088
2012-07-31 22:40:31 +00:00
Dmitri Gribenko 34df220410 Comment parsing: add support for \tparam command on all levels.
The only caveat is renumbering CXCommentKind enum for aesthetic reasons -- this
breaks libclang binary compatibility, but should not be a problem since API is
so new.

This also fixes PR13372 as a side-effect.

llvm-svn: 161087
2012-07-31 22:37:06 +00:00
Douglas Gregor f4cc61d525 When testing whether we can perform copy or move initialization, be
sure to supply an initialization location. Fixes <rdar://problem/11951661>.

llvm-svn: 161084
2012-07-31 22:15:04 +00:00
Rafael Espindola fb4263f156 Consider the visibility of template template arguments. GCC doesn't, but it also
fails to consider the linkage, which we were already considering.

llvm-svn: 161070
2012-07-31 19:02:02 +00:00
Jordan Rose a765bac7a1 [analyzer] Turn -cfg-add-initializers on by default, and remove the flag.
llvm-svn: 161060
2012-07-31 18:04:59 +00:00
Jordan Rose 6a97d92ef5 [analyzer] Don't try to inline if there's no region for a message receiver.
While usually we'd use a symbolic region rather than a straight-up Unknown,
we can still generate unknowns via array subscripts with symbolic indexes.
(And if this ever changes in the future, we still shouldn't crash.)

llvm-svn: 161059
2012-07-31 18:04:53 +00:00
Hans Wennborg 16250c7c18 -Wformat: better handling of qualifiers on pointer arguments
Warn about using pointers to const-qualified types as arguments to
scanf. Ignore the volatile qualifier when checking if types match.

llvm-svn: 161052
2012-07-31 16:37:47 +00:00
Jordan Rose e8a21b73ac [analyzer] Getting an lvalue for a reference field still requires a load.
This was causing a crash in our array-to-pointer logic, since the region
was clearly not an array.

PR13440 / <rdar://problem/11977113>

llvm-svn: 161051
2012-07-31 16:34:07 +00:00
Douglas Gregor 2d8db8fe7a Tweak code-completion heuristics deciding between a lambda
code-completion and an Objective-C message send, based on Jordan's
feedback.

llvm-svn: 161049
2012-07-31 15:27:48 +00:00
Manuel Klimek d627ec8a05 This test actually works on Win32...
llvm-svn: 161048
2012-07-31 14:45:10 +00:00
Manuel Klimek 3aad855a89 Fixes a segfault in Tooling when using pch's:
Clear the FileManager's stat cache in between running
translation units, as the stat cache loaded from a pch
is only valid for one compiler invocation.

llvm-svn: 161047
2012-07-31 13:56:54 +00:00
Jiangning Liu 5007bb6c0b Add two more .keep files to avoid the missing of empty folders in git repository.
llvm-svn: 161043
2012-07-31 10:52:55 +00:00
Jiangning Liu 43f37dca77 Add two .keep files to avoid the missing of empty folders in git repository.
llvm-svn: 161042
2012-07-31 10:24:27 +00:00
Jiangning Liu 61b06cbcb4 Support ARM hard float (arm-linux-gnueabihf).
llvm-svn: 161038
2012-07-31 08:06:29 +00:00
Sylvestre Ledru a5202660fb Fix some minor typos
llvm-svn: 161036
2012-07-31 06:56:50 +00:00
Rafael Espindola 06b2b4a7c9 Handle functions with struct arguments or return types and the regparm
attribute. It is a variation of the x86_64 ABI:

* A struct returned indirectly uses the first register argument to pass the
  pointer.
* Floats, Doubles and structs containing only one of them are not passed in
  registers.
* Other structs are split into registers if they fit on the remaining ones.
  Otherwise they are passed in memory.
* When a struct doesn't fit it still consumes the registers.

llvm-svn: 161022
2012-07-31 02:44:24 +00:00
Jordan Rose 3865c6e670 [analyzer] Add a test that messages to super invalidate ivars.
llvm-svn: 161021
2012-07-31 02:05:30 +00:00
Rafael Espindola 74ec5c03ca Attributes preceding a function declaration are first applied to the return
type and then propagated to the function. This was failing for destructors,
constructors and constructors templates since they don't have a return type.

Fix that by directly calling processTypeAttrs on the dummy type we use as the
return type in these cases.

llvm-svn: 161020
2012-07-31 01:54:04 +00:00
Aaron Ballman 1f10cc5eb4 No longer emitting a PCH file when using -fsyntax-only on a header file. Fixes PR13343.
llvm-svn: 161019
2012-07-31 01:21:00 +00:00
Douglas Gregor 721b14d1b3 When we encounter a code-completion token while parsing an ill-formed
lambda-introducer in Objective-C++11, fall back to treating the tokens
as an Objective-C message send to provide those (more likely)
completions. Fixes <rdar://problem/11980263>.

llvm-svn: 161015
2012-07-31 00:50:07 +00:00
John McCall ff755cda9c Don't crash *or* insert a bogus autorelease when emitting a
this-adjustment thunk in ARC++.

llvm-svn: 161014
2012-07-31 00:33:55 +00:00
Anna Zaks 5808eb8029 [analyzer] Handle inlining of instance calls to super.
Use self-init.m for testing. (It used to have a bunch of failing tests
with dynamic inlining turned on.)

llvm-svn: 161012
2012-07-30 23:48:36 +00:00
Anna Zaks 160dcdf2d6 [analyzer] Only run this test with no IPA
The inlinable portion of the test relies on attributes/instead of the
function implementation.

llvm-svn: 161011
2012-07-30 23:48:31 +00:00
Richard Smith 7f78227ce9 PR13479: If we see the definition of an out-of-line destructor in C++11, be
sure to update the exception specification on the declaration as well as the
definition. If we're building in -fno-exceptions mode, nothing else will
trigger it to be updated.

llvm-svn: 161008
2012-07-30 23:48:14 +00:00
Richard Smith 711ceba5ab Extend the ',' versus ';' diagnostic for -Wvexing-parse to cover the with-arguments case as well as the no-arguments case.
llvm-svn: 160999
2012-07-30 21:42:05 +00:00
Richard Smith 943c440455 Improvements to vexing-parse warnings. Make the no-parameters case more
accurate by asking the parser whether there was an ambiguity rather than trying
to reverse-engineer it from the DeclSpec. Make the with-parameters case have
better diagnostics by using semantic information to drive the warning,
improving the diagnostics and adding a fixit.

Patch by Nikola Smiljanic. Some minor changes by me to suppress diagnostics for
declarations of the form 'T (*x)(...)', which seem to have a very high false
positive rate, and to reduce indentation in 'warnAboutAmbiguousFunction'.

llvm-svn: 160998
2012-07-30 21:30:52 +00:00
Fariborz Jahanian b7f03c191c objective-c arc: ARC IRGen correctly assumes result
type of generated call to super dealloc is 'void'
and asserts if user's dealloc is not of 'void type.
This rule must be enforced in clang front-end (with a 
fixit) if this is not the case, instead of asserting in CodeGen.
// rdar://11987838

llvm-svn: 160993
2012-07-30 20:52:48 +00:00
Anna Zaks 63282aefb9 [analyzer] Very simple ObjC instance method inlining
- Retrieves the type of the object/receiver from the state.
- Binds self during stack setup.
- Only explores the path on which the method is inlined (no
bifurcation to explore the path on which the method is not inlined).

llvm-svn: 160991
2012-07-30 20:31:29 +00:00
Anna Zaks e49190984c [analyzer] Add -analyzer-ipa=dynamic option for inlining dynamically
dispatched methods.

Disabled by default for now.

llvm-svn: 160988
2012-07-30 20:31:18 +00:00
Matt Beaumont-Gay 5c8de784f6 Do not warn on correct use of the '%n' format specifier.
While '%n' can be used for evil in an attacker-controlled format string, there
isn't any acute danger in using it in a literal format string with an argument
of the appropriate type.

llvm-svn: 160984
2012-07-30 20:21:58 +00:00
Dmitri Gribenko 1ba47ca4b5 Comment parser: don't crash on a completely empty \param followed by a block
command

llvm-svn: 160975
2012-07-30 18:05:28 +00:00
Hans Wennborg ebcd1c7ca2 Make -Wformat check the argument type for %n.
This makes Clang check that the corresponding argument for "%n" in a
format string is a pointer to int.

llvm-svn: 160966
2012-07-30 17:11:32 +00:00
Benjamin Kramer 6d574fe155 Update source location in test.
llvm-svn: 160964
2012-07-30 16:51:34 +00:00
Benjamin Kramer e3895eb050 Use the location of the copy assignment when diagnosing classes that are nontrivial because of it.
llvm-svn: 160962
2012-07-30 16:41:40 +00:00
Benjamin Kramer bc7dd9ea02 Fix ambiguity detection in GetBestOverloadCandidateSimple.
When performing the simplistic overload resolution for single-argument methods,
don't check the best overload for ambiguity with itself when the best overload
doesn't happen to be the first one.

Fixes PR13480.

llvm-svn: 160961
2012-07-30 15:53:26 +00:00
Jiangning Liu eabbf92223 Fix dynamic object linker for ARM GNUEABIHF.
llvm-svn: 160958
2012-07-30 11:05:56 +00:00
David Chisnall 5f99f48bcd Provide correct linker command line options on FreeBSD 8 (GNU ld 2.15) and on newer FreeBSD (GNU ld 2.17).
Patch by Dimitry Andric!

llvm-svn: 160931
2012-07-29 15:24:44 +00:00
Richard Smith f86b0ae196 PR13433: In Microsoft mode, don't require function calls within decltype
expressions to have complete return types (or accessible destructors). If the
return type is required to be complete for some other reason (for instance, if
it is needed by overload resolution), then it will still be required to be
complete. This is apparently required in order to parse a MSVC11 header.

llvm-svn: 160924
2012-07-28 19:54:11 +00:00
Rafael Espindola a83aaa0da4 Add a missing testcase for merging the visibility of two declarations used
as arguments of a template.

llvm-svn: 160911
2012-07-28 02:51:03 +00:00
Fariborz Jahanian ae5bbfc0d0 objc-arc: change per Jordy's comments.
// rdar://11923822

llvm-svn: 160902
2012-07-27 23:55:46 +00:00
Fariborz Jahanian 36986c6e0f objective-c arc: When function calls with known CFCreate naming convention
are cast to retainable types, only suggest CFBridgingRelease/
CFBridgingRetain and not the __bridge casts.
// rdar://11923822

llvm-svn: 160900
2012-07-27 22:37:07 +00:00
Fariborz Jahanian 84c97cafd0 revert r160839 for now.
llvm-svn: 160895
2012-07-27 21:34:23 +00:00
Dmitri Gribenko 4586df765e Implement resolving of HTML character references (named: &amp;, decimal: &#42;,
hex: &#x1a;) during comment parsing.

Now internal representation of plain text in comment AST does not contain
character references, but the characters themselves.

llvm-svn: 160891
2012-07-27 20:37:06 +00:00
Hans Wennborg 08574d3559 Make -Wformat walk the typedef chain when looking for size_t, etc.
Clang's -Wformat fix-its currently suggest using "%zu" for values of
type size_t (in C99 or C++11 mode). However, for a type such as
std::vector<T>::size_type, it does not notice that type is actually
typedeffed to size_t, and instead suggests a format for the underlying
type, such as "%lu" or "%u".

This commit makes the format string fix mechanism walk the typedef chain
so that it notices if the type is size_t, even if that isn't "at the
top".

llvm-svn: 160886
2012-07-27 19:17:46 +00:00
Anna Zaks c77a3b1aab Consolidate ObjC lookupPrivateMethod methods from Sema and DeclObjC.
Also, fix a subtle bug, which occurred due to lookupPrivateMethod
defined in DeclObjC.h not looking up the method inside parent's
categories.

Note, the code assumes that Class's parent object has the same methods
as what's in the Root class of a the hierarchy, which is a heuristic
that might not hold for hierarchies which do not descend from NSObject.
Would be great to fix this in the future.

llvm-svn: 160885
2012-07-27 19:07:44 +00:00
Anna Zaks 8e3b260313 [analyzer] Another false positive in Class method inlining.
We are currently not setting the self object to the calling class object
during inlining nor do we reason about [AAA class].

llvm-svn: 160884
2012-07-27 19:07:34 +00:00
Anna Zaks 15b13a9f0c [analyzer] Address Jordan's and Fariborz's review of r160768.
llvm-svn: 160883
2012-07-27 19:07:32 +00:00
Dylan Noblesmith 673728fe57 Preprocessor: add __BYTE_ORDER__ predefined macro
The __BYTE_ORDER__ predefined macro was added in GCC 4.6:
http://gcc.gnu.org/onlinedocs/gcc-4.6.0/cpp/Common-Predefined-Macros.html

It's used like the following:

 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 ...
 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
 ...
 #else
 #error insane architecture like the pdp-11
 #endif

There's a similar macro, __FLOAT_WORD_ORDER__, but it looks like it
mainly exist to accommodate fairly obscure architectures and ARM's
old FPA instructions, so it doesn't seem nearly as useful.

The tests are updated to check for the correct(at least, based on
clang's current output) value of the macro on each target. So now the
suite will catch bugs like the one fixed in r157626.

llvm-svn: 160879
2012-07-27 18:34:31 +00:00
Dylan Noblesmith eaea2a884b test/Preprocessor: add NVPTX predefine tests
llvm-svn: 160866
2012-07-27 16:37:53 +00:00
Peter Collingbourne 6b4fdc25d3 Fix an assertion failure when code completing an auto variable's initialiser.
llvm-svn: 160857
2012-07-27 12:56:09 +00:00
Benjamin Kramer a2dcac1095 Fix PR13394: Erasing from a vector changes the end of the vector, so make sure we always have the right end.
llvm-svn: 160855
2012-07-27 10:21:08 +00:00
Richard Smith d3b5c90865 Final piece of core issue 1330: delay computing the exception specification of
a defaulted special member function until the exception specification is needed
(using the same criteria used for the delayed instantiation of exception
specifications for function temploids).

EST_Delayed is now EST_Unevaluated (using 1330's terminology), and, like
EST_Uninstantiated, carries a pointer to the FunctionDecl which will be used to
resolve the exception specification.

This is enabled for all C++ modes: it's a little faster in the case where the
exception specification isn't used, allows our C++11-in-C++98 extensions to
work, and is still correct for C++98, since in that mode the computation of the
exception specification can't fail.

The diagnostics here aren't great (in particular, we should include implicit
evaluation of exception specifications for defaulted special members in the
template instantiation backtraces), but they're not much worse than before.

Our approach to the problem of cycles between in-class initializers and the
exception specification for a defaulted default constructor is modified a
little by this change -- we now reject any odr-use of a defaulted default
constructor if that constructor uses an in-class initializer and the use is in
an in-class initialzer which is declared lexically earlier. This is a closer
approximation to the current draft solution in core issue 1351, but isn't an
exact match (but the current draft wording isn't reasonable, so that's to be
expected).

llvm-svn: 160847
2012-07-27 04:22:15 +00:00
Jordan Rose 41c98d9dc3 [analyzer] Look through SubstNonTypeTemplateParmExprs.
We were treating this like a CXXDefaultArgExpr, but
SubstNonTypeTemplateParmExpr actually appears when a template is
instantiated, i.e. we have all the information necessary to evaluate it.
This allows us to inline functions like llvm::array_lengthof.

<rdar://problem/11949235>

llvm-svn: 160846
2012-07-27 01:15:02 +00:00
Fariborz Jahanian 226459efff objc-arc: When objects with known CF semantics are assigned to
retainable types in arc, only suggest CFBridgingRelease/
CFBridgingRetain and not the confusing __bridge casts.
// rdar://11923822

llvm-svn: 160839
2012-07-26 23:17:04 +00:00
Ted Kremenek ecc928c89b Tweak test case to not emit warning.
llvm-svn: 160822
2012-07-26 22:32:35 +00:00
Ted Kremenek 313c2ff375 Look at the preceding CFGBlock for the expression to load from in ExprEngine::VisitGuardedExpr
instead of walking to the preceding PostStmt node.  There are cases where the last evaluated
expression does not appear in the ExplodedGraph.

Fixes PR 13466.

llvm-svn: 160819
2012-07-26 22:23:41 +00:00
Jordan Rose 25bc20f846 [analyzer] Don't crash on implicit statements inside initializers.
Our BugReporter knows how to deal with implicit statements: it looks in
the ParentMap until it finds a parent with a valid location. However, since
initializers are not in the body of a constructor, their sub-expressions are
not in the ParentMap. That was easy enough to fix in AnalysisDeclContext.

...and then even once THAT was fixed, there's still an extra funny case
of Objective-C object pointer fields under ARC, which are initialized with
a top-level ImplicitValueInitExpr. To catch these cases,
PathDiagnosticLocation will now fall back to the start of the current
function if it can't find any other valid SourceLocations. This isn't great,
but it's miles better than a crash.

(All of this is only relevant when constructors and destructors are being
inlined, i.e. under -cfg-add-initializers and -cfg-add-implicit-dtors.)

llvm-svn: 160810
2012-07-26 20:04:30 +00:00
Jordan Rose 20edae8749 [analyzer] Don't crash on array constructors and destructors.
This workaround is fairly lame: we simulate the first element's constructor
and destructor and rely on the region invalidation to "initialize" the rest
of the elements.

llvm-svn: 160809
2012-07-26 20:04:25 +00:00
Jordan Rose 54529a347e [analyzer] Handle C++ member initializers and destructors.
This uses CFG to tell if a constructor call is for a member, and uses
the member's region appropriately.

llvm-svn: 160808
2012-07-26 20:04:21 +00:00
Jordan Rose a4c0d21f42 [analyzer] Show paths for destructor calls.
This modifies BugReporter and friends to handle CallEnter and CallExitEnd
program points that came from implicit call CFG nodes (read: destructors).

This required some extra handling for nested implicit calls. For example,
the added multiple-inheritance test case has a call graph that looks like this:

testMultipleInheritance3
  ~MultipleInheritance
    ~SmartPointer
    ~Subclass
      ~SmartPointer
        ***bug here***

In this case we correctly notice that we started in an inlined function
when we reach the CallEnter program point for the second ~SmartPointer.
However, when we reach the next CallEnter (for ~Subclass), we were
accidentally re-using the inner ~SmartPointer call in the diagnostics.

Rather than guess if we saw the corresponding CallExitEnd based on the
contents of the active path, we now just ask the PathDiagnostic if there's
any known stack before popping off the top path.

(A similar issue could have occured without multiple inheritance, but there
wasn't a test case for it.)

llvm-svn: 160804
2012-07-26 20:04:05 +00:00
Jordan Rose c5d852447b [analyzer] Inline ctors + dtors when the CFG is built for them.
At the very least this means initializer nodes for constructors and
automatic object destructors are present in the CFG.

llvm-svn: 160803
2012-07-26 20:04:00 +00:00
Fariborz Jahanian a5fc75f4f5 objective-c parsing. Don't crash when selector name
is missing in method prototype. // rdar://11939584

llvm-svn: 160789
2012-07-26 17:32:28 +00:00
Timur Iskhodzhanov 3c80d5aa15 Remove an outdated comment; add one test to compare function pointer and block mangling
llvm-svn: 160783
2012-07-26 13:41:30 +00:00
Timur Iskhodzhanov a703956422 Add more tests for PR13207 (Mangling of template back references with -cxx-abi microsoft) now that PR13389 is fixed (mangling of return types)
llvm-svn: 160782
2012-07-26 11:01:05 +00:00
Timur Iskhodzhanov 25fabdbace Fix PR13389 (Wrong mangling of return type qualifiers with -cxx-abi microsoft)
llvm-svn: 160780
2012-07-26 10:41:15 +00:00
Alexander Kornienko cdc3987ca8 Removed standalone clang-ast-dump tool.
llvm-svn: 160772
2012-07-26 01:44:18 +00:00
Anna Zaks 83f1495fcb [analyzer] Inline ObjC class methods.
- Some cleanup(the TODOs) will be done after ObjC method inlining is
complete.
- Simplified CallEvent::getDefinition not to require ISDynamicDispatch
parameter.
- Also addressed Jordan's comments from r160530.

llvm-svn: 160768
2012-07-26 00:27:51 +00:00
Ted Kremenek faef9cb694 Add static analyzer check for calling a C++ instance method with a null/uninitialized pointer.
llvm-svn: 160767
2012-07-26 00:22:32 +00:00
Tanya Lattner 4bfc355094 Disable the warning for missing prototypes for OpenCL kernels. Includes testcase.
llvm-svn: 160766
2012-07-26 00:08:28 +00:00
Ted Kremenek bb81ffb342 Update ExprEngine's handling of ternary operators to find the ternary expression
value by scanning the path, rather than assuming we have visited the '?:' operator
as a terminator (which sets a value indicating which expression to grab the
final ternary expression value from).

llvm-svn: 160760
2012-07-25 21:58:25 +00:00
Ted Kremenek b1fcddfc6a Remove experimental invalid iterators checker from the codebase until we have the time
to fix all the issues.  Currently the code is essentially unmaintained and buggy, and
needs major revision (with coupled enhancements to the analyzer core).

llvm-svn: 160754
2012-07-25 20:02:05 +00:00
Chad Rosier ae7581dfd6 [driver crash diagnostics] Strip -internal-isystem and -internal-externc-isystem.
rdar://11949066

llvm-svn: 160752
2012-07-25 18:55:43 +00:00
Chad Rosier 7a42ff546a [driver crash diagnostics] Strip -idirafter, -iprefix, -iwithprefix,
-iwithprefixbefore, and -isystem options, per Matt's suggestion.
rdar://11949066

llvm-svn: 160750
2012-07-25 18:38:57 +00:00
Chad Rosier 959f0b3a07 [driver crash diagnostics] A few enhancements:
-Strip -iquote and -M options.
 -Quote -D options to avoid problems with command line macros that include
  parens.
rdar://11949066

llvm-svn: 160743
2012-07-25 17:52:16 +00:00
Dmitri Gribenko 6b375193a2 libclang comment to HTML rendering: \result is the same as \returns
llvm-svn: 160738
2012-07-25 17:14:58 +00:00
NAKAMURA Takumi 2538bf111e test/PCH/objc_stmts.m: Suppress stderr to be fed to FileCheck.
llvm-svn: 160720
2012-07-25 11:14:11 +00:00
NAKAMURA Takumi e1efe31948 test/Analysis/iterators.cpp: Mark as REQUIRES:asserts. It crashes due to assertion failure.
I saw the case it XPASSes.

llvm-svn: 160715
2012-07-25 09:47:24 +00:00
Ted Kremenek 875a402dc3 Turn -Wobjc-root-class on by default. <rdar://problem/11203649>.
llvm-svn: 160707
2012-07-25 07:26:32 +00:00
Ted Kremenek 2b619662ee Promote warn_unknown_analyzer_checker to an error. Addresses <rdar://problem/10987863>.
llvm-svn: 160706
2012-07-25 07:12:13 +00:00
Richard Smith 2589b9808e PR12057: Allow variadic template pack expansions to cross lambda boundaries.
Rather than adding a ContainsUnexpandedParameterPack bit to essentially every
AST node, we tunnel the bit directly up to the surrounding lambda expression
when we reach a context where an unexpanded pack can not normally appear.
Thus any statement or declaration within a lambda can now potentially contain
an unexpanded parameter pack.

llvm-svn: 160705
2012-07-25 03:56:55 +00:00
Dmitri Gribenko 3c54128715 Comment parsing tests: fix test
llvm-svn: 160700
2012-07-24 21:56:59 +00:00
Jordan Rose 68449acea4 Add __has_feature(attribute_availability_with_message).
This tests for the ability to include a "message" field in availability
attributes, like so:

  extern void ATSFontGetName(const char *oName)
    __attribute__((availability(macosx,introduced=8.0,deprecated=9.0,
                                message="use CTFontCopyFullName")));

This was actually supported in Clang 3.1, but we got a request for a
__has_feature so that header files can use this more safely. It's
unfortunate that the 3.1 release doesn't include this, however.

<rdar://problem/11886458>

llvm-svn: 160699
2012-07-24 21:55:34 +00:00
Dmitri Gribenko 5b8a1d4854 Comment diagnostics tests: add a function with zero arguments, for completeness.
llvm-svn: 160697
2012-07-24 21:46:24 +00:00
Dmitri Gribenko 8f0f1b0c41 Comment diagnostics: add warning for multiple \param commands with duplicate
parameter names.

llvm-svn: 160696
2012-07-24 21:44:16 +00:00
Richard Smith f676e45e5f When a && or || appears as the condition of a ?:, perform appropriate
short-circuiting when building the CFG. Also be sure to skip parens before
checking for the && / || special cases. Finally, fix some crashes in CFG
printing in the presence of calls to destructors for array of array of class
type.

llvm-svn: 160691
2012-07-24 21:02:14 +00:00
Richard Smith 7ac3c6af87 Pedantic -pedantic correction. Duplicate cv-qualifiers are permitted in C++11
unless they appear in a decl-specifier-seq.

llvm-svn: 160688
2012-07-24 20:24:58 +00:00
Rafael Espindola a8842b4884 Don't use a temporary file.
llvm-svn: 160686
2012-07-24 20:00:35 +00:00
Hans Wennborg 84ce606b91 Tweak warning text for returning incomplete type from extern "C" functions.
A warning was added in r150128 for returning non-C compatible
user-defined types from functions with C linkage.

This makes the text more clear for the case when the type isn't
decidedly non-C compatible, but incomplete.

llvm-svn: 160681
2012-07-24 17:59:41 +00:00
Timur Iskhodzhanov bf0f663bca Fix PR13207 (Mangling of templates with back references when using -cxx-abi microsoft)
llvm-svn: 160667
2012-07-24 09:37:54 +00:00
NAKAMURA Takumi 3c72621570 clang/test/CodeGenCXX/debug-info-globalinit.cpp: Fix for -Asserts.
llvm-svn: 160660
2012-07-24 02:03:39 +00:00
Nick Lewycky 085970736f Emit debug info for dynamic initializers. Permit __attribute__((nodebug)) on
variables that have static storage duration, it removes debug info on the
emitted initializer function but not all debug info about this variable.

llvm-svn: 160659
2012-07-24 01:40:49 +00:00
Richard Smith 45fbfc7f11 Do not warn about a function decl / direct init ambiguity if the function has a trailing return type.
llvm-svn: 160646
2012-07-23 21:41:30 +00:00
Dmitri Gribenko 378458d597 libclang comments AST: clang_ParamCommandComment_getParamName: don't assert
when a \param command does not have a parameter name, just return an empty
string instead.

llvm-svn: 160638
2012-07-23 19:41:49 +00:00
Dmitri Gribenko d73e4ce992 Comment AST: add InlineContentComment::RenderKind to specify a default
rendering mode for clients that don't want to interpret Doxygen commands.

Also add a libclang API to query this information.

llvm-svn: 160633
2012-07-23 16:43:01 +00:00
Timur Iskhodzhanov 49b52efab1 Follow-up: fix the quotes
llvm-svn: 160626
2012-07-23 09:43:03 +00:00
Timur Iskhodzhanov 284f98414b Replace wrong CHECK array mangling expectations with correct CHECK-NOT+FIXME (PR13182)
llvm-svn: 160625
2012-07-23 09:32:54 +00:00
Sylvestre Ledru 830885ca64 Fix a typo (the the => the)
llvm-svn: 160622
2012-07-23 08:59:39 +00:00
Richard Smith 87f5dc53b2 Add diagnostics for comma at end of enum and for extra semicolon at namespace
scope to -Wc++11-extensions. Move extra semicolon after member function
definition diagnostic out of -pedantic, since C++ allows a single semicolon
there. Keep it in -Wextra-semi, though, since it's still questionable.

llvm-svn: 160618
2012-07-23 05:45:25 +00:00
Douglas Gregor 6fa6942dda When we have an Objective-C object with non-trivial lifetime in a
structor class under ARC, that struct/class does not have a trivial
move constructor or move assignment operator. Fixes the rest of
<rdar://problem/11738725>.

llvm-svn: 160615
2012-07-23 04:23:39 +00:00
Richard Smith 505df2340a PR12917: Remove incorrect assumption that lambda mangling information cannot
change once it's been assigned. It can change in two ways:
 1) In a template instantiation, the context declaration should be the
    instantiated declaration, not the declaration in the template.
 2) If a lambda appears in the pattern of a variadic pack expansion, the
    mangling number will depend on the pack length.

llvm-svn: 160614
2012-07-22 23:45:10 +00:00
Francois Pichet f5b24e0136 Allow the parser to recover gracefully if a typename is used to introduce a decltype type.
In Microsoft mode, we emit a warning instead of an error.

This fixes a couple of errors when parsing the MSVC 11 RC headers with clang.

llvm-svn: 160613
2012-07-22 15:10:57 +00:00
Francois Pichet 0e2b84312f char16_t and char32_t are defined via typedef in MSVC 11 RC. So introduce a way to disable keywords under Microsoft mode.
llvm-svn: 160612
2012-07-22 11:32:41 +00:00
Dmitri Gribenko 4c6d7a2ed2 Comment to HTML conversion: add more CSS classes to identify function arguments
by index.  This is useful if the user does not document all arguments, and we
can't find a particular argument by index via :nth-of-type() CSS selector.

llvm-svn: 160595
2012-07-21 01:47:43 +00:00
Chad Rosier d3957e57f6 Rename -fms-inline-asm to -fenable-experimental-ms-inline-asm.
llvm-svn: 160590
2012-07-20 23:12:26 +00:00
Tim Northover eb752d43c9 Add "long double" to permitted list of ARM complex homogeneous aggregates.
Under AAPCS, long double is the same as double, which means it should be
allowed as part of a homogeneous aggregate.

llvm-svn: 160586
2012-07-20 22:29:29 +00:00
Dmitri Gribenko 5e4fe00e64 Add libclang APIs to walk comments ASTs and an API to convert a comment to an
HTML fragment.

For testing, c-index-test now has even more output:
* HTML rendering of a comment
* comment AST tree dump in S-expressions like Comment::dump(), but implemented
* with libclang APIs.

llvm-svn: 160577
2012-07-20 21:34:34 +00:00
Chad Rosier ed94324e70 Add a new flag, -fms-inline-asm, that enables the output of MS-style inline
assembly.  

By default, we don't emit IR for MS-style inline assembly (see r158833 as to 
why).  This is strictly for testing purposes and should not be enabled with the
expectation that things will work.  This is a temporary flag and will be removed
once MS-style inline assembly is fully supported.

llvm-svn: 160573
2012-07-20 21:20:33 +00:00
Aaron Ballman 9bca21ed25 No longer assuming the number of prototype arguments is always less than the number of formal parameters for a variadic function call.
llvm-svn: 160570
2012-07-20 20:40:35 +00:00
Dmitri Gribenko 66a00c765f Fix PR13411: Comment parsing: failed assertion on unterminated verbatim block.
The assertion was wrong in case we have a verbatim block without a closing
command.

Also add tests for closing command name in a verbatim block, since now it can
be empty in such cases.

llvm-svn: 160568
2012-07-20 20:18:53 +00:00
Jordan Rose 9dd82c1d94 Re-apply r160319 "Don't crash when emitting fixits following Unicode chars"
This time, make sure we don't try to print fixits with newline characters,
since they don't have a valid column width, and they don't look good anyway.

PR13417 (and originally <rdar://problem/11877454>)

llvm-svn: 160561
2012-07-20 18:50:51 +00:00
Eric Christopher ec21f68740 Don't need to specify the abi as it's the default.
rdar://11842763

llvm-svn: 160554
2012-07-20 17:42:31 +00:00
Fariborz Jahanian deb144ab51 Fixes an ObjC++ parse crash caused by delayed parsing
of c-functions nested in namespace in method implementations
by turning off its delayed parsing until a proper solution is 
figured out. pr13418

llvm-svn: 160552
2012-07-20 17:19:54 +00:00
Dmitri Gribenko 77369eead6 CommentBriefParser: use \returns if we can't find the \brief or just a plain
paragraph.

llvm-svn: 160550
2012-07-20 17:01:34 +00:00
Nico Weber cd8a546b6c Revert r160319, it caused PR13417. Add a test for PR13417.
llvm-svn: 160542
2012-07-20 06:44:52 +00:00
Nico Weber 9035951409 Let Expr::HasSideEffects() return false for NULL, bool literals, this, and nullptr.
Fixes PR13413, -Wunused-private-field now warns on unused fields initialized to NULL.

llvm-svn: 160541
2012-07-20 03:39:05 +00:00
Nico Weber 55a952bfcf Rename warn-unused-member.cpp to warn-unused-private-field.cpp to
make it match the flag it tests.

llvm-svn: 160536
2012-07-20 01:42:44 +00:00
Chandler Carruth 1649088ba1 Switch to the canonical pipe-based testing of clang output using
FileCheck.

This avoids copying files around needlessly during test runs.

llvm-svn: 160535
2012-07-20 00:49:53 +00:00
Chandler Carruth 1687e0ed35 Remove dos line endings. Please remember to configure your windows SVN
clients to default text files to 'eol-native'.

llvm-svn: 160534
2012-07-20 00:49:51 +00:00
Eric Christopher 4bbb3c459e FileCheck-ize.
llvm-svn: 160528
2012-07-19 22:22:58 +00:00
Eric Christopher 7457aaf8c9 Reset the layout of an ObjC class if we see an ivar in a category
or implementation since we've now got a different layout.

Fixes rdar://11842763

llvm-svn: 160526
2012-07-19 22:22:51 +00:00
Jordan Rose 3e0ec58c09 For varargs, diagnose passing ObjC objects by value like other non-POD types.
While we still want to consider this a hard error (non-POD variadic args are
normally a DefaultError warning), delaying the diagnostic allows us to give
better error messages, which also match the usual non-POD errors more closely.

In addition, this change improves the diagnostic messages for format string
argument type mismatches by passing down the type of the callee, so we can
say "variadic method" or "variadic function" appropriately.

<rdar://problem/11825593>

llvm-svn: 160517
2012-07-19 18:10:23 +00:00
Jordan Rose 96c49686b9 Capitalize "Objective-C" and "C++" in user-facing contexts.
No functionality change.

llvm-svn: 160516
2012-07-19 18:10:18 +00:00
Jordan Rose 58bbe4206f Don't crash checking a format string if one of the arguments is invalid.
Previously, we would ask for the SourceLocation of an argument even if
it were NULL (i.e. if Sema resulted in an ExprError trying to build it).

<rdar://problem/11890818>

llvm-svn: 160515
2012-07-19 18:10:08 +00:00
Argyrios Kyrtzidis ac4cdc8ef4 Add a test case for rdar://11806334.
Makes sure we don't overflow the stack.

llvm-svn: 160511
2012-07-19 16:08:28 +00:00
Bob Wilson 6a039161d7 Define __FINITE_MATH_ONLY__ based on -ffast-math and -ffinite-math-only.
This macro was being unconditionally set to zero, preceded by a FIXME comment.
This fixes <rdar://problem/11845441>.  Patch by Michael Gottesman!

llvm-svn: 160491
2012-07-19 03:52:53 +00:00
Aaron Ballman 24a1047c8c Relaxed enumeration constant naming rules for scoped enumerators so they no longer emit a diagnostic when the enumeration's name matches that of the class. Fixes PR13128.
llvm-svn: 160490
2012-07-19 03:12:23 +00:00
Bob Wilson 25d3bfd895 Force the OS X version to 10.6 for old-style simulator builds.
The hack of recognizing a -D__IPHONE_OS_VERSION_MIN_REQUIRED option
in place of -mios-simulator-version-min leaves the Darwin version
unspecified.  It can be set separately with -mmacosx-version-min (which
makes no sense) or inferred to match the host version (which is unpredictable
and usually wrong).  This really needs to get cleaned up, but in the
meantime, force the OS X version to 10.6 so that the behavior is sane for
the iOS simulator.  Thanks for Argyrios for the patch.
<rdar://problem/11858187>

llvm-svn: 160484
2012-07-19 01:35:55 +00:00
Dmitri Gribenko 7b2ca3e80b Fix ParagraphComment::isWhitespace(): a paragraph without a non-whitespace
TextComment node was considered whitespace even if it contained other child
nodes.

llvm-svn: 160474
2012-07-19 00:01:56 +00:00
Aaron Ballman 462bb9fdf6 Rolling this change back because the fix doesn't fit the symptoms (even if it solves them).
llvm-svn: 160462
2012-07-18 22:38:11 +00:00
Jordan Rose 627b046c88 [analyzer] Combine all ObjC message CallEvents into ObjCMethodCall.
As pointed out by Anna, we only differentiate between explicit message sends

This also adds support for ObjCSubscriptExprs, which are basically the same
as properties in many ways. We were already checking these, but not emitting
nice messages for them.

This depends on the llvm::PointerIntPair change in r160456.

llvm-svn: 160461
2012-07-18 21:59:51 +00:00
Aaron Ballman 68777ac253 Fixing up a test case that was failing due to the lack of -std=c++11
llvm-svn: 160455
2012-07-18 21:56:43 +00:00
Ted Kremenek 46dcfc9431 Fix crash in RegionStoreManager::evalDerivedToBase() due to not handling references
(in uses of dynamic_cast<>).

Fixes <rdar://problem/11817693>.

llvm-svn: 160427
2012-07-18 05:57:33 +00:00
Ted Kremenek 3d6177306b Teach CFG construction about destructors resulting from references to array types. Fixes crash in <rdar://problem/11671507>.
llvm-svn: 160424
2012-07-18 04:57:57 +00:00
Richard Smith af136f8191 PR13381, part 2: when determining if a defaulted special member function should
be defined as deleted, take cv-qualifiers on class members into account when
looking up the copy or move constructor or assignment operator which will be
used for them.

llvm-svn: 160418
2012-07-18 03:51:16 +00:00
Richard Smith 1c6461ef63 PR13381: consider cv-qualifiers on a class member's type when determining which
constructor will be used for moving that object, in the computation of its
exception specification.

llvm-svn: 160417
2012-07-18 03:36:00 +00:00
Richard Smith 198223b7e6 PR13386: When matching up parameters between a function template declaration
and a function template instantiation, if there's a parameter pack in the
declaration and one at the same place in the instantiation, don't assume that
the pack wasn't expanded -- it may have expanded to nothing. Instead, go ahead
and check whether the parameter pack was expandable. We can do this as a
side-effect of the work we'd need to do anyway, to find how many parameters
were produced.

llvm-svn: 160416
2012-07-18 01:29:05 +00:00
Eli Friedman ea90a40339 Fix test so it works the same way on 32-bit and 64-bit.
llvm-svn: 160415
2012-07-18 01:03:11 +00:00
Douglas Gregor a906ad2f9e When performing the deduced/actual argument type check for C++
[temp.deduct.call]p4 under Objective-C++ ARC, make sure to adjust the
qualifiers to introduce the implicit strong lifetime when
needed. Fixes <rdar://problem/11825671>.

llvm-svn: 160412
2012-07-18 00:14:59 +00:00
Douglas Gregor 951de307e4 Remove unnecessary spacing around Objective-C object literal code
completions. Fixes <rdar://problem/11889572>.

llvm-svn: 160407
2012-07-17 23:24:47 +00:00
Aaron Ballman 8f94ac6922 Adding a fixit for includes that cannot be found with angle brackets, but can be found with quoted strings instead. Implements PR13201.
llvm-svn: 160406
2012-07-17 23:19:16 +00:00
Eric Christopher 8b808c0c3d Robustify test in the face of no assertions.
llvm-svn: 160399
2012-07-17 21:52:07 +00:00
Eli Friedman 4eafb6b77b Don't treat overflow in floating-point conversions as a hard error in constant evaluation. <rdar://problem/11874571>.
llvm-svn: 160394
2012-07-17 21:03:05 +00:00
Rafael Espindola 60a2bba976 Handle the case where the base type is not dependent, but the derived one is.
Fixes pr13353.cpp.

llvm-svn: 160393
2012-07-17 20:24:05 +00:00
Eric Christopher 0cd70b84e2 Fix regexp for this test to properly check.
Patch by Eli Bendersky.

llvm-svn: 160385
2012-07-17 18:40:46 +00:00
Dmitri Gribenko 3e242d6d3c CommentBriefParser: make \short should equivalent to \brief, per Doxygen manual.
llvm-svn: 160383
2012-07-17 18:35:14 +00:00
Fariborz Jahanian 268fec1e2e Issue warning when assigning out-of-range integer values to enums.
Due to performance cost, this is an opt-in option placed
under -Wassign-enum. // rdar://11824807

llvm-svn: 160382
2012-07-17 18:00:08 +00:00
Jordan Rose 63ffaa8c18 -Wobjc-literal-compare: don't warn when comparing against nil.
Checks against nil often appear as guards in macros, and comparing
Objective-C literals to nil has well-defined behavior (if tautological).

On OS X, 'nil' has not been typed as 'id' since 10.6 (possibly earlier),
so the warning was already not firing, but other runtimes continue to use
((id)0) or some variant. This change accepts comparisons to any null pointer;
to keep it simple, it looks through all casts (not just casts to 'id').

PR13276

llvm-svn: 160379
2012-07-17 17:46:48 +00:00
Jordan Rose ea70bf7154 Add -Wobjc-string-compare under -Wobjc-literal-compare.
Suggested by Ted, since string literal comparison is at least slightly more
sensible than comparison of runtime literals. (Ambiguous language on
developer.apple.com implies that strings are guaranteed to be uniqued within
a translation unit and possibly across a linked binary.)

llvm-svn: 160378
2012-07-17 17:46:44 +00:00
Jordan Rose 7660f78fb9 Now that -Wobjc-literal-compare is a warning, put the fixit on a note.
Recovering as if the user had actually called -isEqual: is a bit too far from
the semantics of the program as written, /even though/ it's probably what they
intended.

llvm-svn: 160377
2012-07-17 17:46:40 +00:00
Rafael Espindola e3a14bb95b Merge visibility from previous decls before looking at visibility pragma. This
is a bit fuzzy, but matches gcc behavior and existing code bases seem to
depend on it.

llvm-svn: 160364
2012-07-17 15:14:47 +00:00
NAKAMURA Takumi 878f1445f9 test/Driver/crash-report.c: Remove "REQUIRES: shell". env(1) can be used also with gnuwin32.
llvm-svn: 160362
2012-07-17 12:00:24 +00:00
Simon Atanasyan 94a6d863a9 Revert commit r160308. We decide to move builtins selection to the backend.
llvm-svn: 160353
2012-07-17 08:15:06 +00:00
NAKAMURA Takumi ed5bbe9020 [Win32] Rework crash-report since r145389.
- lib/Driver/Driver.cpp, tools/driver/driver.cpp: Exit status should not be propagated, although clang driver should catch exceptions.
  - test/Driver/crash-report.c: Add REQUIRES:shell for now.
    FIXME: setenv should work also on Lit.InternalShellRunner.
  - test/Driver/crash-report.c: Remove XFAIL.

Thanks to Chad, To point out the issue.

llvm-svn: 160343
2012-07-17 05:09:29 +00:00
NAKAMURA Takumi 78c0295fcf test/Driver/crash-report.c: Small tweaks. 1) Use %t instead %T for TMP. 2) Set all of $TMPDIR, $TEMP and $TMP, or a certain host might set $TEMP.
llvm-svn: 160342
2012-07-17 05:09:20 +00:00
Rafael Espindola f97c636812 Record visibility pragmas when we see a tag declaration. We might use it
to build a type before seeing the definition.

llvm-svn: 160339
2012-07-17 04:22:25 +00:00
Richard Smith b21dd02e61 Uninitialized variables: two little changes:
* Treat compound assignment as a use, at Jordy's request.
 * Always add compound assignments into the CFG, so we can correctly diagnose the use in 'return x += 1;'

llvm-svn: 160334
2012-07-17 01:27:33 +00:00
NAKAMURA Takumi b7fa0d58fa clang/test/Tooling/clang-ast-dump.cpp: Mark it as REQUIRES: asserts, for now.
llvm-svn: 160332
2012-07-17 00:33:36 +00:00
Richard Smith 6376d1fd9c -Wuninitialized: Split the classification of DeclRefExprs as initialization or
use out of TransferFunctions, and compute it in advance rather than on-the-fly.

This allows us to handle compound assignments with DeclRefExprs on the RHS
correctly, and also makes it trivial to treat const& function parameters as not
initializing the argument. The patch also makes both of those changes.

llvm-svn: 160330
2012-07-17 00:06:14 +00:00
Jordan Rose 5089f3b398 [analyzer] Handle new-expressions with initializers for scalars.
<rdar://problem/11818967>

llvm-svn: 160328
2012-07-16 23:38:09 +00:00
Jordan Rose aa9f35a6b6 Weaken Unicode fixit test to work even if the character is printed escaped.
This should fix the failure on Windows.

llvm-svn: 160324
2012-07-16 22:18:33 +00:00
Ted Kremenek a0d18e51f9 This test appears to fail on win32.
llvm-svn: 160322
2012-07-16 21:43:16 +00:00
Ted Kremenek cf74cef104 This test appears to be passing on win32.
llvm-svn: 160320
2012-07-16 21:17:01 +00:00
Jordan Rose fb12a53d5d Don't crash when emitting fixits following Unicode characters.
This code is very sensitive to the difference between "columns" as printed
and "bytes" (SourceManager columns). All variables are now named explicitly
and our assumptions are (hopefully) documented as both comment and assertion.

Whether parseable fixits should use byte offsets or Unicode character counts
is pending discussion on the mailing list; currently the implementation uses
bytes (and has no problems on lines containing multibyte characters).
This has been added to the user manual.

<rdar://problem/11877454>

llvm-svn: 160319
2012-07-16 20:52:12 +00:00
Simon Atanasyan a06d06b660 MIPS: Implement __builtin_mips_shll_qb builtin function overloading.
This function has two versions. The first one is used for a register operand.
The second one is used for an immediate number.

llvm-svn: 160308
2012-07-16 18:52:02 +00:00
David Blaikie 5a0956e98d Fix rejects-valid: explicit specialization of redeclared deleted function template.
Review by Richard Smith.

llvm-svn: 160306
2012-07-16 18:50:45 +00:00
Alexander Kornienko 277f6cf805 Fixing an obvious bug in a test.
llvm-svn: 160268
2012-07-16 13:31:37 +00:00
Alexander Kornienko f2f82550fd The new clang-ast-dump tool for selective AST dumping. Moved common command-line tool stuff to CommandLineClangTool
llvm-svn: 160265
2012-07-16 12:46:48 +00:00
Daniel Jasper 3e1a9cf3b8 Add correct parenthesis range to CXXConstructExprs inside
CXXFunctionalCastExprs.

llvm-svn: 160252
2012-07-16 08:05:07 +00:00
Richard Smith 3beb930cfd More for PR11848: a pack expansion type isn't necessarily type-dependent (its
pattern might be an alias template which doesn't use its arguments). It's always
instantiation-dependent, though.

llvm-svn: 160246
2012-07-16 01:59:26 +00:00
Richard Smith 8093465a0b PR13365: Fix code which was trying to treat an array of DeducedTemplateArgument
as an array of its base class TemplateArgument. Switch the const
TemplateArgument* parameters of InstantiatingTemplate's constructors to
ArrayRef<TemplateArgument> to prevent this from happening again in the future.

llvm-svn: 160245
2012-07-16 01:09:10 +00:00
Richard Smith 68eea507fa Related to PR11848 and core-21989: switch ContainsUnexpandedParameterPack from
being a property of a canonical type to being a property of the fully-sugared
type. This should only make a difference in the case where an alias template
ignores one of its parameters, and that parameter is an unexpanded parameter
pack.

llvm-svn: 160244
2012-07-16 00:20:35 +00:00
Richard Smith 7dfc0240ea PR13368: Halve the instantiation depth of this test again. Apparently, FreeBSD
has a much lower default stack limit than the systems I have access to.

llvm-svn: 160240
2012-07-15 23:29:50 +00:00
David Chisnall d5ca836c01 Add test case for tweaks to clang driver.
llvm-svn: 160236
2012-07-15 21:18:01 +00:00
Rafael Espindola faf556b745 Without this patch clang warns on
struct __attribute__((visibility("hidden"))) zed {
};
struct __attribute__((visibility("hidden"))) zed;

Which is a bit silly and got a lot noisier now that we correctly handle
visibility pragmas. This patch fixes that and also has some extra quality
improvements:

* We now produce an error instead of a warning for

struct __attribute__((visibility("hidden"))) zed {
};
struct __attribute__((visibility("default"))) zed;

* The "after definition" warning now points to the new attribute that is
  ignored instead of pointing to the declaration.

llvm-svn: 160227
2012-07-15 01:33:40 +00:00
Eric Christopher 11d08bd931 Use llvm::APSInt::isSameValue to compare for the same value.
Finishes rdar://11875995

llvm-svn: 160225
2012-07-15 00:24:00 +00:00
Ted Kremenek b50e716bac Refine CFG so that '&&' and '||' don't lead to extra confluence points when used in a branch, but
instead push the terminator for the branch down into the basic blocks of the subexpressions of '&&' and '||'
respectively.  This eliminates some artifical control-flow from the CFG and results in a more
compact CFG.

Note that this patch only alters the branches 'while', 'if' and 'for'.  This was complex enough for
one patch.  The remaining branches (e.g., do...while) can be handled in a separate patch, but they
weren't immediately tackled because they were less important.

It is possible that this patch introduces some subtle bugs, particularly w.r.t. to destructor placement.
I've tried to audit these changes, but it is also known that the destructor logic needs some refinement
in the area of '||' and '&&' regardless (i.e., their are known bugs).

llvm-svn: 160218
2012-07-14 05:04:10 +00:00
Chad Rosier cc40ea7f9a Add a per target max vector alignment field (e.g., 32-byte alignment for x86 due to
AVX).  Currently, if no aligned attribute is specified the alignment of a vector is
inferred from its size.  Thus, very large vectors will be over-aligned with no 
benefit.  Target owners should set this target max.

llvm-svn: 160209
2012-07-13 23:57:43 +00:00
Richard Smith 130b8d4e97 PR13360: When deciding the earliest point which inevitably leads to an
uninitialized variable use, walk back over branches where we've reached all the
non-null successors, not just cases where we've reached all successors.

llvm-svn: 160206
2012-07-13 23:33:44 +00:00
Nuno Lopes e61e9dbf73 add support for conditional expressions in Expr::HasSideEffects()
This fixes a bug in __builtin_object_size() codegen

llvm-svn: 160191
2012-07-13 20:48:52 +00:00
Tanya Lattner 72db6d04e1 Move a bunch of the attribute warnings under the IgnoreAttributes group. Cleaned up test case.
llvm-svn: 160190
2012-07-13 20:45:35 +00:00
Rafael Espindola 385c04269f Apply visibility pragmas to class template declarations. This is needed because
we might use the declaration to build a type before seeing the definition.

llvm-svn: 160176
2012-07-13 18:04:45 +00:00
Rafael Espindola c7c7ad5f7e Use -fvisibility-inlines-hidden in inline functions too. This matches gcc
behavior since gcc pr30066. Thanks to Benjamin Kramer for pointing it out.

llvm-svn: 160174
2012-07-13 14:25:36 +00:00
Richard Smith 57e7ff9c0c Provide a special-case diagnostic when two class member functions instantiate
to the same signature. Fix a bug in the type printer which would cause this
diagnostic to print wonderful types like 'const const int *'.

llvm-svn: 160161
2012-07-13 04:12:04 +00:00
Rafael Espindola eca5cd20a1 Fix a bug in my previous commit. The problem is not that we were not using the
canonical decl for the template, but that we were not merging attributes for
templates at all!

llvm-svn: 160157
2012-07-13 01:19:08 +00:00
Dmitri Gribenko e7bb944c85 Attaching comments to declarations during parsing: handle more Objective-C declarations.
llvm-svn: 160156
2012-07-13 01:06:46 +00:00
Dmitri Gribenko e00ffc7bb8 Comment parsing: repaint the bikesched: rename 'HTML open tags' to 'HTML start tags' and 'HTML close tags' to 'HTML end tags' according to HTML spec.
llvm-svn: 160153
2012-07-13 00:44:24 +00:00
Dmitri Gribenko 9460fbf219 Make concepts of optional and forbidden end tags separate. Thanks Jordan for pointing this!
llvm-svn: 160149
2012-07-12 23:37:09 +00:00
Rafael Espindola 6140847647 Use the canonical template decl when trying to find if it has a visibility
attribute.

llvm-svn: 160139
2012-07-12 20:05:04 +00:00
Timur Iskhodzhanov 3f7e9d2b45 [Windows] Split the back reference tests into two separate files as the templates are getting hairy
llvm-svn: 160131
2012-07-12 14:33:58 +00:00
NAKAMURA Takumi ff4cd7792a test/CodeGen/rdrand-builtins.c: Define __MM_MALLOC_H before including <*mmintrin.h> .
Rawr!

llvm-svn: 160125
2012-07-12 10:36:27 +00:00
Benjamin Kramer 72ec3756f9 Don't include mm_malloc.h in test, it pulls in system headers on msvc.
llvm-svn: 160122
2012-07-12 09:56:18 +00:00
Timur Iskhodzhanov c5098ad371 [Windows] Use thiscall as the default calling convention for class methods. PR12785
llvm-svn: 160121
2012-07-12 09:50:54 +00:00
Benjamin Kramer a43b6999ff Add _rdrand{16,32,64}_step intrinsics to immintrin.h
llvm-svn: 160118
2012-07-12 09:33:03 +00:00
Benjamin Kramer 20863e3692 Be lax about trailing whitespace when checking fixit formatting, this depends on locale settings.
If a non-unicode locale is used, the unicode character is escaped and any
byte that is in the escaped representation but not the semicolon will
become whitespace.

llvm-svn: 160113
2012-07-12 08:34:31 +00:00
Benjamin Kramer 29f90e804d PR13312: Don't crash when printing a fixit that ends in a unicode character.
llvm-svn: 160112
2012-07-12 08:20:49 +00:00
Rafael Espindola 4dedd0ceb8 Process #pragma visibility early in the parsing of class definitions. Fixes
pr13338.

llvm-svn: 160105
2012-07-12 04:47:34 +00:00
Rafael Espindola 06e1b13209 Ignore visibility attributes after definitions. This matches newer (4.7) gcc's
behavior and is the first step in fixing pr13338.

llvm-svn: 160104
2012-07-12 04:32:30 +00:00
John McCall 775086e67c Add the ObjFW runtime. Patch by Jonathan Schleifer!
llvm-svn: 160102
2012-07-12 02:07:58 +00:00
Jordan Rose d66bee3f76 [analyzer] Don't inline virtual calls unless we can devirtualize properly.
Previously we were using the static type of the base object to inline
methods, whether virtual or non-virtual. Now, we try to see if the base
object has a known type, and if so ask for its implementation of the method.

llvm-svn: 160094
2012-07-12 00:16:25 +00:00
Tanya Lattner 7445ada9c8 Add OpenCL metadata for kernel arg names. This output is controlled via a flag as noted in the OpenCL Spec.
Includes a test case.

llvm-svn: 160092
2012-07-11 23:02:10 +00:00
Nico Weber 1325384b32 Don't try to do RVO on block variables that refer to an enclosing local.
Fixes PR13314, clang crashing on blocks refering to an enclosing local
when the enclosing function returns void.

llvm-svn: 160089
2012-07-11 22:50:15 +00:00
Richard Smith ded9c2ee92 Stop instantiating a class if we hit a static_assert failure. Also, if the
static_assert fails when parsing the template, don't diagnose it again on every
instantiation.

llvm-svn: 160088
2012-07-11 22:37:56 +00:00
Dmitri Gribenko f26054f0fb Enable comment parsing and semantic analysis to emit diagnostics. A few
diagnostics implemented -- see testcases.

I created a new TableGen file for comment diagnostics,
DiagnosticCommentKinds.td, because comment diagnostics don't logically
fit into AST diagnostics file.  But I don't feel strongly about it.

This also implements support for self-closing HTML tags in comment
lexer and parser (for example, <br />).

In order to issue precise diagnostics CommentSema needs to know the
declaration the comment is attached to.  There is no easy way to find a decl by 
comment, so we match comments and decls in lockstep: after parsing one
declgroup we check if we have any new, not yet attached comments.  If we do --
then we do the usual comment-finding process.

It is interesting that this automatically handles trailing comments.
We pick up not only comments that precede the declaration, but also
comments that *follow* the declaration -- thanks to the lookahead in
the lexer: after parsing the declgroup we've consumed the semicolon
and looked ahead through comments.

Added -Wdocumentation-html flag for semantic HTML errors to allow the user to 
disable only HTML warnings (but not HTML parse errors, which we emit as
warnings in -Wdocumentation).

llvm-svn: 160078
2012-07-11 21:38:39 +00:00
Jordan Rose 1fa2acaed4 Start testing some commented-out cases of badly-formed __has_include.
Filed PR13334 for the cases that cause the compiler to crash, and
PR13335 for the cases where we should be recovering more gracefully.

llvm-svn: 160070
2012-07-11 20:12:19 +00:00
Jordan Rose b13eb8dca5 Allow -verify directives to be filtered by preprocessing.
This is accomplished by making VerifyDiagnosticsConsumer a CommentHandler,
which then only reads the -verify directives that are actually in live
blocks of code. It also makes it simpler to handle -verify directives that
appear in header files, though we still have to manually reparse some files
depending on how they are generated.

This requires some test changes. In particular, all PCH tests now have their
-verify directives outside the "header" portion of the file, using the @line
syntax added in r159978. Other tests have been modified mostly to make it
clear what is being tested, and to prevent polluting the expected output with
the directives themselves.

Patch by Andy Gibbs! (with slight modifications)

The new Frontend/verify-* tests exercise the functionality of this commit,
as well as r159978, r159979, and r160053 (Andy's other -verify enhancements).

llvm-svn: 160068
2012-07-11 19:58:23 +00:00
Rafael Espindola 1fa9fade38 Handle #pragma visibility in explicit specializations and enums.
llvm-svn: 160057
2012-07-11 18:14:09 +00:00
Justin Holewinski 5fafdd9d1d Fix handling of curly braces in NVPTX inline asm
Fixes bug 13322

Patch by Dmitry Mikushin

llvm-svn: 160050
2012-07-11 15:34:55 +00:00
Eric Christopher f8b9809fab Temporarily revert this to see if it brings the gdb bot back.
llvm-svn: 160049
2012-07-11 15:32:13 +00:00
NAKAMURA Takumi b59973e6cd clang/test/Misc/diag-template-diffing-color.cpp: Introduce the feature 'ansi-escape-sequences'.
llvm-svn: 160043
2012-07-11 11:44:00 +00:00
Rafael Espindola 5f0a1b89d7 Don't process #pragma visibility during instantiation. The visibility of the
instantiation depends on the template, its arguments and parameters, but not
where it is instantiated.

llvm-svn: 160034
2012-07-11 02:15:51 +00:00
Eric Christopher 2977378974 The end of a block doesn't necessarily need a line table entry unless
there's something going on there. Remove the unconditional line entry
and only add one if we're emitting cleanups (any other statements
would be handled normally).

Fixes rdar://9199234

llvm-svn: 160033
2012-07-11 01:49:26 +00:00
Eric Christopher 296a710b5b FileCheck-ize.
llvm-svn: 160032
2012-07-11 01:49:24 +00:00
Jordan Rose 6cd16c5152 [analyzer] Guard against C++ member functions that look like system functions.
C++ method calls and C function calls both appear as CallExprs in the AST.
This was causing crashes for an object that had a 'free' method.

<rdar://problem/11822244>

llvm-svn: 160029
2012-07-10 23:13:01 +00:00
Richard Smith 9fce7bc721 Fix crash when constant-evaluating a CXXConstructExpr representing
value-initialization for an array of class type with a trivial default
constructor.

llvm-svn: 160024
2012-07-10 22:12:55 +00:00
Jordan Rose d1d54aa131 [analyzer] Use CallEvent for building inlined stack frames.
In order to accomplish this, we now build the callee's stack frame
as part of the CallEnter node, rather than the subsequent BlockEdge node.
This should not have any effect on perceived behavior or diagnostics.

This makes it safe to re-enable inlining of member overloaded operators.

llvm-svn: 160022
2012-07-10 22:07:57 +00:00
DeLesley Hutchins 868830f727 Thread safety analysis: impove handling of trylock expressions.
llvm-svn: 160018
2012-07-10 21:47:55 +00:00
Arnaud A. de Grandmaison 617f5269c3 Adds support for auto-detection of compilation databases, looking in a directory and all its parents.
llvm-svn: 159998
2012-07-10 16:56:35 +00:00
Manuel Klimek a9c86c980b Fixes the MSVC build.
llvm-svn: 159992
2012-07-10 14:21:30 +00:00
Manuel Klimek 65fd0e1fd3 Adds support for auto-detection of compilation databases
from a source file and changes clang-check to make use of this.

This makes clang-check just work on in-tree builds, and allows
easy setup via a symlink per source directory to make clang-check
work without any extra configuration.

llvm-svn: 159990
2012-07-10 13:10:51 +00:00
Tanya Lattner 724eaea271 TEMPORARY. I will fix this properly shortly.
Silence buildbot so I can figure out the right flag to put this warning under.

llvm-svn: 159967
2012-07-09 23:01:07 +00:00
Tanya Lattner bcffcdfd18 Patch by Anton Lokhmotov to add OpenCL work group size attributes.
llvm-svn: 159965
2012-07-09 22:06:01 +00:00