Commit Graph

17529 Commits

Author SHA1 Message Date
Chad Rosier e348d2724a Typo.
llvm-svn: 174995
2013-02-12 19:15:05 +00:00
Chad Rosier e90add40a9 [ms-inline asm] Add a few test cases for the parsing of hexidecimal integers.
llvm-svn: 174989
2013-02-12 18:45:21 +00:00
Dmitri Gribenko d1c91f1763 Accept over-qualified constructor in MSVC emulation mode
MSVC accepts this:

class A {
  A::A();
};

Clang accepts regular member functions with extra qualification as an MS
extension, but not constructors.  This changes the parser to defer rejecting
qualified constructors so that the same Sema logic can apply to constructors as
regular member functions.  This also improves the error message when MS
extensions are disabled (in my opinion). Before it was:

/Users/jason/Desktop/test.cpp:2:8: error: expected member name or ';' after declaration specifiers
  A::A();
  ~~~~ ^
1 error generated.

After:

/Users/jason/Desktop/test.cpp:2:6: error: extra qualification on member 'A'
  A::A();
  ~~~^
1 error generated.

Patch by Jason Haslam.

llvm-svn: 174980
2013-02-12 17:27:41 +00:00
Timur Iskhodzhanov 584248cf3c Rename -constructors test to just -structors as in fact it tests dtors too. Also, fix a minor typo in the test.
llvm-svn: 174966
2013-02-12 13:22:47 +00:00
Nick Lewycky 94477cb084 Attempt to fix this test on i686 targets.
llvm-svn: 174953
2013-02-12 08:59:01 +00:00
Nick Lewycky a096b14d1d The meat of this patch is in BuildCXXMemberCalLExpr where we make it use
MarkMemberReferenced instead of marking functions referenced directly. An audit
of callers to MarkFunctionReferenced and DiagnoseUseOfDecl also caused a few
other changes:
 * don't mark functions odr-used when considering them for an initialization
   sequence. Do mark them referenced though.
 * the function nominated by the cleanup attribute should be diagnosed.
 * operator new/delete should be diagnosed when building a 'new' expression.

llvm-svn: 174951
2013-02-12 08:08:54 +00:00
John McCall 3d1e2c960d Properly assemble PHIs after a null-checked invoke of objc_msgSend.
rdar://12046763

llvm-svn: 174946
2013-02-12 05:53:35 +00:00
Richard Smith 8858159fb5 Fix a bug reduced from a crash when trying to use modules with libc++. We check
the linkage of functions and variables while merging declarations from modules,
and we don't necessarily have enough of the rest of the AST loaded at that
point to allow us to compute linkage, so serialize it instead.

llvm-svn: 174943
2013-02-12 05:48:23 +00:00
John McCall e142ad50f1 Call __cxa_begin_catch with the current exception before
calling std::terminate().  rdar://11904428

llvm-svn: 174940
2013-02-12 03:51:46 +00:00
Richard Smith a00399c949 Remove an assert which triggers when a decl context in a module hits the 'has
lexical storage but not visible storage' case in C++. It's unclear whether we
even need the special-case handling for C++, since it seems to be working
around our not serializing a lookup table for the TU in C. But in any case,
the assertion is incorrect.

llvm-svn: 174931
2013-02-12 02:32:35 +00:00
John McCall 587b348504 Perform placeholder conversions on the controller of a _Generic
expression.

llvm-svn: 174930
2013-02-12 02:08:12 +00:00
John McCall 6ced97aaae Diagnose loads of 'half' l-values in OpenCL.
Patch by Joey Gouly!

llvm-svn: 174928
2013-02-12 01:29:43 +00:00
Lang Hames 697b004219 Backing out r174919 while I investigate a self-host bug on Takumi's builder.
llvm-svn: 174925
2013-02-12 00:44:43 +00:00
John McCall d21cdd4947 In ARC, emit non-peepholed +1s within the full-expression instead
of immediately afterwards.

llvm-svn: 174922
2013-02-12 00:25:08 +00:00
John McCall 8e24e861be Split a couple of tests out into their own file.
llvm-svn: 174921
2013-02-12 00:25:02 +00:00
Lang Hames 5824a4f1b0 When generating IR for default copy-constructors, copy-assignment operators,
move-constructors and move-assignment operators, use memcpy to copy adjacent
POD members.

Previously, classes with one or more Non-POD members would fall back on
element-wise copies for all members, including POD members. This often
generated a lot of IR. Without padding metadata, it wasn't often possible
for the LLVM optimizers to turn the element-wise copies into a memcpy.

This code hasn't yet received any serious tuning. I didn't see any serious
regressions on a self-hosted clang build, or any of the nightly tests, but
I think it's important to get this out in the wild to get more testing.
Insights, feedback and comments welcome.

Many thanks to David Blaikie, Richard Smith, and especially John McCall for
their help and feedback on this work.

llvm-svn: 174919
2013-02-11 23:44:11 +00:00
Fariborz Jahanian b0fdab26d1 objective-C modern translator: Fixes a mistranslation
of @throw statement by finding location of the ';'
correctly. // rdar://13186010

llvm-svn: 174898
2013-02-11 19:30:33 +00:00
Douglas Gregor dcf2508791 [Modules] Cope better with top-level declarations loaded after being declared in the current translation unit <rdar://problem/13189985>.
These two related tweaks to keep the information associated with a
given identifier correct when the identifier has been given some
top-level information (say, a top-level declaration) and more
information is then loaded from a module. The first ensures that an
identifier that was "interesting" before being loaded from an AST is
considered to be different from its on-disk counterpart. Otherwise, we
lose such changes when writing the current translation unit as a
module.

Second, teach the code that injects AST-loaded names into the
identifier chain for name lookup to keep the most recent declaration,
so that we don't end up confusing our declaration chains by having a
different declaration in there.

llvm-svn: 174895
2013-02-11 18:16:18 +00:00
Bill Wendling 832d3c2fac Update test to not fail with attribute groups.
llvm-svn: 174866
2013-02-11 08:35:52 +00:00
Bob Wilson 2616e2ec85 Use -mno-implicit-float by default for kernel/kext code. <rdar://13177960>
Apple's kernel engineers have been expecting this behavior even though
we've never implemented it before, as far as I can tell. In recent months,
clang has gotten better at using vector instructions to optimize memcpy-like
operations, and that has exposed problems when vector/floating-point
instructions are used in kexts that don't support that. This behavior also
matches what Apple's GCC did for PowerPC targets.

llvm-svn: 174838
2013-02-10 16:01:41 +00:00
Bob Wilson 2cc9690f5e Recognize -mno-implicit-float option for x86 as well as ARM. <rdar://13180731>
For x86 targets, we've been using the -msoft-float option to control passing
the no-implicit-float option to cc1. Since the -mno-implicit-float option is
now accepted by the driver, this just makes it work for x86 the same as it
does for ARM targets.

llvm-svn: 174836
2013-02-10 15:25:44 +00:00
Fariborz Jahanian 234c00d6d0 objective-C: Fixes a bogus warning due to not setting
the "nonatomic" attribute in property redeclaration
in class extension. Also, improved on diagnostics in
this area while at it. // rdar://13156292

llvm-svn: 174821
2013-02-10 00:16:04 +00:00
Dmitri Gribenko 4b8a84fdca FileCheck'ize tests
llvm-svn: 174815
2013-02-09 16:41:47 +00:00
Dmitri Gribenko f37d0cd780 FileCheck'ize a test
llvm-svn: 174814
2013-02-09 16:25:38 +00:00
Ted Kremenek 7ee25676a5 QoI: -Wreadonly-iboutlet-property should have the warning's location on the property.
There's no need to refer to the @implementation at all.

Fixes <rdar://problem/13186515>

llvm-svn: 174802
2013-02-09 07:13:16 +00:00
Douglas Gregor 7dab26b87c Ensure that type definitions present in just-loaded modules are
visible.

The basic problem here is that a given translation unit can use
forward declarations to form pointers to a given type, say,

  class X;
  X *x;

and then import a module that includes a definition of X:

  import XDef;

We will then fail when attempting to access a member of X, e.g., 

  x->method()

because the AST reader did not know to look for a default of a class
named X within the new module.

This implementation is a bit of a C-centric hack, because the only
definitions that can have this property are enums, structs, unions,
Objective-C classes, and Objective-C protocols, and all of those are
either visible at the top-level or can't be defined later. Hence, we
can use the out-of-date-ness of the name and the identifier-update
mechanism to force the update.

In C++, we will not be so lucky, and will need a more advanced
solution, because the definitions could be in namespaces defined in
two different modules, e.g.,

  // module 1
  namespace N { struct X; }

  // module 2
  namespace N { struct X { /* ... */ }; }

One possible implementation here is for C++ to extend the information
associated with each identifier table to include the declaration IDs
of any definitions associated with that name, regardless of
context. We would have to eagerly load those definitions.

llvm-svn: 174794
2013-02-09 01:35:03 +00:00
Jordan Rose 58c61e006f Properly validate UCNs for C99 and C++03 (both more restrictive than C(++)11).
Add warnings under -Wc++11-compat, -Wc++98-compat, and -Wc99-compat when a
particular UCN is incompatible with a different standard, and -Wunicode when
a UCN refers to a surrogate character in C++03.

llvm-svn: 174788
2013-02-09 01:10:25 +00:00
Anna Zaks 7811c3efd5 [analyzer] Invalidation checker: move the "missing implementation" check
The missing definition check should be in the same category as the
missing ivar validation - in this case, the intent is to invalidate in
the given class, as described in the declaration, but the implementation
does not perform the invalidation. Whereas the MissingInvalidationMethod
checker checks the cases where the method intention is not to
invalidate. The second checker has potential to have a much higher false
positive rate.

llvm-svn: 174787
2013-02-09 01:09:27 +00:00
Anna Zaks 91a5fdf83a [analyzer] Split IvarInvalidation into two checkers
Separate the checking for the missing invalidation methods into a
separate checker so that it can be turned on/off independently.

llvm-svn: 174781
2013-02-08 23:55:47 +00:00
Anna Zaks a5096f6f51 [analyzer] IvarInvalidation: add annotation for partial invalidation
The new annotation allows having methods that only partially invalidate
IVars and might not be called from the invalidation methods directly
(instead, are guaranteed to be called before the invalidation occurs).
The checker is going to trust the programmer to call the partial
invalidation method before the invalidator.This is common in cases when
partial object tear down happens before the death of the object.

llvm-svn: 174779
2013-02-08 23:55:43 +00:00
Fariborz Jahanian f3c171ebec objective-C: don't issue bogus warning about
"auto-synthesized may not work correctly with 'nib' loader"
when 'readonly' property is redeclared 'readwrite' in class
extension. // rdar://13123861

llvm-svn: 174775
2013-02-08 23:32:30 +00:00
Jordan Rose a08ed5965c Simplify logic for avoiding concatenation after numeric constants.
I threw in a couple of test cases for UD-suffixes -- already working, but
it wasn't immediately obvious to me.

llvm-svn: 174767
2013-02-08 22:30:31 +00:00
Jordan Rose 00d1b59184 StmtPrinter: Write large char values using \u or \U.
This may not always be valid, but we were previously just
emitting them raw.

While here, s/isprint/isPrintable/ (using the new CharInfo).

llvm-svn: 174766
2013-02-08 22:30:27 +00:00
Ted Kremenek ca3ed7230d Teach BugReporter (extensive diagnostics) to emit a diagnostic when a loop body is skipped.
Fixes <rdar://problem/12322528>.

llvm-svn: 174736
2013-02-08 19:51:43 +00:00
Argyrios Kyrtzidis ba91ab65aa [libclang] Add a test to make sure annotation works fine in the presence of
'override' on the method.

This was fixed in a previous commit, generally handling attributes that are at the
end of the declaration.

rdar://13140589

llvm-svn: 174734
2013-02-08 19:27:23 +00:00
Fariborz Jahanian 4254cdb7ed objective-C modern translation: Fix another random translation bug
involving property getter expressions on rhs of property setter.
// rdar://13138459

llvm-svn: 174729
2013-02-08 18:57:50 +00:00
Fariborz Jahanian e8730a3558 objective-C modern translator. Fixes a trivial
rewriting bug where #ifdef ended up on the same
line as the attribute declaration.

llvm-svn: 174719
2013-02-08 17:15:07 +00:00
Tim Northover d3c543703d Improve filechecking of volatile test.
My previous attempt was extremely deficient, allowing more volatiles
to be introduced and not even checking all of the ones that are
present.

This attempt doesn't try to keep track of the values stored or offsets
within particular objects, just that the correct objects are accessed
in a correctly volatile manner throughout.

llvm-svn: 174700
2013-02-08 08:00:13 +00:00
Jordan Rose 08bf4fd345 CMake: Include Clang unit tests in check-clang target in standalone builds.
Also, remove CLANG_BUILD_TESTS option. It won't have consistent behavior
between standalone and non-standalone builds, so I'm not going to bother
hooking it up for standalone builds. LLVM_BUILD_TESTS will continue to
control unit test inclusion in the "all" target in non-standalone builds.

Finally, fix the default value of CLANG_INCLUDE_TESTS, which was being set
to the boolean value of "LLVM_INCLUDE_TESTS", i.e. OFF, rather than actually
reading the variable ${LLVM_INCLUDE_TESTS}! If you picked up my earlier
commit, YOU WILL HAVE TO MANUALLY SET THIS OPTION BACK ON. My apologies!

Part two of r174691 (allow the unit tests to be built in standalone mode).

llvm-svn: 174698
2013-02-08 07:28:25 +00:00
Nick Lewycky a245d3e1fc Fix test failure by making sure this file isn't identical to any other file
included in the same test. Clang gets confused about whether it's already built
a module for this file, when running on a content-addressible filesystem.

llvm-svn: 174694
2013-02-08 02:38:30 +00:00
Richard Smith 684f9687c7 Fix conflict between r174685 and r174645 (rename -fmodule-cache-path <foo> to -fmodules-cache-path=<foo>).
llvm-svn: 174690
2013-02-08 01:35:44 +00:00
Argyrios Kyrtzidis a2ed813afd [libclang] Attribute visitation happens out-of-source-order, make sure
we annotate properly when there is an attribute and not skip type specs
if the attribute is after the declaration.

rdar://13129077

llvm-svn: 174689
2013-02-08 01:12:25 +00:00
Tanya Lattner 60e93a6390 Use the target address space value when mangling names.
llvm-svn: 174688
2013-02-08 01:07:32 +00:00
Richard Smith 75fc3bf5fe Fix stack overflow and improve performance when a module contains many
overloads of a name by claiming that there are no lookup results for that name
in modules while loading the names from the module. Lookups in deserialization
really don't want to find names which they themselves are in the process of
introducing. This also has the pleasant side-effect of automatically caching
PCH lookups which found no names.

The runtime here is still quadratic in the number of overloads, but the
constant is lower.

llvm-svn: 174685
2013-02-08 00:37:45 +00:00
Fariborz Jahanian e4c7e855f1 objective-C modern translator. Generate #line
info in the translated code under -g only.
// rdar://13138170

llvm-svn: 174684
2013-02-08 00:27:34 +00:00
Douglas Gregor f5f9452808 Teach subframework header lookup to suggest modules <rdar://problem/13176200>.
llvm-svn: 174683
2013-02-08 00:10:48 +00:00
Anna Zaks c89ad07d39 [analyzer] Report bugs when freeing memory with offset pointer
The malloc checker will now catch the case when a previously malloc'ed
region is freed, but the pointer passed to free does not point to the
start of the allocated memory. For example:

int *p1 = malloc(sizeof(int));
p1++;
free(p1); // warn

From the "memory.LeakPtrValChanged enhancement to unix.Malloc" entry
in the list of potential checkers.

A patch by Branden Archer!

llvm-svn: 174678
2013-02-07 23:05:47 +00:00
Anna Zaks acdc13cb00 [analyzer] Add pointer escape type param to checkPointerEscape callback
The checkPointerEscape callback previously did not specify how a
pointer escaped. This change includes an enum which describes the
different ways a pointer may escape. This enum is passed to the
checkPointerEscape callback when a pointer escapes. If the escape
is due to a function call, the call is passed. This changes
previous behavior where the call is passed as NULL if the escape
was due to indirectly invalidating the region the pointer referenced.

A patch by Branden Archer!

llvm-svn: 174677
2013-02-07 23:05:43 +00:00
Anna Zaks 7c1f408636 [analyzer] Don't reinitialize static globals more than once along a path
This patch makes sure that we do not reinitialize static globals when
the function is called more than once along a path. The motivation is
code with initialization patterns that rely on 2 static variables, where
one of them has an initializer while the other does not. Currently, we
reset the static variables with initializers on every visit to the
function along a path.

llvm-svn: 174676
2013-02-07 23:05:37 +00:00
Douglas Gregor 4bedb499ea Form the default -fmodules-cache-path= properly.
llvm-svn: 174674
2013-02-07 22:59:12 +00:00
Fariborz Jahanian e499613d60 objective-C modern translator. More fixups for
modern meta-data abi translation. Still wip.
// rdar://13138459

llvm-svn: 174672
2013-02-07 22:50:40 +00:00
Douglas Gregor 7861dc7991 Add missing header from r174648
llvm-svn: 174649
2013-02-07 19:15:44 +00:00
Douglas Gregor 560b7fa0c4 Retain all hidden methods in the global method pool, because they may become visible <rdar://problem/13172858>.
llvm-svn: 174648
2013-02-07 19:13:24 +00:00
Douglas Gregor 35b04d6fd2 Rename -fmodule-cache-path <blah> to -fmodules-cache-path=<blah> for consistency.
llvm-svn: 174645
2013-02-07 19:01:24 +00:00
DeLesley Hutchins eb849c6bd5 Thread safety analysis: make sure that expressions in attributes are parsed
in an unevaluated context.

llvm-svn: 174644
2013-02-07 19:01:07 +00:00
Chad Rosier b31d71367b Testcase for r174477.
llvm-svn: 174640
2013-02-07 18:32:25 +00:00
Guy Benyei 259f9f4531 Enable overloading of OpenCL events - this is needed for the overloaded OpenCL builtin functions.
llvm-svn: 174630
2013-02-07 16:05:33 +00:00
Tim Northover ed9eae90d4 FileCheckize volatile test
llvm-svn: 174627
2013-02-07 15:39:16 +00:00
Tim Northover ffed8fe5c9 Only check for volatile memcpys in test.
AArch64 handles aggFct's return struct slightly differently, leading
to an extra memcpy. This test is fortunately only concerned about
volatile copies, so we can modify the grep text to filter it.

llvm-svn: 174621
2013-02-07 15:11:48 +00:00
Tim Northover 570b7478fa Add AArch64 wchar definition to test
This should allow it to pass if the default triple is AArch64

llvm-svn: 174620
2013-02-07 15:11:44 +00:00
Tim Northover 7df5c0df3b XFAIL test that's inappropriate for AArch64 ABI
Only some ABIs require the "signext" attribute on parameters. On most
platforms, however, it's a useful test so it's best not to limit it to some
random arbitrary platform.

llvm-svn: 174619
2013-02-07 15:11:40 +00:00
Tim Northover dd9809dd72 Permit ABIs where the caller extends the result (test change).
This test was written to make sure *something* sane is generated, not
to test any ABI's signedness semantics.

This should allow the test to pass if AArch64 is the default target.

llvm-svn: 174618
2013-02-07 15:11:36 +00:00
Guy Benyei 610541989a Add OpenCL samplers as Clang builtin types and check sampler related restrictions.
llvm-svn: 174601
2013-02-07 10:55:47 +00:00
Nick Lewycky 134af91b06 Apply the pure-virtual odr rule to other constructs which can call overloaded
operators.

llvm-svn: 174584
2013-02-07 05:08:22 +00:00
Richard Smith 645d755d3e Fix handling of module imports adding names to a DeclContext after qualified
name lookup has been performed in that context (this probably only happens in
C++).

1) Whenever we add names to a context, set a flag on it, and if we perform
lookup and discover that the context has had a lookup table built but has the
flag set, update all entries in the lookup table with additional names from
the external source.

2) When marking a DeclContext as having external visible decls, mark the
context in which lookup is performed, not the one we are adding. These won't
be the same if we're adding another copy of a pre-existing namespace.

llvm-svn: 174577
2013-02-07 03:37:08 +00:00
Alexander Kornienko c121b9b796 -Wimplicit-fallthrough: fixed two cases where "fallthrough annotation in unreachable code" was issued incorrectly.
Summary:
-Wimplicit-fallthrough: fixed two cases where "fallthrough annotation in unreachable code" was issued incorrectly:

1. In actual unreachable code, but not immediately on a fall-through execution
path "fallthrough annotation does not directly precede switch label" is better;
2. After default: in a switch with covered enum cases. Actually, these shouldn't
be treated as unreachable code for our purpose.

Reviewers: rsmith

Reviewed By: rsmith

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D374

llvm-svn: 174575
2013-02-07 02:17:19 +00:00
Fariborz Jahanian 57dd66baa4 objective-C modern translator. Fix up the translated
metadata to handle ivar bitfields. This is wip.
// rdar://13138459

llvm-svn: 174573
2013-02-07 01:53:15 +00:00
Richard Smith f5f43546b3 AST dumping: indicate the previous declaration for a redeclaration, and
indicate the semantic DC if it's not the lexical DC. In passing, correct
the ascii-art child marker for a child of a FriendDecl.

llvm-svn: 174570
2013-02-07 01:35:44 +00:00
Douglas Gregor 2236c20f5a Be a little more permissive with -fmodules-ignore-macro= by removing everything after the second '=' if it is there.
llvm-svn: 174567
2013-02-07 01:18:48 +00:00
Douglas Gregor 5dc3899ca4 Introduce -fmodules-ignore-macro=NNN to ignore a macro when building/loading modules.
The use of this flag enables a modules optimization where a given set
of macros can be labeled as "ignored" by the modules
system. Definitions of those macros will be completely ignored when
building the module hash and will be stripped when actually building
modules. The overall effect is that this flag can be used to
drastically reduce the number of

Eventually, we'll want modules to tell us what set of macros they
respond to (the "configuration macros"), and anything not in that set
will be excluded. However, that requires a lot of per-module
information that must be accurate, whereas this option can be used
more readily.

Fixes the rest of <rdar://problem/13165109>.

llvm-svn: 174560
2013-02-07 00:21:12 +00:00
Douglas Gregor 8a114ab557 Detect when we end up trying to load conflicting module files.
This can happen when one abuses precompiled headers by passing more -D
options when using a precompiled hedaer than when it was built. This
is intentionally permitted by precompiled headers (and is exploited by
some build environments), but causes problems for modules.

First part of <rdar://problem/13165109>, detecting when something when
horribly wrong.

llvm-svn: 174554
2013-02-06 22:40:31 +00:00
Ted Kremenek c43636a53d Remove unneeded test. We have plenty of subgroup relations between warnings,
and for those we care about we should have a general way of testing them.

llvm-svn: 174531
2013-02-06 19:24:28 +00:00
Jordan Rose dd77041973 Accept and ignore the -fextended-identifiers option.
This was GCC's option to turn on UCN support, which we always have on now
in C99 and C++ modes.

Additionally, mark the -fno-extended-identifiers option as unsupported,
since we don't support disabling UCNs in C99 and C++ modes.

PR11538

llvm-svn: 174530
2013-02-06 18:15:40 +00:00
Nick Lewycky 36722d2694 Don't check whether a friend declaration is correctly formed when instantiating,
we already checked it when parsing.

llvm-svn: 174486
2013-02-06 05:59:33 +00:00
Michael Gottesman e7b56375e1 Added test for r174461 that checks that the desired behavior also occurs in ObjC++ alongside ObjC.
\end paranoia.

llvm-svn: 174471
2013-02-06 00:14:48 +00:00
Anna Zaks 258f9357ef [analyzer]Revert part of r161511; suppresses leak false positives in C++
This is a "quick fix".

The underlining issue is that when a const pointer to a struct is passed
into a function, we do not invalidate the pointer fields. This results
in false positives that are common in C++ (since copy constructors are
prevalent). (Silences two llvm false positives.)

llvm-svn: 174468
2013-02-06 00:01:14 +00:00
Michael Gottesman 5c2059603c Changed CGObjCMac.cpp to add the marker externally_initialized to SELECTOR_REFERENCES in both the fragile and non-fragile API.
This is to ensure that GlobalOpt in LLVM does not attempt to look through a
selector reference to a method var name at compile time.

I also added a test/updated old tests that need to recognize the new keyword.

rdar://12580965.

llvm-svn: 174461
2013-02-05 23:08:45 +00:00
Ted Kremenek 8ae67871b4 Change subexpressions to be visited in the CFG from left-to-right.
This is a more natural order of evaluation, and it is very important
for visualization in the static analyzer.  Within Xcode, the arrows
will not jump from right to left, which looks very visually jarring.
It also provides a more natural location for dataflow-based diagnostics.

Along the way, we found a case in the analyzer diagnostics where we
needed to indicate that a variable was "captured" by a block.

-fsyntax-only timings on sqlite3.c show no visible performance change,
although this is just one test case.

Fixes <rdar://problem/13016513>

llvm-svn: 174447
2013-02-05 22:00:19 +00:00
Anna Zaks fe9c7c87c9 [analyzer] Teach the analyzer to use a symbol for p when evaluating
(void*)p.

Addresses the false positives similar to the test case.

llvm-svn: 174436
2013-02-05 19:52:28 +00:00
Argyrios Kyrtzidis 88c0d3b1ae [arcmt] Make sure the objc migrators work fine when used with a PCH.
rdar://13140508

llvm-svn: 174386
2013-02-05 16:37:00 +00:00
Argyrios Kyrtzidis 48b72d81c8 [frontend] Don't put a PCH/PTH filename into the set of includes in the preprocessor options;
since only one of them is allowed in command-line, process them separately.

Otherwise, if more than one is specified in the command-line, one is processed normally
and the others are going to be treated and included as header files.

Related to radar://13140508

llvm-svn: 174385
2013-02-05 16:36:52 +00:00
Eric Christopher 2ba5fcb759 Driver and option support for -gsplit-dwarf. This is a part of
the DWARF5 split dwarf proposal.

llvm-svn: 174349
2013-02-05 07:29:57 +00:00
Richard Smith 6b21696ee8 Add some missing diagnostics for C++11 narrowing conversions.
llvm-svn: 174337
2013-02-05 05:52:24 +00:00
Dmitri Gribenko b614fab39d DeclPrinter: fix CXXConstructExpr printing with implicit default argument
This is an improvement of r173630, that handles the following case:

  struct VirualDestrClass
  {
    VirualDestrClass(int arg);
    virtual ~VirualDestrClass();
  };

  struct ConstrWithCleanupsClass
  {
    ConstrWithCleanupsClass(const VirualDestrClass& cplx = VirualDestrClass(42));
  };

  ConstrWithCleanupsClass cwcNoArg;

That was printed as:

  ConstrWithCleanupsClass cwcNoArg();

llvm-svn: 174296
2013-02-03 23:02:47 +00:00
Benjamin Kramer 96951253bf Drop value names from test to get -Asserts builds back to green.
llvm-svn: 174294
2013-02-03 20:22:35 +00:00
Benjamin Kramer d9c8455adf CodeGen: Implement hint values for dynamic_cast as described in the Itanium C++ ABI.
This can yield dramatic speedups of dynamic_cast for simple inheritance trees,
at least with libsupc++. Neither libcxxabi nor libcxxrt make use of this
hint currently, it was never implemented because clang didn't support it.

There was some concern about the number of class hierarchy walks this change
introduces. If it turns out to be an issue we can add caching either at the cast
pair level or even deeper, but we also do a lot of walks in Sema so this
codepath is probably fairly optimized already.

llvm-svn: 174293
2013-02-03 19:59:25 +00:00
Benjamin Kramer b520633048 CodeGen: Mark the runtime function __dynamic_cast as readonly & nounwind.
This allows the optimizer to CSE dynamic_casts.

llvm-svn: 174289
2013-02-03 17:44:25 +00:00
NAKAMURA Takumi 2209f97d19 clang/test/CodeGenCXX/debug-info-class.cpp: Tweak to unbreak test for a few targets.
- Relax a expression for arm-gnueabi.
  - Exclude msvc to limit target triplets to add limited a few targets.
    Feel free to remove actions if guys thought they redundant.

llvm-svn: 174278
2013-02-03 12:52:54 +00:00
Jordan Rose e0c260f137 Revert "[analyzer] Model trivial copy/move ctors with an aggregate bind."
...again. The problem has not been fixed and our internal buildbot is still
getting hangs.

This reverts r174212, originally applied in r173951, then reverted in r174069.
Will not re-apply until the entire project analyzes successfully on my
local machine.

llvm-svn: 174265
2013-02-02 05:15:53 +00:00
Richard Smith c084bd2888 PR15132: Replace "address expression must be an lvalue or a function
designator" diagnostic with more correct and more human-friendly "cannot take
address of rvalue of type 'T'".

For the case of & &T::f, provide a custom diagnostic, rather than unhelpfully
saying "cannot take address of rvalue of type '<overloaded function type>'".

For the case of &array_temporary, treat it just like a class temporary
(including allowing it as an extension); the existing diagnostic wording
for the class temporary case works fine.

llvm-svn: 174262
2013-02-02 02:14:45 +00:00
Richard Smith 4be2c36921 Correctly classify T{} as an array temporary if T is an array of class type with nontrivial destructor.
llvm-svn: 174261
2013-02-02 02:11:36 +00:00
Richard Smith d712d0dbdd Don't forget to run destructors when we create an array temporary of class type.
llvm-svn: 174257
2013-02-02 01:13:06 +00:00
Michael Gottesman cf50e6d6ce On platforms which do not support ARC natively, do not mark objc_retain/objc_release as "nonlazybind".
rdar://13108298.
rdar://13129783.

llvm-svn: 174253
2013-02-02 00:57:44 +00:00
David Blaikie f85744235b Generalize DebugInfo tests by avoiding explicit metadata numbers
This addresses several (not all) debug info tests that use explicit metadata
numbers. Wherever the same number appeared more than once in a test I used
a named match to ensure the same number appeared in all those cases (this may
still be overly constraining test cases as they may not have actually cared
about that relationship). For one-off numbers I just replaced them with an
unnamed regex.

This may underconstrain poorly written test cases that were interested in
checking that certain metadata nodes were related but didn't actually match
on all the related nodes numbers.

llvm-svn: 174247
2013-02-02 00:34:26 +00:00
Anna Zaks 00c69a597c [analyzer] Always inline functions with bodies generated by BodyFarm.
Inlining these functions is essential for correctness. We often have
cases where we do not inline calls. For example, the shallow mode and
when reanalyzing previously inlined ObjC methods as top level.

llvm-svn: 174245
2013-02-02 00:30:04 +00:00
Nick Lewycky 45b5052834 This patch makes "&Cls::purevfn" not an odr use. This isn't what the standard
says, but that's a defect (to be filed). "Cls::purevfn()" is still an odr use.

Also fixes a bug that caused us to not mark the function referenced just
because we didn't want to mark it odr used.

llvm-svn: 174242
2013-02-02 00:25:55 +00:00
Douglas Gregor 44180f8f6d Merge "special" types from different modules in the AST reader.
Different modules may have different views of the various "special"
types in the AST, such as the redefinition type for "id". Merge those
types rather than only considering the redefinition types for the
first AST file loaded.

llvm-svn: 174234
2013-02-01 23:45:03 +00:00
NAKAMURA Takumi a7c84e6050 clang/test/CodeGenCXX/debug-info-class.cpp: Fixup for -Asserts.
llvm-svn: 174229
2013-02-01 22:53:19 +00:00
Dmitri Gribenko 2e72dd4a43 Comment parsing: improve the fidelity of XML output for many block commands
This change introduces a 'kind' attribute for the <Para> tag, that captures the
kind of the parent block command.

For example:

\todo Meow.

used to be just <Para>Meow.</Para>, but now it is
<Para kind="todo">Meow.</Para>

llvm-svn: 174216
2013-02-01 20:23:57 +00:00
Bill Schmidt 38378a06dd Add some missing PPC cpus
llvm-svn: 174215
2013-02-01 20:23:10 +00:00
Fariborz Jahanian 4dca1d3d81 objc: Provide correct fixit instruction when two mismatched
nsstringis are compared without. // rdar://12716301

llvm-svn: 174214
2013-02-01 20:04:49 +00:00
Jordan Rose b54cfa310a [analyzer] Explain why we have system-header-simulator*.h files.
Suggested by Csaba. Text based on an e-mail of mine on cfe-dev.

llvm-svn: 174213
2013-02-01 19:50:01 +00:00
Jordan Rose b6717cc6d0 Re-apply "[analyzer] Model trivial copy/move ctors with an aggregate bind."
With the optimization in the previous commit, this should be safe again.

Originally applied in r173951, then reverted in r174069.

llvm-svn: 174212
2013-02-01 19:49:59 +00:00
Jordan Rose 49d5f8825d [analyzer] Reuse a LazyCompoundVal if its type matches the new region.
This allows us to keep from chaining LazyCompoundVals in cases like this:
  CGRect r = CGRectMake(0, 0, 640, 480);
  CGRect r2 = r;
  CGRect r3 = r2;

Previously we only made this optimization if the struct did not begin with
an aggregate member, to make sure that we weren't picking up an LCV for
the first field of the struct. But since LazyCompoundVals are typed, we can
make that inference directly by comparing types.

This is a pure optimization; the test changes are to guard against possible
future regressions.

llvm-svn: 174211
2013-02-01 19:49:57 +00:00
David Blaikie 357aafb566 Fix exception handling line table problems introduced by r173593
r173593 made us a little too eager to associate all code at the end of a
function with the user-written 'return' line. This caused problems with
breakpoints as they'd be set in exception handling code preceeding the
actual non-exception return handling code, leading to the breakpoint never
being hit in non-exceptional execution.

This change restores the pre-r173593 exception handling line information where
the cleanup code is associated with the '}' not the return line.

llvm-svn: 174206
2013-02-01 19:09:49 +00:00
Hal Finkel b58ce85ecc Add -mqpx and -mno-qpx feature flags to toggle use of the PPC QPX vector instruction set
I've renamed the altivec test to ppc-features (because now there is more than one feature to test).

llvm-svn: 174204
2013-02-01 18:44:19 +00:00
Bill Schmidt b02158d474 Add check for @foo
llvm-svn: 174185
2013-02-01 15:52:51 +00:00
Bill Schmidt 3e439e4223 Fix a string not seen without asserts
llvm-svn: 174183
2013-02-01 15:41:02 +00:00
Alexander Kornienko 527fa4f24f Fixed segmentation fault when a CFGBlock has NULL successor.
llvm-svn: 174182
2013-02-01 15:39:20 +00:00
Bill Schmidt eb03ae268e Fix PR14881 by implementing conversion rules between int and complex int.
Prior to the patch, Clang does not properly promote types when a complex
integer operand is combined with an integer via a binary operator, or when
one is assigned to the other in either order.  This patch detects when
promotion is needed (and permissible) and generates the necessary code.

The test assmes no target has the same size operands for "char" and
"long long," and that no target performs arithmetic on char operands without
extending them to a larger format first.  If there are any targets for
which this is not the case, they should be XFAILed.

llvm-svn: 174181
2013-02-01 15:34:29 +00:00
Bill Schmidt 102bb32bf7 Revise unit testing for -fno-altivec, -mno-altivec.
As suggested, reverted the end-to-end test and added variations to an
existing Driver test.

llvm-svn: 174176
2013-02-01 14:45:29 +00:00
Richard Smith 9eaab4be04 Fix diagnostic for bad alignas use: it can't be applied to functions.
llvm-svn: 174160
2013-02-01 08:25:07 +00:00
Nick Lewycky 9c7eb1d887 Add a new -Wundefined-inline warning for inline functions which are used but not
defined. Fixes PR14993!

llvm-svn: 174158
2013-02-01 08:13:20 +00:00
Richard Smith 848e1f1960 Implement [dcl.align]p5 and C11 6.7.5/4: alignas cannot underalign.
Also support alignas(0), which C++11 and C11 require us to ignore.

llvm-svn: 174157
2013-02-01 08:12:08 +00:00
Hal Finkel df1e4bfcb2 Add PPC A2Q core and BG/Q preprocessor definitions
The a2q core is the variant of the a2 core used on the BG/Q supercomputers.

llvm-svn: 174151
2013-02-01 05:53:33 +00:00
John McCall 12cc42aa1b Destroy arrays and ARC fields when throwing out of ctors.
Previously we were only handling non-array fields of class type.

Testcases derived from a patch by WenHan Gu.

llvm-svn: 174146
2013-02-01 05:11:40 +00:00
Douglas Gregor bc0e5c0114 Don't do delayed exception-specification checking on an invalid
class. Fixes <rdar://problem/13017229>.

llvm-svn: 174145
2013-02-01 04:49:10 +00:00
Bill Schmidt 2fe4c67374 Enable -fno-altivec, -mno-altivec for PowerPC.
Introduces these negation forms explicitly and uses them to control a new
"altivec" target feature for PowerPC.  This allows avoiding generating
Altivec instructions on processors that support Altivec.

The new test case verifies that the Altivec "lvx" instruction is not
used when -fno-altivec is present on the command line.

llvm-svn: 174140
2013-02-01 02:14:03 +00:00
Michael Han af02bbe84f [Sema][Attr]Fix alignment attribute printing.
Remove "IsMSDeclspec" argument from Align attribute since the arguments in Attr.td should
only model those appear in source code. Introduce attribute Accessor, and teach TableGen
to generate syntax kind accessors for Align attribute, and use those accessors to decide
if an alignment attribute is a declspec attribute.

llvm-svn: 174133
2013-02-01 01:19:17 +00:00
NAKAMURA Takumi 524bed1467 clang/test/Index/headerfile-comment-to-html.m: Try to unbreak libxml2-less hosts to eliminate "CommentXMLValid".
llvm-svn: 174124
2013-02-01 00:17:45 +00:00
Bill Wendling 85ab57ac5d Update the tests.
This update coincides with r174110. That change ordered the attributes
alphabetically.

llvm-svn: 174111
2013-01-31 23:17:12 +00:00
Fariborz Jahanian 1a0cf80533 [Comment parsing] Add support for recognizing
\headerfile command and representing it in an xml
document. Patch reviewed by Dmitri Gribenko.
// rdar://12397511

llvm-svn: 174109
2013-01-31 23:12:39 +00:00
Anna Zaks a8bcc65819 [analyzer]RetainCount: Fix an autorelease related false positive.
The Cnt variable is adjusted (incremented) for simplification of
checking logic. The increment should not be stored in the state.

llvm-svn: 174104
2013-01-31 22:36:17 +00:00
Jordan Rose 95bf3b0a6c [analyzer] Don't track autorelease pools created by +new.
This matches our behavior for autorelease pools created by +alloc. Some
people like to create autorelease pools in one method and release them
somewhere else.

If you want safe autorelease pool semantics, use the new ARC-compatible
syntax: @autoreleasepool { ... }

<rdar://problem/13121353>

llvm-svn: 174096
2013-01-31 22:06:02 +00:00
Jordan Rose cc538345be Lexer: Don't warn about Unicode in preprocessor directives.
This allows people to use Unicode in their #pragma mark and in macros
that exist only to be string-ized.

<rdar://problem/13107323&13121362>

llvm-svn: 174081
2013-01-31 19:48:48 +00:00
Jordan Rose 92d999b3f1 Revert "[analyzer] Model trivial copy/move ctors with an aggregate bind."
It's causing hangs on our internal analyzer buildbot. Will restore after
investigating.

This reverts r173951 / baa7ca1142990e1ad6d4e9d2c73adb749ff50789.

llvm-svn: 174069
2013-01-31 18:04:03 +00:00
NAKAMURA Takumi ad1e5ce8ea clang/test/Index/skip-parsed-bodies/compile_commands.json: Mark it as XFAIL:mingw32, for now.
llvm-svn: 174064
2013-01-31 16:01:13 +00:00
Tim Northover 9bb857a4f1 Add support for AArch64 target.
In cooperation with the LLVM patch, this should implement all scalar front-end
parts of the C and C++ ABIs for AArch64.

This patch excludes the NEON support also reviewed due to an outbreak of
batshit insanity in our legal department. That will be committed soon bringing
the changes to precisely what has been approved.

Further reviews would be gratefully received.

llvm-svn: 174055
2013-01-31 12:13:10 +00:00
Douglas Gregor 6153500517 When we're emitting a constructor or destructor call from a delegating
constructor, retrieve our VTT parameter directly. Fixes PR14588 /
<rdar://problem/12867962>.

llvm-svn: 174042
2013-01-31 05:50:40 +00:00
Richard Smith 44ecdbdc61 Improve 'failed template argument deduction' diagnostic for the case where we
have a direct mismatch between some component of the template and some
component of the argument. The diagnostic now says what the mismatch was, but
doesn't yet say which part of the template doesn't match.

llvm-svn: 174039
2013-01-31 05:19:49 +00:00
Douglas Gregor 52e0de4c6e When code completing in a statement, parenthesized expression, or
Objective-C message receiver, the user is as likely to want to write a
type name as any other declaration, so give types the same priority as
other declarations. Fixes <rdar://problem/12480600>.

llvm-svn: 174038
2013-01-31 05:03:46 +00:00
Douglas Gregor 0a0e2b3631 Allow the computation of the base priority for a declaration code completion result to consider the completion context
llvm-svn: 174037
2013-01-31 04:52:16 +00:00
Richard Smith 8c6eeb9599 Replace "failed template argument deduction" diagnostic with something useful
in the one case where we've already factored out a reason code.

llvm-svn: 174036
2013-01-31 04:03:12 +00:00
Richard Smith d202924db6 Clarify the diagnostic for -Wnested-anon-types.
llvm-svn: 174032
2013-01-31 03:11:12 +00:00
Jordan Rose 9a6d4f3644 [analyzer] If a lazy binding is undefined, pretend that it's unknown instead.
This is a hack to work around the fact that we don't track extents for our
default bindings:

  CGPoint p;
  p.x = 0.0;
  p.y = 0.0;
  rectParam.origin = p;
  use(rectParam.size); // warning: uninitialized value in rectParam.size.width

In this case, the default binding for 'p' gets copied into 'rectParam',
because the 'origin' field is at offset 0 within CGRect. From then on,
rectParam's old default binding (in this case a symbol) is lost.

This patch silences the warning by pretending that lazy bindings are never
made from uninitialized memory, but not only is that not true, the original
default binding is still getting overwritten (see FIXME test cases).
The long-term solution is tracked in <rdar://problem/12701038>

PR14765 and <rdar://problem/12875012>

llvm-svn: 174031
2013-01-31 02:57:06 +00:00
Richard Trieu e673d71a07 When comparing two template template arguments in the template differ, consider
them the same if they are actually the same; having the same name isn't enough.

Similar to r174013, template template arguments were also mistakenly considered
the same when they had the same name but were in different namespaces.
In addition, when printing template template arguments, use the qualified name
if the regular name is the same.

llvm-svn: 174029
2013-01-31 02:47:46 +00:00
Richard Trieu de5cc7d3d8 Add indents to AST dumping and removed parenthesis from AST nodes.
Indents were given the color blue when outputting with color.
AST dumping now looks like this:

Node
|-Node
| `-Node
`-Node
  `-Node

Compared to the previous:

(Node
  (Node
    (Node))
  (Node
    (Node)))

llvm-svn: 174022
2013-01-31 01:44:26 +00:00
Nick Lewycky 35d2359b1c Fix ODR-use of a MemberExpr to check before marking a pure function used. Remove
a workaround for this bug from the -Wundefined-internals warning.

llvm-svn: 174020
2013-01-31 01:34:31 +00:00
Anna Zaks 3a86267192 [analyzer] Fix a bug in region store that lead to undefined value false
positives.

The includeSuffix was only set on the first iteration through the
function, resulting in invalid regions being produced by getLazyBinding
(ex: zoomRegion.y).

llvm-svn: 174016
2013-01-31 01:19:52 +00:00
Matt Beaumont-Gay c7cd308274 Sometimes ld is just ld.
Don't expect a character between the double-quotes and 'ld'.

llvm-svn: 174015
2013-01-31 01:15:55 +00:00
Douglas Gregor 8e9f55ff13 When comparing two templates in the template differ, consider them the
same if they are actually the same; having the same name isn't
enough. Fixes <rdar://problem/12931988>.

llvm-svn: 174013
2013-01-31 01:08:35 +00:00
Douglas Gregor 1a347f76c2 Reinstate r173952, this time limiting it to exactly the form
#define X X

for which there is no point warning, ever.

llvm-svn: 173991
2013-01-30 23:10:17 +00:00
Jordan Rose 2da0d1cfd3 Diagnostics: if a line is longer than 4096 characters, don't print it.
Specifically, don't print snippets, caret diagnostics, or ranges for
lines over 4096 characters. We copy the line around a few times in our
diagnostics machinery, and we have to print a caret line that's just as
long. This uses a lot of memory just to create a poor user experience as
we print out a line much too long for anyone to read...or spend extra
energy trying to fit it to -fmessage-length.

<rdar://problem/13106850>

llvm-svn: 173976
2013-01-30 21:41:07 +00:00
Argyrios Kyrtzidis a94bd438f8 Revert "[preprocessor] Don't warn about "disabled expansion of recursive macro""
This reverts commit r173952

llvm-svn: 173970
2013-01-30 20:42:17 +00:00
Richard Trieu 90c31f51c6 Handle passing non-Qualtypes to %diff better. Instead of asserting, fall back
to printing the default case.  This is a fix for PR15023.

llvm-svn: 173965
2013-01-30 20:04:31 +00:00
Tanya Lattner 0f86433efb Add OpenCL error that a kernel function must have void return type. Includes a test case.
llvm-svn: 173963
2013-01-30 19:48:52 +00:00
Jordan Rose 9588a02b77 Fix comment in test/Lexer/utf8-invalid.c for updates in r173959.
llvm-svn: 173961
2013-01-30 19:29:14 +00:00
Jordan Rose f649795f84 Fix r173881 to properly skip invalid UTF-8 characters in raw lexing and -E.
This caused hangs as we processed the same invalid byte over and over.

<rdar://problem/13115651>

llvm-svn: 173959
2013-01-30 19:21:12 +00:00
Anna Zaks c84d151892 [analyzer] Make shallow mode more shallow.
Redefine the shallow mode to inline all functions for which we have a
definite definition (ipa=inlining). However, only inline functions that
are up to 4 basic blocks large and cut the max exploded nodes generated
per top level function in half.

This makes shallow faster and allows us to keep inlining small
functions. For example, we would keep inlining wrapper functions and
constructors/destructors.

With the new shallow, it takes 104s to analyze sqlite3, whereas
the deep mode is 658s and previous shallow is 209s.

llvm-svn: 173958
2013-01-30 19:12:39 +00:00
Anna Zaks 66b9f1660e [analyzer] Use analyzer config for max-inlinable-size option.
llvm-svn: 173957
2013-01-30 19:12:36 +00:00
Argyrios Kyrtzidis 8c8684bbe1 [preprocessor] Don't warn about "disabled expansion of recursive macro"
for "#define X X".

This is a pattern that, for example, stdbool.h uses.
rdar://12435773

llvm-svn: 173952
2013-01-30 18:55:52 +00:00
Jordan Rose 4cf4f8a5d4 [analyzer] Model trivial copy/move ctors with an aggregate bind.
This is faster for the analyzer to process than inlining the constructor
and performing a member-wise copy, and it also solves the problem of
warning when a partially-initialized POD struct is copied.

Before:
  CGPoint p;
  p.x = 0;
  CGPoint p2 = p; <-- assigned value is garbage or undefined

After:
  CGPoint p;
  p.x = 0;
  CGPoint p2 = p; // no-warning

This matches our behavior in C, where we don't see a field-by-field copy.

<rdar://problem/12305288>

llvm-svn: 173951
2013-01-30 18:16:06 +00:00
Dmitri Gribenko efe3038fbf Comment parsing: fold named character references test into other HTML tests
llvm-svn: 173934
2013-01-30 14:44:47 +00:00
Dmitri Gribenko 37bf6d9c4d Index/special-html-characters.m: mark this as XFAIL for valgrind
Fix is being discussed on cfe-dev.

llvm-svn: 173925
2013-01-30 12:17:33 +00:00
Tim Northover da16507111 Also promote fp16 types to double when they're anonymous variadic arguments.
__fp16 isn't covered by the standard, but this resolves the oddity that float
gets promoted when passed variadically, but not the smaller type. This is
required by the AArch64 ABI, and a sane action elsewhere.

llvm-svn: 173918
2013-01-30 09:46:55 +00:00
Douglas Gregor ed1f59701e Add "instancetype" as a code completion result for the return type of
an Objective-C method. Fixes <rdar://problem/13069990>.

llvm-svn: 173905
2013-01-30 07:11:43 +00:00
Douglas Gregor 41778c3fa9 The instance methods of the root class of an Objective-C hieararchy
can be messaged via the metaclass. Provide code completions for this
case. Fixes <rdar://problem/12560296>.

llvm-svn: 173903
2013-01-30 06:58:39 +00:00
Richard Smith 4dab709484 C11: Provide the missing half of <stdalign.h>
llvm-svn: 173900
2013-01-30 06:33:54 +00:00
Richard Smith d4cca6b2db Fix test failure from previous change.
llvm-svn: 173899
2013-01-30 06:27:44 +00:00
Richard Smith debc59d1f3 Semantic analysis and CodeGen support for C11's _Noreturn. This is modeled as
an attribute for consistency with our other noreturn mechanisms.

llvm-svn: 173898
2013-01-30 05:45:05 +00:00
Alexander Kornienko afed1ddb40 Don't warn on fall-through from unreachable code.
Summary:
A motivating example:
class ClassWithDtor {
public:
  ~ClassWithDtor() {}
};
void fallthrough3(int n) {
  switch (n) {
    case 2:
      do {
        ClassWithDtor temp;
        return;
      } while (0);  // This generates a chain of unreachable CFG blocks.
    case 3:
      break;
  }
}

Reviewers: rsmith, doug.gregor, alexfh

Reviewed By: alexfh

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D330

llvm-svn: 173889
2013-01-30 03:49:44 +00:00
Douglas Gregor 29d18a8b93 Unresolved lookups can have using declarations that refer to
unresolved using declarations. Fixes PR14768 / <rdar://problem/13030296>.

llvm-svn: 173883
2013-01-30 02:10:08 +00:00
Jordan Rose 17441589c3 Don't warn about Unicode characters in -E mode.
People use the C preprocessor for things other than C files. Some of them
have Unicode characters. We shouldn't warn about Unicode characters
appearing outside of identifiers in this case.

There's not currently a way for the preprocessor to tell if it's in -E mode,
so I added a new flag, derived from the PreprocessorOutputOptions. This is
only used by the Unicode warnings for now, but could conceivably be used by
other warnings or even behavioral differences later.

<rdar://problem/13107323>

llvm-svn: 173881
2013-01-30 01:52:57 +00:00
David Blaikie 1105821f55 [Sema] Constrain test added in r173873 with expected-error-re
Suggested in post-commit review by Richard Smith.

llvm-svn: 173880
2013-01-30 01:43:36 +00:00
David Blaikie 35506f8202 Provide a fixit for constexpr non-static data members.
If the member has an initializer, assume it was probably intended to be static
and suggest/recover with that.

If the member doesn't have an initializer, assume it was probably intended to
be const instead of constexpr and suggest that.

(if the attempt to apply these changes fails, don't make any suggestion &
produce the same diagnostic experience as before. The only case where this can
come up that I know of is with a mutable constexpr with an initializer, since
mutable is incompatible with static (but it's already incompatible with
const anyway))

llvm-svn: 173873
2013-01-30 01:22:18 +00:00
Fariborz Jahanian 4d365ba9b9 c: When checking on validity of sizeof passed as size of
argument to be memset, check for its type to be complete 
before calling Context.getTypeSize(PointeeTy) to prevent 
crash. // rdar://13081751.

llvm-svn: 173872
2013-01-30 01:12:44 +00:00
NAKAMURA Takumi 26afef3e8d clang/test/Driver/asan-ld.c: Try not to mismatch temporary file, like "tmpkcfdld".
If we had the regular expression "\b" in FileCheck like Perl...

llvm-svn: 173861
2013-01-30 00:21:41 +00:00
Fariborz Jahanian 7b3ae19048 [Doc parsing] Patch to parse Doxygen-supported HTML character
references to their UTIF-8 encoding. Reviewed offline by Doug.
// rdar://12392215

llvm-svn: 173850
2013-01-29 23:42:26 +00:00
Chad Rosier ae229d599b [ubsan] Implement the -fcatch-undefined-behavior flag using a trapping
implementation; this is much more inline with the original implementation
(i.e., pre-ubsan) and does not require run-time library support.

The trapping implementation can be invoked using either '-fcatch-undefined-behavior'
or '-fsanitize=undefined-trap -fsanitize-undefined-trap-on-error', with the latter
being preferred.  Eventually, the -fcatch-undefined-behavior' flag will be removed.

llvm-svn: 173848
2013-01-29 23:31:22 +00:00
NAKAMURA Takumi cdf766326d clang/test/Index/getcursor-preamble.m: Formatting.
llvm-svn: 173844
2013-01-29 23:03:22 +00:00
NAKAMURA Takumi 473a5828f6 clang/test/Index/getcursor-preamble.m: Tweak for win32. env(1) is required to change variables locally.
llvm-svn: 173843
2013-01-29 23:03:16 +00:00
David Blaikie 8505c29593 Move -Wstatic-float-init fixit into a note & don't recover as if constexpr
llvm-svn: 173841
2013-01-29 22:26:08 +00:00
David Blaikie 3645cf99f2 Don't fixit/recover from -Wstatic-float-init when it's not an error.
Fix to change r173414 that lead to Clang changing const to constexpr even under
-Wno-static-float-init.

llvm-svn: 173835
2013-01-29 21:40:37 +00:00
Argyrios Kyrtzidis 005206a813 [Preprocessor] When checking if we can concatenate two tokens, check
if they were already concatenated in source using the spelling locations
even if they came from a macro expansion.

This fixes an issue where a GUID passed as macro argument ends up
malformed after preprocessing because we added spaces inside it.

rdar://13016645

llvm-svn: 173826
2013-01-29 20:28:24 +00:00
Chad Rosier dd60e09021 [driver] Refactor the driver so that a failing commands doesn't prevent
subsequent commands from being executed.

The diagnostics generation isn't designed for this use case, so add a note to
fix this in the very near future.  For now, just generated the diagnostics for
the first failing command.
Part of rdar://12984531

llvm-svn: 173825
2013-01-29 20:15:05 +00:00
Argyrios Kyrtzidis c821f739b5 Mark a struct definition in an objc container with the TopLevelDeclInObjCContainer bit.
Fixes accurately getting a cursor inside an objc container containing a struct definition,
from a PCH/preamble file.

rdar://12584613

llvm-svn: 173811
2013-01-29 18:00:54 +00:00
Joey Gouly 0942e0b5e1 Fix a crash in OpenCL code by using the proper (RHS) bit-width.
llvm-svn: 173802
2013-01-29 15:09:40 +00:00
Joey Gouly 39989dadd3 Add a diagnostic for an OpenCL kernel with a pointer pointer argument.
Also refactor the surrounding code a little.

llvm-svn: 173791
2013-01-29 10:54:06 +00:00
Richard Smith 064697ca06 Test update missed in r173789.
llvm-svn: 173790
2013-01-29 10:18:33 +00:00
Richard Smith 7dd5fe5ce6 Produce a diagnostic if alignas is applied to an expression. Neither C11 nor
C++11 allows that.

llvm-svn: 173789
2013-01-29 10:18:18 +00:00
Richard Smith 810ad3eb44 Downgrade 'attribute ignored when parsing type' from error to warning, to match
the diagnostic's warn_ name. Switch some places (notably C++11 attributes)
which really wanted an error over to a different diagnostic. Finally, suppress
the diagnostic entirely for __ptr32, __ptr64 and __w64, to avoid producing
diagnostics in important system headers.

llvm-svn: 173788
2013-01-29 10:02:16 +00:00
Richard Smith 1dba27cd49 Implement C++11 [dcl.align]p1 and C11 6.7.5/2 rules for alignas and _Alignas.
llvm-svn: 173779
2013-01-29 09:02:09 +00:00
Richard Smith a5aaca9295 Propagate the spelling list index for an attribute across template instantiation.
llvm-svn: 173768
2013-01-29 04:21:28 +00:00
Richard Smith 52c5b87cc9 PR15017: A '>' can appear after a type-specifier in a template-argument-list.
It turns out that there's no correctness bug here (because we can't have a type
definition in this location), but there was a diagnostic bug.

llvm-svn: 173766
2013-01-29 04:13:32 +00:00
Michael Han ff37d94e6f Add a test case for attribute print.
llvm-svn: 173765
2013-01-29 04:13:20 +00:00
Bill Wendling 9806806f39 Modify the tests for the (sorted) order that the attributes come out as now.
llvm-svn: 173762
2013-01-29 03:21:00 +00:00
Richard Smith 685cef6499 PR15100: look through type sugar when determining whether we have one of the
forms of 'main' which we accept as an extension.

llvm-svn: 173758
2013-01-29 02:49:47 +00:00
Richard Smith e1564ea65b Fold tests for C++ 'main' into a single file.
llvm-svn: 173756
2013-01-29 02:42:09 +00:00
Richard Smith 210b67d221 Test that we print MS keyword attributes without a __declspec(...) adornment.
llvm-svn: 173754
2013-01-29 02:31:57 +00:00
Richard Smith d11c7a1628 Treat alignas and _Alignas as keyword attributes. This allows us to
pretty-print them properly (modulo the more general badness in alignment
attribute printing).

llvm-svn: 173752
2013-01-29 01:48:07 +00:00
Richard Smith 9a629abf3d Actually remove the hack which was blocking the Borland-style attributes from
working, and add the missing attribute spellings. This brings _pascal,
_fastcall, _stdcall and _cdecl to life in -fborland-extensions mode.

llvm-svn: 173749
2013-01-29 01:38:41 +00:00
Douglas Gregor 0b7bc7f996 Don't crash while printing APValues that are lvalues casted to a
decidedly non-reference, non-pointer type. Fixes <rdar://problem/13090123>.

llvm-svn: 173747
2013-01-29 01:26:43 +00:00
Richard Smith 0cdcc98200 Replace AS_MSTypespec with AS_Keyword, for representing any attribute spelled
as a keyword. Rationalize existing attributes to use it as appropriate, and to
not lie about some __declspec attributes being GNU attributes. In passing,
remove a gross hack which was discarding attributes which we could handle. This
results in us actually respecting the __pascal keyword again.

llvm-svn: 173746
2013-01-29 01:24:26 +00:00
Richard Smith e233fbfc16 Finish semantic analysis for [[carries_dependency]] attribute.
This required plumbing through a new flag to determine whether a ParmVarDecl is
actually a parameter of a function declaration (as opposed to a function
typedef etc, where the attribute is prohibited). Weirdly, this attribute (just
like [[noreturn]]) cannot be applied to a function type, just to a function
declaration (and its parameters).

llvm-svn: 173726
2013-01-28 22:42:45 +00:00
Dmitri Gribenko 35630ec93a FileCheck'ize tests
llvm-svn: 173720
2013-01-28 21:43:46 +00:00
Dmitri Gribenko 6f2082b28c FileCheck'ize a test
llvm-svn: 173717
2013-01-28 21:04:29 +00:00
Dmitri Gribenko 1223762783 Migrate a test to -verify
llvm-svn: 173716
2013-01-28 20:55:54 +00:00
Chad Rosier 6cae695cc7 [driver] Revise this test to remove the dependency on the integrate assembler.
llvm-svn: 173715
2013-01-28 20:51:27 +00:00
Dmitri Gribenko 75bd3a8ec1 FileCheck'ize and merge tests
llvm-svn: 173714
2013-01-28 20:40:50 +00:00
Douglas Gregor 0ad84b46e3 Undo my re-wording of the "ARC forbids Objective-C objects in ..."
error. Jordan is right.

llvm-svn: 173713
2013-01-28 20:13:44 +00:00