Commit Graph

19268 Commits

Author SHA1 Message Date
Fariborz Jahanian dbbdd2fe50 "note" location of forward class used as receiver of
a 'deprecated' selector in the diagnostics for the
selector. // rdar://9309223

llvm-svn: 130062
2011-04-23 17:27:19 +00:00
Francois Pichet a7d337d196 Remove unnecessary const away cast in LateTemplateParserCallback.
llvm-svn: 130058
2011-04-23 11:52:20 +00:00
Chandler Carruth a3e1f9a02c Implement basic __is_trivial type-trait support, enough to close PR9472.
This introduces a few APIs on the AST to bundle up the standard-based
logic so that programmatic clients have access to exactly the same
behavior.

There is only one serious FIXME here: checking for non-trivial move
constructors and move assignment operators. Those bits need to be added
to the declaration and accessors provided.

This implementation should be enough for the uses of __is_trivial in
libstdc++ 4.6's C++98 library implementation.

Ideas for more thorough test cases or any edge cases missing would be
appreciated. =D

llvm-svn: 130057
2011-04-23 10:47:28 +00:00
Chandler Carruth 7980348fcf Sort the type traits in a few places where they weren't previously
sorted in order to prepare for adding some new ones.

llvm-svn: 130056
2011-04-23 10:47:20 +00:00
Chandler Carruth 61fbf62838 Fix Clang's __DEPRECATED define to be controled by -Wdeprecated. This
matches GCC behavior which libstdc++ uses to limit #warning-based
messages about deprecation.

The machinery involves threading this through a new '-fdeprecated-macro'
flag for CC1. The flag defaults to "on", similarly to -Wdeprecated. We
turn the flag off in the driver when the warning is turned off (modulo
matching some GCC bugs). We record this as a language option, and key
the preprocessor on the option when introducing the define.

A separate flag rather than a '-D' flag allows us to properly represent
the difference between C and C++ builds (only C++ receives the define),
and it allows the specific behavior of following -Wdeprecated without
potentially impacting the set of user-provided macro flags.

llvm-svn: 130055
2011-04-23 09:27:53 +00:00
Jay Foad 72e705ed94 Like the coding standards say, do not use "using namespace std".
llvm-svn: 130054
2011-04-23 09:06:00 +00:00
Chandler Carruth b009b14971 There were some frustrating problems with the implementation of
-Wwrite-strings. First and foremost, once the positive form of the flag
was passed, it could never be disabled by passing -Wno-write-strings.
Also, the diagnostic engine couldn't in turn use -Wwrite-strings to
control diagnostics (as GCC does) because it was essentially hijacked to
drive the language semantics.

Fix this by giving CC1 a clean '-fconst-strings' flag to enable
const-qualified strings in C and ObjC compilations. Corresponding
'-fno-const-strings' is also added. Then the driver is taught to
introduce '-fconst-strings' in the CC1 command when '-Wwrite-strings'
dominates.

This entire flag is basically GCC-bug-compatibility driven, so we also
match GCC's bug where '-w' doesn't actually disable -Wwrite-strings. I'm
open to changing this though as it seems insane.

llvm-svn: 130051
2011-04-23 06:30:43 +00:00
John McCall d44f4d741c Diagnose C++ abstract parameters for Objective-C methods.
llvm-svn: 130045
2011-04-23 02:46:06 +00:00
Argyrios Kyrtzidis 3d2185ba82 Exhaust the cases.
llvm-svn: 130043
2011-04-23 01:10:24 +00:00
Argyrios Kyrtzidis 7d94c9277a Fix an assertion when code-completing, rdar://9288730 & http://llvm.org/PR9728.
llvm-svn: 130042
2011-04-23 01:04:12 +00:00
Devang Patel a6cb0642b2 Tie debug information for method declaration with debug information for method definition.
llvm-svn: 130037
2011-04-23 00:08:01 +00:00
Argyrios Kyrtzidis bf04231a72 Don't allow reinterpret_cast to reference of vector element and property expression. Thanks goes to Eli Friedman!
llvm-svn: 130036
2011-04-22 23:57:57 +00:00
Chris Lattner 9fa385d437 don't warn about empty macro arguments in c++'0x mode, since it sucked in
the c99 preprocessor.  Patch by Jonathan Sauer!

llvm-svn: 130031
2011-04-22 23:25:09 +00:00
Francois Pichet dcb3ebeb2c Correctly emit a diagnostic for multiple templated function definitions in -flate-template-parsing mode.
llvm-svn: 130030
2011-04-22 23:20:44 +00:00
Argyrios Kyrtzidis 47a1285a69 reinterpret_cast to reference of a bit-field is not allowed.
Fixes rdar://9202628 & http://llvm.org/PR9564.

llvm-svn: 130024
2011-04-22 22:31:13 +00:00
Douglas Gregor 9750969178 At the end of the translation unit, defining a vtable can introduce
new templates that need to be instantiated and vice-versa. Iterate
until we've instantiated all required templates and defined all
required vtables. Fixed PR9325 / <rdar://problem/9055177>.

llvm-svn: 130023
2011-04-22 22:25:37 +00:00
Francois Pichet 1c229c0472 Add -fdelayed-template-parsing option. Using this option all templated function definitions are parsed at the end of the translation unit only if it is required by an actual instantiation. As such all the symbols of the TU are available during name lookup.
Using this flag is necessary for compatibility with Microsoft template code.
This also provides some parsing speed improvement.

llvm-svn: 130022
2011-04-22 22:18:13 +00:00
Fariborz Jahanian c057794adb Fixes an instance method meta-data generation bug in
ObjC NeXt runtime where method pointer registered in
metadata belongs to an unrelated method. Ast part of this fix,
I turned at @end missing warning (for class
implementations) into an error as we can never
be sure that meta-data being generated is correct.
// rdar://9072317

llvm-svn: 130019
2011-04-22 22:02:28 +00:00
Francois Pichet 6841a12845 Do not return true from MergeFunctionDecl for a warn_static_non_static warning in Microsoft mode.
llvm-svn: 130010
2011-04-22 19:50:06 +00:00
Argyrios Kyrtzidis ad8b4d402e For -Wlogical-op-parentheses, point at '&&', not '||'. Fixes rdar://9125333.
llvm-svn: 130009
2011-04-22 19:16:27 +00:00
Chandler Carruth 56773db7d4 I concur with DPG here. This does indeed apply in 0x mode. Added test
cases that demonstrates exactly why this does indeed apply in 0x mode.

If isPOD is currently broken in 0x mode, we should fix that directly
rather than papering over it here.

llvm-svn: 130007
2011-04-22 19:01:39 +00:00
Argyrios Kyrtzidis 8e4be0b1ea Don't enter a qualified scope for an invalid decl.
Fixes assertion later on. rdar://9122937 & http://llvm.org/PR9459

llvm-svn: 130006
2011-04-22 18:52:25 +00:00
Ted Kremenek 11e5c8b31a Add static analyzer support for C++'0X nullptr. Patch by Jim Goodnow II.
llvm-svn: 130003
2011-04-22 18:01:30 +00:00
Ken Dyck 0fed10e704 Replace a couple of literal 8s with ASTContext::getCharWidth(). No change in
functionality intended.

llvm-svn: 130002
2011-04-22 17:59:22 +00:00
Ken Dyck c5c416f7db Eliminate some literal 8s from EmitNullInitialization() by converting
variables to CharUnits. No change in functionality intended.

llvm-svn: 130001
2011-04-22 17:51:05 +00:00
Argyrios Kyrtzidis 7a6f2a358a In IsUserDefinedConversion try to recover from RequireCompleteType returning true.
Fixes an assertion later on, rdar://9122862 & http://llvm.org/PR9460.

llvm-svn: 130000
2011-04-22 17:45:37 +00:00
Ken Dyck bbe3862d95 Eliminate some literal 8s from EmitDeclare by converting to CharUnits. No
change in functionality intended.

llvm-svn: 129999
2011-04-22 17:41:34 +00:00
Ken Dyck 8159c1f2df Use CharUnits to eliminate some literal 8s in
EmitTypeForVarWithBlocksAttr(). No change in functionality intended.

llvm-svn: 129998
2011-04-22 17:34:18 +00:00
Ken Dyck abae3beec5 Replace some literal 8s with char width and char align. No change in
functionality intended.

llvm-svn: 129996
2011-04-22 17:23:43 +00:00
Justin Holewinski bd4a3c03ff PTX: Add default PTX calling conventions
llvm-svn: 129987
2011-04-22 11:10:38 +00:00
Francois Pichet 9392165a17 For consistency, change suffix from war_ to warn_ for some Microsoft warnings I introduced lately.
llvm-svn: 129986
2011-04-22 08:25:24 +00:00
Francois Pichet e900b10a29 Downgrade error "static declaration of 'foo' follows non-static declaration" to a warning in Microsoft mode.
llvm-svn: 129985
2011-04-22 08:14:00 +00:00
Argyrios Kyrtzidis bbcefa7d50 For
double data[20000000] = { [19999999] = 1 };

Don't serialize the filler multiple times.

llvm-svn: 129983
2011-04-22 05:29:30 +00:00
Argyrios Kyrtzidis 98feafed27 Fix crashing rdar://9122854 & http://llvm.org/PR9461.
llvm-svn: 129967
2011-04-22 01:18:40 +00:00
Nick Lewycky 207bce31e1 Wire up the -ftest-coverage and -fprofile-arcs flags to .gcno file emission (at
compile time) and .gcda emission (at runtime). --coverage enables both.

This does not yet add the profile_rt library to the link step if -fprofile-arcs
is enabled when linking.

llvm-svn: 129956
2011-04-21 23:44:07 +00:00
Nick Lewycky ab18d3088a Fix indentation. No functional change.
llvm-svn: 129954
2011-04-21 23:37:32 +00:00
Argyrios Kyrtzidis b77d6f0fd1 Don't hide #warnings in a system header, same as gcc. Fixes rdar://8495837.
llvm-svn: 129951
2011-04-21 23:08:23 +00:00
Argyrios Kyrtzidis 8a8b8773b6 Move the check whether a diagnostic must be ignored because it is in a system header
inside DiagnosticIDs::getDiagnosticLevel.

llvm-svn: 129950
2011-04-21 23:08:18 +00:00
Richard Smith d4257d847e Fix gcc warning. Add parens to this assert, incidentally reassociating it, but the condition is the same either way.
llvm-svn: 129948
2011-04-21 22:48:40 +00:00
Richard Trieu 2c850c0980 Add a fixit suggest for missing case keywords inside a switch scope. For instance, in the following code, 'case ' will be suggested before the '1:'
switch (x) {
  1: return 0;
  default: return 1;
}

llvm-svn: 129943
2011-04-21 21:44:26 +00:00
Daniel Dunbar bbd482226e Driver/Darwin: Allow OS X deployment targets like 10.4.11, even though they
can't be represented in the environment define.

llvm-svn: 129939
2011-04-21 21:27:33 +00:00
Argyrios Kyrtzidis 446bcf2d4a Use the ArrayFiller to fill out "holes" in the array initializer due to designated initializers,
avoiding to create separate Exprs for each one.

llvm-svn: 129933
2011-04-21 20:03:38 +00:00
Jay Foad ea324f154b PR9214: Convert Metadata API to use ArrayRef.
llvm-svn: 129929
2011-04-21 19:59:12 +00:00
Manuel Klimek d861e8b7be Adds a function to run FrontendActions over in-memory code. This is
the first step towards a standalone Clang tool infrastructure.
The plan is to make it easy to build command line tools that run over
the AST of source files in a project outside of the build system.

llvm-svn: 129924
2011-04-21 18:37:41 +00:00
Daniel Dunbar 5a784c8ed1 Driver: Tweak -Xarch diags a bit more, we can't actually differentiate between
unknown and "required more arguments", but only the latter should be feasible in
practice.

llvm-svn: 129919
2011-04-21 17:41:34 +00:00
Daniel Dunbar 6914a98ccd Driver: Improve -Xarch argument diagnostics a bit.
llvm-svn: 129918
2011-04-21 17:32:21 +00:00
Argyrios Kyrtzidis 1f329402ae Fixit suggestion for adding missing tag name should have a space after the tag name. Fixes rdar://9295072
llvm-svn: 129917
2011-04-21 17:29:47 +00:00
Eli Friedman 4547752402 PR9772: Fix the definition of WINT_MIN and WINT_MAX on Linux -ffreestanding.
llvm-svn: 129907
2011-04-21 05:45:45 +00:00
John McCall e0fda7377e The 0.98 revision of the x86-64 ABI clarified a lot of things, some
of which break strict compatibility with previous compilers.  Implement
one of them and then immediately opt out on Darwin.

llvm-svn: 129899
2011-04-21 01:20:55 +00:00
Argyrios Kyrtzidis b2ed28ea4b For
double data[20000000] = {0};

we would blow out the memory by creating 20M Exprs to fill out the initializer.

To fix this, if the initializer list initializes an array with more elements than
there are initializers in the list, have InitListExpr store a single 'ArrayFiller' expression
that specifies an expression to be used for value initialization of the rest of the elements.

Fixes rdar://9275920.

llvm-svn: 129896
2011-04-21 00:27:41 +00:00
Anders Carlsson f03f3ec9dd Don't add type names for enums; they're never used in LLVM IR.
llvm-svn: 129894
2011-04-20 23:51:43 +00:00
Chris Lattner 54fd1a1ad3 fix a crash on code that uses the result value of __builtin___memcpy_chk.
llvm-svn: 129892
2011-04-20 23:14:50 +00:00
Justin Holewinski 514cce8e43 PTX: Add PTX intrinsics as builtins and add ptx32 and ptx64 as valid architectures for triples, e.g. ptx32-unknown-unknown
llvm-svn: 129870
2011-04-20 19:34:15 +00:00
Douglas Gregor d645931066 Fix a crash-on-invalid involving non-identifier names in a member
access expression that appears to be a property reference. Fixes
<rdar://problem/8985943>.

llvm-svn: 129865
2011-04-20 18:19:55 +00:00
Douglas Gregor 7f97189b53 Give invalid tag types 8-bit size and alignment, rather than 1-bit
alignment, which causes traps further down the line. Fixes
<rdar://problem/9109755>, which contains a test case far too large to
commit :(

llvm-svn: 129861
2011-04-20 17:29:44 +00:00
Douglas Gregor 57477675ef Eliminate an uninteresting assertion; invalid code involving
out-of-line destructors can result in the addition of redundant
destructors to a class. It's not harmful to the AST. Fixes
<rdar://problem/9158632>.

llvm-svn: 129860
2011-04-20 17:22:00 +00:00
Fariborz Jahanian 5b72ed9798 Use S.str() to force a flush.
llvm-svn: 129856
2011-04-20 16:38:37 +00:00
Daniel Dunbar 2db3e73c38 Driver: Suppress some additional warnings with -Qunused-arguments.
llvm-svn: 129853
2011-04-20 15:44:48 +00:00
Douglas Gregor 3719d3455a Be sure to flush raw_string_ostream objects in the Objective-C
rewriter, from Eric Niebler!

llvm-svn: 129849
2011-04-20 13:35:54 +00:00
Douglas Gregor 49f754f423 Teach SourceManager::getSLocEntry() that it can fail due to problems
during deserialization from  a precompiled header, and update all of
its callers to note when this problem occurs and recover (more)
gracefully. Fixes <rdar://problem/9119249>.

llvm-svn: 129839
2011-04-20 00:21:03 +00:00
Daniel Dunbar fcd2389b7a TWEAK
llvm-svn: 129835
2011-04-19 23:34:21 +00:00
Daniel Dunbar 308cfd045f Driver/Darwin: Switch to using -macosx for OS name in triples.
llvm-svn: 129834
2011-04-19 23:34:17 +00:00
Daniel Dunbar 914bc4106c IRgen/ARM: Fix a think-o in conversion-to-null for member function pointers, we
were computing the conversion as (ptr != 0 && non-virtual), when it should be
(ptr != 0 || is-virtual).
 - Test to follow in LLVM test-suite.

llvm-svn: 129830
2011-04-19 23:10:47 +00:00
Chris Lattner 2531eb421f some cleanups to use IRBuilder methods instead of llvm:: foo methods.
llvm-svn: 129829
2011-04-19 22:55:03 +00:00
Daniel Dunbar 5c56828d91 Driver/Darwin: Switch to using new style triples.
llvm-svn: 129824
2011-04-19 21:45:47 +00:00
Daniel Dunbar 14ad22f09d ADT/Triple: Switch to using .isOSDarwin() predicate.
llvm-svn: 129823
2011-04-19 21:43:27 +00:00
Fariborz Jahanian 2b059998f7 Avoid superfluous warning after an error is detcted and reported.
// rdar://9132143

llvm-svn: 129822
2011-04-19 21:42:37 +00:00
Daniel Dunbar ecf1356057 Basic/Darwin: Add support for new -osx and -ios style triples (not yet used).
llvm-svn: 129820
2011-04-19 21:40:34 +00:00
Chris Lattner 46f1614d56 use the newly introduced IRBuilder getInt() method to reduce some
redundancy pointed out by John.

llvm-svn: 129808
2011-04-19 20:53:45 +00:00
Argyrios Kyrtzidis 1618023018 We regard a function as 'unused' from the codegen perspective, so our warnings diverge from
gcc's unused warnings which don't get emitted if the function is referenced even in an unevaluated context
(e.g. in templates, sizeof, etc.). Also, saying that a function is 'unused' because it won't get codegen'ed
is somewhat misleading.

- Don't emit 'unused' warnings for functions that are referenced in any part of the user's code.
- A warning that an internal function/variable won't get emitted is useful though, so introduce
  -Wunneeded-internal-declaration which will warn if a function/variable with internal linkage is not
  "needed" ('used' from the codegen perspective), e.g:

  static void foo() { }

  template <int>
  void bar() {
    foo();
  }

test.cpp:1:13: warning: function 'foo' is not needed and will not be emitted
static void foo() { }
            ^

Addresses rdar://8733476.

llvm-svn: 129794
2011-04-19 19:51:10 +00:00
Peter Collingbourne 133587f08b Add a new expression classification, CL_AddressableVoid
CL_AddressableVoid is the expression classification used for void
expressions whose address can be taken, i.e. the result of [], *
or void variable references in C, as opposed to things like the
result of a void function call.

llvm-svn: 129783
2011-04-19 18:51:51 +00:00
Anders Carlsson d1f65f61ee Make the VariadicMethodTypeChecker accept block pointers as Objective-C pointers. Fixes PR9746.
llvm-svn: 129741
2011-04-19 01:16:46 +00:00
Daniel Dunbar d107638328 Driver/Darwin: Change to use generic iOS runtime library, which we now always need.
llvm-svn: 129734
2011-04-18 23:48:36 +00:00
Ted Kremenek 1c2239e9b1 Add SelectorTable::getTotalMemory() to allow clients to query how much memory is used by selectors.
llvm-svn: 129728
2011-04-18 22:47:04 +00:00
Daniel Dunbar ed904c82b1 Driver/Darwin: Disable movw/movt with -mkernel or -fapple-kext.
llvm-svn: 129721
2011-04-18 21:26:42 +00:00
Fariborz Jahanian b107143fed Fix a bug in calculation of composite type
of conditional expressions of objc pointer types
where one type is the immediate base type of the
other. // rdar://9296866

llvm-svn: 129718
2011-04-18 21:16:59 +00:00
Daniel Dunbar 10d0868efb Driver: Support -fno-lto.
llvm-svn: 129712
2011-04-18 19:44:09 +00:00
Ted Kremenek 00abe8ee31 Add ToolChain path support for linker on Slackware.
llvm-svn: 129704
2011-04-18 17:50:19 +00:00
Devang Patel 43cfa5dce1 Fix typo in comment.
llvm-svn: 129703
2011-04-18 17:30:25 +00:00
Richard Smith 0c502d2a62 Fix PR9741. The implicit declarations created for range-based for loops weren't being added to the DeclContext (nor were they being marked as implicit). Also, the declarations were being emitted in the wrong order when building the CFG.
llvm-svn: 129700
2011-04-18 15:49:25 +00:00
Douglas Gregor 6c7a9eec42 When providing code completions of ivar names for a property
implementation such as

  @synthesize Prop1 = 

Give priority to ivars whose type matches or closely matches the
property type (as we do for several other kinds of
results). Additionally, if there is an ivar with the same name as the
property, or differs only due to a _ prefix or suffix, give that ivar
a priority bump. Finally, verify that this search is properly
returning ivars within class extensions and implementations
(<rdar://problem/8488854>).

llvm-svn: 129699
2011-04-18 14:40:46 +00:00
Anders Carlsson 566ae67ef8 Get rid of std::vector usage when getting function types in CGException.cpp
llvm-svn: 129698
2011-04-18 14:24:10 +00:00
Douglas Gregor 331faa0f73 When producing code completion results for the Objective-C property
implementation 

  @synthesize <property> = 

also produce a completion for a to-be-synthesized ivar named
_<property>.

llvm-svn: 129697
2011-04-18 14:13:53 +00:00
Anders Carlsson 940f02d248 Clean up code generation of typeid expressions and add C++ standard references.
llvm-svn: 129682
2011-04-18 00:57:03 +00:00
Chris Lattner 97bbee2fb4 Fix a miscompilation I introduced in r129652, thanks for Eli for tracking
it down.  we effectively were compile the testcase into:

void test14(int x) {
  switch (x) {
    case 11: break;
    case 42: test14(97);  // fallthrough
    default: test14(42); break;

which is not the same thing at all.  This fixes a miscompilation of 
MallocBench/gs seen on the clang-x86_64-linux-fnt buildbot.

llvm-svn: 129679
2011-04-17 23:21:26 +00:00
Anders Carlsson fcaaa697ec When laying out bases in, always try the "base subobject" LLVM type. If it
turns out that a field or base needs to be laid out in the tail padding of
the base, CGRecordLayoutBuilder::ResizeLastBaseFieldIfNecessary will convert
it to an array of i8.

I've audited the new test results to make sure that they are still valid. I've
also verified that we pass a self-host with this change.

This (finally) fixes PR5589!

llvm-svn: 129673
2011-04-17 21:56:13 +00:00
Anders Carlsson 56c4d80a4e Add addBaseSubobjectTypeName which isn't used yet.
llvm-svn: 129671
2011-04-17 21:40:34 +00:00
Anders Carlsson c58f8cb7fc Move code to add a type name to a TagDecl type out into a helper function. No functionality change.
llvm-svn: 129669
2011-04-17 21:36:59 +00:00
Anders Carlsson b6d31e7dcc Use a SmallVector for field types in CGRecordLayoutBuilder now that llvm::StructType::get takes an ArrayRef.
llvm-svn: 129667
2011-04-17 21:32:41 +00:00
Michael J. Spencer a9e4117991 Make -mno-mmx imply -mno-3dnow. This is what gcc does, and it makes sense.
Also, fold the sse4 and sse4.1 cases together.

Patch by Alexander Best!

llvm-svn: 129665
2011-04-17 19:22:03 +00:00
Eli Friedman 2e2ff8894d Hack to turn the valgrind buildbot green, until Devang can address it
properly.

llvm-svn: 129657
2011-04-17 06:40:15 +00:00
Chris Lattner bc204c8043 implement rdar://9289524 - case followed immediately by break results in empty IR block,
a -O0 code quality issue.

llvm-svn: 129652
2011-04-17 00:54:30 +00:00
Chris Lattner 30107ed600 fold memcpy/set/move_chk to llvm.memcpy/set/move when the sizes
are trivial.  This exposes opportunities earlier, and allows fastisel
to do good things with these at -O0.

This addresses rdar://9289468 - clang doesn't fold memset_chk at -O0

llvm-svn: 129651
2011-04-17 00:40:24 +00:00
Chris Lattner 56784f9de6 fix rdar://9289603 - clang should fold trivial ?: for enums as well as integer constants into select at -O0
by making the isCheapEnoughToEvaluateUnconditionally predicate handle anything that folds to a constant.  In particular, we now fold enums.

llvm-svn: 129649
2011-04-16 23:15:35 +00:00
Richard Trieu 70d14f5df3 Testing my commit access. A few whitespace changes to Sema/SemaCXXCast.cpp.
llvm-svn: 129629
2011-04-16 01:09:30 +00:00
Argyrios Kyrtzidis 0e993c3249 Introduce Rewriter::IncreaseIndentation() which increase indentations for the lines between the given source range.
To determine what the indentation should be, a SourceLocation 'parentIndent' parameter is used that should be at
a source location with an indentation one degree lower than the given range.

llvm-svn: 129628
2011-04-16 01:03:33 +00:00
Devang Patel 7294d74627 Emit proper selector name in debug info.
llvm-svn: 129626
2011-04-16 00:37:51 +00:00
Devang Patel 9d6c857862 Emit debug info for Objective-C properties.
llvm-svn: 129625
2011-04-16 00:12:55 +00:00
Tanya Lattner 5ac257d738 Fix bug in vector initializer when initializing a vector with another vector.
Add test case.

llvm-svn: 129617
2011-04-15 22:42:59 +00:00
Fariborz Jahanian 0fe1a9861c Enforce nonnull __attribute__ on Objective-C method calls.
// rdar://9287695

llvm-svn: 129615
2011-04-15 22:06:22 +00:00
Douglas Gregor 46ce91a964 Initial work to improve documentation for Clang's diagnostics, from Matthieu Monrocq
llvm-svn: 129614
2011-04-15 22:04:17 +00:00
Douglas Gregor 5d3d3fa33d For the purposes of overload resolution, consider a conversion from an
Objective-C pointer to void* as a "conversion to void*". This allows
us to prefer an Objective-C object pointer conversion to a superclass
object pointer over an Objective-C object pointer conversion to
cv-void*. Fixes PR9735.

llvm-svn: 129603
2011-04-15 20:45:44 +00:00
Douglas Gregor 39d1a0973d Forbid the use of C++ new/delete to allocate/free objects within an
address space. I could see that this functionality would be useful,
but not in its current form (where the address space is ignored):
rather, we'd want to encode the address space into the parameter list
passed to operator new/operator delete somehow, which would require a
bunch more semantic analysis.

llvm-svn: 129593
2011-04-15 19:46:20 +00:00
Douglas Gregor a3a020ae0b Parse GNU-style attributes prior to the type-id/new-type-id in a C++
"new" expression. This matches GCC's parser. Test is forthcoming.

llvm-svn: 129592
2011-04-15 19:40:02 +00:00
Fariborz Jahanian 193f783a99 Fixes a crash when generating dependency file stuff
and output file is not writable. // rdar://9286457.

llvm-svn: 129587
2011-04-15 18:49:23 +00:00
Douglas Gregor b472e93af7 Implement appropriate semantics for C++ casting and conversion when
dealing with address-space- and GC-qualified pointers. Previously,
these qualifiers were being treated just like cvr-qualifiers (in some
cases) or were completely ignored, leading to uneven behavior. For
example, const_cast would allow conversion between pointers to
different address spaces.

The new semantics are fairly simple: reinterpret_cast can be used to
explicitly cast between pointers to different address spaces
(including adding/removing addresss spaces), while
static_cast/dynamic_cast/const_cast do not tolerate any changes in the
address space. C-style casts can add/remove/change address spaces
through the reinterpret_cast mechanism. Other non-CVR qualifiers
(e.g., Objective-C GC qualifiers) work similarly.

As part of this change, I tweaked the "casts away constness"
diagnostic to use the term "casts away qualifiers". The term
"constness" actually comes from the C++ standard, despite the fact
that removing "volatile" also falls under that category. In Clang, we
also have restrict, address spaces, ObjC GC attributes, etc., so the
more general "qualifiers" is clearer.

llvm-svn: 129583
2011-04-15 17:59:54 +00:00
Fariborz Jahanian 66a6c06dd6 Allow shadowin of 'self' in objc methods in
cases where stand-alone ivar can be looked up
in shadowed object. To fix gcc compatibility
breakage. // rdar://9284603

llvm-svn: 129576
2011-04-15 17:04:42 +00:00
Richard Smith 9bc6eedab4 Add __has_feature(cxx_range_for) check for C++11 range-based for loop.
llvm-svn: 129573
2011-04-15 15:14:40 +00:00
Michael J. Spencer 1737c9e0b5 Add mm3dnow.h.
llvm-svn: 129572
2011-04-15 15:11:21 +00:00
Michael J. Spencer 6826eb816a Add 3DNow! Intrinsics.
llvm-svn: 129570
2011-04-15 15:07:13 +00:00
Richard Smith dda56e4b4a Support for C++11 (non-template) alias declarations.
llvm-svn: 129567
2011-04-15 14:24:37 +00:00
Richard Smith 030f499d2f Teach -ast-print how to print template template parameters.
llvm-svn: 129565
2011-04-15 13:38:57 +00:00
Benjamin Kramer 3462376c65 Fix mismatched delete.
llvm-svn: 129564
2011-04-15 11:21:57 +00:00
Ted Kremenek 1551d55295 Improve diagnostics on GNU attributes by warning about attributes that should have no arguments or parameters. Patch by Michael Han!
llvm-svn: 129560
2011-04-15 05:49:29 +00:00
Chris Lattner 57540c5be0 fix a bunch of comment typos found by codespell. Patch by
Luis Felipe Strano Moraes!

llvm-svn: 129559
2011-04-15 05:22:18 +00:00
Peter Collingbourne 3d9cbdc3e6 C1X: implement static asserts
llvm-svn: 129555
2011-04-15 00:35:57 +00:00
Peter Collingbourne 9114759641 C1X: implement generic selections
As an extension, generic selection support has been added for all
supported languages.  The syntax is the same as for C1X.

llvm-svn: 129554
2011-04-15 00:35:48 +00:00
Peter Collingbourne a686b5f8bf C1X: add a language standard
llvm-svn: 129553
2011-04-15 00:35:23 +00:00
Tanya Lattner ee840b85b1 Do not expand the opencl pragma names. This is so you can also have a define named the samed as the pragma and they do not interfere (ie. cl_khr_fp64).
llvm-svn: 129549
2011-04-14 23:35:31 +00:00
Douglas Gregor 6ca6410e3a If the declaration of a C++ member function with an inline definition
is so broken that Sema can't form a declaration for it, don't bother
trying to parse the definition later. Fixes <rdar://problem/9221993>.

llvm-svn: 129547
2011-04-14 23:19:27 +00:00
Douglas Gregor 40965fa78a When we transform a C++ exception declaration (e.g., for template
instantiation), be sure to add the transformed declaration into the
current DeclContext. Also, remove the -Wuninitialized hack that works
around this bug. Fixes <rdar://problem/9200676>.

llvm-svn: 129544
2011-04-14 22:32:28 +00:00
Richard Smith 02e85f3bc5 Add support for C++0x's range-based for loops, as specified by the C++11 draft standard (N3291).
llvm-svn: 129541
2011-04-14 22:09:26 +00:00
Richard Smith 55858499e2 Detect when the string "<::" is found in code after a cast or template name and is interpreted as "[:" because of the digraph "<:". When found, give an error with a fix-it to add whitespace between the "<" and "::".
Patch by Richard Trieu! Plus a small tweak from me to deal with one of the tokens coming from a macro.

llvm-svn: 129540
2011-04-14 21:45:45 +00:00
Fariborz Jahanian bc2ee9382c Match pointer of compatible vection types.
// rdar://9208404

llvm-svn: 129536
2011-04-14 20:33:36 +00:00
Douglas Gregor af670a81e9 When determining the "usage" type of a declaration for the purposes of code
completion, look through block pointer and function pointer types to the
result type of the block/function. Fixes <rdar://problem/9282583>.

llvm-svn: 129535
2011-04-14 20:33:34 +00:00
Anton Korobeynikov 231e875b5c Implement ARM pcs attribute. Basically it's another way of calling convention selection (AAPCS or
AAPCS+VFP), similar to fastcall / stdcall / whatevercall seen on x86.

In particular, all library functions should always be AAPCS regardless of floating point ABI used.

llvm-svn: 129534
2011-04-14 20:06:49 +00:00
Richard Smith f7b6202e6c Implement C++0x [lex.pptoken]p3's handling of <::.
llvm-svn: 129525
2011-04-14 18:36:27 +00:00
Douglas Gregor 23c8476748 Parse an '@' in an Objective-C++ class member specification,
diagnosing it as an error rather than looping infinitely. Also,
explicitly disallow @defs in Objective-C++. Fixes <rdar://problem/9260136>.

llvm-svn: 129521
2011-04-14 17:21:19 +00:00
Sebastian Redl 9ab988fe00 Chained PCH: Remember when additional specializations are added to a function template from a previous PCH. Fixes the only crasher when using massive chains on Clang's Sema component. We still have some incomplete codegen there.
llvm-svn: 129516
2011-04-14 14:07:59 +00:00
Sebastian Redl 4e52123d06 Fix -H. It was pretty broken.
llvm-svn: 129514
2011-04-14 14:07:45 +00:00
Sebastian Redl eb931c6b0e The ASTReader created by -chain-include used the generated PCH buffers in the wrong order. The effect was that all but the first chain-include files was ignored for subsequent compilations.
llvm-svn: 129513
2011-04-14 14:07:41 +00:00
Ted Kremenek 9eb0b7d2f1 Return the correct lastly populated block from CFGBuilder::VisitUnaryExprOrTypeTraitExpr().
llvm-svn: 129499
2011-04-14 01:50:50 +00:00
Ken Dyck 3563aa6520 Replace a couple of divide-by-8s with divide-by-charwidths. No change in
functionality intended.

llvm-svn: 129496
2011-04-14 01:00:39 +00:00
Eli Friedman 6620ddeaa4 Re-fix r129481 and r129465 properly. Nulls fixits shouldn't be dropped in
DiagnosticBuilder::AddFixItHint: they will be dropped along with any
other (possibly valid) fixits later.

llvm-svn: 129495
2011-04-14 00:51:41 +00:00
Argyrios Kyrtzidis 36e4ae3e57 When creating an implicit member expression through a qualified-id, check that the class
named by the nested-name-specifier is same or base of the class in which the member expression appears.

It seems we also had an ill-formed test case, mon dieu! Fixes rdar://8576107.

llvm-svn: 129493
2011-04-14 00:46:47 +00:00
Ken Dyck c5ca87675e Replace a couple of divisions-by-'8' with divisions-by-charwidth. No change
in functionality intended.

llvm-svn: 129491
2011-04-14 00:43:09 +00:00
Anders Carlsson d162fb83f2 In C++, when initializing an array from a pascal string, it's OK if the array
is 1 element smaller than the string, because we can just strip off the last
null character. This matches GCC.

llvm-svn: 129490
2011-04-14 00:41:11 +00:00
Anders Carlsson 752454092c Add a flag to StringLiteral to keep track of whether the string is a pascal string or not.
llvm-svn: 129488
2011-04-14 00:40:03 +00:00
Fariborz Jahanian 38675543c5 Issue the 2nd fixit even if fix-it hint is supressed.
// rdar://9091893

llvm-svn: 129481
2011-04-13 22:18:37 +00:00
Fariborz Jahanian e72509c10c No fixit hint for builtin expressions which are
defined in a macro. // rdar://9091893

llvm-svn: 129465
2011-04-13 20:31:26 +00:00
Bill Wendling a865185ad6 Removing the unaligned load tests from builtins-x86.c since they're generated by a regular 'load' now.
llvm-svn: 129464
2011-04-13 20:17:22 +00:00
Axel Naumann 43dec14079 From Vassil Vassilev: Give external source's last resort lookup a chance, even if an identifier could resolve to a builtin.
llvm-svn: 129438
2011-04-13 13:19:46 +00:00
Bill Wendling 2c1c33552d Remove comment that snuck in there.
llvm-svn: 129434
2011-04-13 10:05:14 +00:00
Bill Wendling 88ae43772a It looks like the FreeBSD buildbot needs this for the builtins-x86.c test.
llvm-svn: 129433
2011-04-13 10:02:54 +00:00
Chandler Carruth 0a7aa3b60b Teach -Wuninitialized about C++'s typeid expression, including both the
evaluated and unevaluated contexts. Add some testing of sizeof and
typeid.

Both of the typeid tests added here were triggering warnings previously.
Now the one false positive is suppressed without suppressing the warning
on actually buggy code.

llvm-svn: 129431
2011-04-13 08:18:42 +00:00
Argyrios Kyrtzidis 71c58f3d59 Collect the options applicable to the Rewriter methods into a RewriterOptions struct.
llvm-svn: 129430
2011-04-13 07:15:11 +00:00
Bill Wendling b9c9e34cb3 Just use a native "load" instead of translating the builtin later. Clang can
take it!

I wasn't able to get __builtin_ia32_loaddqu to transform into an unaligned
load...I'll have to look into it further.

llvm-svn: 129427
2011-04-13 05:58:17 +00:00
Francois Pichet efc283c076 Still not used to put the * next to the variable name.
llvm-svn: 129426
2011-04-13 02:44:57 +00:00
Francois Pichet 48c946e5ef In Microsoft mode, within class scope, if a CXXScopeSpec's type is equal to the type of one of the base classes then downgrade the missing typename error to a warning. Up to now this is the only case I found where MSVC doesn't require "typename" at class scope. Really strange!
This fixes 1 error when parsing the MSVC 2008 header files.
Example:

template<class T> class A {
public:
  typedef int TYPE;
};
template<class T> class B : public A<T> {
public:
  A<T>::TYPE a; // no typename required because A<T> is a base class.
};

llvm-svn: 129425
2011-04-13 02:38:49 +00:00
Anders Carlsson bbe277c4a9 Use EmitCallOrInvoke in EmitBadTypeidCall and EmitBadCastCall.
llvm-svn: 129424
2011-04-13 02:35:36 +00:00
Bill Wendling 3137d3cb49 Convert the unaligned load builtins to the first-class versions.
llvm-svn: 129420
2011-04-13 00:36:37 +00:00
Daniel Dunbar dc8355e81a Driver/no-integrated-as: Fix forwarding of -g flag to assembler, when .s input
undergoes preprocessing.

llvm-svn: 129414
2011-04-12 23:59:20 +00:00
Fariborz Jahanian 82bc436c28 Redeclaration of 'self' should be flagged in
objective-c instead of crashing in IRgen.
// rdar://9154582.

llvm-svn: 129412
2011-04-12 23:39:33 +00:00
Daniel Dunbar 9c8cd4c097 IRgen/Obj-C: Emit CFStrings and NSStrings with the alignment of the char type,
there is no reason to align them higher.
 - This roughly matches llvm-gcc's r126913.
 - It is an open question whether or not we should do this for cstring's in
   general (code size vs optimization potential), for now we just match llvm-gcc
   until someone wants to run some experiments.

llvm-svn: 129410
2011-04-12 23:30:52 +00:00
John McCall 58989b7125 We can't emit an aggregate cast as its sub-expression in general just
because the result is ignored.  The particular example here is with
property l-values, but there could be all sorts of lovely casts that this
isn't safe for.  Sink the check into the one case that seems to actually
be capable of honoring this.

llvm-svn: 129397
2011-04-12 22:02:02 +00:00
Ted Kremenek ced5feaec9 Teach VariadicMethodTypeChecker to not crash when processing methods declared in protocols.
llvm-svn: 129395
2011-04-12 21:47:05 +00:00
Ted Kremenek 905a602e0c Fix another IdempotentOperationsChecker corner case when determining if an active block on the worklist
impacts the results of the check.

llvm-svn: 129394
2011-04-12 21:47:02 +00:00
Ted Kremenek 8a4c760c20 ArrayBoundCheckerV2: don't arbitrarily warn about indexing before the 0-index of a symbolic region. In many cases that isn't really the base offset.
llvm-svn: 129366
2011-04-12 17:21:33 +00:00
Lenny Maiorani f3539ad5c7 This patch adds modeling of strcmp() to the CString checker. Validates inputs are not NULL and are real C strings, then does the comparison and binds the proper return value. Unit tests included.
llvm-svn: 129364
2011-04-12 17:08:43 +00:00
Fariborz Jahanian 240400b746 Fix a regression where the initializer implements
the initialized's protocol and yet clang warns.
objective-c issue, // rdar://9267196

llvm-svn: 129363
2011-04-12 16:34:14 +00:00
Richard Smith 0f538460d2 Fix AST serialization of reference-to-reference types. This previously caused
a crash when deserializing the AST for this:

  typedef char (&R);
    extern R &r;

llvm-svn: 129358
2011-04-12 10:38:03 +00:00
Ted Kremenek f52718899f static analyzer: invalidate by-ref arguments passed to constructors in a 'new' expression.
llvm-svn: 129349
2011-04-12 05:12:39 +00:00
Ted Kremenek 57a4a152b2 Fix bug in SimpleSValBuilder where '--' pointer arithmetic was treated like '++' pointer arithmetic.
llvm-svn: 129348
2011-04-12 03:49:37 +00:00
Douglas Gregor c05f657d83 Don't suggest dynamic_cast or typeid as code completion results when
RTTI is disabled. Similarly, don't suggest throw or try as code
completion results when C++ exceptions are disabled. Fixes
<rdar://problem/9193560>.

llvm-svn: 129346
2011-04-12 02:47:21 +00:00
John McCall a97f329869 Template static data members can have weak_odr linkage, not just
weak linkage.  Also, fix a problem where global weak variables
with non-trivial initializers were getting guard variables, or at
least were checking for them and then crashing.

llvm-svn: 129342
2011-04-12 01:46:54 +00:00
Douglas Gregor 8e93666a71 Objective-C++: The global namespace is an associated namespace of an
Objective-C pointer type. Fixes <rdar://problem/9142559>.

llvm-svn: 129339
2011-04-12 01:02:45 +00:00
John McCall 32f44bd0fc Ignore indirect field declarations. Fixes PR9570.
llvm-svn: 129337
2011-04-12 01:01:22 +00:00
Ted Kremenek 4f939da02d RegionStoreManager::invalidateRegions: treat classes the same as structs.
llvm-svn: 129333
2011-04-12 00:44:31 +00:00
John McCall 2979fe01da After some discussion with Doug, we decided that it made a lot more sense
for __unknown_anytype resolution to destructively modify the AST.  So that's
what it does now, which significantly simplifies some of the implementation.
Normal member calls work pretty cleanly now, and I added support for
propagating unknown-ness through &.

llvm-svn: 129331
2011-04-12 00:42:48 +00:00
Ted Kremenek 8ef59e5c03 C++ static analysis: also invalidate fields of objects that are the callees in C++ method calls.
llvm-svn: 129308
2011-04-11 22:22:05 +00:00
Fariborz Jahanian fae2e8df37 Fixup more objc rwriter bug having to do with
rewriting of blocks which have objective-c
stuff which need be rewritten as well. // rdar://9254348

llvm-svn: 129300
2011-04-11 21:17:02 +00:00
Chris Lattner 20b90d061a fix the path to ld.so for darwin/ppc, resolving PR9677. Patch
by Jeremy Huddleston!

llvm-svn: 129299
2011-04-11 21:15:37 +00:00
Anders Carlsson 0c63350b0b If there's an invoke destination, we should use invoke instead of call when calling the __cxa_bad_typeid function. Fixes PR7400.
llvm-svn: 129273
2011-04-11 14:13:40 +00:00
John McCall 2d2e870745 More __unknown_anytype work.
llvm-svn: 129269
2011-04-11 07:02:50 +00:00
Anders Carlsson 8a01a751c9 Remove CK_DynamicToNull.
llvm-svn: 129265
2011-04-11 02:03:26 +00:00
Anders Carlsson c1c9971cab When we know that a dynamic_cast always returns null, we can make
CodeGenFunction::EmitDynamicCast always return null or throw a bad_cast 
exception.

llvm-svn: 129264
2011-04-11 01:45:29 +00:00
Anders Carlsson 267c0c930e Add CXXDynamicCastExpr::isAlwaysNull() which will be replacing the cast kind I added.
llvm-svn: 129263
2011-04-11 01:43:55 +00:00
Anders Carlsson 882d790f72 Clean up CodeGenFunction::EmitDynamicCast. No functionality change.
llvm-svn: 129262
2011-04-11 00:46:40 +00:00
Anders Carlsson 98981b10c8 Replace a couple of Builder.CreateICmpEQ with Builder.CreateIsNull. No functionality change.
llvm-svn: 129261
2011-04-11 00:30:07 +00:00
Eli Friedman 554eba9c08 PR9669: implement correct checking for [dcl.init.string]p2.
llvm-svn: 129260
2011-04-11 00:23:45 +00:00
Anders Carlsson c602006638 As a first step towards fixing PR9641, add a CK_DynamicToNull cast kind which
represents a dynamic cast where we know that the result is always null.

For example:

struct A {
  virtual ~A();
};
struct B final : A { };
struct C { };

bool f(B* b) {
  return dynamic_cast<C*>(b);
}

llvm-svn: 129256
2011-04-10 20:33:22 +00:00
John McCall 3aef3d8713 Simplify calling CheckPlaceholderExpr, converge on it in a few places,
and move a vector-splat check to follow l-value conversion.

llvm-svn: 129254
2011-04-10 19:13:55 +00:00
Anders Carlsson c53d9e8350 Strip off parens and no-op casts when deciding if an expr can be devirtualized. Fixes the second half of PR9660.
llvm-svn: 129253
2011-04-10 18:20:53 +00:00
Anders Carlsson e5ec21c977 Change CollectPrimaryBases to collect the bases in the right order. Fixes one half of PR9660.
llvm-svn: 129252
2011-04-10 18:00:32 +00:00
Anders Carlsson 68aad14dd3 Make -fdump-vtable-layouts also dump vtable indices for all virtual member functions in the class.
llvm-svn: 129250
2011-04-10 17:42:45 +00:00
Chandler Carruth 016ef400c4 Enhance the diagnostic for literal float -> int conversions to suggest
rewriting the literal when the value is integral. It is not uncommon to
see code written as:

  const int kBigNumber = 42e5;

Without any real awareness that this is no longer an ICE. The note helps
automate and ease the process of fixing code that violates the warning.

llvm-svn: 129243
2011-04-10 08:36:24 +00:00
Francois Pichet 8cb243a78f Refactor 129240 to merge the old default argument into the new parameter.
llvm-svn: 129242
2011-04-10 04:58:30 +00:00
Eli Friedman 493c34a86c PR9580: Handle vectors correctly in ScalarExprEmitter::EmitRem.
While I'm here, FileCheck-ize the ext-vector test, so we actually check
what it is generating.

llvm-svn: 129241
2011-04-10 04:44:11 +00:00
Francois Pichet 53fe2bb29e MSVC accepts that default parameters be redefined for member functions
of template class. The new value is ignored.

This fixes 1 error when parsing MSVC 2010 header files with clang.

llvm-svn: 129240
2011-04-10 03:03:52 +00:00
John McCall 39439739cf Fix a bunch of major problems with __unknown_anytype and properly test
for them.  The only major missing feature is references.

llvm-svn: 129234
2011-04-09 22:50:59 +00:00
Eli Friedman db42a3e876 Make sure we or together the overflow flags of the multiply and add, so the
check is triggered appropriately.  Reported on cfe-dev.

llvm-svn: 129231
2011-04-09 19:54:33 +00:00
Lenny Maiorani 467dbd5f13 strcat() and strncat() model additions to CStringChecker.
Validates inputs are not NULL, checks for overlapping strings, concatenates the strings checking for buffer overflow, sets the length of the destination string to the sum of the s1 length and the s2 length, binds the return value to the s1 value.

llvm-svn: 129215
2011-04-09 15:12:58 +00:00
Dylan Noblesmith 92c07c27be refactor flags for TokenKinds.def
Make KEYALL a combination of all other flags instead
of its own separate flag. Also rewrite the enum
definitions in hex instead of decimal.

llvm-svn: 129213
2011-04-09 13:34:05 +00:00
Dylan Noblesmith 70e73a3d60 refactor -ccc-gcc-name code
Put the logic for deciding the default name for gcc/g++
in the only place that actually cares about it.

This also pushes an ifdef out of the generic driver code
to a little further down, when the target is actually known.
Hopefully it can be changed into just a runtime check
in the future.

llvm-svn: 129212
2011-04-09 13:31:59 +00:00
Eli Friedman c5b20b5283 PR8369: make __attribute((regparm(0))) work correctly. Original patch by
pageexec@freemail.hu, tweaks by me.

llvm-svn: 129206
2011-04-09 08:18:08 +00:00
Chandler Carruth 66a7b04767 Clean up the bool conversion warning. Group it with other conversion
warnings, and make its text appropriate for constant bool expressions
other than 'false'. This should finish off PR9612.

llvm-svn: 129205
2011-04-09 07:48:17 +00:00
Chandler Carruth ffab873ed5 Add support for warning on general null pointer expressions of boolean
type rather than just the literal 'false'. This begins fixing PR9612,
but the message is now wrong. WIP, the cleanup of the messaging is next.

llvm-svn: 129204
2011-04-09 07:32:05 +00:00
Chris Lattner e4ec5abf1b fix indentation
llvm-svn: 129202
2011-04-09 07:11:53 +00:00
Chris Lattner 5045cf1a61 accept -x objc-cpp-output as an alias for -x objective-c-cpp-output,
per PR9577

llvm-svn: 129201
2011-04-09 07:09:31 +00:00
Chris Lattner 9cb59fa834 add a __sync_swap builtin to fill out the rest of the __sync builtins.
Patch by Dave Zarzycki!

llvm-svn: 129189
2011-04-09 03:57:26 +00:00