Commit Graph

40784 Commits

Author SHA1 Message Date
Lang Hames 05a3e31a21 Test file-scoped FP_CONTRACT pragma.
llvm-svn: 165196
2012-10-04 03:07:37 +00:00
Eli Friedman 68be1649ee Permanently end the whole "pragma got handled by the parser too early"
mess by handling all pragmas which the parser touches uniformly.
<rdar://problem/12248901>, etc.

llvm-svn: 165195
2012-10-04 02:36:51 +00:00
Bill Wendling 84ad5129a2 Add an explicit -object_path_lto flag during linking with a uniquified temporary
file name if building Apple-style.

llvm-svn: 165184
2012-10-03 23:49:57 +00:00
Fariborz Jahanian 8061f92c6b use ';' instead of '-' in the note part of my last patch.
llvm-svn: 165177
2012-10-03 22:39:32 +00:00
Chad Rosier bea1fa1ac3 Update test case for r165174.
llvm-svn: 165175
2012-10-03 22:18:51 +00:00
Sean Silva f85f39df47 tblgen: Migrate clang-tblgen to new TableGenMain API.
llvm-svn: 165167
2012-10-03 21:29:30 +00:00
Bill Wendling a1ec84474b Remove the directory that these are already in.
llvm-svn: 165162
2012-10-03 21:08:21 +00:00
Argyrios Kyrtzidis f484b139db [libclang] When indexing, invoke the importedASTFile for PCH files as well.
llvm-svn: 165161
2012-10-03 21:05:51 +00:00
Argyrios Kyrtzidis 184b14428e [libclang] Simplify indexing of module imports by handling implicit
imports via ImportDecls.

llvm-svn: 165160
2012-10-03 21:05:44 +00:00
Richard Smith b815525223 PR14004: Fix typo in documentation.
llvm-svn: 165158
2012-10-03 21:02:25 +00:00
Benjamin Kramer bf56beab7e Fix invalid reads by memcmp.
Str may be smaller than Start->Name here. Use strncmp to avoid scanning past the
end. Found by valgrind.

llvm-svn: 165157
2012-10-03 20:58:09 +00:00
Benjamin Kramer b15b97ef9a Always initialize FPContractable.
false is used as a baseline here, we may want to allow contraction in some of
the cases.  Found by valgrind.

llvm-svn: 165156
2012-10-03 20:58:04 +00:00
Michael J. Spencer bfdde7cb60 [Options] Store the owning OptTable in Option so it can construct Group and Alias.
llvm-svn: 165150
2012-10-03 19:58:10 +00:00
Simon Atanasyan b16488c9fb Remove useless parameter "WantFile" from Driver::GetProgramPath().
This parameter is useless because nowhere used explicitly and always
gets its default value - "false".

The patch reviewed by Rafael Espindola.

llvm-svn: 165149
2012-10-03 19:52:37 +00:00
Bill Schmidt 25cb349a17 This patch enables general varargs support for the 64-bit PPC SVR4 ABI.
Most of the pieces for this were already in place, but a proper EmitVAArg
is needed for aggregates and complex numbers to be handled.  Although the
va_list for 64-bit PowerPC SVR4 consists of GPRs 3 through 10 together with
the overflow portion of the parameter save area, we can treat va_list as
pointing to contiguous memory for all parameters, since the back end forces
the parameter GPRs to memory for varargs functions.

There is no need at this time to model parameters and return values beyond
what the DefaultABIInfo provides.

llvm-svn: 165143
2012-10-03 19:18:57 +00:00
Fariborz Jahanian e0e4bd3c76 Fix a typo in my last patch reported by Erik Schwiebert.
llvm-svn: 165142
2012-10-03 19:05:41 +00:00
Douglas Gregor e96037923f Remove ASTReader::needPendingInstantiation(), introduced in r164993,
which is neither correct nor necessary. The use of this routine was
eliminated by r165137.

llvm-svn: 165139
2012-10-03 18:38:43 +00:00
Douglas Gregor e4a838ac3f Add some FIXMEs to the ASTReader code
llvm-svn: 165138
2012-10-03 18:36:10 +00:00
Douglas Gregor 559458c830 Revert most of the functionality in r165001. Instead, make sure that
the ASTReader doesn't attach a body to a function that is already
defined elsewhere.

llvm-svn: 165137
2012-10-03 18:34:48 +00:00
Fariborz Jahanian 4a67508685 objective-C arc: Warn under arc about a use of an ivar inside a block
that doesn't have a 'self' as this implicitly captures 'self' and could
create retain cycles. Provide fixit. // rdar://11194874

llvm-svn: 165133
2012-10-03 17:55:29 +00:00
Simon Atanasyan 53fefd1f6a Implement Adnroid MIPS toolchain support:
1. Add mipsel-linux-android to the list of valid MIPS target triples.
2. Add <gcc install path>/mips-r2 to the list of toolchain specific path
   prefixes if target is mipsel-linux-android.

The patch reviewed by Logan Chien.

llvm-svn: 165131
2012-10-03 17:46:38 +00:00
Preston Gurd 7912de6829 Fix failure of newly added test, by using %clang instead of %clang_cc1
and by specifying a target.

llvm-svn: 165130
2012-10-03 16:52:40 +00:00
Preston Gurd a3d7df6fee Adds a test to verify that Clang does the optimization to use a
fast div/rem instruction (for Intel Atom).

Test case for llvm commit 165126.

Patch by Tyler Nowicki.

llvm-svn: 165129
2012-10-03 16:37:56 +00:00
Jordan Rose ef77a87a9e Revert "InlineObjCInstanceMethod.m: Remove lines introduced in r165079."
...and fix the run line so that the expected warnings are the same on
all platforms.

This reverts r165088 / d09074f0ca06626914108f1c0d4e70adeb851e01.

llvm-svn: 165124
2012-10-03 16:00:32 +00:00
Benjamin Kramer 3da0563a35 clang-check: Add clangRewriteCore.a to the Makefile build to make it link again.
llvm-svn: 165119
2012-10-03 14:35:38 +00:00
Benjamin Kramer f5c3b9c7cb Matching block names with FileCheck requires asserts.
llvm-svn: 165118
2012-10-03 14:21:33 +00:00
Benjamin Kramer daa0961244 CodeGen: Fix a silly typo when emitting subs of block addresses.
Part of PR14005.

llvm-svn: 165117
2012-10-03 14:15:39 +00:00
Nico Weber 90a415e7ca When mangling an APSInt with the ms abi, make sure to look at all nibbles.
Currently, it's ignored if the number of set bits isn't divisible by 4.

llvm-svn: 165116
2012-10-03 13:39:49 +00:00
Daniel Jasper 30abda1612 As opposed to the clang-fixit tool described on
http://clang.llvm.org/docs/ClangTools.html, this adds -fixit option to
clang-check. Thus, clang-check can become a general-purpose tool to run
clang capitalizing on the info stored in a compilation database.

Review: http://llvm-reviews.chandlerc.com/D51
llvm-svn: 165110
2012-10-03 13:28:43 +00:00
Logan Chien b914d14e67 Fix typo in comments.
llvm-svn: 165105
2012-10-03 09:26:43 +00:00
Dmitri Gribenko 61b1db1629 Comment to XML conversion: escape XML special chars correctly; use correct
regex for version tuples.

llvm-svn: 165104
2012-10-03 09:04:56 +00:00
Bill Wendling 766d4d22ac The top-level clang Makefile is #included into other Makefiles. (sigh) So we
can't have the logic here to add in the 'tools/{driver,libclang}' directories,
because they will be added in for ALL Makefiles which #include the top-level
one. Place the logic into the 'tools' Makefile.

llvm-svn: 165103
2012-10-03 08:39:19 +00:00
Bill Wendling 32669834d3 Add the missing backslash-newline which was causing make errors.
llvm-svn: 165098
2012-10-03 08:07:20 +00:00
Alexey Samsonov 0bd3665a5c Make sure 32-bit ASan runtime is available on 64-bit Linux platforms
llvm-svn: 165097
2012-10-03 07:23:03 +00:00
Nico Weber 7dfc8be995 While I'm here, resync a %select with the enum definition it selects on.
* nullptr used to be mapped to ERROR, now mapped to nullptr
* integral was missing
* expressions now have their own error message, so they won't reach
  this. Map them to ERROR.

Note that clang usually crashes before emitting this diagnostic anyway
(see PR13984), so this change alone doesn't have an observable effect.
It makes the code more correct though.

llvm-svn: 165095
2012-10-03 06:57:02 +00:00
Nico Weber a682681058 Move expression mangling in the microsoft mangler to its own function.
This matches what's done in ItaniumMangle and makes it a bit easier
to implement mangling for more expressions. Also use the slightly nicer
"not yet implemented" error message from there.

No functionality change (except for the different error message).

llvm-svn: 165093
2012-10-03 06:46:47 +00:00
Nico Weber 1dc7e03047 Replace a default: with an explicit list of cases. No functionality change.
llvm-svn: 165091
2012-10-03 06:12:27 +00:00
John McCall d014c9e6f7 Update the block specification for some long-settled subleties.
llvm-svn: 165090
2012-10-03 04:57:59 +00:00
NAKAMURA Takumi d10e270ae6 InlineObjCInstanceMethod.m: Remove lines introduced in r165079. It broke some builds, on FreeBSD, Linux and Windows.
error: 'warning' diagnostics expected but not seen:
  Line 94: types are incompatible
1 error generated.

llvm-svn: 165088
2012-10-03 02:35:19 +00:00
Argyrios Kyrtzidis 7b8e555814 [PCH] Fix serialization of an ImportDecl.
ImportDecl's module ID was not written out and the reader accepted as module ID
the serialized:
  Record.push_back(!IdentifierLocs.empty());

llvm-svn: 165087
2012-10-03 01:58:45 +00:00
Argyrios Kyrtzidis aedf7144d1 Set the file entry for a Module* that was created during deserialization
of a module file.

llvm-svn: 165086
2012-10-03 01:58:42 +00:00
Argyrios Kyrtzidis 842ffe8806 Add a FIXME.
llvm-svn: 165085
2012-10-03 01:58:39 +00:00
Argyrios Kyrtzidis 72d1aa3cff Introduce ASTConsumer::HandleImplicitImportDecl() callback that is invoked
when an ImportDecl that was implicitly created due to an inclusion directive.

llvm-svn: 165084
2012-10-03 01:58:37 +00:00
Argyrios Kyrtzidis e514b200aa Some renames to use the 'visitor' nomenclature, no functionality change.
llvm-svn: 165083
2012-10-03 01:58:28 +00:00
Michael Han 23214e5046 Improve C++11 attribute parsing.
- General C++11 attributes were previously parsed and ignored. Now they are parsed and stored in AST.
- Add support to parse arguments of attributes that in 'gnu' namespace.
- Differentiate unknown attributes and known attributes that can't be applied to statements when emitting diagnostic.

llvm-svn: 165082
2012-10-03 01:56:22 +00:00
Jordan Rose 1dd2afd876 [analyzer] Adjust the return type of an inlined devirtualized method call.
In C++, overriding virtual methods are allowed to specify a covariant
return type -- that is, if the return type of the base method is an
object pointer type (or reference type), the overriding method's return
type can be a pointer to a subclass of the original type. The analyzer
was failing to take this into account when devirtualizing a method call,
and anything that relied on the return value having the proper type later
would crash.

In Objective-C, overriding methods are allowed to specify ANY return type,
meaning we can NEVER be sure that devirtualizing will give us a "safe"
return value. Of course, a program that does this will most likely crash
at runtime, but the analyzer at least shouldn't crash.

The solution is to check and see if the function/method being inlined is
the function that static binding would have picked. If not, check that
the return value has the same type. If the types don't match, see if we
can fix it with a derived-to-base cast (the C++ case). If we can't,
return UnknownVal to avoid crashing later.

<rdar://problem/12409977>

llvm-svn: 165079
2012-10-03 01:08:35 +00:00
Jordan Rose 9aa9980217 [analyzer] Push evalDynamicCast and evalDerivedToBase up to Store.
These functions are store-agnostic, and would benefit from information in
DynamicTypeInfo but gain nothing from the store type.

No intended functionality change.

llvm-svn: 165078
2012-10-03 01:08:32 +00:00
Jordan Rose 7bb2611400 Teach getCXXRecordDeclForPointerType about references.
Then, rename it getPointeeCXXRecordDecl and give it a nice doc comment,
and actually use it.

No intended functionality change.

llvm-svn: 165077
2012-10-03 01:08:28 +00:00
Richard Trieu 742c6ed9bf Change how the SelfReferenceChecker handles MemberExpr. Instead of treating
each one separately, process a stack of MemberExpr's as a single unit so that
static calls and member access will not be warned on.

llvm-svn: 165074
2012-10-03 00:41:36 +00:00
Chad Rosier 0c1b62779e Revert 165058, per Jim request. This requires further discussion.
llvm-svn: 165070
2012-10-02 23:38:55 +00:00
Alexander Kornienko 2d4f311642 Added a test for C++11 statement attributes serialization.
Summary: Uses [[clang::fallthrough]] attribute in a template function, and -Wimplicit-fallthrough to check the attribute presence in an instantiation.

Reviewers: rsmith

Reviewed By: rsmith

CC: cfe-commits

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

llvm-svn: 165068
2012-10-02 23:11:53 +00:00
Fariborz Jahanian e61fc44c3d [Doc parse]: SUpport for message in deprecated/unavailable
attribute going iinto XML document.

llvm-svn: 165066
2012-10-02 23:01:04 +00:00
Ted Kremenek f1245ddc78 Silence -Wunused-value warning.
llvm-svn: 165059
2012-10-02 21:50:18 +00:00
Chad Rosier 09d7710e04 [ms-inline asm] Rewrite the symbol references as wildcard MCParsedAsmOperands.
A Sema lookup is used to determine the size of the variable, which is in turn
used during wildcard matching.

llvm-svn: 165058
2012-10-02 21:49:14 +00:00
Argyrios Kyrtzidis 4db774a8ef [PCH/Module] Change the map of file-level DeclIDs to use a FileID
as key instead of a SLocEntry pointer. This allows the array of
file sorted declarations in a PCH/module to be deterministic.

llvm-svn: 165047
2012-10-02 21:09:17 +00:00
Argyrios Kyrtzidis 10e7846abf [libclang] When indexing an AST file, only deserialize the file level
declarations of the current primary module.

llvm-svn: 165046
2012-10-02 21:09:13 +00:00
Chad Rosier 7768299b98 [ms-inline asm] Fixup test case to be valid ms-style asm. Fix whitespace.
llvm-svn: 165045
2012-10-02 20:55:30 +00:00
Ted Kremenek 4924a0161b Refactor clients of AnalyzerOptions::getBooleanOption() to have
an intermediate helper method to query and populate the Optional value.

llvm-svn: 165043
2012-10-02 20:42:16 +00:00
Ted Kremenek 3c6932922e Tweak AnalyzerOptions::getOptionAsInteger() to populate the string
table, making it printable with the ConfigDump checker.  Along the
way, fix a really serious bug where the value was getting parsed
from the string in code that was in an assert() call.  This means
in a Release-Asserts build this code wouldn't work as expected.

llvm-svn: 165041
2012-10-02 20:31:56 +00:00
Ted Kremenek 5faa5e04a3 Change AnalyzerOptions::mayInlineCXXMemberFunction to default populate
the config string table.  Also setup a test for dumping the analyzer
configuration for C++.

llvm-svn: 165040
2012-10-02 20:31:52 +00:00
Fariborz Jahanian de0ae1e406 [Doc parsing]: Add available and deprecated attribute info
to XML output. // rdar://12378879

llvm-svn: 165039
2012-10-02 20:05:47 +00:00
Chad Rosier 04d5664295 [ms-inline asm] Enhance the isSimpleMSAsm() function to handle operands with pointer size
directives (e.g., dword ptr [eax]).

llvm-svn: 165031
2012-10-02 18:51:05 +00:00
Bill Wendling 5e5cf1a50c Fix test for r165028. It only generates that flag for source files now.
<rdar://problem/12401423>

llvm-svn: 165029
2012-10-02 18:07:59 +00:00
Bill Wendling 3b2000fcac During LTO, we call 'dsymutil' when we compile source files. This necessitates
clang specifying a temporary file that it later cleans up so that it can survive
the linking stage. However, when we compile object files during LTO we don't
call 'dsymutil'. That's done at a different stage (if at all). We rely upon the
linker to specify a unique name for the temporary file it generates.
<rdar://problem/12401423>

llvm-svn: 165028
2012-10-02 18:02:50 +00:00
Rafael Espindola ea0c5ecb28 Convert to FileCheck.
llvm-svn: 165026
2012-10-02 17:41:03 +00:00
Chad Rosier 0ede0986b9 No need to call the InitializeAll* functions.
llvm-svn: 165025
2012-10-02 16:41:12 +00:00
NAKAMURA Takumi 18fc445af5 FP_CONTRACT: Fix two tests for -Asserts.
llvm-svn: 165024
2012-10-02 16:36:54 +00:00
Argyrios Kyrtzidis d4fcf58070 [libclang] When indexing an AST file, only deserialize the preprocessing record
entities of the current primary module.

llvm-svn: 165023
2012-10-02 16:10:51 +00:00
Argyrios Kyrtzidis f590e094ad Add info in the preprocessing record whether an inclusion directive
resulted in an automatic module import.

llvm-svn: 165022
2012-10-02 16:10:46 +00:00
Argyrios Kyrtzidis b36ee5c592 [libclang] Even though we disable the preprocessing record during indexing,
make sure that it gets enabled for when a module needs to be created.

llvm-svn: 165021
2012-10-02 16:10:41 +00:00
Argyrios Kyrtzidis 472eda06b0 [libclang] Implement the importedASTFile indexing callback to provide
info about imported modules.

llvm-svn: 165020
2012-10-02 16:10:38 +00:00
Aaron Ballman a99c35702d Splitting this test case into two because the behavior for the calling convention code is target-specific.
llvm-svn: 165016
2012-10-02 14:56:00 +00:00
Aaron Ballman e91c6be01e Allowing individual targets to determine whether a given calling convention is allowed or ignored with warning. This allows for correct name mangling for x64 targets on Windows, which in turn allows for linking against the Win32 APIs.
Fixes PR13782

llvm-svn: 165015
2012-10-02 14:26:08 +00:00
Aaron Ballman ac11a9b572 Silencing an MSVC warning about */ being found outside of a comment.
llvm-svn: 165007
2012-10-02 13:54:25 +00:00
Axel Naumann 0439f03bcf Add redecls into their lexical DeclContext: this is what they assert on, and the merging should have set it correctly.
This is especially relevant for templatedDecls that might be injected (and thus have their DeclContext set to) somewhere completely different.

llvm-svn: 165005
2012-10-02 13:06:13 +00:00
Axel Naumann 2bd39fd2de Enable programmatic provisioning of virtual module.map files (instead of writing out actual module.map files).
Opens up the wonders of clang::Modules to tools - though they remain as experimental as before.

llvm-svn: 165002
2012-10-02 12:26:36 +00:00
Axel Naumann d9a25b3c17 Only those InterestingDecls that got added to the AST should be passed to the ASTConsumer.
llvm-svn: 165001
2012-10-02 12:18:46 +00:00
Benjamin Kramer e42d406105 -arch is a darwin-specific driver feature, use a triple instead in rewriter test.
llvm-svn: 164995
2012-10-02 09:42:36 +00:00
Benjamin Kramer 4bb04704f3 Force triple in test to unbreak it on non-darwin platforms.
llvm-svn: 164994
2012-10-02 09:29:48 +00:00
Axel Naumann 63469422c4 Merge pending instantiations instead of overwriting existing ones.
Check whether a pending instantiation needs to be instantiated (or whether an instantiation already exists).
Verify the size of the PendingInstantiations record (was only checking size of existing PendingInstantiations).

Migrate Obj-C++ part of redecl-merge into separate test, now that this is growing.
templates.mm: test that CodeGen has seen exactly one definition of template instantiations.
redecl-merge.m: use "@" specifier for expected-diagnostics.

llvm-svn: 164993
2012-10-02 09:09:43 +00:00
Bill Wendling 7e5ef83cdb Use an environment variable instead of what's in the make cmd goals.
llvm-svn: 164992
2012-10-02 06:19:15 +00:00
Ted Kremenek 2f88c40ded Tweak diagnostic text to indicate that __weak on a local variable is only allowed
for ARC.  Fixes <rdar://problem/12407705>

llvm-svn: 164990
2012-10-02 05:36:02 +00:00
Lang Hames 5de91cc35f Add FP_CONTRACT support for clang.
Clang will now honor the FP_CONTRACT pragma and emit LLVM
fmuladd intrinsics for expressions of the form A * B + C (when they occur in a
single statement).

llvm-svn: 164989
2012-10-02 04:45:10 +00:00
Ted Kremenek b67c6cc24d Check if an IdentifierInfo* is null when the FunctionDecl isn't a simple C function.
Fixes <rdar://problem/12355298>

llvm-svn: 164988
2012-10-02 04:36:54 +00:00
Chandler Carruth 01f63b950c Re-enable this test to reflect re-enabling the new SROA pass.
llvm-svn: 164987
2012-10-02 04:24:16 +00:00
Jordan Rose 3c14b2339d -Wformat: Don't check format strings in uninstantiated templates.
Also applies to -Wnonnull, -Wtype-safety, and -Wnon-pod-varargs.
All of these can be better checked at instantiation time.

This change does not actually affect regular CallExpr function calls,
since the checks there only happen after overload resolution.
However, it will affect Objective-C method calls.

<rdar://problem/12373934>

llvm-svn: 164984
2012-10-02 01:49:54 +00:00
NAKAMURA Takumi 5d62a7c5bb clang/test/Index: Fix two tests. Both %S and %t are expanded to absolute paths.
llvm-svn: 164982
2012-10-02 00:11:53 +00:00
Chad Rosier bb90c414c4 [ms-inline asm] Use the convertToMapAndConstraints() function in the front-end.
Rework the logic to account for the fact that we no longer create a MCInst.

llvm-svn: 164980
2012-10-01 23:45:59 +00:00
Michael Gottesman 101290bcef [clang-tests] Changed relative paths to absolute paths in run command for annotate-macro-args.m, get-cursor-macro-args.m, import_self.c.
This fixes make check-all failures when make -C is used to run the tests.

llvm-svn: 164978
2012-10-01 23:39:44 +00:00
Fariborz Jahanian e2a9d42297 Modern translator test. Breakup test into two and
skip the x86_64 version for mingw32 and win32.

llvm-svn: 164977
2012-10-01 23:25:52 +00:00
Fariborz Jahanian 40b169ec68 Rename a test I just added.
llvm-svn: 164971
2012-10-01 21:21:50 +00:00
Fariborz Jahanian 572cc970fb objective-C modern translator. Test for producing both
32bit and 64bit version of modern translator.
// rdar://12189793

llvm-svn: 164970
2012-10-01 20:55:56 +00:00
Richard Smith cdd1da209d Fix treatment of case which came up on std-proposals@: 'void' is permitted in core constant expressions, despite not being a literal type.
llvm-svn: 164968
2012-10-01 20:36:17 +00:00
Richard Smith 1620ebd98f PR13978: A 'decltype' DeclSpec has an expression representation, not a type
representation. Fix crash if it appears in the return type of a member function
definition.

llvm-svn: 164967
2012-10-01 20:35:07 +00:00
Anna Zaks 97c7ce3368 Move isObjCSelf into Expr.
llvm-svn: 164966
2012-10-01 20:34:04 +00:00
Anna Zaks bfacf17b8b [analyzer] Address Jordan's review for r164868.
llvm-svn: 164965
2012-10-01 20:33:58 +00:00
Fariborz Jahanian a3102b9cde Add xml test for availability to comment-xml-schema.c
llvm-svn: 164961
2012-10-01 19:10:40 +00:00
Jordan Rose 92375adafb [analyzer] Allow ObjC ivar lvalues where the base is nil.
By analogy with C structs, this seems to be legal, if probably discouraged.
It's only if the ivar is read from or written to that there's a problem.
Running a program that gets the "address" of an instance variable does in
fact return the offset when the base "object" is nil.

This isn't a full revert because r164442 includes some diagnostic tweaks
as well; those have been kept.

This partially reverts r164442 / 08965091770c9b276c238bac2f716eaa4da2dca4.

llvm-svn: 164960
2012-10-01 19:07:22 +00:00
Jordan Rose 28c06b268e [analyzer] Add a test for PR13927 "offsetof replacement flagged as null deref"
This seems to be legal according to C11 6.5.3.2.

No functionality change.

llvm-svn: 164959
2012-10-01 19:07:19 +00:00
Jordan Rose 12024f8776 Revert "[analyzer] Check that a member expr is valid even when the result is an lvalue."
The original intent of this commit was to catch potential null dereferences
early, but it breaks the common "home-grown offsetof" idiom (PR13927):

 (((struct Foo *)0)->member - ((struct foo *)0))

As it turns out, this appears to be legal in C, per a footnote in
C11 6.5.3.2: "Thus, &*E is equivalent to E (even if E is a null pointer)".
In C++ this issue is still open:
  http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#232

We'll just have to make sure we have good path notes in the future.

This reverts r164441 / 9be016dcd1ca3986873a7b66bd4bc027309ceb59.

llvm-svn: 164958
2012-10-01 19:07:15 +00:00
Fariborz Jahanian c491c3f27a availability in structured documents. Takes
care of comments by Dimitri and Doug.

llvm-svn: 164957
2012-10-01 18:42:25 +00:00
Ted Kremenek 4a5b35eeec Have AnalyzerOptions::getBooleanOption() stick the matching config
string in the config table so that it can be dumped as part of the 
config dumper.  Add a test to show that these options are sticking
and can be cross-checked using FileCheck.

llvm-svn: 164954
2012-10-01 18:28:19 +00:00
Ted Kremenek 86917fdbe0 Add checker debug.ConfigDumper to dump the contents of the configuration table.
The format of this output is a WIP; largely I'm bringing it up now
for regression testing.  We can evolve the output format over time.

llvm-svn: 164953
2012-10-01 18:28:14 +00:00
Jordan Rose 88dd13fdca Reapply "[analyzer] Handle inlined constructors for rvalue temporaries correctly."
This is related to but not blocked by <rdar://problem/12137950>
("Return-by-value structs do not have associated regions")

This reverts r164875 / 3278d41e17749dbedb204a81ef373499f10251d7.

llvm-svn: 164952
2012-10-01 17:51:35 +00:00
Richard Trieu 3267347cca Cleaning up the self initialization checker.
-Allow Sema to do more processing on the initial Expr before checking it.
-Remove the special conditions in HandleExpr()
-Move the code so that only one call site is needed.
-Removed the function from Sema and only call it locally.
-Warn on potentially evaluated reference variables, not just casts to r-values.
-Update tests.

llvm-svn: 164951
2012-10-01 17:39:51 +00:00
Jordan Rose d63f04d8a7 [analyzer] Make ProgramStateManager's SubEngine parameter optional.
It is possible and valid to have a state manager and associated objects
without having a SubEngine or checkers.

Patch by Olaf Krzikalla!

llvm-svn: 164947
2012-10-01 16:53:40 +00:00
Daniel Jasper 6f595397bc Fix ASTMatchersTests in configurations where
"#include <initializer_list>" is unavailable for whatever reason.

llvm-svn: 164944
2012-10-01 15:05:34 +00:00
Daniel Jasper 5901e47e8f Add matchers for selected C++11 features.
Patch by Gábor Horváth.
Review: http://llvm-reviews.chandlerc.com/D46

llvm-svn: 164943
2012-10-01 13:40:41 +00:00
Axel Naumann a8243e9aa2 The Redeclarable part of named decls is read before their name.
Lookup can nevertheless find them due to the serialized lookup table.
For instance when reading a template decl's templatedDecl, it will search for existing decls that it could be a redeclaration of, and find the half-read template decl.
Thus there is no point in asserting the names of decls.

llvm-svn: 164932
2012-10-01 09:51:27 +00:00
Axel Naumann 866ba3e365 Also merge template redeclarations.
Don't require specializations (of existing and read template) to be unique.

llvm-svn: 164931
2012-10-01 09:18:00 +00:00
Nico Weber 24d05b0f29 Mark two Clang tests as passing on ARM
Also move one of them from grep to FileCheck.
Patch from Joey Gouly <joey.gouly@arm.com>!

llvm-svn: 164929
2012-10-01 08:44:54 +00:00
Kostya Serebryany f6645c8071 fix test/CodeGen/tbaa-for-vptr.cpp: don't hardcode the index of metadata
llvm-svn: 164928
2012-10-01 08:39:00 +00:00
Axel Naumann a31dee2e04 Bring ASTReader and Writer into sync for the case where a canonical template specialization was written, which is non-canonical at the time of reading: force the reading of the ClassTemplateDecl if it was written.
The easiest way out is to store whether the decl was canonical at the time of writing.
Add test.

llvm-svn: 164927
2012-10-01 07:34:47 +00:00
Benjamin Kramer 1ca66919a5 CodeGen: Copy tail padding when we're not dealing with a trivial copy assign or move assign operator.
This fixes a regression from r162254, the optimizer has problems reasoning
about the smaller memcpy as it's often not safe to widen a store but making it
smaller is.

llvm-svn: 164917
2012-09-30 12:43:37 +00:00
Bill Wendling aae78b861f Filter out tools and unittests which we don't want to build when we're building clang only.
llvm-svn: 164916
2012-09-30 11:23:30 +00:00
Bill Wendling 446fb68894 Remove this hack in favor of another, better way of performing the same thing.
llvm-svn: 164915
2012-09-30 11:22:45 +00:00
Bob Wilson 7a2c7aa3d9 Specify a full target in an attempt to appease buildbots.
llvm-svn: 164908
2012-09-30 00:58:28 +00:00
Bob Wilson 2afa011e0b Add Clang support for iOS6.
llvm-svn: 164907
2012-09-29 23:52:58 +00:00
Bob Wilson 6fc8fb8da5 Add ARM VFPv4 feature and enable it by default for Swift.
llvm-svn: 164906
2012-09-29 23:52:52 +00:00
Bob Wilson d7cf104dae Add armv7s and some other arm variants supported by Mach-O files.
llvm-svn: 164905
2012-09-29 23:52:50 +00:00
Bob Wilson 39d8a132df Add an FMA intrinsic for ARM Neon.
llvm-svn: 164904
2012-09-29 23:52:48 +00:00
Bob Wilson f001a9293d Whitespace.
llvm-svn: 164900
2012-09-29 22:08:54 +00:00
Daniel Jasper 0c30337f6b Fix refersToDeclaration()-matcher and add missing test case. This was
broken as of r164656 as TemplateArgument::getAsDecl() now asserts
instead of returning NULL for other template arugment kinds.

llvm-svn: 164896
2012-09-29 15:55:18 +00:00
Dmitri Gribenko 6743e04699 Move the 'find macro by spelling' infrastructure to the Preprocessor class and
use it to suggest appropriate macro for __attribute__((deprecated)) in
-Wdocumentation-deprecated-sync.

llvm-svn: 164892
2012-09-29 11:40:46 +00:00
Dmitri Gribenko 261c9683e2 Comment XML schema: correct indentation.
llvm-svn: 164889
2012-09-29 08:27:37 +00:00
NAKAMURA Takumi 060cfdc8e9 clang/test/CodeGen/tbaa-struct.cpp: Fix. Be aware of 32 bit pointer.
llvm-svn: 164879
2012-09-29 02:00:04 +00:00
Jordan Rose d60b9168fa Revert "[analyzer] Create a temporary region for rvalue structs when accessing fields"
This reverts commit 6f61df3e7256413dcb99afb9673f4206e3c4992c.

llvm-svn: 164877
2012-09-29 01:36:51 +00:00
Jordan Rose d9b0268401 Revert "[analyzer] Create a temp region when a method is called on a struct rvalue."
This reverts commit 0006ba445962621ed82ec84400a6b978205a3fbc.

llvm-svn: 164876
2012-09-29 01:36:47 +00:00
Jordan Rose cd9000e840 Revert "[analyzer] Handle inlined constructors for rvalue temporaries correctly."
This reverts commit 580cd17f256259f39a382e967173f34d68e73859.

llvm-svn: 164875
2012-09-29 01:36:42 +00:00
Argyrios Kyrtzidis 19d78b743f For PPCallbacks::InclusionDirective() add a parameter for the module, whenever
an inclusion directive was automatically turned into a module import, and
PPCallbacks::moduleImport() for an explicit module import.

llvm-svn: 164874
2012-09-29 01:06:10 +00:00
Argyrios Kyrtzidis 43af5132c5 In the Module class, add a reference to the corresponding AST file.
llvm-svn: 164873
2012-09-29 01:06:04 +00:00
Argyrios Kyrtzidis 051b443242 Add an assertion to make sure the implicitly imported module
is the same as the suggested one when looking up the include filename.

llvm-svn: 164872
2012-09-29 01:06:01 +00:00
Anna Zaks 00a896e7a2 [analyzer] Do not visit ObjCMethodDecl twice in the AST checkers.
llvm-svn: 164869
2012-09-29 00:20:40 +00:00
Anna Zaks 0353aad5a9 [analyzer] Re-implement IvarInvalidationChecker so that it verifies that
the validation occurred.

The original implementation was pessimistic - we assumed that ivars
which escape are invalidated. This version is optimistic, it assumes
that the ivars will always be explicitly invalidated: either set to nil
or sent an invalidation message.

llvm-svn: 164868
2012-09-29 00:20:38 +00:00
Richard Smith b555a767ba PR13941: Mark all virtual functions as unnamed_addr. It's not possible to
observe their addresses (taking their address gives the vtable slot) so we are
free to merge their definitions.

llvm-svn: 164864
2012-09-28 22:46:07 +00:00
Jordan Rose 8d17c19796 Use a custom DenseMapInfo for WeakObjectProfileTy.
We can't specialize the usual llvm::DenseMapInfo at the end of the file
because by that point the DenseMap in FunctionScopeInfo has already been
instantiated.

No functionality change.

llvm-svn: 164862
2012-09-28 22:42:04 +00:00
Fariborz Jahanian 35760a8937 [Doc parsing] Add availability information to generated Comment XML.
(I still need to add a test once I figure it out).
Reviewed off-line by Doug. // rdar://12378879

llvm-svn: 164861
2012-09-28 22:35:49 +00:00
Jordan Rose d61f3b4dae Fix buildbots by not using a template from another namespace.
No need to specialize BeforeThanCompare for a comparator that's only
going to be used once.

llvm-svn: 164859
2012-09-28 22:29:02 +00:00
Alexander Kornienko e61e5625e7 Compatibility macro detection for the -Wimplicit-fallthrough diagnostic.
Summary:
When issuing a diagnostic message for the -Wimplicit-fallthrough diagnostics, always try to find the latest macro, defined at the point of fallthrough, which is immediately expanded to "[[clang::fallthrough]]", and use it's name instead of the actual sequence.

Known issues: 
  * uses PP.getSpelling() to compare macro definition with a string (anyone can suggest a convenient way to fill a token array, or maybe lex it in runtime?);
  * this can be generalized and used in other similar cases, any ideas where it should reside then?

Reviewers: doug.gregor, rsmith

Reviewed By: rsmith

CC: cfe-commits

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

llvm-svn: 164858
2012-09-28 22:24:03 +00:00
Jordan Rose 13d6b71929 -Wreceiver-is-weak: rephrase warning text and add a suggestion Note.
New output:
  warning: weak property may be unpredictably set to nil
  note: property declared here
  note: assign the value to a strong variable to keep the object alive
        during use

<rdar://problem/12277204>

llvm-svn: 164857
2012-09-28 22:21:42 +00:00
Jordan Rose 62b379873d Pull ScopeInfo implementation into its own file.
The infrastructure for -Warc-repeated-use-of-weak got a little too heavy
to leave sitting at the top of Sema.cpp.

No functionality change.

llvm-svn: 164856
2012-09-28 22:21:39 +00:00
Jordan Rose 657b5f464d -Warc-repeated-use-of-weak: check ivars and variables as well.
Like properties, loading from a weak ivar twice in the same function can
give you inconsistent results if the object is deallocated between the
two loads. It is safer to assign to a strong local variable and use that.

Second half of <rdar://problem/12280249>.

llvm-svn: 164855
2012-09-28 22:21:35 +00:00
Jordan Rose d393458c33 Add a warning (off by default) for repeated use of the same weak property.
The motivating example:

if (self.weakProp)
  use(self.weakProp);

As with any non-atomic test-then-use, it is possible a weak property to be
non-nil at the 'if', but be deallocated by the time it is used. The correct
way to write this example is as follows:

id tmp = self.weakProp;
if (tmp)
  use(tmp);

The warning is controlled by -Warc-repeated-use-of-receiver, and uses the
property name and base to determine if the same property on the same object
is being accessed multiple times. In cases where the base is more
complicated than just a single Decl (e.g. 'foo.bar.weakProp'), it picks a
Decl for some degree of uniquing and reports the problem under a subflag,
-Warc-maybe-repeated-use-of-receiver. This gives a way to tune the
aggressiveness of the warning for a particular project.

The warning is not on by default because it is not flow-sensitive and thus
may have a higher-than-acceptable rate of false positives, though it is
less noisy than -Wreceiver-is-weak. On the other hand, it will not warn
about some cases that may be legitimate issues that -Wreceiver-is-weak
will catch, and it does not attempt to reason about methods returning weak
values.

Even though this is not a real "analysis-based" check I've put the bug
emission code in AnalysisBasedWarnings for two reasons: (1) to run on
every kind of code body (function, method, block, or lambda), and (2) to
suggest that it may be enhanced by flow-sensitive analysis in the future.

The second (smaller) half of this work is to extend it to weak locals
and weak ivars. This should use most of the same infrastructure.

Part of <rdar://problem/12280249>

llvm-svn: 164854
2012-09-28 22:21:30 +00:00
Dan Gohman 22695fcec3 Add basic support for adding !tbaa.struct metadata on llvm.memcpy calls for
struct assignment.

llvm-svn: 164853
2012-09-28 21:58:29 +00:00
Richard Smith 845aa66a8a When processing an InitListExpr and skipping the initialization of an invalid
record, skip at least one element from the InitListExpr to avoid an infinite
loop if we're initializing an array of unknown bound.

llvm-svn: 164851
2012-09-28 21:23:50 +00:00
Richard Trieu b7243855d9 Update template type diffing to handle qualifiers. Differing qualifiers will
now be printed with highlighting.

llvm-svn: 164843
2012-09-28 20:32:51 +00:00
Richard Smith 80ac9efec4 Allow __builtin_bswap32/64 in constant expressions, like gcc does. Patch by Tijl Coosemans!
llvm-svn: 164841
2012-09-28 20:20:52 +00:00
Richard Trieu 8e14cacfb9 Clean up part of template type diffing. Moved repeated code to separate
functions.  Reworked one of the conditionals.  No functional changes.

llvm-svn: 164839
2012-09-28 19:51:57 +00:00
Fariborz Jahanian 659bc4a792 Modern objcective-C translator. When doing rewriting, Do not
use the integrated pre-processor, preprocess in objective-c++ mode. 
// rdar://12189793.

llvm-svn: 164836
2012-09-28 19:05:17 +00:00
Jordan Rose 19ed6748ea [analyzer] Handle inlined constructors for rvalue temporaries correctly.
Previously the analyzer treated all inlined constructors like lvalues,
setting the value of the CXXConstructExpr to the newly-constructed
region. However, some CXXConstructExprs behave like rvalues -- in
particular, the implicit copy constructor into a pass-by-value argument.
In this case, we want only the /contents/ of a temporary object to be
passed, so that we can use the same "copy each argument into the
parameter region" algorithm that we use for scalar arguments.

This may change when we start modeling destructors of temporaries,
but for now this is the last part of <rdar://problem/12137950>.

llvm-svn: 164830
2012-09-28 17:15:25 +00:00