]> granicus.if.org Git - clang/log
clang
11 years agoclang/test/Index/annotate-tokens.cpp: Appease msvc-targets with -fno-delayed-template...
NAKAMURA Takumi [Mon, 8 Apr 2013 23:05:10 +0000 (23:05 +0000)]
clang/test/Index/annotate-tokens.cpp: Appease msvc-targets with -fno-delayed-template-parsing.

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

11 years agoRecognize function-like macro usages without semicolon in declaration context.
Alexander Kornienko [Mon, 8 Apr 2013 22:16:06 +0000 (22:16 +0000)]
Recognize function-like macro usages without semicolon in declaration context.

Summary:
Preserve line breaks after function-like macro usages without
semicolon, e.g.:

QQQ(xxx)
class X {
};

Reviewers: djasper, klimek

Reviewed By: djasper

CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D638

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

11 years agoFix typo in assertion.
Nick Lewycky [Mon, 8 Apr 2013 21:55:21 +0000 (21:55 +0000)]
Fix typo in assertion.

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

11 years agoThe PNaCl target no longer permits __attribute__((regparm)).
Eli Bendersky [Mon, 8 Apr 2013 21:31:01 +0000 (21:31 +0000)]
The PNaCl target no longer permits __attribute__((regparm)).

Remove the custom lowering code dealing with it, disallow it in PNaclTargetInfo
and adjust tests accordingly.

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

11 years ago<rdar://problem/13559825> Further reduce template instantiation depth down to 256...
Douglas Gregor [Mon, 8 Apr 2013 21:13:13 +0000 (21:13 +0000)]
<rdar://problem/13559825> Further reduce template instantiation depth down to 256, since we're blowing the stack for a trivial "factorial" class template.

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

11 years agoFix PR15634, better error message for template deduction failure.
Richard Trieu [Mon, 8 Apr 2013 21:11:40 +0000 (21:11 +0000)]
Fix PR15634, better error message for template deduction failure.

When two template decls with the same name are used in this diagnostic,
force them to print their qualified names.  This changes the bad message of:

candidate template ignored: could not match 'array' against 'array'

to the better message of:

candidate template ignored: could not match 'NS2::array' against 'NS1::array'

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

11 years agoUpdate checker build to checker-273
Ted Kremenek [Mon, 8 Apr 2013 21:02:16 +0000 (21:02 +0000)]
Update checker build to checker-273

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

11 years ago<rdar://problem/13540921> Fix a crasher when an Objective-C for-in loop gets a non...
Douglas Gregor [Mon, 8 Apr 2013 20:52:24 +0000 (20:52 +0000)]
<rdar://problem/13540921> Fix a crasher when an Objective-C for-in loop gets a non-variable iteration declaration.

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

11 years agofix indentation
Adrian Prantl [Mon, 8 Apr 2013 20:52:12 +0000 (20:52 +0000)]
fix indentation

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

11 years agoThe recent GCOV changes expect the initial version string to be in forward order.
Bill Wendling [Mon, 8 Apr 2013 20:36:44 +0000 (20:36 +0000)]
The recent GCOV changes expect the initial version string to be in forward order.

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

11 years agoRevamp indentation behavior for complex binary expressions.
Daniel Jasper [Mon, 8 Apr 2013 20:33:42 +0000 (20:33 +0000)]
Revamp indentation behavior for complex binary expressions.

The idea is to indent according to operator precedence and pretty much
identical to how stuff would be indented with parenthesis.

Before:
bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
             aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
             aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
             aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *
             bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +
             bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb &&
             aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *
             aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >
             ccccccccccccccccccccccccccccccccccccccccc;

After:
  bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
                       aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
                       aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
                   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *
                           bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +
                       bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb &&
               aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *
                       aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >
                   ccccccccccccccccccccccccccccccccccccccccc;

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

11 years agoThread safety analysis: turn on checking within lock and unlock functions.
DeLesley Hutchins [Mon, 8 Apr 2013 20:11:11 +0000 (20:11 +0000)]
Thread safety analysis: turn on checking within lock and unlock functions.
These checks are enabled with the -Wthread-safety-beta flag.

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

11 years agofixes a typo in my last patch.
Fariborz Jahanian [Mon, 8 Apr 2013 19:14:15 +0000 (19:14 +0000)]
fixes a typo in my last patch.
// rdar://12379114

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

11 years agoIn the comparison, both clang and GCC are popular and widely adopted. This is no...
Chris Lattner [Mon, 8 Apr 2013 18:56:15 +0000 (18:56 +0000)]
In the comparison, both clang and GCC are popular and widely adopted.  This is no longer a win of GCC.

This whole doc should really be looked at.

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

11 years agodoce parsing: adding few more headerdoc tags.
Fariborz Jahanian [Mon, 8 Apr 2013 18:53:25 +0000 (18:53 +0000)]
doce parsing: adding few more headerdoc tags.
// rdar://12379114

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

11 years ago<rdar://problem/13540921> Cope with instantiations of the C++11 range-based for loop...
Douglas Gregor [Mon, 8 Apr 2013 18:40:13 +0000 (18:40 +0000)]
<rdar://problem/13540921> Cope with instantiations of the C++11 range-based for loop that end up being Objective-C fast enumeration loops.

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

11 years ago<rdar://problem/13540921> Cope with deduced 'auto' in a C++11 for-range loop that...
Douglas Gregor [Mon, 8 Apr 2013 18:25:02 +0000 (18:25 +0000)]
<rdar://problem/13540921> Cope with deduced 'auto' in a C++11 for-range loop that is actually an Objective-C fast enumeration loop.

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

11 years agoTweak warning text for nil value in ObjC container warning.
Ted Kremenek [Mon, 8 Apr 2013 18:09:16 +0000 (18:09 +0000)]
Tweak warning text for nil value in ObjC container warning.

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

11 years agoTest case for r179030.
Chad Rosier [Mon, 8 Apr 2013 17:44:05 +0000 (17:44 +0000)]
Test case for r179030.

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

11 years ago<rdar://problem/12806802> Propagate access specifiers for conversion functions to...
Douglas Gregor [Mon, 8 Apr 2013 17:12:58 +0000 (17:12 +0000)]
<rdar://problem/12806802> Propagate access specifiers for conversion functions to the conversion function set eagerly.

This slightly propagates an existing hack that delays when we provide
access specifiers for the visible conversion functions of a class by
copying the available access specifier early. The only client this
affects is LLDB, which tends to discover and add conversion functions
after the class is technically "complete". As such, the only
observable difference is in LLDB, so the testing will go there.

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

11 years agoAdd matcher for NamespaceDecls.
Daniel Jasper [Mon, 8 Apr 2013 16:44:05 +0000 (16:44 +0000)]
Add matcher for NamespaceDecls.

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

11 years agoRemove outdated part of help message.
Daniel Jasper [Mon, 8 Apr 2013 10:50:02 +0000 (10:50 +0000)]
Remove outdated part of help message.

The styles are now documented with the -style option. This fixes
llvm.org/PR15689.

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

11 years agoRevert accidental commit r179015.
Daniel Jasper [Mon, 8 Apr 2013 10:45:44 +0000 (10:45 +0000)]
Revert accidental commit r179015.

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

11 years agox
Daniel Jasper [Mon, 8 Apr 2013 10:36:32 +0000 (10:36 +0000)]
x

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

11 years agoSema: Don't crash when trying to emit a warning for a duplicate value in an invalid...
Benjamin Kramer [Sun, 7 Apr 2013 14:10:40 +0000 (14:10 +0000)]
Sema: Don't crash when trying to emit a warning for a duplicate value in an invalid enum.

Fixes PR15693. A null check on a pointer returned from cast<> is a very dubious
construct, do we have a checker for this somewhere?

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

11 years agoRemove nondeterminism introduced in r178950.
Richard Smith [Sat, 6 Apr 2013 07:07:44 +0000 (07:07 +0000)]
Remove nondeterminism introduced in r178950.

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

11 years agoWhen an internal-linkage function or variable is declared within an extern "C"
Richard Smith [Sat, 6 Apr 2013 05:00:46 +0000 (05:00 +0000)]
When an internal-linkage function or variable is declared within an extern "C"
linkage specification, and is marked as __attribute__((used)), try to also give
it the unmangled name (by emitting an internal linkage alias) if nothing else
within the translation unit would use that name. This allows inline asm in that
translation unit to use the entity via its unmangled name, which people
apparently rely on.

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

11 years ago[analyzer] When creating a trimmed graph, preserve whether a node is a sink.
Jordan Rose [Sat, 6 Apr 2013 01:42:02 +0000 (01:42 +0000)]
[analyzer] When creating a trimmed graph, preserve whether a node is a sink.

This is important because sometimes two nodes are identical, except the
second one is a sink.

This bug has probably been around for a while, but it wouldn't have been an
issue in the old report graph algorithm. I'm ashamed to say I actually looked
at this the first time around and thought it would never be a problem...and
then didn't include an assertion to back that up.

PR15684

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

11 years ago[objcmt] Fix a mishandled conversion to objc directory literal.
Argyrios Kyrtzidis [Sat, 6 Apr 2013 01:13:17 +0000 (01:13 +0000)]
[objcmt] Fix a mishandled conversion to objc directory literal.

rdar://13181413

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

11 years ago<rdar://problem/13325066> Destroy std::initializer_list temporaries whose lifetime...
Douglas Gregor [Sat, 6 Apr 2013 00:46:20 +0000 (00:46 +0000)]
<rdar://problem/13325066> Destroy std::initializer_list temporaries whose lifetime has been extended by reference binding.

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

11 years ago[analyzer] Shorten the malloc checker’s leak message
Anna Zaks [Sat, 6 Apr 2013 00:41:36 +0000 (00:41 +0000)]
[analyzer] Shorten the malloc checker’s leak message

As per Ted’s suggestion!

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

11 years agoRework how ObjC method inherit deprecated/availability.
Ted Kremenek [Sat, 6 Apr 2013 00:34:27 +0000 (00:34 +0000)]
Rework how ObjC method inherit deprecated/availability.

New rule:
- Method decls in @implementation are considered "redeclarations"
  and inherit deprecated/availability from the @interface.
- All other cases are consider overrides, which do not inherit
  deprecated/availability.  For example:

  (a) @interface redeclares a method in an adopted protocol.
  (b) A subclass redeclares a method in a superclass.
  (c) A protocol redeclares a method from another protocol it adopts.

The idea is that API authors should have the ability to easily
move availability/deprecated up and down a class/protocol hierarchy.
A redeclaration means that the availability/deprecation is a blank
slate.

Fixes <rdar://problem/13574571>

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

11 years ago[analyzer] Reword error messages for nil keys and values of NSMutableDictionary.
Anna Zaks [Fri, 5 Apr 2013 23:50:18 +0000 (23:50 +0000)]
[analyzer] Reword error messages for nil keys and values of NSMutableDictionary.

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

11 years ago[analyzer] Remove another redundancy from trackNullOrUndef
Anna Zaks [Fri, 5 Apr 2013 23:50:14 +0000 (23:50 +0000)]
[analyzer] Remove another redundancy from trackNullOrUndef

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

11 years ago[analyzer] Fix null tracking for the given test case, by using the proper state and...
Anna Zaks [Fri, 5 Apr 2013 23:50:11 +0000 (23:50 +0000)]
[analyzer] Fix null tracking for the given test case, by using the proper state and removing redundant code.

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

11 years agoWhen -Woverloaded-virtual is triggered, call HandleFunctionTypeMismatch to add
Richard Trieu [Fri, 5 Apr 2013 23:02:24 +0000 (23:02 +0000)]
When -Woverloaded-virtual is triggered, call HandleFunctionTypeMismatch to add
more information to the notes.  This information is already present on other
diagnostic messages that involves overloads.

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

11 years ago[libclang] Fix cursor visitation to not ignore template arguments in out-of-line...
Argyrios Kyrtzidis [Fri, 5 Apr 2013 21:04:10 +0000 (21:04 +0000)]
[libclang] Fix cursor visitation to not ignore template arguments in out-of-line member functions.

rdar://13535645

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

11 years agoAdd an error to check that all program scope variables are in the constant address...
Tanya Lattner [Fri, 5 Apr 2013 20:14:50 +0000 (20:14 +0000)]
Add an error to check that all program scope variables are in the constant address space in OpenCL.

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

11 years agodoce parsing: adding few more headerdoc tags.
Fariborz Jahanian [Fri, 5 Apr 2013 19:40:53 +0000 (19:40 +0000)]
doce parsing: adding few more headerdoc tags.
// rdar://12379114

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

11 years ago[analyzer] Eliminates all the cases with unknown family.
Anton Yartsev [Fri, 5 Apr 2013 19:08:04 +0000 (19:08 +0000)]
[analyzer] Eliminates all the cases with unknown family.

Now treat AF_None family as impossible in isTrackedFamily()

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

11 years agoTry to appease the atom buildbots
Manman Ren [Fri, 5 Apr 2013 19:06:10 +0000 (19:06 +0000)]
Try to appease the atom buildbots

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

11 years ago[analyzer] Re-enable cplusplus.NewDelete (but not NewDeleteLeaks).
Jordan Rose [Fri, 5 Apr 2013 17:55:07 +0000 (17:55 +0000)]
[analyzer] Re-enable cplusplus.NewDelete (but not NewDeleteLeaks).

As mentioned in the previous commit message, the use-after-free and
double-free warnings for 'delete' are worth enabling even while the
leak warnings still have false positives.

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

11 years ago[analyzer] Split new/delete checker into use-after-free and leaks parts.
Jordan Rose [Fri, 5 Apr 2013 17:55:00 +0000 (17:55 +0000)]
[analyzer] Split new/delete checker into use-after-free and leaks parts.

This splits the leak-checking part of alpha.cplusplus.NewDelete into a
separate user-level checker, alpha.cplusplus.NewDeleteLeaks. All the
difficult false positives we've seen with the new/delete checker have been
spurious leak warnings; the use-after-free warnings and mismatched
deallocator warnings, while rare, have always been valid.

<rdar://problem/6194569>

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

11 years agoAllow breaking after 'class' for classes with looong names.
Daniel Jasper [Fri, 5 Apr 2013 17:22:09 +0000 (17:22 +0000)]
Allow breaking after 'class' for classes with looong names.

(Don't ask, this was a user request).

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

11 years agoFix bad formatting of overloaded operator definitions.
Daniel Jasper [Fri, 5 Apr 2013 17:21:59 +0000 (17:21 +0000)]
Fix bad formatting of overloaded operator definitions.

Before:
bool operator<
    (const aaaaaaaaaaaaaaaaaaaaa &left, const aaaaaaaaaaaaaaaaaaaaa &right) {
  return left.group < right.group;
}

After:
bool operator<(const aaaaaaaaaaaaaaaaaaaaa &left,
               const aaaaaaaaaaaaaaaaaaaaa &right) {
  return left.group < right.group;
}

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

11 years agoAdd triple to testing case to appease poewrpc64 buildbots
Manman Ren [Fri, 5 Apr 2013 17:11:45 +0000 (17:11 +0000)]
Add triple to testing case to appease poewrpc64 buildbots

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

11 years agoAdd test case for r178881.
Chad Rosier [Fri, 5 Apr 2013 16:29:17 +0000 (16:29 +0000)]
Add test case for r178881.

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

11 years agoProper prefix for doxygen comments
Eli Bendersky [Fri, 5 Apr 2013 15:35:12 +0000 (15:35 +0000)]
Proper prefix for doxygen comments

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

11 years agoAArch64: bring predefines in line with most recent ACLE document
Tim Northover [Fri, 5 Apr 2013 14:08:55 +0000 (14:08 +0000)]
AArch64: bring predefines in line with most recent ACLE document

The prefixes and names used are now identical to 32-bit ARM, which is also
expected to remain unchanged.

If we made this change after a release, we'd probably have to support both
variants for a while, but I think since AArch64 exists only on trunk now, it's
acceptable to simply swap them now.

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

11 years ago[analyzer] Path notes for the MismatchedDeallocator checker.
Anton Yartsev [Fri, 5 Apr 2013 11:25:10 +0000 (11:25 +0000)]
[analyzer] Path notes for the MismatchedDeallocator checker.

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

11 years ago[analyzer] Better name for the test.
Anton Yartsev [Fri, 5 Apr 2013 10:49:41 +0000 (10:49 +0000)]
[analyzer] Better name for the test.

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

11 years agoImprove formatting of multi-variable DeclStmts.
Daniel Jasper [Fri, 5 Apr 2013 09:38:50 +0000 (09:38 +0000)]
Improve formatting of multi-variable DeclStmts.

This fixed llvm.org/PR15670

Before:
aaaaaaaaa a = aaaaaaaaaaaaaaaaaaaa, b = bbbbbbbbbbbbbbbbbbbb,
                                    c = cccccccccccccccccccc,
                                    d = dddddddddddddddddddd;
aaaaaaaaa *a = aaaaaaaaaaaaaaaaaaa, *b = bbbbbbbbbbbbbbbbbbb,
                                     *c = ccccccccccccccccccc,
                                      *d = ddddddddddddddddddd;

After:
aaaaaaaaa a = aaaaaaaaaaaaaaaaaaaa, b = bbbbbbbbbbbbbbbbbbbb,
          c = cccccccccccccccccccc, d = dddddddddddddddddddd;
aaaaaaaaa *a = aaaaaaaaaaaaaaaaaaa, *b = bbbbbbbbbbbbbbbbbbb,
          *c = ccccccccccccccccccc, *d = ddddddddddddddddddd;

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

11 years agoAllow EmitConstantInit() to emit constant initializers for objects with trivial const...
Alexey Samsonov [Fri, 5 Apr 2013 07:47:28 +0000 (07:47 +0000)]
Allow EmitConstantInit() to emit constant initializers for objects with trivial constructors and non-trivial destructors. Test that such objects are ignored by init-order checker.

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

11 years ago[analyzer] Check allocation family more precise.
Anton Yartsev [Fri, 5 Apr 2013 02:25:02 +0000 (02:25 +0000)]
[analyzer] Check allocation family more precise.

The statement passed to isTrackedFamily() might be a user defined function calling malloc; in this case we got AF_NONE family for this function.
Now the allocation family is derived from Sym, that holds a family of a real allocator.

This commit is also a movement towards getting rid of tracking memory allocating by unknown means.

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

11 years ago[analyzer] Corrected the switch statement.
Anton Yartsev [Fri, 5 Apr 2013 02:12:04 +0000 (02:12 +0000)]
[analyzer] Corrected the switch statement.

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

11 years ago[analyzer] Show path diagnostic for C++ initializers
Anna Zaks [Fri, 5 Apr 2013 00:59:33 +0000 (00:59 +0000)]
[analyzer] Show path diagnostic for C++ initializers

Also had to modify the PostInitializer ProgramLocation to contain the field region.

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

11 years agoAdd a module testcase with a using declaration.
Rafael Espindola [Fri, 5 Apr 2013 00:52:14 +0000 (00:52 +0000)]
Add a module testcase with a using declaration.

Thanks a lot to Richard Smith for the suggestion.

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

11 years ago[analyzer] Updated the testcase.
Anton Yartsev [Fri, 5 Apr 2013 00:37:32 +0000 (00:37 +0000)]
[analyzer] Updated the testcase.

Missed check added to testMallocFreeNoWarn().
Removed FIXMEs as the current behaviour is considered acceptable now.

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

11 years ago[analyzer] Fully-covered switch for families in isTrackedFamily()
Anton Yartsev [Fri, 5 Apr 2013 00:31:02 +0000 (00:31 +0000)]
[analyzer] Fully-covered switch for families in isTrackedFamily()

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

11 years agoAdd testing case for r178797
Manman Ren [Fri, 5 Apr 2013 00:05:09 +0000 (00:05 +0000)]
Add testing case for r178797

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

11 years agoAdd support for __GCC_HAVE_SYNC_COMPARE_AND_SWAP_{1,2,4,8} on x86.
Michael J. Spencer [Thu, 4 Apr 2013 23:53:43 +0000 (23:53 +0000)]
Add support for __GCC_HAVE_SYNC_COMPARE_AND_SWAP_{1,2,4,8} on x86.

This fixes std::thread with libstdc++.

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

11 years ago[analyzer] Reduced the unwanted correlations between checkers living inside MallocChe...
Anton Yartsev [Thu, 4 Apr 2013 23:46:29 +0000 (23:46 +0000)]
[analyzer] Reduced the unwanted correlations between checkers living inside MallocChecker.cpp

This fixes an issue pointed to by Jordan: if unix.Malloc and unix.MismatchedDeallocator are both on, then we end up still tracking leaks of memory allocated by new.
Moved the guards right before emitting the bug reports to unify and simplify the logic of handling of multiple checkers. Now all the checkers perform their checks regardless of if they were enabled, or not, and it is decided just before the emitting of the report, if it should be emitted. (idea from Anna).

Additional changes:
improved test coverage for checker correlations;
refactoring: BadDealloc -> MismatchedDealloc

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

11 years agoRevert 178811 until I fix the unit tests.
Tanya Lattner [Thu, 4 Apr 2013 23:45:52 +0000 (23:45 +0000)]
Revert 178811 until I fix the unit tests.

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

11 years agoAdd an error to check that all program scope variables are in the constant address...
Tanya Lattner [Thu, 4 Apr 2013 23:36:11 +0000 (23:36 +0000)]
Add an error to check that all program scope variables are in the constant address space in OpenCL.

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

11 years ago[analyzer] Enable destructor inlining by default (c++-inlining=destructors).
Jordan Rose [Thu, 4 Apr 2013 23:10:29 +0000 (23:10 +0000)]
[analyzer] Enable destructor inlining by default (c++-inlining=destructors).

This turns on not only destructor inlining, but inlining of constructors
for types with non-trivial destructors. Per r178516, we will still not
inline the constructor or destructor of anything that looks like a
container unless the analyzer-config option 'c++-container-inlining' is
set to 'true'.

In addition to the more precise path-sensitive model, this allows us to
catch simple smart pointer issues:

  #include <memory>

  void test() {
    std::auto_ptr<int> releaser(new int[4]);
  } // memory allocated with 'new[]' should not be deleted with 'delete'

<rdar://problem/12295363>

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

11 years agoAdd some documentation for PNaClABIInfo.
Eli Bendersky [Thu, 4 Apr 2013 22:49:35 +0000 (22:49 +0000)]
Add some documentation for PNaClABIInfo.

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

11 years ago[libclang] Add some checks to make sure the given CXTranslationUnit is not null,...
Argyrios Kyrtzidis [Thu, 4 Apr 2013 22:40:59 +0000 (22:40 +0000)]
[libclang] Add some checks to make sure the given CXTranslationUnit is not null, before using it.

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

11 years ago[analyzer] RetainCountChecker: refactor annotation handling.
Jordan Rose [Thu, 4 Apr 2013 22:31:48 +0000 (22:31 +0000)]
[analyzer] RetainCountChecker: refactor annotation handling.

...and add a new test case.

I thought this was broken, but it isn't; refactoring and reformatting anyway
so that I don't make the same mistake again. No functionality change.

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

11 years agoInitial support for struct-path aware TBAA.
Manman Ren [Thu, 4 Apr 2013 21:53:22 +0000 (21:53 +0000)]
Initial support for struct-path aware TBAA.

Added TBAABaseType and TBAAOffset in LValue. These two fields are initialized to
the actual type and 0, and are updated in EmitLValueForField.
Path-aware TBAA tags are enabled for EmitLoadOfScalar and EmitStoreOfScalar.
Added command line option -struct-path-tbaa.

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

11 years agorevert r178784 since it does not have a commit message
Manman Ren [Thu, 4 Apr 2013 21:51:07 +0000 (21:51 +0000)]
revert r178784 since it does not have a commit message

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

11 years agoDon't patch the storage class of static data members.
Rafael Espindola [Thu, 4 Apr 2013 21:21:25 +0000 (21:21 +0000)]
Don't patch the storage class of static data members.

This removes a bit of patching that survived r178663. Without it we can produce
better a better error message for

const int a = 5;
static const int a;

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

11 years agoXFAIL example-dynarray.cpp test for Hexagon as some of the header files
Jyotsna Verma [Thu, 4 Apr 2013 20:56:42 +0000 (20:56 +0000)]
XFAIL example-dynarray.cpp test for Hexagon as some of the header files
are unavailable on Hexagon.

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

11 years agoIndex: include/clang/Driver/CC1Options.td
Manman Ren [Thu, 4 Apr 2013 20:14:17 +0000 (20:14 +0000)]
Index: include/clang/Driver/CC1Options.td
===================================================================
--- include/clang/Driver/CC1Options.td (revision 178718)
+++ include/clang/Driver/CC1Options.td (working copy)
@@ -161,6 +161,8 @@
   HelpText<"Use register sized accesses to bit-fields, when possible.">;
 def relaxed_aliasing : Flag<["-"], "relaxed-aliasing">,
   HelpText<"Turn off Type Based Alias Analysis">;
+def struct_path_tbaa : Flag<["-"], "struct-path-tbaa">,
+  HelpText<"Turn on struct-path aware Type Based Alias Analysis">;
 def masm_verbose : Flag<["-"], "masm-verbose">,
   HelpText<"Generate verbose assembly output">;
 def mcode_model : Separate<["-"], "mcode-model">,
Index: include/clang/Driver/Options.td
===================================================================
--- include/clang/Driver/Options.td (revision 178718)
+++ include/clang/Driver/Options.td (working copy)
@@ -587,6 +587,7 @@
   Flags<[CC1Option]>, HelpText<"Disable spell-checking">;
 def fno_stack_protector : Flag<["-"], "fno-stack-protector">, Group<f_Group>;
 def fno_strict_aliasing : Flag<["-"], "fno-strict-aliasing">, Group<f_Group>;
+def fstruct_path_tbaa : Flag<["-"], "fstruct-path-tbaa">, Group<f_Group>;
 def fno_strict_enums : Flag<["-"], "fno-strict-enums">, Group<f_Group>;
 def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group<f_Group>;
 def fno_threadsafe_statics : Flag<["-"], "fno-threadsafe-statics">, Group<f_Group>,
Index: include/clang/Frontend/CodeGenOptions.def
===================================================================
--- include/clang/Frontend/CodeGenOptions.def (revision 178718)
+++ include/clang/Frontend/CodeGenOptions.def (working copy)
@@ -85,6 +85,7 @@
 VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) is specified.
 CODEGENOPT(RelaxAll          , 1, 0) ///< Relax all machine code instructions.
 CODEGENOPT(RelaxedAliasing   , 1, 0) ///< Set when -fno-strict-aliasing is enabled.
+CODEGENOPT(StructPathTBAA    , 1, 0) ///< Whether or not to use struct-path TBAA.
 CODEGENOPT(SaveTempLabels    , 1, 0) ///< Save temporary labels.
 CODEGENOPT(SanitizeAddressZeroBaseShadow , 1, 0) ///< Map shadow memory at zero
                                                  ///< offset in AddressSanitizer.
Index: lib/CodeGen/CGExpr.cpp
===================================================================
--- lib/CodeGen/CGExpr.cpp (revision 178718)
+++ lib/CodeGen/CGExpr.cpp (working copy)
@@ -1044,7 +1044,8 @@
 llvm::Value *CodeGenFunction::EmitLoadOfScalar(LValue lvalue) {
   return EmitLoadOfScalar(lvalue.getAddress(), lvalue.isVolatile(),
                           lvalue.getAlignment().getQuantity(),
-                          lvalue.getType(), lvalue.getTBAAInfo());
+                          lvalue.getType(), lvalue.getTBAAInfo(),
+                          lvalue.getTBAABaseType(), lvalue.getTBAAOffset());
 }

 static bool hasBooleanRepresentation(QualType Ty) {
@@ -1106,7 +1107,9 @@

 llvm::Value *CodeGenFunction::EmitLoadOfScalar(llvm::Value *Addr, bool Volatile,
                                               unsigned Alignment, QualType Ty,
-                                              llvm::MDNode *TBAAInfo) {
+                                              llvm::MDNode *TBAAInfo,
+                                              QualType TBAABaseType,
+                                              uint64_t TBAAOffset) {
   // For better performance, handle vector loads differently.
   if (Ty->isVectorType()) {
     llvm::Value *V;
@@ -1158,8 +1161,11 @@
     Load->setVolatile(true);
   if (Alignment)
     Load->setAlignment(Alignment);
-  if (TBAAInfo)
-    CGM.DecorateInstruction(Load, TBAAInfo);
+  if (TBAAInfo) {
+    llvm::MDNode *TBAAPath = CGM.getTBAAStructTagInfo(TBAABaseType, TBAAInfo,
+                                                      TBAAOffset);
+    CGM.DecorateInstruction(Load, TBAAPath);
+  }

   if ((SanOpts->Bool && hasBooleanRepresentation(Ty)) ||
       (SanOpts->Enum && Ty->getAs<EnumType>())) {
@@ -1217,7 +1223,8 @@
                                         bool Volatile, unsigned Alignment,
                                         QualType Ty,
                                         llvm::MDNode *TBAAInfo,
-                                        bool isInit) {
+                                        bool isInit, QualType TBAABaseType,
+                                        uint64_t TBAAOffset) {

   // Handle vectors differently to get better performance.
   if (Ty->isVectorType()) {
@@ -1268,15 +1275,19 @@
   llvm::StoreInst *Store = Builder.CreateStore(Value, Addr, Volatile);
   if (Alignment)
     Store->setAlignment(Alignment);
-  if (TBAAInfo)
-    CGM.DecorateInstruction(Store, TBAAInfo);
+  if (TBAAInfo) {
+    llvm::MDNode *TBAAPath = CGM.getTBAAStructTagInfo(TBAABaseType, TBAAInfo,
+                                                      TBAAOffset);
+    CGM.DecorateInstruction(Store, TBAAPath);
+  }
 }

 void CodeGenFunction::EmitStoreOfScalar(llvm::Value *value, LValue lvalue,
                                         bool isInit) {
   EmitStoreOfScalar(value, lvalue.getAddress(), lvalue.isVolatile(),
                     lvalue.getAlignment().getQuantity(), lvalue.getType(),
-                    lvalue.getTBAAInfo(), isInit);
+                    lvalue.getTBAAInfo(), isInit, lvalue.getTBAABaseType(),
+                    lvalue.getTBAAOffset());
 }

 /// EmitLoadOfLValue - Given an expression that represents a value lvalue, this
@@ -2494,9 +2505,12 @@

   llvm::Value *addr = base.getAddress();
   unsigned cvr = base.getVRQualifiers();
+  bool TBAAPath = CGM.getCodeGenOpts().StructPathTBAA;
   if (rec->isUnion()) {
     // For unions, there is no pointer adjustment.
     assert(!type->isReferenceType() && "union has reference member");
+    // TODO: handle path-aware TBAA for union.
+    TBAAPath = false;
   } else {
     // For structs, we GEP to the field that the record layout suggests.
     unsigned idx = CGM.getTypes().getCGRecordLayout(rec).getLLVMFieldNo(field);
@@ -2508,6 +2522,8 @@
       if (cvr & Qualifiers::Volatile) load->setVolatile(true);
       load->setAlignment(alignment.getQuantity());

+      // Loading the reference will disable path-aware TBAA.
+      TBAAPath = false;
       if (CGM.shouldUseTBAA()) {
         llvm::MDNode *tbaa;
         if (mayAlias)
@@ -2541,6 +2557,16 @@

   LValue LV = MakeAddrLValue(addr, type, alignment);
   LV.getQuals().addCVRQualifiers(cvr);
+  if (TBAAPath) {
+    const ASTRecordLayout &Layout =
+        getContext().getASTRecordLayout(field->getParent());
+    // Set the base type to be the base type of the base LValue and
+    // update offset to be relative to the base type.
+    LV.setTBAABaseType(base.getTBAABaseType());
+    LV.setTBAAOffset(base.getTBAAOffset() +
+                     Layout.getFieldOffset(field->getFieldIndex()) /
+                                           getContext().getCharWidth());
+  }

   // __weak attribute on a field is ignored.
   if (LV.getQuals().getObjCGCAttr() == Qualifiers::Weak)
Index: lib/CodeGen/CGValue.h
===================================================================
--- lib/CodeGen/CGValue.h (revision 178718)
+++ lib/CodeGen/CGValue.h (working copy)
@@ -157,6 +157,11 @@

   Expr *BaseIvarExp;

+  /// Used by struct-path-aware TBAA.
+  QualType TBAABaseType;
+  /// Offset relative to the base type.
+  uint64_t TBAAOffset;
+
   /// TBAAInfo - TBAA information to attach to dereferences of this LValue.
   llvm::MDNode *TBAAInfo;

@@ -175,6 +180,10 @@
     this->ImpreciseLifetime = false;
     this->ThreadLocalRef = false;
     this->BaseIvarExp = 0;
+
+    // Initialize fields for TBAA.
+    this->TBAABaseType = Type;
+    this->TBAAOffset = 0;
     this->TBAAInfo = TBAAInfo;
   }

@@ -232,6 +241,12 @@
   Expr *getBaseIvarExp() const { return BaseIvarExp; }
   void setBaseIvarExp(Expr *V) { BaseIvarExp = V; }

+  QualType getTBAABaseType() const { return TBAABaseType; }
+  void setTBAABaseType(QualType T) { TBAABaseType = T; }
+
+  uint64_t getTBAAOffset() const { return TBAAOffset; }
+  void setTBAAOffset(uint64_t O) { TBAAOffset = O; }
+
   llvm::MDNode *getTBAAInfo() const { return TBAAInfo; }
   void setTBAAInfo(llvm::MDNode *N) { TBAAInfo = N; }

Index: lib/CodeGen/CodeGenFunction.h
===================================================================
--- lib/CodeGen/CodeGenFunction.h (revision 178718)
+++ lib/CodeGen/CodeGenFunction.h (working copy)
@@ -2211,7 +2211,9 @@
   /// the LLVM value representation.
   llvm::Value *EmitLoadOfScalar(llvm::Value *Addr, bool Volatile,
                                 unsigned Alignment, QualType Ty,
-                                llvm::MDNode *TBAAInfo = 0);
+                                llvm::MDNode *TBAAInfo = 0,
+                                QualType TBAABaseTy = QualType(),
+                                uint64_t TBAAOffset = 0);

   /// EmitLoadOfScalar - Load a scalar value from an address, taking
   /// care to appropriately convert from the memory representation to
@@ -2224,7 +2226,9 @@
   /// the LLVM value representation.
   void EmitStoreOfScalar(llvm::Value *Value, llvm::Value *Addr,
                          bool Volatile, unsigned Alignment, QualType Ty,
-                         llvm::MDNode *TBAAInfo = 0, bool isInit=false);
+                         llvm::MDNode *TBAAInfo = 0, bool isInit = false,
+                         QualType TBAABaseTy = QualType(),
+                         uint64_t TBAAOffset = 0);

   /// EmitStoreOfScalar - Store a scalar value to an address, taking
   /// care to appropriately convert from the memory representation to
Index: lib/CodeGen/CodeGenModule.cpp
===================================================================
--- lib/CodeGen/CodeGenModule.cpp (revision 178718)
+++ lib/CodeGen/CodeGenModule.cpp (working copy)
@@ -227,6 +227,20 @@
   return TBAA->getTBAAStructInfo(QTy);
 }

+llvm::MDNode *CodeGenModule::getTBAAStructTypeInfo(QualType QTy) {
+  if (!TBAA)
+    return 0;
+  return TBAA->getTBAAStructTypeInfo(QTy);
+}
+
+llvm::MDNode *CodeGenModule::getTBAAStructTagInfo(QualType BaseTy,
+                                                  llvm::MDNode *AccessN,
+                                                  uint64_t O) {
+  if (!TBAA)
+    return 0;
+  return TBAA->getTBAAStructTagInfo(BaseTy, AccessN, O);
+}
+
 void CodeGenModule::DecorateInstruction(llvm::Instruction *Inst,
                                         llvm::MDNode *TBAAInfo) {
   Inst->setMetadata(llvm::LLVMContext::MD_tbaa, TBAAInfo);
Index: lib/CodeGen/CodeGenModule.h
===================================================================
--- lib/CodeGen/CodeGenModule.h (revision 178718)
+++ lib/CodeGen/CodeGenModule.h (working copy)
@@ -501,6 +501,11 @@
   llvm::MDNode *getTBAAInfo(QualType QTy);
   llvm::MDNode *getTBAAInfoForVTablePtr();
   llvm::MDNode *getTBAAStructInfo(QualType QTy);
+  /// Return the MDNode in the type DAG for the given struct type.
+  llvm::MDNode *getTBAAStructTypeInfo(QualType QTy);
+  /// Return the path-aware tag for given base type, access node and offset.
+  llvm::MDNode *getTBAAStructTagInfo(QualType BaseTy, llvm::MDNode *AccessN,
+                                     uint64_t O);

   bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor);

Index: lib/CodeGen/CodeGenTBAA.cpp
===================================================================
--- lib/CodeGen/CodeGenTBAA.cpp (revision 178718)
+++ lib/CodeGen/CodeGenTBAA.cpp (working copy)
@@ -21,6 +21,7 @@
 #include "clang/AST/Mangle.h"
 #include "clang/AST/RecordLayout.h"
 #include "clang/Frontend/CodeGenOptions.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Metadata.h"
@@ -225,3 +226,87 @@
   // For now, handle any other kind of type conservatively.
   return StructMetadataCache[Ty] = NULL;
 }
+
+/// Check if the given type can be handled by path-aware TBAA.
+static bool isTBAAPathStruct(QualType QTy) {
+  if (const RecordType *TTy = QTy->getAs<RecordType>()) {
+    const RecordDecl *RD = TTy->getDecl()->getDefinition();
+    // RD can be struct, union, class, interface or enum.
+    // For now, we only handle struct.
+    if (RD->isStruct() && !RD->hasFlexibleArrayMember())
+      return true;
+  }
+  return false;
+}
+
+llvm::MDNode *
+CodeGenTBAA::getTBAAStructTypeInfo(QualType QTy) {
+  const Type *Ty = Context.getCanonicalType(QTy).getTypePtr();
+  assert(isTBAAPathStruct(QTy));
+
+  if (llvm::MDNode *N = StructTypeMetadataCache[Ty])
+    return N;
+
+  if (const RecordType *TTy = QTy->getAs<RecordType>()) {
+    const RecordDecl *RD = TTy->getDecl()->getDefinition();
+
+    const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
+    SmallVector <std::pair<uint64_t, llvm::MDNode*>, 4> Fields;
+    // To reduce the size of MDNode for a given struct type, we only output
+    // once for all the fields with the same scalar types.
+    // Offsets for scalar fields in the type DAG are not used.
+    llvm::SmallSet <llvm::MDNode*, 4> ScalarFieldTypes;
+    unsigned idx = 0;
+    for (RecordDecl::field_iterator i = RD->field_begin(),
+         e = RD->field_end(); i != e; ++i, ++idx) {
+      QualType FieldQTy = i->getType();
+      llvm::MDNode *FieldNode;
+      if (isTBAAPathStruct(FieldQTy))
+        FieldNode = getTBAAStructTypeInfo(FieldQTy);
+      else {
+        FieldNode = getTBAAInfo(FieldQTy);
+        // Ignore this field if the type already exists.
+        if (ScalarFieldTypes.count(FieldNode))
+          continue;
+        ScalarFieldTypes.insert(FieldNode);
+       }
+      if (!FieldNode)
+        return StructTypeMetadataCache[Ty] = NULL;
+      Fields.push_back(std::make_pair(
+          Layout.getFieldOffset(idx) / Context.getCharWidth(), FieldNode));
+    }
+
+    // TODO: This is using the RTTI name. Is there a better way to get
+    // a unique string for a type?
+    SmallString<256> OutName;
+    llvm::raw_svector_ostream Out(OutName);
+    MContext.mangleCXXRTTIName(QualType(Ty, 0), Out);
+    Out.flush();
+    // Create the struct type node with a vector of pairs (offset, type).
+    return StructTypeMetadataCache[Ty] =
+      MDHelper.createTBAAStructTypeNode(OutName, Fields);
+  }
+
+  return StructMetadataCache[Ty] = NULL;
+}
+
+llvm::MDNode *
+CodeGenTBAA::getTBAAStructTagInfo(QualType BaseQTy, llvm::MDNode *AccessNode,
+                                  uint64_t Offset) {
+  if (!CodeGenOpts.StructPathTBAA)
+    return AccessNode;
+
+  const Type *BTy = Context.getCanonicalType(BaseQTy).getTypePtr();
+  TBAAPathTag PathTag = TBAAPathTag(BTy, AccessNode, Offset);
+  if (llvm::MDNode *N = StructTagMetadataCache[PathTag])
+    return N;
+
+  llvm::MDNode *BNode = 0;
+  if (isTBAAPathStruct(BaseQTy))
+    BNode  = getTBAAStructTypeInfo(BaseQTy);
+  if (!BNode)
+    return StructTagMetadataCache[PathTag] = AccessNode;
+
+  return StructTagMetadataCache[PathTag] =
+    MDHelper.createTBAAStructTagNode(BNode, AccessNode, Offset);
+}
Index: lib/CodeGen/CodeGenTBAA.h
===================================================================
--- lib/CodeGen/CodeGenTBAA.h (revision 178718)
+++ lib/CodeGen/CodeGenTBAA.h (working copy)
@@ -35,6 +35,14 @@
 namespace CodeGen {
   class CGRecordLayout;

+  struct TBAAPathTag {
+    TBAAPathTag(const Type *B, const llvm::MDNode *A, uint64_t O)
+      : BaseT(B), AccessN(A), Offset(O) {}
+    const Type *BaseT;
+    const llvm::MDNode *AccessN;
+    uint64_t Offset;
+  };
+
 /// CodeGenTBAA - This class organizes the cross-module state that is used
 /// while lowering AST types to LLVM types.
 class CodeGenTBAA {
@@ -46,8 +54,13 @@
   // MDHelper - Helper for creating metadata.
   llvm::MDBuilder MDHelper;

-  /// MetadataCache - This maps clang::Types to llvm::MDNodes describing them.
+  /// MetadataCache - This maps clang::Types to scalar llvm::MDNodes describing
+  /// them.
   llvm::DenseMap<const Type *, llvm::MDNode *> MetadataCache;
+  /// This maps clang::Types to a struct node in the type DAG.
+  llvm::DenseMap<const Type *, llvm::MDNode *> StructTypeMetadataCache;
+  /// This maps TBAAPathTags to a tag node.
+  llvm::DenseMap<TBAAPathTag, llvm::MDNode *> StructTagMetadataCache;

   /// StructMetadataCache - This maps clang::Types to llvm::MDNodes describing
   /// them for struct assignments.
@@ -89,9 +102,49 @@
   /// getTBAAStructInfo - Get the TBAAStruct MDNode to be used for a memcpy of
   /// the given type.
   llvm::MDNode *getTBAAStructInfo(QualType QTy);
+
+  /// Get the MDNode in the type DAG for given struct type QType.
+  llvm::MDNode *getTBAAStructTypeInfo(QualType QType);
+  /// Get the tag MDNode for a given base type, the actual sclar access MDNode
+  /// and offset into the base type.
+  llvm::MDNode *getTBAAStructTagInfo(QualType BaseQType,
+                                     llvm::MDNode *AccessNode, uint64_t Offset);
 };

 }  // end namespace CodeGen
 }  // end namespace clang

+namespace llvm {
+
+template<> struct DenseMapInfo<clang::CodeGen::TBAAPathTag> {
+  static clang::CodeGen::TBAAPathTag getEmptyKey() {
+    return clang::CodeGen::TBAAPathTag(
+      DenseMapInfo<const clang::Type *>::getEmptyKey(),
+      DenseMapInfo<const MDNode *>::getEmptyKey(),
+      DenseMapInfo<uint64_t>::getEmptyKey());
+  }
+
+  static clang::CodeGen::TBAAPathTag getTombstoneKey() {
+    return clang::CodeGen::TBAAPathTag(
+      DenseMapInfo<const clang::Type *>::getTombstoneKey(),
+      DenseMapInfo<const MDNode *>::getTombstoneKey(),
+      DenseMapInfo<uint64_t>::getTombstoneKey());
+  }
+
+  static unsigned getHashValue(const clang::CodeGen::TBAAPathTag &Val) {
+    return DenseMapInfo<const clang::Type *>::getHashValue(Val.BaseT) ^
+           DenseMapInfo<const MDNode *>::getHashValue(Val.AccessN) ^
+           DenseMapInfo<uint64_t>::getHashValue(Val.Offset);
+  }
+
+  static bool isEqual(const clang::CodeGen::TBAAPathTag &LHS,
+                      const clang::CodeGen::TBAAPathTag &RHS) {
+    return LHS.BaseT == RHS.BaseT &&
+           LHS.AccessN == RHS.AccessN &&
+           LHS.Offset == RHS.Offset;
+  }
+};
+
+}  // end namespace llvm
+
 #endif
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp (revision 178718)
+++ lib/Driver/Tools.cpp (working copy)
@@ -2105,6 +2105,8 @@
                     options::OPT_fno_strict_aliasing,
                     getToolChain().IsStrictAliasingDefault()))
     CmdArgs.push_back("-relaxed-aliasing");
+  if (Args.hasArg(options::OPT_fstruct_path_tbaa))
+    CmdArgs.push_back("-struct-path-tbaa");
   if (Args.hasFlag(options::OPT_fstrict_enums, options::OPT_fno_strict_enums,
                    false))
     CmdArgs.push_back("-fstrict-enums");
Index: lib/Frontend/CompilerInvocation.cpp
===================================================================
--- lib/Frontend/CompilerInvocation.cpp (revision 178718)
+++ lib/Frontend/CompilerInvocation.cpp (working copy)
@@ -324,6 +324,7 @@
   Opts.UseRegisterSizedBitfieldAccess = Args.hasArg(
     OPT_fuse_register_sized_bitfield_access);
   Opts.RelaxedAliasing = Args.hasArg(OPT_relaxed_aliasing);
+  Opts.StructPathTBAA = Args.hasArg(OPT_struct_path_tbaa);
   Opts.DwarfDebugFlags = Args.getLastArgValue(OPT_dwarf_debug_flags);
   Opts.MergeAllConstants = !Args.hasArg(OPT_fno_merge_all_constants);
   Opts.NoCommon = Args.hasArg(OPT_fno_common);
Index: test/CodeGen/tbaa.cpp
===================================================================
--- test/CodeGen/tbaa.cpp (revision 0)
+++ test/CodeGen/tbaa.cpp (working copy)
@@ -0,0 +1,217 @@
+// RUN: %clang_cc1 -O1 -disable-llvm-optzns %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -O1 -struct-path-tbaa -disable-llvm-optzns %s -emit-llvm -o - | FileCheck %s -check-prefix=PATH
+// Test TBAA metadata generated by front-end.
+
+#include <stdint.h>
+typedef struct
+{
+   uint16_t f16;
+   uint32_t f32;
+   uint16_t f16_2;
+   uint32_t f32_2;
+} StructA;
+typedef struct
+{
+   uint16_t f16;
+   StructA a;
+   uint32_t f32;
+} StructB;
+typedef struct
+{
+   uint16_t f16;
+   StructB b;
+   uint32_t f32;
+} StructC;
+typedef struct
+{
+   uint16_t f16;
+   StructB b;
+   uint32_t f32;
+   uint8_t f8;
+} StructD;
+
+typedef struct
+{
+   uint16_t f16;
+   uint32_t f32;
+} StructS;
+typedef struct
+{
+   uint16_t f16;
+   uint32_t f32;
+} StructS2;
+
+uint32_t g(uint32_t *s, StructA *A, uint64_t count) {
+// CHECK: define i32 @{{.*}}(
+// CHECK: store i32 1, i32* %{{.*}}, align 4, !tbaa !4
+// CHECK: store i32 4, i32* %{{.*}}, align 4, !tbaa !4
+// PATH: define i32 @{{.*}}(
+// PATH: store i32 1, i32* %{{.*}}, align 4, !tbaa !4
+// PATH: store i32 4, i32* %{{.*}}, align 4, !tbaa !5
+  *s = 1;
+  A->f32 = 4;
+  return *s;
+}
+
+uint32_t g2(uint32_t *s, StructA *A, uint64_t count) {
+// CHECK: define i32 @{{.*}}(
+// CHECK: store i32 1, i32* %{{.*}}, align 4, !tbaa !4
+// CHECK: store i16 4, i16* %{{.*}}, align 2, !tbaa !5
+// PATH: define i32 @{{.*}}(
+// PATH: store i32 1, i32* %{{.*}}, align 4, !tbaa !4
+// PATH: store i16 4, i16* %{{.*}}, align 2, !tbaa !8
+  *s = 1;
+  A->f16 = 4;
+  return *s;
+}
+
+uint32_t g3(StructA *A, StructB *B, uint64_t count) {
+// CHECK: define i32 @{{.*}}(
+// CHECK: store i32 1, i32* %{{.*}}, align 4, !tbaa !4
+// CHECK: store i32 4, i32* %{{.*}}, align 4, !tbaa !4
+// PATH: define i32 @{{.*}}(
+// PATH: store i32 1, i32* %{{.*}}, align 4, !tbaa !5
+// PATH: store i32 4, i32* %{{.*}}, align 4, !tbaa !9
+  A->f32 = 1;
+  B->a.f32 = 4;
+  return A->f32;
+}
+
+uint32_t g4(StructA *A, StructB *B, uint64_t count) {
+// CHECK: define i32 @{{.*}}(
+// CHECK: store i32 1, i32* %{{.*}}, align 4, !tbaa !4
+// CHECK: store i16 4, i16* %{{.*}}, align 2, !tbaa !5
+// PATH: define i32 @{{.*}}(
+// PATH: store i32 1, i32* %{{.*}}, align 4, !tbaa !5
+// PATH: store i16 4, i16* %{{.*}}, align 2, !tbaa !11
+  A->f32 = 1;
+  B->a.f16 = 4;
+  return A->f32;
+}
+
+uint32_t g5(StructA *A, StructB *B, uint64_t count) {
+// CHECK: define i32 @{{.*}}(
+// CHECK: store i32 1, i32* %{{.*}}, align 4, !tbaa !4
+// CHECK: store i32 4, i32* %{{.*}}, align 4, !tbaa !4
+// PATH: define i32 @{{.*}}(
+// PATH: store i32 1, i32* %{{.*}}, align 4, !tbaa !5
+// PATH: store i32 4, i32* %{{.*}}, align 4, !tbaa !12
+  A->f32 = 1;
+  B->f32 = 4;
+  return A->f32;
+}
+
+uint32_t g6(StructA *A, StructB *B, uint64_t count) {
+// CHECK: define i32 @{{.*}}(
+// CHECK: store i32 1, i32* %{{.*}}, align 4, !tbaa !4
+// CHECK: store i32 4, i32* %{{.*}}, align 4, !tbaa !4
+// PATH: define i32 @{{.*}}(
+// PATH: store i32 1, i32* %{{.*}}, align 4, !tbaa !5
+// PATH: store i32 4, i32* %{{.*}}, align 4, !tbaa !13
+  A->f32 = 1;
+  B->a.f32_2 = 4;
+  return A->f32;
+}
+
+uint32_t g7(StructA *A, StructS *S, uint64_t count) {
+// CHECK: define i32 @{{.*}}(
+// CHECK: store i32 1, i32* %{{.*}}, align 4, !tbaa !4
+// CHECK: store i32 4, i32* %{{.*}}, align 4, !tbaa !4
+// PATH: define i32 @{{.*}}(
+// PATH: store i32 1, i32* %{{.*}}, align 4, !tbaa !5
+// PATH: store i32 4, i32* %{{.*}}, align 4, !tbaa !14
+  A->f32 = 1;
+  S->f32 = 4;
+  return A->f32;
+}
+
+uint32_t g8(StructA *A, StructS *S, uint64_t count) {
+// CHECK: define i32 @{{.*}}(
+// CHECK: store i32 1, i32* %{{.*}}, align 4, !tbaa !4
+// CHECK: store i16 4, i16* %{{.*}}, align 2, !tbaa !5
+// PATH: define i32 @{{.*}}(
+// PATH: store i32 1, i32* %{{.*}}, align 4, !tbaa !5
+// PATH: store i16 4, i16* %{{.*}}, align 2, !tbaa !16
+  A->f32 = 1;
+  S->f16 = 4;
+  return A->f32;
+}
+
+uint32_t g9(StructS *S, StructS2 *S2, uint64_t count) {
+// CHECK: define i32 @{{.*}}(
+// CHECK: store i32 1, i32* %{{.*}}, align 4, !tbaa !4
+// CHECK: store i32 4, i32* %{{.*}}, align 4, !tbaa !4
+// PATH: define i32 @{{.*}}(
+// PATH: store i32 1, i32* %{{.*}}, align 4, !tbaa !14
+// PATH: store i32 4, i32* %{{.*}}, align 4, !tbaa !17
+  S->f32 = 1;
+  S2->f32 = 4;
+  return S->f32;
+}
+
+uint32_t g10(StructS *S, StructS2 *S2, uint64_t count) {
+// CHECK: define i32 @{{.*}}(
+// CHECK: store i32 1, i32* %{{.*}}, align 4, !tbaa !4
+// CHECK: store i16 4, i16* %{{.*}}, align 2, !tbaa !5
+// PATH: define i32 @{{.*}}(
+// PATH: store i32 1, i32* %{{.*}}, align 4, !tbaa !14
+// PATH: store i16 4, i16* %{{.*}}, align 2, !tbaa !19
+  S->f32 = 1;
+  S2->f16 = 4;
+  return S->f32;
+}
+
+uint32_t g11(StructC *C, StructD *D, uint64_t count) {
+// CHECK: define i32 @{{.*}}(
+// CHECK: store i32 1, i32* %{{.*}}, align 4, !tbaa !4
+// CHECK: store i32 4, i32* %{{.*}}, align 4, !tbaa !4
+// PATH: define i32 @{{.*}}(
+// PATH: store i32 1, i32* %{{.*}}, align 4, !tbaa !20
+// PATH: store i32 4, i32* %{{.*}}, align 4, !tbaa !22
+  C->b.a.f32 = 1;
+  D->b.a.f32 = 4;
+  return C->b.a.f32;
+}
+
+uint32_t g12(StructC *C, StructD *D, uint64_t count) {
+// CHECK: define i32 @{{.*}}(
+// CHECK: store i32 1, i32* %{{.*}}, align 4, !tbaa !4
+// CHECK: store i32 4, i32* %{{.*}}, align 4, !tbaa !4
+// TODO: differentiate the two accesses.
+// PATH: define i32 @{{.*}}(
+// PATH: store i32 1, i32* %{{.*}}, align 4, !tbaa !9
+// PATH: store i32 4, i32* %{{.*}}, align 4, !tbaa !9
+  StructB *b1 = &(C->b);
+  StructB *b2 = &(D->b);
+  // b1, b2 have different context.
+  b1->a.f32 = 1;
+  b2->a.f32 = 4;
+  return b1->a.f32;
+}
+
+// CHECK: !1 = metadata !{metadata !"omnipotent char", metadata !2}
+// CHECK: !2 = metadata !{metadata !"Simple C/C++ TBAA"}
+// CHECK: !4 = metadata !{metadata !"int", metadata !1}
+// CHECK: !5 = metadata !{metadata !"short", metadata !1}
+
+// PATH: !1 = metadata !{metadata !"omnipotent char", metadata !2}
+// PATH: !4 = metadata !{metadata !"int", metadata !1}
+// PATH: !5 = metadata !{metadata !6, metadata !4, i64 4}
+// PATH: !6 = metadata !{metadata !"_ZTS7StructA", i64 0, metadata !7, i64 4, metadata !4}
+// PATH: !7 = metadata !{metadata !"short", metadata !1}
+// PATH: !8 = metadata !{metadata !6, metadata !7, i64 0}
+// PATH: !9 = metadata !{metadata !10, metadata !4, i64 8}
+// PATH: !10 = metadata !{metadata !"_ZTS7StructB", i64 0, metadata !7, i64 4, metadata !6, i64 20, metadata !4}
+// PATH: !11 = metadata !{metadata !10, metadata !7, i64 4}
+// PATH: !12 = metadata !{metadata !10, metadata !4, i64 20}
+// PATH: !13 = metadata !{metadata !10, metadata !4, i64 16}
+// PATH: !14 = metadata !{metadata !15, metadata !4, i64 4}
+// PATH: !15 = metadata !{metadata !"_ZTS7StructS", i64 0, metadata !7, i64 4, metadata !4}
+// PATH: !16 = metadata !{metadata !15, metadata !7, i64 0}
+// PATH: !17 = metadata !{metadata !18, metadata !4, i64 4}
+// PATH: !18 = metadata !{metadata !"_ZTS8StructS2", i64 0, metadata !7, i64 4, metadata !4}
+// PATH: !19 = metadata !{metadata !18, metadata !7, i64 0}
+// PATH: !20 = metadata !{metadata !21, metadata !4, i64 12}
+// PATH: !21 = metadata !{metadata !"_ZTS7StructC", i64 0, metadata !7, i64 4, metadata !10, i64 28, metadata !4}
+// PATH: !22 = metadata !{metadata !23, metadata !4, i64 12}
+// PATH: !23 = metadata !{metadata !"_ZTS7StructD", i64 0, metadata !7, i64 4, metadata !10, i64 28, metadata !4, i64 32, metadata !1}

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

11 years agoRemove the unused MemoryBuffers, no functionality change.
Argyrios Kyrtzidis [Thu, 4 Apr 2013 19:44:10 +0000 (19:44 +0000)]
Remove the unused MemoryBuffers, no functionality change.

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

11 years agoFix bug discovered with address sanitizer.
Daniel Jasper [Thu, 4 Apr 2013 19:31:00 +0000 (19:31 +0000)]
Fix bug discovered with address sanitizer.

Now, this works again with an empty stack.

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

11 years agoObjective-C: Issue deprecated warning when using a
Fariborz Jahanian [Thu, 4 Apr 2013 18:45:52 +0000 (18:45 +0000)]
Objective-C: Issue deprecated warning when using a
deprecated typedef to subclass or invoke a class method.
// rdar://13569424

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

11 years agoAdd test case to show that 'availability' and 'deprecated' do *not* inherit when...
Ted Kremenek [Thu, 4 Apr 2013 17:58:30 +0000 (17:58 +0000)]
Add test case to show that 'availability' and 'deprecated' do *not* inherit when redeclaring ObjC properties.

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

11 years agoUse isExternalLinkage instead of hasExternalLinkage.
Rafael Espindola [Thu, 4 Apr 2013 17:16:12 +0000 (17:16 +0000)]
Use isExternalLinkage instead of hasExternalLinkage.

Having these not be the same makes an easy to misuse API. We should audit the
uses and probably rename to something like

foo->hasExternalLinkage():
  The c++ standard one. That is UniqueExternalLinkage or ExternalLinkage.

foo->hasUniqueExternalLinkage():
  Is UniqueExternalLinkage.

foo->hasCogeGenExternalLinkage():
  Is ExternalLinkage.

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

11 years agoMake helpers static & 80 cols.
Benjamin Kramer [Thu, 4 Apr 2013 17:07:04 +0000 (17:07 +0000)]
Make helpers static & 80 cols.

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

11 years agoFix a recent linkage regression.
Rafael Espindola [Thu, 4 Apr 2013 16:43:41 +0000 (16:43 +0000)]
Fix a recent linkage regression.

Now that we don't have a semantic storage class, use the linkage.

Thanks to Bruce Stephens for reporting this.

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

11 years agoPropagate path to ASan/MSan symbolizer into test environment to produce useful report...
Alexey Samsonov [Thu, 4 Apr 2013 07:41:20 +0000 (07:41 +0000)]
Propagate path to ASan/MSan symbolizer into test environment to produce useful reports on errors.

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

11 years agoPlumb through the -fsplit-stack option using the existing backend
Eric Christopher [Thu, 4 Apr 2013 06:29:47 +0000 (06:29 +0000)]
Plumb through the -fsplit-stack option using the existing backend
support.

Caveat: Other than the existing segmented stacks support, no
claims are made of this working.

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

11 years agoRevert r177948. We decided that we do not want ObjC property redeclarations to inher...
Ted Kremenek [Thu, 4 Apr 2013 05:29:15 +0000 (05:29 +0000)]
Revert r177948.  We decided that we do not want ObjC property redeclarations to inherit "deprecated".

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

11 years agoAdd hasExternalLinkageUncached back with the test that Richard provided, but
Rafael Espindola [Thu, 4 Apr 2013 04:40:17 +0000 (04:40 +0000)]
Add hasExternalLinkageUncached back with the test that Richard provided, but
keep the call at the current location.

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

11 years agoDon't build this test with modules for now, it's causing buildbot failures.
Richard Smith [Thu, 4 Apr 2013 03:48:33 +0000 (03:48 +0000)]
Don't build this test with modules for now, it's causing buildbot failures.

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

11 years agoAvoid computing the linkage instead of avoiding caching it.
Rafael Espindola [Thu, 4 Apr 2013 03:27:32 +0000 (03:27 +0000)]
Avoid computing the linkage instead of avoiding caching it.

This mostly reverts 178733, but keeps the tests.

I don't claim to understand how hidden sub modules work or when we need to see
them (is that documented?), but this has the same semantics and avoids adding
hasExternalLinkageUncached which has the same foot gun potential as the old
hasExternalLinkage.

Last but not least, not computing linkage when it is not needed is more
efficient.

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

11 years agoAdd tests that build modules for our builtin headers, and fix two buglets exposed...
Richard Smith [Thu, 4 Apr 2013 02:55:24 +0000 (02:55 +0000)]
Add tests that build modules for our builtin headers, and fix two buglets exposed by doing so.

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

11 years agoFix linkage related crash.
Rafael Espindola [Thu, 4 Apr 2013 02:47:57 +0000 (02:47 +0000)]
Fix linkage related crash.

This test was exactly the opposite of what it should be. We should check if
there old decl has linkage (where it makes sense) and if the new decl has
the extern keyword.

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

11 years agoFix 41 of the 61 tests which fail with modules enabled: we were computing and
Richard Smith [Thu, 4 Apr 2013 01:51:11 +0000 (01:51 +0000)]
Fix 41 of the 61 tests which fail with modules enabled: we were computing and
caching the linkage for a declaration before we set up its redeclaration chain,
when determining whether a declaration could be a redeclaration of something
from an unimported submodule. We actually want to look at the declaration as if
it were not a redeclaration here, so compute the linkage but don't cache it.

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

11 years agoBe sure to check ARC conventions on the implicit method declarations
John McCall [Thu, 4 Apr 2013 01:38:37 +0000 (01:38 +0000)]
Be sure to check ARC conventions on the implicit method declarations
of a property just in case the property's getter happens to be +1.
We won't synthesize a getter for such a property, but we will allow
the user to define a +1 method for it.
rdar://13115896

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

11 years agocmake: mark clang as needing exported symbol.
Rafael Espindola [Thu, 4 Apr 2013 00:58:40 +0000 (00:58 +0000)]
cmake: mark clang as needing exported symbol.

This is a nop right now, but committing this first avoids a temporary breakage
when the llvm files change to not default to exporting symbols.

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

11 years agoProtect the values of array and dictionary literals from the
John McCall [Thu, 4 Apr 2013 00:20:38 +0000 (00:20 +0000)]
Protect the values of array and dictionary literals from the
ARC optimizer while they're held in local unsafe buffers.

Based on a patch by Jesse Rusak!

rdar://13573224

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

11 years agoMake the ObjC attributes diagnostics a bit more informative.
Nico Weber [Thu, 4 Apr 2013 00:15:10 +0000 (00:15 +0000)]
Make the ObjC attributes diagnostics a bit more informative.

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

11 years agoUpdate OpenCL comments to mention spec section and version.
Tanya Lattner [Wed, 3 Apr 2013 23:55:58 +0000 (23:55 +0000)]
Update OpenCL comments to mention spec section and version.

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

11 years ago<rdar://problem/13560075> Teach name lookup for builtin names to find hidden declarat...
Douglas Gregor [Wed, 3 Apr 2013 23:06:26 +0000 (23:06 +0000)]
<rdar://problem/13560075> Teach name lookup for builtin names to find hidden declarations.

Normal name lookup ignores any hidden declarations. When name lookup
for builtin declarations fails, we just synthesize a new
declaration at the point of use. With modules, this could lead to
multiple declarations of the same builtin, if one came from a (hidden)
submodule that was later made visible. Teach name lookup to always
find builtin names, so we don't create these redundant declarations in
the first place.

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

11 years agoRevert accidental commit.
Richard Smith [Wed, 3 Apr 2013 22:50:34 +0000 (22:50 +0000)]
Revert accidental commit.

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

11 years agoPare back r164351 somewhat. The problem that change was addressing was that we
Richard Smith [Wed, 3 Apr 2013 22:49:41 +0000 (22:49 +0000)]
Pare back r164351 somewhat. The problem that change was addressing was that we
don't serialize a lookup map for the translation unit outside C++ mode, so we
can't tell when lookup within the TU needs to look within modules. Only apply
the fix outside C++ mode, and only to the translation unit.

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

11 years ago[analyzer] Allow tracknullOrUndef look through the ternary operator even when conditi...
Anna Zaks [Wed, 3 Apr 2013 21:34:12 +0000 (21:34 +0000)]
[analyzer] Allow tracknullOrUndef look through the ternary operator even when condition is unknown

Improvement of r178684 and r178685.

Jordan has pointed out that I should not rely on the value of the condition to know which expression branch
has been taken. It will not work in cases the branch condition is an unknown value (ex: we do not track the constraints for floats).
The better way of doing this would be to find out if the current node is the right or left successor of the node
that has the ternary operator as a terminator (which is how this is done in other places, like ConditionBRVisitor).

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

11 years ago[preprocessor] Minor optimization following r178671.
Argyrios Kyrtzidis [Wed, 3 Apr 2013 21:29:07 +0000 (21:29 +0000)]
[preprocessor] Minor optimization following r178671.

Don't bother looking for parameter index of 'B' token if 'A' is not a parameter.

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

11 years agoComplain about attempts to befriend declarations via a using
John McCall [Wed, 3 Apr 2013 21:19:47 +0000 (21:19 +0000)]
Complain about attempts to befriend declarations via a using
declaration.  Patch by Stephen Lin!

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