]> granicus.if.org Git - clang/log
clang
11 years agoFileCheck'ize tests
Dmitri Gribenko [Sat, 9 Feb 2013 16:41:47 +0000 (16:41 +0000)]
FileCheck'ize tests

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174815 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFileCheck'ize a test
Dmitri Gribenko [Sat, 9 Feb 2013 16:25:38 +0000 (16:25 +0000)]
FileCheck'ize a test

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174814 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoRemove unreachable statement
Dmitri Gribenko [Sat, 9 Feb 2013 15:24:28 +0000 (15:24 +0000)]
Remove unreachable statement

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174811 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoComment parsing: use CharInfo.h
Dmitri Gribenko [Sat, 9 Feb 2013 15:16:58 +0000 (15:16 +0000)]
Comment parsing: use CharInfo.h

This also gives us 0.2% speedup on '-fsyntax-only -Wdocumentation' time for
a testcase that consists of all Clang headers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174810 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agolibclang: use CXCursor getters to simplify code
Dmitri Gribenko [Sat, 9 Feb 2013 14:12:09 +0000 (14:12 +0000)]
libclang: use CXCursor getters to simplify code

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174809 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoRemove some stray uses of <ctype.h> functions.
Jordan Rose [Sat, 9 Feb 2013 10:09:43 +0000 (10:09 +0000)]
Remove some stray uses of <ctype.h> functions.

These are causing assertions on some MSVC builds.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174805 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoQoI: -Wreadonly-iboutlet-property should have the warning's location on the property.
Ted Kremenek [Sat, 9 Feb 2013 07:13:16 +0000 (07:13 +0000)]
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>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174802 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoRelease notes: mention support for Unicode and UCNs in identifiers.
Jordan Rose [Sat, 9 Feb 2013 02:12:23 +0000 (02:12 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174798 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoEnsure that type definitions present in just-loaded modules are
Douglas Gregor [Sat, 9 Feb 2013 01:35:03 +0000 (01:35 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174794 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoclang/lib/StaticAnalyzer/Core/BugReporter.cpp: Appease old msvc in std::pair(0, 0).
NAKAMURA Takumi [Sat, 9 Feb 2013 01:22:23 +0000 (01:22 +0000)]
clang/lib/StaticAnalyzer/Core/BugReporter.cpp: Appease old msvc in std::pair(0, 0).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174792 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoProperly validate UCNs for C99 and C++03 (both more restrictive than C(++)11).
Jordan Rose [Sat, 9 Feb 2013 01:10:25 +0000 (01:10 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174788 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[analyzer] Invalidation checker: move the "missing implementation" check
Anna Zaks [Sat, 9 Feb 2013 01:09:27 +0000 (01:09 +0000)]
[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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174787 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[analyzer] Move DefaultBool so that all checkers can share it.
Anna Zaks [Fri, 8 Feb 2013 23:55:50 +0000 (23:55 +0000)]
[analyzer] Move DefaultBool so that all checkers can share it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174782 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[analyzer] Split IvarInvalidation into two checkers
Anna Zaks [Fri, 8 Feb 2013 23:55:47 +0000 (23:55 +0000)]
[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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174781 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[analyzer] IvarInvalidation: refactor, pull out the diagnostic printing
Anna Zaks [Fri, 8 Feb 2013 23:55:45 +0000 (23:55 +0000)]
[analyzer] IvarInvalidation: refactor, pull out the diagnostic printing

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174780 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[analyzer] IvarInvalidation: add annotation for partial invalidation
Anna Zaks [Fri, 8 Feb 2013 23:55:43 +0000 (23:55 +0000)]
[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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174779 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoobjective-C: don't issue bogus warning about
Fariborz Jahanian [Fri, 8 Feb 2013 23:32:30 +0000 (23:32 +0000)]
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174775 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoCharInfo: Add missing "using namespace clang::charinfo" in .cpp file.
Jordan Rose [Fri, 8 Feb 2013 22:37:49 +0000 (22:37 +0000)]
CharInfo: Add missing "using namespace clang::charinfo" in .cpp file.

Should fix the MSC bot.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174769 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoExcise <cctype> from Clang (except clang-tblgen) in favor of CharInfo.h.
Jordan Rose [Fri, 8 Feb 2013 22:30:41 +0000 (22:30 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174768 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoSimplify logic for avoiding concatenation after numeric constants.
Jordan Rose [Fri, 8 Feb 2013 22:30:31 +0000 (22:30 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174767 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoStmtPrinter: Write large char values using \u or \U.
Jordan Rose [Fri, 8 Feb 2013 22:30:27 +0000 (22:30 +0000)]
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).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174766 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoPull Lexer's CharInfo table out for general use throughout Clang.
Jordan Rose [Fri, 8 Feb 2013 22:30:22 +0000 (22:30 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174765 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoNote that checker-271 is newer than the analyzer in Xcode 4.6
Ted Kremenek [Fri, 8 Feb 2013 22:19:43 +0000 (22:19 +0000)]
Note that checker-271 is newer than the analyzer in Xcode 4.6

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174759 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoUpdate open source checker build to checker-271.
Ted Kremenek [Fri, 8 Feb 2013 22:18:26 +0000 (22:18 +0000)]
Update open source checker build to checker-271.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174758 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAlways keep highest identifier, selector, and macro IDs when we've
Douglas Gregor [Fri, 8 Feb 2013 21:30:59 +0000 (21:30 +0000)]
Always keep highest identifier, selector, and macro IDs when we've
read another one, just as we do for types.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174745 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoNever cache the result of a module file lookup.
Douglas Gregor [Fri, 8 Feb 2013 21:27:45 +0000 (21:27 +0000)]
Never cache the result of a module file lookup.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174744 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix indentation-detection at indent level 0.
Manuel Klimek [Fri, 8 Feb 2013 19:53:32 +0000 (19:53 +0000)]
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;'.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174737 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoTeach BugReporter (extensive diagnostics) to emit a diagnostic when a loop body is...
Ted Kremenek [Fri, 8 Feb 2013 19:51:43 +0000 (19:51 +0000)]
Teach BugReporter (extensive diagnostics) to emit a diagnostic when a loop body is skipped.

Fixes <rdar://problem/12322528>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174736 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[libclang] Add a test to make sure annotation works fine in the presence of
Argyrios Kyrtzidis [Fri, 8 Feb 2013 19:27:23 +0000 (19:27 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174734 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoRemove stale instance variable.
Ted Kremenek [Fri, 8 Feb 2013 18:59:17 +0000 (18:59 +0000)]
Remove stale instance variable.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174730 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoobjective-C modern translation: Fix another random translation bug
Fariborz Jahanian [Fri, 8 Feb 2013 18:57:50 +0000 (18:57 +0000)]
objective-C modern translation: Fix another random translation bug
involving property getter expressions on rhs of property setter.
// rdar://13138459

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174729 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoTakes the context into account when re-indenting regions.
Manuel Klimek [Fri, 8 Feb 2013 17:38:27 +0000 (17:38 +0000)]
Takes the context into account when re-indenting regions.

Fixes llvm.org/PR14916.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174720 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoobjective-C modern translator. Fixes a trivial
Fariborz Jahanian [Fri, 8 Feb 2013 17:15:07 +0000 (17:15 +0000)]
objective-C modern translator. Fixes a trivial
rewriting bug where #ifdef ended up on the same
line as the attribute declaration.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174719 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix handling of fake parenthesis during formatting.
Daniel Jasper [Fri, 8 Feb 2013 16:49:27 +0000 (16:49 +0000)]
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);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174718 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoImplement a tiny expression parser to improve formatting decisions.
Daniel Jasper [Fri, 8 Feb 2013 15:28:42 +0000 (15:28 +0000)]
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 && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa && 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174714 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAvoid unnecessary line breaks in nested ObjC calls.
Daniel Jasper [Fri, 8 Feb 2013 08:22:00 +0000 (08:22 +0000)]
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];

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174701 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoImprove filechecking of volatile test.
Tim Northover [Fri, 8 Feb 2013 08:00:13 +0000 (08:00 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174700 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoCMake: Include Clang unit tests in check-clang target in standalone builds.
Jordan Rose [Fri, 8 Feb 2013 07:28:25 +0000 (07:28 +0000)]
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).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174698 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix test failure by making sure this file isn't identical to any other file
Nick Lewycky [Fri, 8 Feb 2013 02:38:30 +0000 (02:38 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174694 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoCMake: Optionally allow running the Clang unit tests in standalone builds.
Jordan Rose [Fri, 8 Feb 2013 01:42:37 +0000 (01:42 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174691 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix conflict between r174685 and r174645 (rename -fmodule-cache-path <foo> to -fmodul...
Richard Smith [Fri, 8 Feb 2013 01:35:44 +0000 (01:35 +0000)]
Fix conflict between r174685 and r174645 (rename -fmodule-cache-path <foo> to -fmodules-cache-path=<foo>).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174690 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[libclang] Attribute visitation happens out-of-source-order, make sure
Argyrios Kyrtzidis [Fri, 8 Feb 2013 01:12:25 +0000 (01:12 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174689 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoUse the target address space value when mangling names.
Tanya Lattner [Fri, 8 Feb 2013 01:07:32 +0000 (01:07 +0000)]
Use the target address space value when mangling names.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174688 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix stack overflow and improve performance when a module contains many
Richard Smith [Fri, 8 Feb 2013 00:37:45 +0000 (00:37 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174685 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoobjective-C modern translator. Generate #line
Fariborz Jahanian [Fri, 8 Feb 2013 00:27:34 +0000 (00:27 +0000)]
objective-C modern translator. Generate #line
info in the translated code under -g only.
// rdar://13138170

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174684 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoTeach subframework header lookup to suggest modules <rdar://problem/13176200>.
Douglas Gregor [Fri, 8 Feb 2013 00:10:48 +0000 (00:10 +0000)]
Teach subframework header lookup to suggest modules <rdar://problem/13176200>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174683 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[analyzer] Remove redundant check as per Jordan's feedback.
Anna Zaks [Thu, 7 Feb 2013 23:29:22 +0000 (23:29 +0000)]
[analyzer] Remove redundant check as per Jordan's feedback.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174680 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[analyzer] Fix typo.
Anna Zaks [Thu, 7 Feb 2013 23:29:20 +0000 (23:29 +0000)]
[analyzer] Fix typo.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174679 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[analyzer] Report bugs when freeing memory with offset pointer
Anna Zaks [Thu, 7 Feb 2013 23:05:47 +0000 (23:05 +0000)]
[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!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174678 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[analyzer] Add pointer escape type param to checkPointerEscape callback
Anna Zaks [Thu, 7 Feb 2013 23:05:43 +0000 (23:05 +0000)]
[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!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174677 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[analyzer] Don't reinitialize static globals more than once along a path
Anna Zaks [Thu, 7 Feb 2013 23:05:37 +0000 (23:05 +0000)]
[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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174676 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoForm the default -fmodules-cache-path= properly.
Douglas Gregor [Thu, 7 Feb 2013 22:59:12 +0000 (22:59 +0000)]
Form the default -fmodules-cache-path= properly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174674 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoobjective-C modern translator. More fixups for
Fariborz Jahanian [Thu, 7 Feb 2013 22:50:40 +0000 (22:50 +0000)]
objective-C modern translator. More fixups for
modern meta-data abi translation. Still wip.
// rdar://13138459

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174672 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoclang-format: Don't put useless space in f( ::g()).
Daniel Jasper [Thu, 7 Feb 2013 21:08:36 +0000 (21:08 +0000)]
clang-format: Don't put useless space in f( ::g()).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174662 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAdd missing header from r174648
Douglas Gregor [Thu, 7 Feb 2013 19:15:44 +0000 (19:15 +0000)]
Add missing header from r174648

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174649 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoRetain all hidden methods in the global method pool, because they may become visible...
Douglas Gregor [Thu, 7 Feb 2013 19:13:24 +0000 (19:13 +0000)]
Retain all hidden methods in the global method pool, because they may become visible <rdar://problem/13172858>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174648 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agolibclang: reduce CXString abuse
Dmitri Gribenko [Thu, 7 Feb 2013 19:09:22 +0000 (19:09 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174647 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoRename -fmodule-cache-path <blah> to -fmodules-cache-path=<blah> for consistency.
Douglas Gregor [Thu, 7 Feb 2013 19:01:24 +0000 (19:01 +0000)]
Rename -fmodule-cache-path <blah> to -fmodules-cache-path=<blah> for consistency.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174645 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoThread safety analysis: make sure that expressions in attributes are parsed
DeLesley Hutchins [Thu, 7 Feb 2013 19:01:07 +0000 (19:01 +0000)]
Thread safety analysis: make sure that expressions in attributes are parsed
in an unevaluated context.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174644 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoTestcase for r174477.
Chad Rosier [Thu, 7 Feb 2013 18:32:25 +0000 (18:32 +0000)]
Testcase for r174477.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174640 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoEnable overloading of OpenCL events - this is needed for the overloaded OpenCL builti...
Guy Benyei [Thu, 7 Feb 2013 16:05:33 +0000 (16:05 +0000)]
Enable overloading of OpenCL events - this is needed for the overloaded OpenCL builtin functions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174630 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFileCheckize volatile test
Tim Northover [Thu, 7 Feb 2013 15:39:16 +0000 (15:39 +0000)]
FileCheckize volatile test

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174627 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoOnly check for volatile memcpys in test.
Tim Northover [Thu, 7 Feb 2013 15:11:48 +0000 (15:11 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174621 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAdd AArch64 wchar definition to test
Tim Northover [Thu, 7 Feb 2013 15:11:44 +0000 (15:11 +0000)]
Add AArch64 wchar definition to test

This should allow it to pass if the default triple is AArch64

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174620 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoXFAIL test that's inappropriate for AArch64 ABI
Tim Northover [Thu, 7 Feb 2013 15:11:40 +0000 (15:11 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174619 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoPermit ABIs where the caller extends the result (test change).
Tim Northover [Thu, 7 Feb 2013 15:11:36 +0000 (15:11 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174618 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoDocumentation: fix typo: stdard -> stdarg
Dmitri Gribenko [Thu, 7 Feb 2013 14:48:33 +0000 (14:48 +0000)]
Documentation: fix typo: stdard -> stdarg

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174613 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoDocumentation: add information about builtin includes to FAQ
Dmitri Gribenko [Thu, 7 Feb 2013 14:36:37 +0000 (14:36 +0000)]
Documentation: add information about builtin includes to FAQ

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174612 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agolibclang: CursorVisitor::VisitBuiltinTypeLoc(): Add OCLSampler. [-Wswitch]
NAKAMURA Takumi [Thu, 7 Feb 2013 12:47:42 +0000 (12:47 +0000)]
libclang: CursorVisitor::VisitBuiltinTypeLoc(): Add OCLSampler. [-Wswitch]

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174606 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoImplements equalsNode for Decl and Stmt.
Manuel Klimek [Thu, 7 Feb 2013 12:42:10 +0000 (12:42 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174605 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAdd OpenCL samplers as Clang builtin types and check sampler related restrictions.
Guy Benyei [Thu, 7 Feb 2013 10:55:47 +0000 (10:55 +0000)]
Add OpenCL samplers as Clang builtin types and check sampler related restrictions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174601 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoApply the pure-virtual odr rule to other constructs which can call overloaded
Nick Lewycky [Thu, 7 Feb 2013 05:08:22 +0000 (05:08 +0000)]
Apply the pure-virtual odr rule to other constructs which can call overloaded
operators.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174584 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix handling of module imports adding names to a DeclContext after qualified
Richard Smith [Thu, 7 Feb 2013 03:37:08 +0000 (03:37 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174577 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoSimplify FindExternalVisibleDeclsByName by making it return a bool indicating
Richard Smith [Thu, 7 Feb 2013 03:30:24 +0000 (03:30 +0000)]
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!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174576 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago-Wimplicit-fallthrough: fixed two cases where "fallthrough annotation in unreachable...
Alexander Kornienko [Thu, 7 Feb 2013 02:17:19 +0000 (02:17 +0000)]
-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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174575 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoobjective-C modern translator. Fix up the translated
Fariborz Jahanian [Thu, 7 Feb 2013 01:53:15 +0000 (01:53 +0000)]
objective-C modern translator. Fix up the translated
metadata to handle ivar bitfields. This is wip.
// rdar://13138459

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174573 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAST dumping: indicate the previous declaration for a redeclaration, and
Richard Smith [Thu, 7 Feb 2013 01:35:44 +0000 (01:35 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174570 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoBe a little more permissive with -fmodules-ignore-macro= by removing everything after...
Douglas Gregor [Thu, 7 Feb 2013 01:18:48 +0000 (01:18 +0000)]
Be a little more permissive with -fmodules-ignore-macro= by removing everything after the second '=' if it is there.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174567 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAdd a *San + modules FIXME.
Richard Smith [Thu, 7 Feb 2013 01:09:29 +0000 (01:09 +0000)]
Add a *San + modules FIXME.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174565 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoIntroduce -fmodules-ignore-macro=NNN to ignore a macro when building/loading modules.
Douglas Gregor [Thu, 7 Feb 2013 00:21:12 +0000 (00:21 +0000)]
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>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174560 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFormatter: Move ObjC literal tests to its own test case.
Nico Weber [Thu, 7 Feb 2013 00:19:29 +0000 (00:19 +0000)]
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174559 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoDetect when we end up trying to load conflicting module files.
Douglas Gregor [Wed, 6 Feb 2013 22:40:31 +0000 (22:40 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174554 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix bug in the alignment of comments.
Daniel Jasper [Wed, 6 Feb 2013 22:04:05 +0000 (22:04 +0000)]
Fix bug in the alignment of comments.

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

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174549 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoBecome a little smarter with formatting long chains of pipes.
Daniel Jasper [Wed, 6 Feb 2013 21:04:05 +0000 (21:04 +0000)]
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;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174545 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoCleanup of ASTMatcher macros and adding support for overloaded matchers.
Manuel Klimek [Wed, 6 Feb 2013 20:36:22 +0000 (20:36 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174540 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAlign trailing block comments like trailing line comments.
Daniel Jasper [Wed, 6 Feb 2013 20:07:35 +0000 (20:07 +0000)]
Align trailing block comments like trailing line comments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174537 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoRemove unneeded test. We have plenty of subgroup relations between warnings,
Ted Kremenek [Wed, 6 Feb 2013 19:24:28 +0000 (19:24 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174531 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAccept and ignore the -fextended-identifiers option.
Jordan Rose [Wed, 6 Feb 2013 18:15:40 +0000 (18:15 +0000)]
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174530 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoEliminate a race condition with the global module index.
Douglas Gregor [Wed, 6 Feb 2013 18:08:37 +0000 (18:08 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174529 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFormatter: Correctly detect ObjC message expressions preceded by a comment.
Nico Weber [Wed, 6 Feb 2013 16:54:35 +0000 (16:54 +0000)]
Formatter: Correctly detect ObjC message expressions preceded by a comment.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174521 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix handling of comments in macros.
Manuel Klimek [Wed, 6 Feb 2013 16:40:56 +0000 (16:40 +0000)]
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)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174517 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoMuch semicolon after namespaces.
Manuel Klimek [Wed, 6 Feb 2013 16:08:09 +0000 (16:08 +0000)]
Much semicolon after namespaces.

We now leave the semicolon in the line of the closing brace in:
namespace {
...
};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174514 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix formatting of ObjC method calls.
Daniel Jasper [Wed, 6 Feb 2013 16:00:26 +0000 (16:00 +0000)]
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];

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174513 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoParse record declarations with token pasted identifiers.
Manuel Klimek [Wed, 6 Feb 2013 15:57:54 +0000 (15:57 +0000)]
Parse record declarations with token pasted identifiers.

This is pretty common in macros:
 #define A(X, Y) class X##Y {};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174512 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix a formatting bug caused by comments in expressions.
Daniel Jasper [Wed, 6 Feb 2013 15:23:09 +0000 (15:23 +0000)]
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;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174508 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoOptionally derive formatting information from the input file.
Daniel Jasper [Wed, 6 Feb 2013 14:22:40 +0000 (14:22 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174504 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix an issue with the formatting of stars in default values.
Daniel Jasper [Wed, 6 Feb 2013 10:57:42 +0000 (10:57 +0000)]
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);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174500 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAdds a convenience function selectFirst to simplify matching.
Manuel Klimek [Wed, 6 Feb 2013 10:33:21 +0000 (10:33 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174499 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoHandle nested ObjC calls.
Daniel Jasper [Wed, 6 Feb 2013 10:05:46 +0000 (10:05 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174498 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFormatter: No space after & and * in front of ObjC message expressions.
Nico Weber [Wed, 6 Feb 2013 06:20:11 +0000 (06:20 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174489 91177308-0d34-0410-b5e6-96231b3b80d8