Commit Graph

43631 Commits

Author SHA1 Message Date
Jordan Rose d9759fdb03 Release notes: mention support for Unicode and UCNs in identifiers.
I'm using the name "Extended Identifiers" for the feature because that's
what GCC calls them. According to the standard, the new feature is
"universal character names are now allowed in identifiers", but the more
interesting "feature" is that identifiers can now contain Unicode characters,
however they are written.

llvm-svn: 174798
2013-02-09 02:12:23 +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
NAKAMURA Takumi 1aa79e9f63 clang/lib/StaticAnalyzer/Core/BugReporter.cpp: Appease old msvc in std::pair(0, 0).
llvm-svn: 174792
2013-02-09 01:22:23 +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 0d8779cb79 [analyzer] Move DefaultBool so that all checkers can share it.
llvm-svn: 174782
2013-02-08 23:55:50 +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 470543bb2b [analyzer] IvarInvalidation: refactor, pull out the diagnostic printing
llvm-svn: 174780
2013-02-08 23:55:45 +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 388d767ab1 CharInfo: Add missing "using namespace clang::charinfo" in .cpp file.
Should fix the MSC bot.

llvm-svn: 174769
2013-02-08 22:37:49 +00:00
Jordan Rose a7d03840e6 Excise <cctype> from Clang (except clang-tblgen) in favor of CharInfo.h.
Nearly all of these changes are one-to-one replacements; the few that
aren't have to do with custom identifier validation.

llvm-svn: 174768
2013-02-08 22:30:41 +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
Jordan Rose a2100d755a Pull Lexer's CharInfo table out for general use throughout Clang.
Rewriting the same predicates over and over again is bad for code size and
code maintainence. Using the functions in <ctype.h> is generally unsafe
unless they are specified to be locale-independent (i.e. only isdigit and
isxdigit).

The next commit will try to clean up uses of <ctype.h> functions within Clang.

llvm-svn: 174765
2013-02-08 22:30:22 +00:00
Ted Kremenek e0cdd752d5 Note that checker-271 is newer than the analyzer in Xcode 4.6
llvm-svn: 174759
2013-02-08 22:19:43 +00:00
Ted Kremenek b3cbef4ad2 Update open source checker build to checker-271.
llvm-svn: 174758
2013-02-08 22:18:26 +00:00
Douglas Gregor 8d7edced83 Always keep highest identifier, selector, and macro IDs when we've
read another one, just as we do for types.

llvm-svn: 174745
2013-02-08 21:30:59 +00:00
Douglas Gregor dadd85dc0c Never cache the result of a module file lookup.
llvm-svn: 174744
2013-02-08 21:27:45 +00:00
Manuel Klimek d076dcd54f Fix indentation-detection at indent level 0.
This correctly formats:
  {
    a;
  }
where { is incorrectly indented by 2, but is at level 0, when
reformatting only 'a;'.

llvm-svn: 174737
2013-02-08 19:53:32 +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
Ted Kremenek 20a43dc29c Remove stale instance variable.
llvm-svn: 174730
2013-02-08 18:59:17 +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
Manuel Klimek b95f5450a9 Takes the context into account when re-indenting regions.
Fixes llvm.org/PR14916.

llvm-svn: 174720
2013-02-08 17:38:27 +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
Daniel Jasper 8360a86c8c Fix handling of fake parenthesis during formatting.
They are much easier to handle when attached to the previous token.

Before:
unsigned Indent =
    formatFirstToken(TheLine.First, IndentForLevel[TheLine.Level] >=
                                    0 ? IndentForLevel[TheLine.Level]
: TheLine.Level * 2, TheLine.InPPDirective, PreviousEndOfLineColumn);

After:
unsigned Indent = formatFirstToken(
    TheLine.First, IndentForLevel[TheLine.Level] >= 0
                       ? IndentForLevel[TheLine.Level] : TheLine.Level * 2,
    TheLine.InPPDirective, PreviousEndOfLineColumn);

llvm-svn: 174718
2013-02-08 16:49:27 +00:00
Daniel Jasper 400adc64da Implement a tiny expression parser to improve formatting decisions.
With this patch, the formatter introduces 'fake' parenthesis according
to the operator precedence of binary operators.

Before:
return aaaa & AAAAAAAAAAAAAAAAAAAAAAAAAAAAA || bbbb &
       BBBBBBBBBBBBBBBBBBBBBBBBBBBBB || cccc & CCCCCCCCCCCCCCCCCCCCCCCCCC ||
       dddd & DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD;
f(aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa &&
  aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa);

After:
return aaaa & AAAAAAAAAAAAAAAAAAAAAAAAAAAAA ||
       bbbb & BBBBBBBBBBBBBBBBBBBBBBBBBBBBB ||
       cccc & CCCCCCCCCCCCCCCCCCCCCCCCCC ||
       dddd & DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD;
f(aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa,
  aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa,
  aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa);

Future improvements:
- Get rid of some of the hacky ways to nicely format certain constructs.
- Merge this parser and the AnnotatingParser as we now have several parsers
  that analyze (), [], etc.

llvm-svn: 174714
2013-02-08 15:28:42 +00:00
Daniel Jasper acc33666f6 Avoid unnecessary line breaks in nested ObjC calls.
Before:
  [pboard setData:[NSData dataWithBytes:&button
                                 length:sizeof(button)]
          forType:kBookmarkButtonDragType];
After:
  [pboard setData:[NSData dataWithBytes:&button length:sizeof(button)]
          forType:kBookmarkButtonDragType];

llvm-svn: 174701
2013-02-08 08:22:00 +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
Jordan Rose dfbe77cdf5 CMake: Optionally allow running the Clang unit tests in standalone builds.
The reason this is not enabled by default is because there is no way for
Clang to guarantee that the LLVM unit testing infrastruture has been built.
However, if it /has/ been built, there's no reason why the standalone Clang
build can't use it!

This should have no effect on existing builds -- in a combined build the
value of the CLANG_INCLUDE_TESTS option defaults to the LLVM equivalent,
and in a standalone build it defaults to off.

llvm-svn: 174691
2013-02-08 01:42:37 +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 907e126be2 [analyzer] Remove redundant check as per Jordan's feedback.
llvm-svn: 174680
2013-02-07 23:29:22 +00:00
Anna Zaks 297176c393 [analyzer] Fix typo.
llvm-svn: 174679
2013-02-07 23:29:20 +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
Daniel Jasper 1455674741 clang-format: Don't put useless space in f( ::g()).
llvm-svn: 174662
2013-02-07 21:08:36 +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
Dmitri Gribenko 0b62f8a632 libclang: reduce CXString abuse
ContainerUSR is not really a CXString, but it should own the underlying memory
buffer.  Thus, it is better to change the type to std::string.  This will not
introduce extra copying overhead, since the workaround that is being removed
was already making a copy.

llvm-svn: 174647
2013-02-07 19:09:22 +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
Dmitri Gribenko 50e5924e43 Documentation: fix typo: stdard -> stdarg
llvm-svn: 174613
2013-02-07 14:48:33 +00:00
Dmitri Gribenko 90ccd44e94 Documentation: add information about builtin includes to FAQ
llvm-svn: 174612
2013-02-07 14:36:37 +00:00
NAKAMURA Takumi 288c42e936 libclang: CursorVisitor::VisitBuiltinTypeLoc(): Add OCLSampler. [-Wswitch]
llvm-svn: 174606
2013-02-07 12:47:42 +00:00
Manuel Klimek bee085762b Implements equalsNode for Decl and Stmt.
This is a powerful tool when doing iterative refined matches,
where another match is started inside the match callback of the first
one; this allows for example to find out whether the node was in
the condition or body of its parent if-statement.

llvm-svn: 174605
2013-02-07 12:42:10 +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
Richard Smith 9ce12e36ab Simplify FindExternalVisibleDeclsByName by making it return a bool indicating
if it found any decls, rather than returning a list of found decls. This
removes a returning-ArrayRef-to-deleted-storage bug from
MultiplexExternalSemaSource (in code not exercised by any of the clang
binaries), reduces the work required in the found-no-decls case with PCH, and
importantly removes the need for DeclContext::lookup to be reentrant.

No functionality change intended!

llvm-svn: 174576
2013-02-07 03:30:24 +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
Richard Smith fc56746f49 Add a *San + modules FIXME.
llvm-svn: 174565
2013-02-07 01:09:29 +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
Nico Weber 0588b509af Formatter: Move ObjC literal tests to its own test case.
Slightly expand the boxed expressions test with a few more snippets from
http://clang.llvm.org/docs/ObjectiveCLiterals.html

llvm-svn: 174559
2013-02-07 00:19:29 +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
Daniel Jasper f79f935f38 Fix bug in the alignment of comments.
Before:
const char *test[] = {
  // A
  "aaaa",
               // B
  "aaaaa",
};

After:
const char *test[] = {
  // A
  "aaaa",
  // B
  "aaaaa",
};

llvm-svn: 174549
2013-02-06 22:04:05 +00:00
Daniel Jasper ba9ddb66e1 Become a little smarter with formatting long chains of pipes.
Assign a high penalty to breaking before "<<" if the previous token is a
string literal ending in ":" or "=".

Before:
llvm::outs()
    << "aaaaaaaaaaaaaaaaa = " << aaaaaaaaaaaaaaaaa << "bbbbbbbbbbbbbbbbb = "
    << bbbbbbbbbbbbbbbbb << "ccccccccccccccccc = " << ccccccccccccccccc
    << "ddddddddddddddddd = " << ddddddddddddddddd << "eeeeeeeeeeeeeeeee = "
    << eeeeeeeeeeeeeeeee;

After:
llvm::outs() << "aaaaaaaaaaaaaaaaa = " << aaaaaaaaaaaaaaaaa
             << "bbbbbbbbbbbbbbbbb = " << bbbbbbbbbbbbbbbbb
             << "ccccccccccccccccc = " << ccccccccccccccccc
             << "ddddddddddddddddd = " << ddddddddddddddddd
             << "eeeeeeeeeeeeeeeee = " << eeeeeeeeeeeeeeeee;

llvm-svn: 174545
2013-02-06 21:04:05 +00:00
Manuel Klimek 4feac28e0e Cleanup of ASTMatcher macros and adding support for overloaded matchers.
This is in preparation for adding other overloaded matchers. This change
alone is a net win in LOC.
I went through all matchers and looked whether we could now encode them
as macro, or simplify them with the matcher atoms that were not
available before.

llvm-svn: 174540
2013-02-06 20:36:22 +00:00
Daniel Jasper 94f0e1382a Align trailing block comments like trailing line comments.
llvm-svn: 174537
2013-02-06 20:07:35 +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
Douglas Gregor cb680661eb Eliminate a race condition with the global module index.
Essentially, a module file on disk could change size between the time
we stat() it and the time we open it, and we need to be robust against
such a problem.

llvm-svn: 174529
2013-02-06 18:08:37 +00:00
Nico Weber ac9bde236f Formatter: Correctly detect ObjC message expressions preceded by a comment.
llvm-svn: 174521
2013-02-06 16:54:35 +00:00
Manuel Klimek 82b836a61d Fix handling of comments in macros.
We now correctly format:
 // Written as a macro, it is reformatted from:
 #define foo(a)                                                                \
   do {                                                                        \
     /* Initialize num to zero. */                                             \
     int num = 10;                                                             \
     /* This line ensures a is never zero. */                                  \
     int i = a == 0 ? 1 : a;                                                   \
     i = num / i; /* This division is OK. */                                   \
     return i;                                                                 \
   } while (false)

llvm-svn: 174517
2013-02-06 16:40:56 +00:00
Manuel Klimek 046b9306d4 Much semicolon after namespaces.
We now leave the semicolon in the line of the closing brace in:
namespace {
...
};

llvm-svn: 174514
2013-02-06 16:08:09 +00:00
Daniel Jasper c485b4e5b8 Fix formatting of ObjC method calls.
This fixes llvm.org/PR15165.

We now correctly align:
  [image_rep drawInRect:drawRect
               fromRect:NSZeroRect
              operation:NSCompositeCopy
               fraction:1.0
             ssssssssdd:NO
                  hints:nil];

llvm-svn: 174513
2013-02-06 16:00:26 +00:00
Manuel Klimek d265090cd6 Parse record declarations with token pasted identifiers.
This is pretty common in macros:
 #define A(X, Y) class X##Y {};

llvm-svn: 174512
2013-02-06 15:57:54 +00:00
Daniel Jasper 3839659140 Fix a formatting bug caused by comments in expressions.
This fixes llvm.org/PR15162.

Before:
    bool aaaaaaaaaaaaa =  // comment
        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
                          aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
                          aaaaaaaaaaaaaaaaaaaaaaaaaaaaa;

After:
    bool aaaaaaaaaaaaa =  // comment
        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaaa;

llvm-svn: 174508
2013-02-06 15:23:09 +00:00
Daniel Jasper 7fce3ab0f2 Optionally derive formatting information from the input file.
With this patch, clang-format can analyze the input file for two
properties:
1. Is "int *a" or "int* a" more common.
2. Are non-C++03 constructs used, e.g. A<A<A>>.

With Google-style, clang-format will now use the more common style for
(1) and format C++03 compatible, unless it finds C++11 constructs in the
input.

llvm-svn: 174504
2013-02-06 14:22:40 +00:00
Daniel Jasper 8035b0a6ce Fix an issue with the formatting of stars in default values.
Before: void f(int *a = d *e, int b = 0);
After:  void f(int *a = d * e, int b = 0);
llvm-svn: 174500
2013-02-06 10:57:42 +00:00
Manuel Klimek 2cff49e026 Adds a convenience function selectFirst to simplify matching.
A very common use case is to search for the first occurrence of
a certain node that is a descendant of another node. In that
case, selectFirst significantly simplifies the code at the client side.

llvm-svn: 174499
2013-02-06 10:33:21 +00:00
Daniel Jasper c697ad29ff Handle nested ObjC calls.
Properly handle annotation contexts while calculating extra information
for each token. This enable nested ObjC calls and thus solves (most of)
llvm.org/PR15164. E.g., we can now format:

[contentsContainer replaceSubview:[subviews objectAtIndex:0]
                             with:contentsNativeView];

Also fix a problem with the formatting of types in casts as this was
trivial now.

llvm-svn: 174498
2013-02-06 10:05:46 +00:00
Nico Weber 5d2624e53a Formatter: No space after & and * in front of ObjC message expressions.
1. let determineStarAmp() check of unary operators before checking for
   "is next '['". That check was added in r173150, and the test from that
   revision passes either way.

2. change determineStarAmp() to categorize '*' and '&' after '=' as unary
   operator.

3. don't let parseSquare() overwrite the type of a '*' or '&' before the start
   of an objc message expression if has the role of unary operator.

llvm-svn: 174489
2013-02-06 06:20:11 +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
Chad Rosier 7029992807 Use a dyn_cast to avoid a crash when the TypeLoc is not a ConstantArrayTypeLoc.
rdar://13153516

llvm-svn: 174477
2013-02-06 00:58:34 +00:00
Daniel Dunbar 230cc79394 [Headers] Use standard builtin defines instead of typeof trickery.
- The trickery can confuse more basic source processors, in particular the
   Unix conformance tool that wants to scan headers.

llvm-svn: 174475
2013-02-06 00:38:13 +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
Renato Golin 2de5efe65b Adding armv7l default to cortex-a8
llvm-svn: 174466
2013-02-05 23:42:01 +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 7d86b9ce1e Add note why we used a switch.
llvm-svn: 174449
2013-02-05 22:03:14 +00:00
Douglas Gregor 948321e328 Minor tweak to install docs
llvm-svn: 174448
2013-02-05 22:01:16 +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
Douglas Gregor 1288408984 Remove an uninteresting note
llvm-svn: 174441
2013-02-05 21:13:55 +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
Anna Zaks 064185a8ce [analyzer] add comment
llvm-svn: 174435
2013-02-05 19:52:26 +00:00
Anna Zaks b28cf9965c [analyzer] Fix typo, better doxygen as per Jordan's feedback.
llvm-svn: 174434
2013-02-05 19:52:24 +00:00
Jordan Rose 1f25dcb167 [analyzer] Add a doc describing the internals of RegionStore.
This is a text file with Markdown-ish formatting because we haven't decided
where analyzer internal documents should go, but it's probably better to
have this in source control than sitting on my local drive forever.

llvm-svn: 174398
2013-02-05 17:31:34 +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
Nico Weber b76de88288 Formatter: Detect ObjC method expressions after unary operators.
llvm-svn: 174384
2013-02-05 16:21:00 +00:00
Daniel Jasper 1ac3e05bbd Initial support for formatting ObjC method declarations/calls.
We can now format stuff like:
- (void)doSomethingWith:(GTMFoo *)theFoo
                   rect:(NSRect)theRect
               interval:(float)theInterval {
  [myObject doFooWith:arg1 //
                 name:arg2
                error:arg3];

}

This seems to fix everything mentioned in llvm.org/PR14939.

llvm-svn: 174364
2013-02-05 10:07:47 +00:00
Daniel Jasper b9ebd5d30e Fix some linebreak decisions in Google format.
Before:
f(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa +
  aaaaaaaaaaaaaaaaaaaa);
aaaaaaa(aaaaaaaaaaaaa, aaaaaaaaaaaaa, aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa,
                                                    aaaaaaaaaaaaaaaa));

After:
f(aaaaaaaaaaaaaaaaaaaa,
  aaaaaaaaaaaaaaaaaaaa,
  aaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaa);
aaaaaaa(aaaaaaaaaaaaa,
        aaaaaaaaaaaaa,
        aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaa));

llvm-svn: 174363
2013-02-05 09:41:21 +00:00
Daniel Jasper a885dbeb96 Fix formatting regression introduced by r174307.
In preprocessor definitions, we would not parse all the tokens and thus
not annotate them anymore. This led to a wrong formatting of comments
in google style:

  #endif // HEADER_GUARD  -- requires two spaces

llvm-svn: 174361
2013-02-05 09:34:14 +00:00
Arnaud A. de Grandmaison 49c04467ea Fix typo in comment
llvm-svn: 174359
2013-02-05 09:06:17 +00:00
NAKAMURA Takumi 0120178909 TextDiagnostic.cpp: Suppress a warning to use ptrdiff_t on i686-clang. [-Wsign-compare]
llvm-svn: 174353
2013-02-05 07:37:07 +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
Eric Christopher c4b0be9700 Spaces instead of tabs.
llvm-svn: 174348
2013-02-05 07:29:49 +00:00
Ted Kremenek 653f523664 Revert "Remove sparse text on diagnostic options. These are not really documented anywhere, and they really aren't for normal users."
I changed my mind.  We should just document these in the man page.

llvm-svn: 174344
2013-02-05 06:33:47 +00:00
Ted Kremenek 03cb13751f Remove dead code related to the now defunct PCH stat cache.
llvm-svn: 174342
2013-02-05 06:21:59 +00:00
Nick Lewycky 192542ce38 Test for virtual instead of pure here. It has the exact same effect, and John
claims it will improve performance.

llvm-svn: 174341
2013-02-05 06:20:31 +00:00
Richard Smith 9ca910111c PR15095: Use more correct source locations for the InitListExpr we fake up for
vector initialization. Patch by John Stratton!

llvm-svn: 174339
2013-02-05 05:55:57 +00:00
Ted Kremenek e2af9b5d2c Remove sparse text on diagnostic options. These are not really documented anywhere, and they really aren't for normal users.
llvm-svn: 174338
2013-02-05 05:55:21 +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
Manuel Klimek abf4371339 Implements the convenience matcher findAll.
We found that findAll has been implemented incorrectly multiple times
by various people using the matchers. To prevent further wasted
development effort, it makes sense to add it as convenience matcher
implemented as eachOf(m, forEachDescendant(m)).

This patch also updates the docs with the new matchers.

llvm-svn: 174320
2013-02-04 10:59:20 +00:00
Manuel Klimek 88b9587293 Add an eachOf matcher.
eachOf gives closure on the forEach and forEachDescendant matchers.
Before, it was impossible to implement a findAll matcher, as matching
the node or any of its descendants was not expressible (since anyOf
only triggers the first match).

llvm-svn: 174315
2013-02-04 09:42:38 +00:00
Daniel Jasper 14e40ec828 Improve handling of trailing block comments
This is a follow up to r174309 to actually make it work.

llvm-svn: 174314
2013-02-04 08:34:57 +00:00
Daniel Jasper 2603ee0dc6 Improve formatting of stream operators.
If there are string literals on either side of a '<<', chances are
high that they represent logically separate concepts. Otherwise,
the author could just have just a single literal (possible split
over multiple lines).

So, we can now nicely format things like:
cout << "somepacket = {\n"
     << "  val a = " << ValueA << "\n"
     << "  val b = " << ValueB << "\n"
     << "}";

llvm-svn: 174310
2013-02-04 07:34:48 +00:00
Daniel Jasper 1f140981b6 Improve handling of trailing block comments.
We can now (even in non-bin-packing modes) format:
someFunction(1, /* comment 1 */
             2, /* comment 2 */
             3, /* comment 3 */
             aaa);

llvm-svn: 174309
2013-02-04 07:32:14 +00:00
Daniel Jasper f7f13c0ef2 Fix an error in formatting of for-loops.
Two minor changes:
* Slight penalty for breaking at "," as opposed to ";".
* Don't apply bin-packing rules to for-loops.

Before:
for (int aaaaaa = aaaaaaaaaa; aaaaaa < bbbbbbbb; ++aaaaaa,
         ++ccccccccccccccc) {}

After:
for (int aaaaaa = aaaaaaaaaa; aaaaaa < bbbbbbbb;
     ++aaaaaa, ++ccccccccccccccc) {}

llvm-svn: 174308
2013-02-04 07:30:30 +00:00
Daniel Jasper 3a9370cbca Restructuring of token annotation for formatting.
This combines several changes:
* Calculation token type (e.g. for * and &) in the AnnotatingParser.
* Calculate the scope binding strength in the AnnotatingParser.
* Let <> and [] scopes bind stronger than () and {} scopes.
* Add minimal debugging output.

llvm-svn: 174307
2013-02-04 07:21:18 +00:00
NAKAMURA Takumi cc4aaef0f2 clang/Analysis: Fix r174245, a valgrind error in AnalysisDeclContext::getBody(bool &IsAutosynthesized), to initialize IsAutosynthesized explicitly.
llvm-svn: 174303
2013-02-04 05:06:21 +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 325d74566f CodeGen: Remove unnecessary const_casts. No functionality change.
llvm-svn: 174292
2013-02-03 18:55:34 +00:00
Daniel Jasper 1ca05ccf68 Fix bug in formatting of nested initializers.
We can now format:
SomeArrayOfSomeType a = { { { 1, 2, 3 } }, { { 1, 2, 3 } },
                          { { 111111111111111111111111111111,
                              222222222222222222222222222222,
                              333333333333333333333333333333 } },
                          { { 1, 2, 3 } }, { { 1, 2, 3 } } };

Before, we did strange things there.

llvm-svn: 174291
2013-02-03 18:07:15 +00:00
Dmitri Gribenko 2aedfbd177 Comment to XML conversion: replace string comparison with command ID comparison
llvm-svn: 174290
2013-02-03 17:48:05 +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
Dmitri Gribenko fb04e1b40c Remove unneeded const_casts
llvm-svn: 174287
2013-02-03 16:10:26 +00:00
Dmitri Gribenko 18aa3bb819 libclang: wrap CXString implementation into 'namespace cxstring'
This removes quite a few 'cxstring::' qualifications where they are obvious.

llvm-svn: 174286
2013-02-03 13:54:26 +00:00
Dmitri Gribenko 7489521eec libclang: remove 'using namespace cxstring'
llvm-svn: 174285
2013-02-03 13:52:47 +00:00
Dmitri Gribenko bf7bf10d45 libclang: migrate IndexingDeclVisitor to ConstDeclVisitor
llvm-svn: 174284
2013-02-03 13:42:20 +00:00
Dmitri Gribenko d73f73b0dd libclang: remove unneeded const_cast
llvm-svn: 174283
2013-02-03 13:26:20 +00:00
Dmitri Gribenko 37527c242a Constify ASTContext::getObjContainingInterface
llvm-svn: 174282
2013-02-03 13:23:21 +00:00
Dmitri Gribenko 82700578d4 libclang: migrate USRGenerator to ConstDeclVisitor
llvm-svn: 174281
2013-02-03 13:21:23 +00:00
Dmitri Gribenko dd7dacfff9 libclang: remove unneeded const_casts
llvm-svn: 174280
2013-02-03 13:19:54 +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
Dmitri Gribenko 2f23e9c520 libclang: introduce cxstring::{createRef,createDup} for StringRefs
Also migrate all clients from the old API.

llvm-svn: 174263
2013-02-02 02:19:29 +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
Ted Kremenek 26c777c409 Add some horrible Perl code to teach scan-build to recursively walk a directory for HTML files.
llvm-svn: 174260
2013-02-02 01:52:41 +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
Ted Kremenek f5209c4b45 Revert "Update checker build to checker-271."
Turns out we didn't update scan-build to work with HTML files in nested directories.

llvm-svn: 174256
2013-02-02 01:06:22 +00:00
Michael Gottesman be9614c755 Fixed another whitespace issue... *sigh*.
llvm-svn: 174255
2013-02-02 01:05:06 +00:00
Michael Gottesman b46072d7ac Fixed whitespace.
llvm-svn: 174254
2013-02-02 01:03:01 +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
Ted Kremenek 93482a523c Update checker build to checker-271.
llvm-svn: 174252
2013-02-02 00:57:28 +00:00
David Blaikie b7d1e1ff57 Revert r174246, accidentally committed.
This reverts commit 1513eb9284c23acfd19cf742b95996fbb11ca741.

llvm-svn: 174249
2013-02-02 00:39:32 +00:00
David Blaikie cbf40d22bf Sentenc-ify comment added in r174206.
Based on post-commit review by Paul Robinson.

llvm-svn: 174248
2013-02-02 00:36:58 +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
David Blaikie ef50169a03 Basics
llvm-svn: 174246
2013-02-02 00:34:16 +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
Anna Zaks e9eb13aba3 [analyzer] Print Inline mode with -analyzer-display-progress.
llvm-svn: 174244
2013-02-02 00:30:02 +00:00
Anna Zaks 10641e66b0 [analyzer] Fix typo.
llvm-svn: 174243
2013-02-02 00:29:59 +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
Dmitri Gribenko 3c66b0be90 libclang: introduce cxstring::{createRef,createDup} for C strings
Also migrate all clients from the old API.

llvm-svn: 174238
2013-02-02 00:02:12 +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
Argyrios Kyrtzidis a364782a15 Const'ify Preprocessor::getPredefinesFileID.
llvm-svn: 174218
2013-02-01 20:35:47 +00:00
Dmitri Gribenko 8db86f6501 Unbreak Makefile build after r174216
llvm-svn: 174217
2013-02-01 20:30:26 +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
Chad Rosier dbf46a16c7 [driver] Don't try to generate diagnostic information for dsymutil crashes.
Part of rdar://13134273

llvm-svn: 174203
2013-02-01 18:30:26 +00:00
Alexander Kornienko b98f6e5bd0 Micro change: moved '{' for better readability (+don't confuse -Wimplicit-fallthrough)
llvm-svn: 174202
2013-02-01 18:28:04 +00:00
Dmitri Gribenko d2f96ef091 Fix indent
llvm-svn: 174201
2013-02-01 18:18:00 +00:00
Dmitri Gribenko f7d563c160 Fix comments: these are not trailing comments
llvm-svn: 174197
2013-02-01 17:25:11 +00:00
Dmitri Gribenko 946aca8524 libclang: document the purpose of createNull()
llvm-svn: 174195
2013-02-01 16:38:41 +00:00
Dmitri Gribenko 74f3e1e028 libclang: add comments for CXStringFlag
llvm-svn: 174194
2013-02-01 16:36:31 +00:00
Argyrios Kyrtzidis 71c1af8760 [modules] Introduce ModuleFile::DirectImportLoc which is the source location
where the module was explicitly or implicitly imported in the local translation unit.

llvm-svn: 174192
2013-02-01 16:36:14 +00:00
Argyrios Kyrtzidis 125df0589b For ModuleLoader::makeModuleVisible() also pass the source location where the
module import occurred.

llvm-svn: 174191
2013-02-01 16:36:12 +00:00
Argyrios Kyrtzidis 22c22f5f9a Introduce SourceManager::PredefinesFileID, to allow each checking of whether
a source location came from the predefines buffer.

llvm-svn: 174190
2013-02-01 16:36:07 +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
Dmitri Gribenko 36a6dd04ef libclang: itroduce cxstring::createEmpty()
llvm-svn: 174174
2013-02-01 14:21:22 +00:00
Dmitri Gribenko f98dfbae94 libclang: introduce cxstring::createNull()
llvm-svn: 174173
2013-02-01 14:13:32 +00:00
Manuel Klimek 191c093af1 Re-design the convenience interfaces on MatchFinder.
First, this implements a match() method on MatchFinder; this allows us
to get rid of the findAll implementation, as findAll is really a special
case of recursive matchers on match.

Instead of findAll, provide a convenience function match() that lets
users iterate easily over the results instead of needing to implement
callbacks.

llvm-svn: 174172
2013-02-01 13:41:35 +00:00
Alexander Kornienko 540bacb1b9 Use const visitors in ASTDumper.
http://llvm-reviews.chandlerc.com/D355
Patch by Philip Craig!

llvm-svn: 174171
2013-02-01 12:35:51 +00:00
Daniel Jasper 83d4e783b0 Hopefully fix windows build due to non-standard pair implementation.
llvm-svn: 174169
2013-02-01 11:28:16 +00:00
Daniel Jasper 4b866274c3 Revamp of the basic layouting algorithm in clang-format.
In order to end up with good solutions, clang-format needs to try
"all" combinations of line breaks, evaluate them and select the
best one. Before, we have done this using a DFS with memoization
and cut-off conditions. However, this approach is very limited
as shown by the huge static initializer in the attachment of
llvm.org/PR14959.

Instead, this new implementation uses a variant of Dijkstra's
algorithm to do a prioritized BFS over the solution space.

Some numbers:
lib/Format/TokenAnnotator.cpp: 1.5s -> 0.15s
Attachment of PR14959: 10min+ (didn't finish) -> 10s

No functional changes intended.

llvm-svn: 174166
2013-02-01 11:00:45 +00:00