]> granicus.if.org Git - clang/log
clang
11 years agoRepeat some #line directive tests for the GNU line marker directive.
Michael Ilseman [Wed, 10 Apr 2013 01:41:19 +0000 (01:41 +0000)]
Repeat some #line directive tests for the GNU line marker directive.

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

11 years agoImprove the diagnostics of the number-reading preprocessor directives.
Michael Ilseman [Wed, 10 Apr 2013 01:04:18 +0000 (01:04 +0000)]
Improve the diagnostics of the number-reading preprocessor directives.

The GNU line marker directive was sharing code with the #line directive, but some of the warnings/errors were reporting as #line directive diagnostics in both cases.

Previously:
#line 11foo1   ==> "#line directive requires a simple digit sequence"
# 11foo1       ==> "#line directive requires a simple digit sequence"

Now, we get:
#line 11foo1   ==> "#line directive requires a simple digit sequence"
# 11foo1       ==> "GNU line marker directive requires a simple digit sequence"

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

11 years agoSuppress -Wunused-variable for variables declared in headers, which may in
Matt Beaumont-Gay [Wed, 10 Apr 2013 00:47:10 +0000 (00:47 +0000)]
Suppress -Wunused-variable for variables declared in headers, which may in
fact be defined and used in another TU.

Reshuffle some test cases because we suppress -Wunused-variable after we've
emitted an error.

This fixes PR15558.

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

11 years agoRemove outdated run lines from tests.
Richard Trieu [Tue, 9 Apr 2013 22:06:27 +0000 (22:06 +0000)]
Remove outdated run lines from tests.

These run lines originally tested that the fix-its were properly applied.
Originally, the fixits were attached to warnings and were applied by -fixit.
Now, the fixits are attached to notes, so nothing happens.  These run lines
still manage to pass since Clang will produce an empty output which gets piped
back to Clang.  Then Clang produces no error on an empty input.

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

11 years agoUpdating cpp11-migrate transform list in ClangTools docs
Edwin Vane [Tue, 9 Apr 2013 20:51:47 +0000 (20:51 +0000)]
Updating cpp11-migrate transform list in ClangTools docs

Author: Philip Dunstan <phil@phildunstan.com>

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

11 years agoAdding new AST Matchers isVirtual and isOverride
Edwin Vane [Tue, 9 Apr 2013 20:46:36 +0000 (20:46 +0000)]
Adding new AST Matchers isVirtual and isOverride

isVirtual - matches CXXMethodDecl nodes for virtual methods
isOverride - matches CXXMethodDecl nodes for methods that override virtual methods from a base class.

Author: Philip Dunstan <phil@philipdunstan.com>

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

11 years ago[c-index-test] Enable 'display diagnostics' when using the -test-load functionality.
Argyrios Kyrtzidis [Tue, 9 Apr 2013 20:29:24 +0000 (20:29 +0000)]
[c-index-test] Enable 'display diagnostics' when using the -test-load functionality.

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

11 years ago[libclang] In cxtu::getASTUnit(), check for a null CXTranslationUnit.
Argyrios Kyrtzidis [Tue, 9 Apr 2013 20:03:03 +0000 (20:03 +0000)]
[libclang] In cxtu::getASTUnit(), check for a null CXTranslationUnit.

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

11 years agoObjective-C: This patch fixes a none-issuance of warning
Fariborz Jahanian [Tue, 9 Apr 2013 17:52:29 +0000 (17:52 +0000)]
Objective-C: This patch fixes a none-issuance of warning
when result type of protocol property and getter method
differ by fixing a more serious problem. When a forward
protocol declaration comes between its definition and
its use in class protocol list, the forward protocol
ast was being used in building the protocol list.
// rdar://12522752

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

11 years agoFix comments before labels.
Daniel Jasper [Tue, 9 Apr 2013 17:46:55 +0000 (17:46 +0000)]
Fix comments before labels.

Before:
switch (...) {
  // a
  // b
// c
case first:
  break;
}

After:
switch (...) {
// a
// b
// c
case first:
  break;
}

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

11 years agoAgain macros without trailing semicolons: don't care about declaration context.
Alexander Kornienko [Tue, 9 Apr 2013 16:15:19 +0000 (16:15 +0000)]
Again macros without trailing semicolons: don't care about declaration context.

Summary:
Some codebases use these kinds of macros in functions, e.g. Chromium's
IPC_BEGIN_MESSAGE_MAP, IPC_BEGIN_MESSAGE_HANDLER, etc.

Reviewers: djasper, klimek

Reviewed By: klimek

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

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

11 years agoImprovements to clang-format integrations.
Daniel Jasper [Tue, 9 Apr 2013 15:23:04 +0000 (15:23 +0000)]
Improvements to clang-format integrations.

This adds an emacs editor integration (thanks to Ami Fischman). Also
pulls out the style into a variable for the vi integration and just
uses clang-formats defaults style in clang-format-diff.py.

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

11 years agoMention the changes in the handling of language linkage in the release notes.
Rafael Espindola [Tue, 9 Apr 2013 12:51:24 +0000 (12:51 +0000)]
Mention the changes in the handling of language linkage in the release notes.

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

11 years ago[ms-cxxabi] Add "$$C" when mangling template arg QualTypes
Reid Kleckner [Tue, 9 Apr 2013 12:47:38 +0000 (12:47 +0000)]
[ms-cxxabi] Add "$$C" when mangling template arg QualTypes

Credit goes to Timur Iskhodzhanov for finding the problem and solution.

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

11 years agoOne more follow-up to r179082 - parse PIC/PIE arguments even on platfroms that force...
Alexey Samsonov [Tue, 9 Apr 2013 12:28:19 +0000 (12:28 +0000)]
One more follow-up to r179082 - parse PIC/PIE arguments even on platfroms that force default PIC (like Darwin x86-64), otherwise specifying -fPIC will produce bogus unused argument warning

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

11 years agoFollow-up for r179082: more careful handling of -f(no-)sanitize-address-zero-base...
Alexey Samsonov [Tue, 9 Apr 2013 07:27:44 +0000 (07:27 +0000)]
Follow-up for r179082: more careful handling of -f(no-)sanitize-address-zero-base-shadow on Android

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

11 years agoIf the user requested a zero-base-shadow sanitizer, infer -pie and -fPIC when appropr...
Peter Collingbourne [Tue, 9 Apr 2013 04:35:11 +0000 (04:35 +0000)]
If the user requested a zero-base-shadow sanitizer, infer -pie and -fPIC when appropriate.

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

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

11 years ago[analyzer] Replace isIntegerType() with isIntegerOrEnumerationType().
Jordan Rose [Tue, 9 Apr 2013 02:30:33 +0000 (02:30 +0000)]
[analyzer] Replace isIntegerType() with isIntegerOrEnumerationType().

Previously, the analyzer used isIntegerType() everywhere, which uses the C
definition of "integer". The C++ predicate with the same behavior is
isIntegerOrUnscopedEnumerationType().

However, the analyzer is /really/ using this to ask if it's some sort of
"integrally representable" type, i.e. it should include C++11 scoped
enumerations as well. hasIntegerRepresentation() sounds like the right
predicate, but that includes vectors, which the analyzer represents by its
elements.

This commit audits all uses of isIntegerType() and replaces them with the
general isIntegerOrEnumerationType(), except in some specific cases where
it makes sense to exclude scoped enumerations, or any enumerations. These
cases now use isIntegerOrUnscopedEnumerationType() and getAs<BuiltinType>()
plus BuiltinType::isInteger().

isIntegerType() is hereby banned in the analyzer - lib/StaticAnalysis and
include/clang/StaticAnalysis. :-)

Fixes real assertion failures. PR15703 / <rdar://problem/12350701>

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

11 years agoWhen checking for illegal expressions in a default-argument
John McCall [Tue, 9 Apr 2013 01:56:28 +0000 (01:56 +0000)]
When checking for illegal expressions in a default-argument
expression, look through pseudo-object expressions.

rdar://13602832

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

11 years agoSkip transparent contexts when looking for using directives in name lookup.
Douglas Gregor [Tue, 9 Apr 2013 01:49:26 +0000 (01:49 +0000)]
Skip transparent contexts when looking for using directives in name lookup.

Fixes the bootstrap regression I introduced in r179067.

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

11 years agoMark as referenced the functions from instantiated UserDefinedLiterals.
Argyrios Kyrtzidis [Tue, 9 Apr 2013 01:17:02 +0000 (01:17 +0000)]
Mark as referenced the functions from instantiated UserDefinedLiterals.

Fixes rdar://13589856

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

11 years ago[analyzer] Keep tracking the pointer after the escape to more aggressively report...
Anna Zaks [Tue, 9 Apr 2013 00:30:28 +0000 (00:30 +0000)]
[analyzer] Keep tracking the pointer after the escape to more aggressively report mismatched deallocator

Test that the path notes do not change. I don’t think we should print a note on escape.

Also, I’ve removed a check that assumed that the family stored in the RefStete could be
AF_None and added an assert in the constructor.

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

11 years agoAdd test case calling a deprecated method from a subclass that reimplements that...
Ted Kremenek [Mon, 8 Apr 2013 23:39:32 +0000 (23:39 +0000)]
Add test case calling a deprecated method from a subclass that reimplements that method gets a warning.

Test case from <rdar://problem/11627873>.

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

11 years agoDon't copy just to capture a strong block pointer under ARC.
John McCall [Mon, 8 Apr 2013 23:27:49 +0000 (23:27 +0000)]
Don't copy just to capture a strong block pointer under ARC.
It turns out that the optimizer can't eliminate this without extra
information, for which there's a separate bug.

rdar://13588325

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

11 years ago<rdar://problem/13584715> Converted constant expressions are expected to have integra...
Douglas Gregor [Mon, 8 Apr 2013 23:24:07 +0000 (23:24 +0000)]
<rdar://problem/13584715> Converted constant expressions are expected to have integral values.

We were assuming that any expression used as a converted constant
expression would either not have a folded constant value or would be
an integer, which is not the case for some ill-formed constant
expressions. Because converted constant expressions are only used
where integral values are expected, we can simply treat this as an
error path. If that ever changes, we'll need to widen the interface of
Sema::CheckConvertedConstantExpression() anyway.

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

11 years ago<rdar://problem/13540899> Collect using directives from all of the semantic contexts...
Douglas Gregor [Mon, 8 Apr 2013 23:11:25 +0000 (23:11 +0000)]
<rdar://problem/13540899> Collect using directives from all of the semantic contexts not represented by scopes.

This fixes a regression I introduced in r178136, where we would not
consider the using directives from the semantic declaration contexts
that aren't represented by the lexical scopes (Scope) when performing
unqualified name lookup. This lead to horribly funny diagnostics like
"no identifier named 'foo'; did you mean 'foo'?".

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

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