Commit Graph

28254 Commits

Author SHA1 Message Date
Douglas Gregor 3c0d263abb Canonicalize path names in the file manager before performing a lookup
on that name. Canonicalization eliminates silliness such as "." and
"foo/.." that breaks the uniquing of files in the presence of virtual
files or files whose inode numbers have changed during
parsing/re-parsing. c-index-test isn't able to create this crazy
situation, so I've resorted to testing outside of the Clang
tree. Fixes <rdar://problem/8928220>.

Note that this hackery will go away once we have a real virtual file
system on which we can layer FileManager; the virtual-files hack is
showing cracks.

llvm-svn: 124754
2011-02-02 22:30:17 +00:00
Devang Patel e3773c2f51 Emit debug info for template type parameters.
llvm-svn: 124753
2011-02-02 21:38:49 +00:00
Daniel Dunbar ac540b3859 clang: Add support for a CC_PRINT_HEADERS environment variable, which mirrors
CC_PRINT_OPTIONS and can be used to get some out-of-band information on header
usage from a build.

llvm-svn: 124751
2011-02-02 21:11:35 +00:00
Daniel Dunbar 1af1d2751a Frontend: Add -header-include-file option, for allowing saving header include
information to a file.

llvm-svn: 124750
2011-02-02 21:11:31 +00:00
Daniel Dunbar fb24485727 Frontend: Add support (unused) for showing all "interesting" headers, not just
ones outside the predefines buffer (which is what -H does).

llvm-svn: 124749
2011-02-02 21:11:24 +00:00
Fariborz Jahanian a5cdc7ea0f Turn test for // rdar://8945175 into a sema test.
llvm-svn: 124748
2011-02-02 21:10:07 +00:00
Fariborz Jahanian 09b2331cf7 For gcc compatibility, size of a class which is zero
but has non-empty data fields, such as array of zero length,
remains zero.
// rdar://8945175

llvm-svn: 124741
2011-02-02 19:36:18 +00:00
Douglas Gregor ac18130050 Revert r124704, which uniqued code-completion strings. The space
savings of 25% sounds impressive, except that this amounted to only
about 360k in our standard "large" completion result set (40,000
results). Since code completion is performance-sensitive, the 4%
slowdown due to uniquing outweighs the 360k benefit. 

llvm-svn: 124737
2011-02-02 19:04:30 +00:00
Benjamin Kramer 24f1d3e60a Add NetBSD target support. Patch by Joerg Sonnenberger.
llvm-svn: 124736
2011-02-02 18:59:27 +00:00
Argyrios Kyrtzidis 83b797f490 Don't warn for -Wnon-virtual-dtor for dependent classes.
llvm-svn: 124735
2011-02-02 18:47:41 +00:00
Daniel Dunbar 27734fdbbf Frontend: Factor out header include dumping (-H) into its own preprocessor
callbacks class.
 - Aside from being generally cleaner, this also allows -H to work correctly in
   modes other than standard preprocessing (e.g., -c, -MM, etc.)

llvm-svn: 124723
2011-02-02 15:41:17 +00:00
John McCall c63de66c4f An insomniac stab at making block declarations list the variables they close
on, as well as more reliably limiting invalid references to locals from
nested scopes.

llvm-svn: 124721
2011-02-02 13:00:07 +00:00
Nick Lewycky fe719128e9 Fix test by fully specifying the platform.
llvm-svn: 124719
2011-02-02 07:17:02 +00:00
Nick Lewycky 75033770f4 Turn on -momit-leaf-frame-pointer by default on all non-Darwin platforms.
Fixes PR9121!

llvm-svn: 124718
2011-02-02 06:43:03 +00:00
Dan Gohman b93f581948 Update this test following recent optimizer changes.
llvm-svn: 124715
2011-02-02 02:21:10 +00:00
Ted Kremenek ae022096db Remove redundant check to not warn for warn_equality_with_extra_parens if we are in a macro. This is checked twice.
llvm-svn: 124714
2011-02-02 02:20:30 +00:00
Douglas Gregor 801acff462 Unique code-completion strings. On Cocoa.h, this costs us about 4% in
speed but saves us about 25% of the memory usage for strings.

llvm-svn: 124704
2011-02-01 23:59:42 +00:00
John McCall 71de91cc09 When diagnosing address-space changes, apply array-to-pointer decay first.
llvm-svn: 124702
2011-02-01 23:28:01 +00:00
Fariborz Jahanian 265c325ef3 -fapple-kext support for indirect call to virtuals dtors - wip.
llvm-svn: 124701
2011-02-01 23:22:34 +00:00
Douglas Gregor 6c7cb188e9 Fix name lookup issue
llvm-svn: 124700
2011-02-01 23:14:23 +00:00
Nick Lewycky 22197c1334 Add support for x86-64 Mandriva 2010.2. Reported by 'rindolf' on IRC!
llvm-svn: 124699
2011-02-01 23:03:29 +00:00
Douglas Gregor bcbf46c7b7 Create a special allocator class for code completion, so that all of
the string copying goes through a single place that can have
associated state.

llvm-svn: 124698
2011-02-01 22:57:45 +00:00
Matt Beaumont-Gay 06cebfd9a5 Use tempfiles for the .o outputs.
llvm-svn: 124697
2011-02-01 22:44:06 +00:00
Ted Kremenek 1dd5646da0 Enable the self-init checker in scan-build.
llvm-svn: 124696
2011-02-01 22:36:11 +00:00
Ted Kremenek c358d9f305 Don't warn about extraneous '()' around a comparison if it occurs within a macro.
Macros frequently contain extra '()' to make instantiation less error prone.
This warning was flagging a ton of times on postgresql because of its use of macros.

llvm-svn: 124695
2011-02-01 22:36:09 +00:00
Argyrios Kyrtzidis f4f8278c95 Don't warn for "if ((a == b))" if the parens came from a macro. Thanks to Fariborz for the hint!
llvm-svn: 124689
2011-02-01 22:23:56 +00:00
John McCall 2725aa13ea Do the right thing for zero-initializing VLAs that don't have a zero
bit-pattern.  It's not clear that this is actually useful given current
language restrictions.

llvm-svn: 124685
2011-02-01 21:35:06 +00:00
Nick Lewycky edda72658a Add updated Debian ARM include path.
llvm-svn: 124684
2011-02-01 21:32:14 +00:00
Douglas Gregor 304f9b0803 Provide constant strings for certain common code completion strings,
eliminating the need to copy those strings.

llvm-svn: 124683
2011-02-01 21:15:40 +00:00
Ted Kremenek e57d88c6a3 Add test case for dead stores checker to not flag dead assignments to 'self' within a nested assignment.
llvm-svn: 124681
2011-02-01 20:45:26 +00:00
Argyrios Kyrtzidis c1b4534e42 Fix the message. Thanks to Thomas Clement for noticing.
llvm-svn: 124680
2011-02-01 20:33:05 +00:00
Argyrios Kyrtzidis 582dd68541 For "if ((a == b))" only warn if 'a' is a modifiable l-value. Caught by John!
llvm-svn: 124675
2011-02-01 19:32:59 +00:00
Argyrios Kyrtzidis 15a3daa189 [analyzer] Slightly improve the diagnostic message of ObjCSelfInitChecker.
llvm-svn: 124674
2011-02-01 19:32:55 +00:00
Douglas Gregor b278aafbfb Allocate CodeCompletionString and all of its components in a
BumpPtrAllocator, rather than manually new/delete'ing them. This
optimization also allows us to avoid allocating memory for and copying
constant strings (e.g., "return", "class").

This also required embedding the priority and availability of results
within the code completion string, to avoid extra memory allocation
within libclang.

llvm-svn: 124673
2011-02-01 19:23:04 +00:00
Argyrios Kyrtzidis 8b6ec6870f Warn for "if ((a == b))" where the equality expression is needlessly wrapped inside parentheses.
It's highly likely that the user intended an assignment used as condition.

Addresses rdar://8848646.

llvm-svn: 124668
2011-02-01 18:24:22 +00:00
Ted Kremenek 5b4288440d Add temporary hack to -Wuninitialize to create a separate CFG (for C++ code) that doesn't include implicit dtors.
Implicit dtors confuse the ad hoc path-sensitivity of UninitializedValuesV2.cpp.  This isn't
the ideal solution, as it will directly impact compile time, but should significantly reduce
the noise of -Wuninitialized on some code bases.

This immediately "fixes" the false positive reported in PR 9063, although this
isn't the right fix in the long run.

llvm-svn: 124667
2011-02-01 17:43:21 +00:00
Ted Kremenek ba357296e7 Enhance -Wuninitialized to better reason about || and &&, tracking dual dataflow facts and properly merging them.
Fixes PR 9076.

llvm-svn: 124666
2011-02-01 17:43:18 +00:00
Douglas Gregor fa7781384e Implement access checking for the "delete" operator. Fixes PR9050,
from Alex Miller!

llvm-svn: 124663
2011-02-01 15:50:11 +00:00
Douglas Gregor 1732850158 Fix a thinko where I didn't update a consistency check for
PackExpansionType in the AST reader. We need more testing for variadic
templates + PCH, but this fixes PR9073.

llvm-svn: 124662
2011-02-01 15:24:58 +00:00
Douglas Gregor dbe3927026 Basic support for -mms-bitfields, from Carl Norum!
llvm-svn: 124661
2011-02-01 15:15:22 +00:00
Douglas Gregor de7a357a30 Support EFI target triple, from Carl Norum!
llvm-svn: 124660
2011-02-01 15:06:18 +00:00
John McCall 9361be98d5 Make that test case actually test something, and add another test.
llvm-svn: 124654
2011-02-01 08:30:38 +00:00
John McCall 04fcd0d58f The code trying to assign a typedef to an anonymous tag declaration was
extremely rambunctious, both on parsing and on template instantiation.
Calm it down, fixing an internal consistency assert on anonymous enum
instantiation manglings.

llvm-svn: 124653
2011-02-01 08:20:08 +00:00
Rafael Espindola 88ea6ab44f Revert 124633. The linker has been told how to merge available_externally.
llvm-svn: 124651
2011-02-01 05:45:26 +00:00
Ken Dyck 49916d786a Correct units in doxygen comment for NonVirtualSize.
llvm-svn: 124647
2011-02-01 02:03:12 +00:00
Ken Dyck 316d6f69bc Convert RecordLayout::NonVirtualSize from bit units to CharUnits.
llvm-svn: 124646
2011-02-01 01:52:10 +00:00
Argyrios Kyrtzidis 0d349f9b8a When initializing struct members, the important thing is that the "initializing" expression is
compatible, not having the same type.

Fix rdar://8183908 in which compatible vector types weren't initialized properly leading to a crash.

llvm-svn: 124637
2011-02-01 00:52:10 +00:00
Rafael Espindola 9fa5a67d3d Set visibility for available_externally globals. This is important for two reasons:
* llvm-link would complains about mismatched visibility
* If we produce a relocation with an available_externally, it is good to know that
it is hidden.

llvm-svn: 124633
2011-02-01 00:37:17 +00:00
John McCall 4fff8f6cff Perform the bad-address-space conversions check as part of
CheckPointerTypesForAssignment.

llvm-svn: 124632
2011-02-01 00:10:29 +00:00
Argyrios Kyrtzidis b5b5a59f18 Improve the diagnostic for -Wcustom-atomic-properties. Suggestion by Fariborz!
llvm-svn: 124620
2011-01-31 23:20:03 +00:00
John McCall aba9082f0f Make Check*PointerTypesForAssignment private and tell them that they're
working on canonical types already.

llvm-svn: 124618
2011-01-31 23:13:11 +00:00
Douglas Gregor 86af98444f Harden Lexer::GetBeginningOfToken() against bogus source locations and
the disappearance/alteration of files.

llvm-svn: 124616
2011-01-31 22:42:36 +00:00
John McCall e5255935d5 Slightly reorganize CheckAssignmentConstraints and remove some redundant
logic.

llvm-svn: 124615
2011-01-31 22:28:28 +00:00
Douglas Gregor 7a964ad4ce Teach Diagnostic::setClient() to free the existing, owned
client. Fixes a libclang leak.

llvm-svn: 124614
2011-01-31 22:04:05 +00:00
Daniel Dunbar a2867c7741 libclang: Don't allow RemoveFileOnSignal to be called via libclang, badness can
ensue.

llvm-svn: 124613
2011-01-31 22:00:44 +00:00
Daniel Dunbar e326f9bb3e Frontend: Add an explicit RemoveFileOnSignal flag argument, to control the
automatic behavior (which is undesirable in a multithreaded context).

llvm-svn: 124612
2011-01-31 22:00:42 +00:00
Argyrios Kyrtzidis dd88dbf9d2 Add -Wcustom-atomic-properties which warns if an atomic-by-default property has custom getter or setter.
The rationale is that it is highly likely that the user's getter/setter isn't atomically implemented. Off by default.
Addresses rdar://8782645.

-Wcustom-atomic-properties and -Wimplicit-atomic-properties are under the -Watomic-properties group.

llvm-svn: 124609
2011-01-31 21:34:11 +00:00
Ted Kremenek 47537b617e Document that set-xcode-analyzer should typically be run using sudo.
llvm-svn: 124602
2011-01-31 20:45:38 +00:00
Douglas Gregor 058d3deab8 Implement reasonable conversion ranking for Objective-C pointer
conversions (<rdar://problem/8592139>) for overload resolution. The
conversion ranking mirrors C++'s conversion ranking fairly closely,
except that we use a same pseudo-subtyping relationship employed by
Objective-C pointer assignment rather than simple checking
derived-to-base conversions. This change covers:

  - Conversions to pointers to a specific object type are better than
  conversions to 'id', 'Class', qualified 'id', or qualified 'Class'
  (note: GCC doesn't perform this ranking, but it matches C++'s rules
  for ranking conversions to void*).
  - Conversions to qualified 'id' or qualified 'Class' are better than
  conversions to 'id' or 'Class', respectively.
  - When two conversion sequences convert to the same type, rank the
  conversions based on the relationship between the types we're
  converting from. 
  - When two conversion sequences convert from the same non-id,
  non-Class type, rank the conversions based on the relationship of
  the types we're converting to. (note: GCC allows this ranking even
  when converting from 'id', which is extremeley dangerous).

llvm-svn: 124591
2011-01-31 18:51:41 +00:00
Argyrios Kyrtzidis 33799caf6d Only warn for -Wnon-virtual-dtor for public destructors. Thanks to Benjamin Kramer for the hint!
llvm-svn: 124585
2011-01-31 17:10:25 +00:00
Douglas Gregor 205d5e3a51 Implement the suggested resolution to core issue 547, extended to also
allow ref-qualifiers on function types used as template type
arguments. GNU actually allows cv-qualifiers on function types in many
places where it shouldn't, so we currently categorize this as a GNU
extension.

llvm-svn: 124584
2011-01-31 16:09:46 +00:00
Argyrios Kyrtzidis 7f3986dc64 Warn if the class has virtual methods but non-virtual destructor. Addresses rdar://8756445.
llvm-svn: 124582
2011-01-31 07:05:00 +00:00
Argyrios Kyrtzidis f46cc65f44 Don't warn that variables in C++ static member functions shadow fields. Fixes rdar://8900456.
llvm-svn: 124581
2011-01-31 07:04:54 +00:00
Argyrios Kyrtzidis 857dd06605 Fix the diagnostic when we are shadowing an external variable and there exists a locally scoped extern with the same name.
llvm-svn: 124580
2011-01-31 07:04:50 +00:00
Argyrios Kyrtzidis 819f610942 Diagnose if extern local variable is followed by non-extern and vice-versa.
llvm-svn: 124579
2011-01-31 07:04:46 +00:00
Argyrios Kyrtzidis f41860c882 'extern' variables in functions don't shadow externs in global scope. Fixes rdar://8883302.
llvm-svn: 124578
2011-01-31 07:04:41 +00:00
Argyrios Kyrtzidis 77fd99f8ae If there were errors, disable 'unused' warnings since they will mostly be noise.
Fixes rdar://8736362.

llvm-svn: 124577
2011-01-31 07:04:37 +00:00
Argyrios Kyrtzidis b85cd7c312 Error for use of field from anonymous struct or union should say "invalid use of nonstatic data member"
not "call to non-static member function without an object argument".

llvm-svn: 124576
2011-01-31 07:04:33 +00:00
Argyrios Kyrtzidis 8322b426a5 Amazing that there are still issues with the fields of anonymous struct/unions..
Allow taking the address of such a field for a pointer-to-member constant. Fixes rdar://8818236.

llvm-svn: 124575
2011-01-31 07:04:29 +00:00
Argyrios Kyrtzidis 1ce7755c35 Fix test that didn't actually test what it wanted to test.
llvm-svn: 124574
2011-01-31 07:04:24 +00:00
Francois Pichet 79f3a87007 Allow Microsoft attributes in a constructor's parameter list.
This fixes a few compile errors when parsing <regex> from MSVC 2008 with clang.

llvm-svn: 124573
2011-01-31 04:54:32 +00:00
Anders Carlsson a03f3a85cb When building with optimizations, emit vtables where the key is not in the
current translation unit as available_externally. 

This helps devirtualize the second example in PR3100, comment 18:

struct S { S() {}; virtual void xyzzy(); };
inline void foo(S *s) { s->xyzzy(); }
void bar() { S s; foo(&s); }

This involved four major changes:

1. In DefineUsedVTables, always mark virtual member functions as referenced for
   non-template classes and class template specializations.
2. In CodeGenVTables::ShouldEmitVTableInThisTU return true if optimizations are
   enabled, even if the key function is not implemented in this translation 
   unit. We don't ever do this for code compiled with -fapple-kext, because we
   don't ever want to devirtualize virtual member function calls in that case.
3. Give the correct linkage for vtables where the key function is not defined.
4. Update the linkage for RTTI structures when necessary.

llvm-svn: 124565
2011-01-30 20:45:54 +00:00
Roman Divacky 115f0fa397 Add hardcoded -L/usr/lib after all -L options to the FreeBSD linker
invocation. 

This mimics what gcc does and fixes libtool check for libraries.

llvm-svn: 124558
2011-01-30 08:12:24 +00:00
Anders Carlsson 064ccbef26 Fix test.
llvm-svn: 124555
2011-01-29 22:39:23 +00:00
Anders Carlsson 5b48bf70a8 Remove dead code.
llvm-svn: 124554
2011-01-29 22:15:18 +00:00
Anders Carlsson 49f17537ee When emitting RTTI for a non-class type, compute the visibility of the RTTI data based on the explicit visibility of the type.
llvm-svn: 124553
2011-01-29 22:10:32 +00:00
Nico Weber 741bf9d872 Support for -plugin-arg- with -add-plugin
llvm-svn: 124551
2011-01-29 21:21:49 +00:00
Anders Carlsson 537fdceded Move GetLLVMVisibility to CodeGenModule.
llvm-svn: 124550
2011-01-29 20:59:35 +00:00
Anders Carlsson 46fcf9f0b7 Update tests.
I'm still not sure if having the typenames be visible with -hidden-weak-vtables, but I think it makes sense.

llvm-svn: 124549
2011-01-29 20:57:16 +00:00
Anders Carlsson 678632fa42 Add RTTIBuilder::GetAddrOfTypeName which uses the newly added CreateOrReplaceCXXRuntimeVariable.
Set the visibility for typeinfo names.

llvm-svn: 124548
2011-01-29 20:36:11 +00:00
Anders Carlsson 265aa7c070 Change CodeGenModule::setTypeVisibility to take a TypeVisibilityKind enum instead of an "IsForRTTI" flag.
llvm-svn: 124546
2011-01-29 20:24:48 +00:00
Anders Carlsson caea35dce2 Add a test for RTTI visibility.
llvm-svn: 124543
2011-01-29 19:52:22 +00:00
Anders Carlsson 072ef7420a Replace an isa/cast with a dyn_cast.
llvm-svn: 124542
2011-01-29 19:41:00 +00:00
Anders Carlsson c6a47895f7 Get rid of an unneeded parameter from setGlobalVisibility.
llvm-svn: 124541
2011-01-29 19:39:23 +00:00
Anders Carlsson 5963024ff6 Give VTTs the right visibility.
llvm-svn: 124540
2011-01-29 19:34:19 +00:00
Anders Carlsson 883fc72c3c Make emitting a VTT a two-step process, much like emitting a VTable. You first get the address of the VTT, and then pass it to EmitVTTDefinition.
llvm-svn: 124539
2011-01-29 19:16:51 +00:00
Anders Carlsson 93be9a90cc Use CGM.CreateOrReplaceCXXRuntimeVariable in CGVTables.cpp
llvm-svn: 124538
2011-01-29 18:25:07 +00:00
Anders Carlsson da80af3681 Add a new function, to be used by CGRTTI, CGVTables and CGVTT (which each has their own copy of this code).
llvm-svn: 124537
2011-01-29 18:20:20 +00:00
Ken Dyck a45a70cf73 Replace a literal '8' with getCharWidth().
llvm-svn: 124536
2011-01-29 17:53:12 +00:00
Anders Carlsson fd4834061c Remove IsDefinition from CodeGenModule::setTypeVisibility; it is always true.
llvm-svn: 124529
2011-01-29 05:26:32 +00:00
Anders Carlsson 6b3afd7df1 When trying to get the most derived class, don't assume that we can ignore all casts. We can only ignore derived-to-base and no-op casts. Fixes selfhost.
llvm-svn: 124528
2011-01-29 05:04:11 +00:00
Anders Carlsson 1ae64c5a9d When calling a virtual member function on a base class and the most derived class is marked 'final', we can devirtualize the call.
llvm-svn: 124524
2011-01-29 03:52:01 +00:00
Anders Carlsson a376b53695 When doing a derived-to-base class through a virtual class, we don't have to get the vbase offset from the vtable if the derived class is marked final.
llvm-svn: 124523
2011-01-29 03:18:56 +00:00
Fariborz Jahanian 9f9438b314 More work to support -fapple-kext regarding
indirect vf calls and addition of extra entry
at bottom of vtbls.

llvm-svn: 124507
2011-01-28 23:42:29 +00:00
Jeffrey Yasskin f66a5283ed Document how to add an attribute to clang. This should be reviewed by someone
who actually knows how it works.

llvm-svn: 124506
2011-01-28 23:41:54 +00:00
John McCall 388ef53234 Fix some corner cases in the __is_base_of logic.
llvm-svn: 124505
2011-01-28 22:02:36 +00:00
John McCall b91ab89729 Add my new file to the CMake lists, sorry about that.
llvm-svn: 124503
2011-01-28 20:10:46 +00:00
Benjamin Kramer ed3d85a7f0 Make the FreeBSD driver test more robust so it doesn't fail when there's a single lib32 path.
llvm-svn: 124494
2011-01-28 18:28:30 +00:00
John McCall ed1ae86ac6 Move all the cleanups framework code into a single file.
Pure motion.

llvm-svn: 124484
2011-01-28 11:13:47 +00:00
John McCall cb5f77f046 Reorganize the value-dominance metaprogram and introduce a specialization
for CodeGen's RValue type.

llvm-svn: 124483
2011-01-28 10:53:53 +00:00
John McCall e4df6c8d96 Convert the exception-freeing cleanup over to the conditional cleanups code,
fixing a crash which probably nobody was ever going to see.  In doing so,
fix a horrendous number of problems with the conditional-cleanups code.
Also, make conditional cleanups re-use the cleanup's activation variable,
which avoids some unfortunate repetitiveness.

llvm-svn: 124481
2011-01-28 08:37:24 +00:00
Nico Weber 24b2a822dd PR9037: Allow override, final, and new as an extension on inline members.
llvm-svn: 124477
2011-01-28 06:07:34 +00:00
John McCall f26870c43d Not really any point to testing control flow in this test without
ret duplication.

llvm-svn: 124476
2011-01-28 06:05:16 +00:00
Eric Christopher 709e1f3711 Update exceptions.m for r124462.
llvm-svn: 124474
2011-01-28 05:13:18 +00:00
Douglas Gregor c03a1083af Give OpaqueValueExpr a source location, because its source location
might be queried in places where we absolutely require a valid
location (e.g., for template instantiation). Fixes some major
brokenness in the use of __is_convertible_to.

llvm-svn: 124465
2011-01-28 02:26:04 +00:00
Douglas Gregor 3fb22baddb Allow elision of invocations of move constructors from temporary objects.
llvm-svn: 124455
2011-01-27 23:24:55 +00:00
Douglas Gregor 21d3fca917 When producing IR for a lvalue-to-rvalue cast *as an lvalue*, only
non-class prvalues actually require the realization of a
temporary. For everything else, we already have an lvalue (or class
prvalue) in the subexpression.

Note: we're missing some move elision in this case. I'll tackle that next.
llvm-svn: 124453
2011-01-27 23:22:05 +00:00
Fariborz Jahanian ee504a0881 Fix an objective-c rewriter bug rewriting a __block
variable declaration of a struct declared type.
// rdar://8918702

llvm-svn: 124451
2011-01-27 23:18:15 +00:00
Douglas Gregor edb7685712 Teach the evaluation of the __is_convertible_to trait to translate
access control errors into SFINAE errors, so that the trait provides
enough support to implement the C++0x std::is_convertible type trait.

To get there, the SFINAETrap now knows how to set up a SFINAE context
independent of any template instantiations or template argument
deduction steps, and (separately) can set a Sema flag to translate
access control errors into SFINAE errors. The latter can also be
useful if we decide that access control errors during template argument
deduction should cause substitution failure (rather than a hard error)
as has been proposed for C++0x.

llvm-svn: 124446
2011-01-27 22:31:44 +00:00
Ted Kremenek 44dc127f78 Adjust casing of attributes in examples.
llvm-svn: 124445
2011-01-27 22:00:02 +00:00
Douglas Gregor 61b7f5e3fd Separate the access-control diagnostics from other diagnostics that do not have SFINAE behavior.
llvm-svn: 124441
2011-01-27 21:06:28 +00:00
Douglas Gregor e5bef035c6 Document some serious badness in our evaluation of the type traits: we need to be sure we have complete types in many cases
llvm-svn: 124428
2011-01-27 20:35:44 +00:00
Douglas Gregor 8006e76b4e Implement the Microsoft __is_convertible_to type trait, modeling the
semantics after the C++0x is_convertible type trait. This
implementation is not 100% complete, because it allows access errors
to be hard errors (rather than just evaluating false).

Original patch by Steven Watanabe!

llvm-svn: 124425
2011-01-27 20:28:01 +00:00
Abramo Bagnara 92141d22ce Fixed parameter names.
llvm-svn: 124408
2011-01-27 19:55:10 +00:00
Ted Kremenek e801399372 Fix download link.
llvm-svn: 124405
2011-01-27 19:49:07 +00:00
Ted Kremenek 8688e078ae Add missing </a>
llvm-svn: 124403
2011-01-27 19:42:34 +00:00
Ted Kremenek cfc9dc6876 Update checker build and post release notes.
llvm-svn: 124402
2011-01-27 19:41:08 +00:00
Jeffrey Yasskin bbc4eea2c2 Revert r124217 because it didn't catch the actual error case it was trying to
catch:

  lock_guard(my_mutex);

declares a variable instead of creating a temporary.

llvm-svn: 124398
2011-01-27 19:17:54 +00:00
Ted Kremenek 1be4a59a11 Teach -Wuninitialized about indirect goto. Fixes PR 9071.
llvm-svn: 124394
2011-01-27 18:51:39 +00:00
Douglas Gregor 5fcfb2fe0c Clean up the diagnostic text for delegating constructors
llvm-svn: 124393
2011-01-27 18:50:39 +00:00
Ted Kremenek afe348ea43 Wire up attributes 'ns_consumed' and 'cf_consumed' in the static analyzer's ObjC retain/release checker.
llvm-svn: 124386
2011-01-27 18:43:03 +00:00
Douglas Gregor 9c2e896d62 Test for previous commit
llvm-svn: 124385
2011-01-27 18:39:26 +00:00
Argyrios Kyrtzidis ff115a2f35 Allow #pragma unused to be used on global variables like gcc. Fixes rdar://8793832.
llvm-svn: 124383
2011-01-27 18:16:48 +00:00
Douglas Gregor ffd6dc432e Teach ASTUnit to save the specified target features, since
TargetInfo::CreateTargetInfo() mangles the target options in a way
that is not idempotent. Fixes <rdar://problem/8807535>.

llvm-svn: 124382
2011-01-27 18:02:58 +00:00
Douglas Gregor 56a6380cb7 Add libclang functions to determine the const/volatile/restrict
qualifiers on a CXType. Patch from Stefan Seefeld, test by me.

llvm-svn: 124377
2011-01-27 16:27:11 +00:00
Argyrios Kyrtzidis add754a02e [analyzer] Fix crash when handling dot syntax on 'super'.
llvm-svn: 124376
2011-01-27 16:17:11 +00:00
Axel Naumann 63fbaeda29 TextDiagnosticPrinter.cpp: Show diagnostics as far as possible even with invalid PresomedLoc, instead of just silencing it.
FileManager.cpp: Allow virtual files in nonexistent directories.
FileManager.cpp: Close FileDescriptor for virtual files that correspond to actual files.
FileManager.cpp: Enable virtual files to be created even for files that were flagged as NON_EXISTENT_FILE, e.g. by a prior (unsuccessful) addFile().

ASTReader.cpp: Read a PCH even if the original source files cannot be found.

Add a test for reading a PCH of a file that has been removed and diagnostics referencing that file.

llvm-svn: 124374
2011-01-27 10:55:51 +00:00
John McCall 284c48fff6 Do a proper recursive lookup when deciding whether a class's usual
deallocation function has a two-argument form.  Store the result of this
check in new[] and delete[] nodes.

Fixes rdar://problem/8913519

llvm-svn: 124373
2011-01-27 09:37:56 +00:00
John McCall d5c9b1d65e Provide Type::castAs<>, which is to getAs<> what cast<> is to dyn_cast<>.
Also provide a method to grab the base element type of a type without
stressing out over qualifiers (but give it a nice scary name).

llvm-svn: 124367
2011-01-27 08:17:49 +00:00
NAKAMURA Takumi f9cbcc4cc2 Fix whitespace.
llvm-svn: 124364
2011-01-27 07:10:08 +00:00
NAKAMURA Takumi 7c2888689d 7bit-ize.
llvm-svn: 124363
2011-01-27 07:09:49 +00:00
Ted Kremenek 35389de110 Fix HTML highlighting and add missing line.
llvm-svn: 124362
2011-01-27 07:02:03 +00:00
Ted Kremenek 4272cbdff5 Fix a few typos in HTML documentation.
llvm-svn: 124361
2011-01-27 06:59:29 +00:00
Ted Kremenek 0e89838ced Hook up attribute ns_consumes_self in the ObjC retain/release checker in the static analyzer.
llvm-svn: 124360
2011-01-27 06:54:14 +00:00
Ted Kremenek 1373e5496b Tweak -Wuninitialized fixit for '_Bool' types to be initialized to 0, and C++ 'bool' types to false.
llvm-svn: 124356
2011-01-27 05:18:52 +00:00
Ted Kremenek 064b0345f5 Teach -Wuninitialized to suggest "= false" for initializing bool variables.
llvm-svn: 124352
2011-01-27 02:57:57 +00:00
John McCall 2903675929 Notes on dynamic array cookies in MSVC.
My thanks to chapuni for his help in investigating this.

llvm-svn: 124351
2011-01-27 02:46:02 +00:00
John McCall 08432c8e00 Import three interesting bits that apply only to C++ methods.
llvm-svn: 124349
2011-01-27 02:37:01 +00:00
Ted Kremenek 93a313869f Teach -Wuninitialized not to assert when analyzing
blocks that reference captured variables.

llvm-svn: 124348
2011-01-27 02:29:34 +00:00
Ted Kremenek 4058d87ad5 Teach -Wuninitialized about ObjC fast enumeration loops.
llvm-svn: 124347
2011-01-27 02:01:31 +00:00
Douglas Gregor 0693defea9 When we run into a template parameter that should have a default
argument but doesn't (because previous template parameters had default
arguments), clear out all of the default arguments so that we maintain
the invariant that a template parameter has a default argument only if
subsequence template parameters also have default arguments.
Fixes a crash-on-invalid <rdar://problem/8913649>.

llvm-svn: 124345
2011-01-27 01:40:17 +00:00
Douglas Gregor dff0be70ba Cope with parenthesized function declarators when emitting a
diagnostic about ref-qualifiers where they do not belong.

llvm-svn: 124344
2011-01-27 01:30:16 +00:00
Douglas Gregor 582813596a Fix a horrible bug in our handling of C-style casting, where a C-style
derived-to-base cast that also casts away constness (one of the cases
for static_cast followed by const_cast) would be treated as a bit-cast
rather than a derived-to-base class, causing miscompiles and
heartburn.

Fixes <rdar://problem/8913298>.

llvm-svn: 124340
2011-01-27 00:58:17 +00:00
Fariborz Jahanian 2f2fa7284b Fixes an IRgen bug where __block variable is
referenced in the block-literal initializer
of that variable. // rdar://8893785

llvm-svn: 124332
2011-01-26 23:08:27 +00:00
Douglas Gregor 9636753d39 Update C++0x status web page
llvm-svn: 124326
2011-01-26 21:35:14 +00:00
Nico Weber 60cd00b2cc make `make` work in examples/PrintFucntionNames on Mac. I checked that it still works on Linux.
llvm-svn: 124325
2011-01-26 21:28:52 +00:00
Douglas Gregor 56d5f0abaa Add __has_feature(cxx_reference_qualified_functions); update tests and
documentation.

llvm-svn: 124322
2011-01-26 21:25:54 +00:00
Douglas Gregor c83f9865a0 Implement the restriction that a function with a ref-qualifier cannot
overload a function without a ref-qualifier (C++0x
[over.load]p2). This, apparently, completes the implementation of
rvalue references for *this.

llvm-svn: 124321
2011-01-26 21:20:37 +00:00
Douglas Gregor ce95084d5c Handle C-style casts to rvalue reference types that cast away constness.
llvm-svn: 124319
2011-01-26 21:04:06 +00:00
Douglas Gregor a52713096d Improve the extension warning for the use of ref-qualifiers, to
distinguish them from rvalue references. Using the rvalue-references
warning was weird when the ref-qualifier was '&'.

llvm-svn: 124316
2011-01-26 20:35:32 +00:00
John McCall 5143d646b9 When mangling a qualified array type, push the qualifiers down to the
element type.  Fixes rdar://problem/8913416.

llvm-svn: 124315
2011-01-26 20:05:40 +00:00
Douglas Gregor e1a47c1766 Rvalue references for *this: explicitly keep track of whether a
reference binding is for the implicit object parameter of a member
function with a ref-qualifier. My previous comment, that we didn't
need to track this explicitly, was wrong: we do in fact get
rvalue-references-prefer-rvalues overloading with ref-qualifiers.

llvm-svn: 124313
2011-01-26 19:41:18 +00:00
Douglas Gregor 0282432039 Rvalue references for *this: implement the implicit conversion rules
for the implicit object argument to a non-static member function with
a ref-qualifier (C++0x [over.match.funcs]p4).

llvm-svn: 124311
2011-01-26 19:30:28 +00:00
John McCall 0a6bf2ebe2 Un-nest the meat of this function.
llvm-svn: 124310
2011-01-26 19:21:13 +00:00
John McCall f256eb54a2 Fix some obvious bugs in the conditional-cleanup code and then make the
dtor cleanup use it.

llvm-svn: 124309
2011-01-26 19:15:39 +00:00
Peter Collingbourne 8bfb2f8ab5 Move InheritableAttr::isInherited to Attr
llvm-svn: 124299
2011-01-26 18:07:13 +00:00
Peter Collingbourne 7b0b89609f Remove Attr::isMerged; it is not used any more and redundant with
InheritableAttr

llvm-svn: 124298
2011-01-26 18:07:07 +00:00
Douglas Gregor b2f8aa9556 Rvalue references for *this: allow functions to be overloaded based on
the presence and form of a ref-qualifier. Note that we do *not* yet
implement the restriction in C++0x [over.load]p2 that requires either
all non-static functions with a given parameter-type-list to have a
ref-qualifier or none of them to have a ref-qualifier.

llvm-svn: 124297
2011-01-26 17:47:49 +00:00
Douglas Gregor f3ea1ed1ad Rvalue references for *this: add name mangling for ref-qualifiers,
using rules that I just made up this morning. This encoding has now
been proposed to the Itanium C++ ABI group for inclusion, but of
course it's still possible that the mangling will change.

llvm-svn: 124296
2011-01-26 17:36:28 +00:00
Douglas Gregor 54e462ac6e Rvalue references for *this: tentative parsing and template argument deduction.
llvm-svn: 124295
2011-01-26 16:50:54 +00:00
Douglas Gregor 1d042091d3 Reference qualifiers for *this: implement C++0x [expr.mptr.oper]p6,
the restrictions on .* and ->* for ref-qualified pointer-to-member
functions.

llvm-svn: 124294
2011-01-26 16:40:18 +00:00
Douglas Gregor c41d94eb1a Clean up the C++0x __has_feature tests. Specifically:
- Don't publicize a C++0x feature through __has_feature if we aren't
    in C++0x mode (even if the feature is available only with a
    warning). 
  - "auto" is not implemented well enough for its __has_feature to be
    turned on.
  - Fix the test of C++0x __has_feature to actually test what we're
  trying to test. Searching for the substring "foo" when our options
  are "foo" and "no_foo" doesn't work :)

llvm-svn: 124291
2011-01-26 15:36:03 +00:00
Douglas Gregor e696ebbd70 Reinstate r124236 (tweaking the rvalue-reference overload resolution
rules), now that we've actually have a clean build for me to sully.

llvm-svn: 124290
2011-01-26 14:52:12 +00:00
Douglas Gregor db9d664244 Rvalue references for *this:
- Add ref-qualifiers to the type system; they are part of the
  canonical type. Print & profile ref-qualifiers
  - Translate the ref-qualifier from the Declarator chunk for
    functions to the function type. 
  - Diagnose mis-uses of ref-qualifiers w.r.t. static member
  functions, free functions, constructors, destructors, etc.
  - Add serialization and deserialization of ref-qualifiers.

llvm-svn: 124281
2011-01-26 05:01:58 +00:00
Ted Kremenek 5d068499a7 Teach -Wreturn-type that destructors can appear
after a 'return' in a CFGBlock.  This accidentally
was working before, but the false assumption that
'return' always appeared at the end of the block
was uncovered by a recent change.

llvm-svn: 124280
2011-01-26 04:49:52 +00:00
Ted Kremenek e543be3531 Merge -Wuninitialized-experimental into -Wuninitialized.
llvm-svn: 124279
2011-01-26 04:49:48 +00:00
Ted Kremenek 33ddd9692d Tweak -Wuninitialized-experimental to not emit
a warning for uses of an uninitialized variable
when the use is a void cast, e.g. (void) x.

llvm-svn: 124278
2011-01-26 04:49:43 +00:00
John McCall ce1de6172c Better framework for conditional cleanups; untested as yet.
I'm separately committing this because it incidentally changes some
block orderings and minor IR issues, like using a phi instead of
an unnecessary alloca.

llvm-svn: 124277
2011-01-26 04:00:11 +00:00
Douglas Gregor 5499235d13 Rvalue references for *this: parse ref-qualifiers.
llvm-svn: 124276
2011-01-26 03:43:54 +00:00
Ken Dyck 02155cb8e8 Use RecordLayout::getBaseClassOffset() where CharUnits are needed instead of
converting getBaseClassOffsetInBits() to CharUnits.

llvm-svn: 124274
2011-01-26 02:17:08 +00:00
Argyrios Kyrtzidis c7ffd35cb7 [analyzer] Enable the self-init checker under command-line option '-analyzer-check-objc-self-init' which by default
is enabled by the driver for '--analyze'.

llvm-svn: 124266
2011-01-26 01:26:50 +00:00
Argyrios Kyrtzidis 7e71884ecb Correct r124242 making sure function chunk that gets diagnosed is really about the block.
Clairvoyance by John!

llvm-svn: 124264
2011-01-26 01:26:44 +00:00
Argyrios Kyrtzidis 8781b7dded [analyzer] Improve the diagnostic for the self-init checker. Suggestion by Ted!
llvm-svn: 124263
2011-01-26 01:26:41 +00:00
Fariborz Jahanian 9312fcc2d3 Tweak the rule for deciding if a provisional ivar is needed
in default ivar synthesis.  Fixes // rdar://8913053.

llvm-svn: 124258
2011-01-26 00:57:01 +00:00
Jeffrey Yasskin d5642d0bcd Remove CompilerInstance::getOutputFileList because it is unimplemented and unused.
llvm-svn: 124256
2011-01-26 00:18:08 +00:00
Argyrios Kyrtzidis 3ae681eb12 [analyzer] Do the self-init check only on NSObject subclasses. Patch by Jean-Daniel Dupas!
llvm-svn: 124249
2011-01-25 23:54:44 +00:00
Douglas Gregor 41e4e2c798 Speculatively revert r124236
llvm-svn: 124247
2011-01-25 23:49:36 +00:00
Argyrios Kyrtzidis 4e52cc7de4 Diagnose calling convention attribute incompatibilities. Fixes rdar://8876096.
llvm-svn: 124244
2011-01-25 23:16:40 +00:00
Argyrios Kyrtzidis cd81fe033c Fix infinite loop during error diagnostics. Fixes rdar://8875304.
llvm-svn: 124243
2011-01-25 23:16:36 +00:00
Argyrios Kyrtzidis 20ad245e3e Change error "function cannot return array type" -> "blocks cannot return array type" when blocks are involved.
Addresses rdar://8876238.

llvm-svn: 124242
2011-01-25 23:16:33 +00:00
Ted Kremenek 4fd3fda33b Tweak return-noreturn.cpp test to have its original
contents, with the additional warning flag (and still marked XFAIL).

llvm-svn: 124239
2011-01-25 22:57:41 +00:00
Ted Kremenek ebe6260137 Fix regression in -Wreturn-type caused by not
handling all CFGElement kinds.  While writing
the test case, it turned out that return-noreturn.cpp
wasn't actually testing anything since it has the wrong -W
flag.  That uncovered another regression with
the handling of destructors marked noreturn.  WIP.

llvm-svn: 124238
2011-01-25 22:50:47 +00:00
Douglas Gregor 407371a1e4 Speculatively implement a tweak to the C++0x overload resolution rules
for reference binding (C++ [over.rank.ics]p3b1sb4), so that we prefer
the binding of an lvalue reference to a function lvalue over the
binding of an rvalue reference. This change resolves the ambiguity
with std::forward and lvalue references to function types in a way
that seems consistent with the original rvalue references proposal.

My proposed wording for this change is shown in
isBetterReferenceBindingKind(); we'll try to get this change adopted
in the C++0x working paper as well.

llvm-svn: 124236
2011-01-25 22:19:32 +00:00
Ted Kremenek 7e1ec9ccd8 Unbreak CMake build.
llvm-svn: 124235
2011-01-25 22:10:37 +00:00
Ted Kremenek fedad3c668 Don't try and symbolicate unions; we don't reason
about them yet.  Fixes crash reported in PR 9049.

llvm-svn: 124228
2011-01-25 21:08:47 +00:00
Nico Weber 2992efa403 Add -add-plugin flag, which runs plugins in addition to codegen.
llvm-svn: 124227
2011-01-25 20:34:14 +00:00
Jeffrey Yasskin 08a4f8f197 Add an attribute to forbid temporary instances of a type. This allows class
authors to write 

  class __attribute__((forbid_temporaries)) Name { ... };

when they want to force users to name all variables of the type. This protects
people from doing things like creating a scoped_lock that only lives for a
single statement instead of an entire scope.

The warning produced by this attribute can be disabled by
-Wno-forbid-temporaries.

llvm-svn: 124217
2011-01-25 20:08:12 +00:00
Douglas Gregor 1c5a53e200 Fix the ranking of reference bindings during overload resolution
(C++0x [over.ics.rank]p3) when one binding is an lvalue reference and
the other is an rvalue reference that binds to an rvalue. In
particular, we were using the predict "is an rvalue reference" rather
than "is an rvalue reference that binds to an rvalue", which was
incorrect in the one case where an rvalue reference can bind to an
lvalue: function references.

This particular issue cropped up with std::forward, where Clang was
picking an std::forward overload while forwarding an (lvalue)
reference to a function. However (and unfortunately!), the right
answer for this code is that the call to std::forward is
ambiguous. Clang now gets that right, but we need to revisit the
std::forward implementation in libc++.

llvm-svn: 124216
2011-01-25 19:39:31 +00:00
Ted Kremenek ade45d9703 Recycle memory for GRStates that are never referenced
by ExplodedNodes.  This leads to about a 4-8%
reduction in memory footprint when analyzing
functions in sqlite3.

llvm-svn: 124214
2011-01-25 19:13:54 +00:00
Ted Kremenek bcf848f70a Teach -Wuninitialized-experimental to also warn
about uninitialized variables captured by blocks.

llvm-svn: 124213
2011-01-25 19:13:48 +00:00
Ted Kremenek 7fd987de23 Tweak wording of static analyzer diagnostic
for a block capturing the value of an uninitialized
variable.

llvm-svn: 124212
2011-01-25 19:13:42 +00:00
Douglas Gregor 2d525f08c2 Teach TemplateSpecializationTypeLoc::initializeArgLocs() to actually
generate meaningful [*] template argument location information.

[*] Well, as meaningful as possible, given that this entire code path
is a hack for when we've lost type-source information.

llvm-svn: 124211
2011-01-25 19:13:18 +00:00
Rafael Espindola 05842dabb8 Move unnamed_addr after the function arguments on Sabre's request.
llvm-svn: 124210
2011-01-25 19:10:24 +00:00
Douglas Gregor d0d7bf32e3 Add test for PR8629
llvm-svn: 124204
2011-01-25 18:11:52 +00:00
Anders Carlsson e771e76326 Don't insert class templates into the DynamicClasses vector.
llvm-svn: 124201
2011-01-25 18:08:22 +00:00
Douglas Gregor a518d5b3ac Be a bit more defensive about setting the temporary base location
during template instantiation. This code needs to eventually die, but
this little tweak fixes PR8629, where bad location information slipped
through to the location of a class template instantiation.

llvm-svn: 124199
2011-01-25 17:51:48 +00:00
Douglas Gregor 85f240c788 Implement the rvalue-reference deduction transformation (from T&& ->
T) when taking the address of an overloaded function or matching a
specialization to a template (C++0x [temp.deduct.type]p10). Fixes
PR9044.

llvm-svn: 124197
2011-01-25 17:19:08 +00:00
Douglas Gregor ba278e2e7d When performing a glvalue-to-xvalue static_cast that involves a
derived-to-base conversion, set the cast kind and base path
appropriately.

llvm-svn: 124189
2011-01-25 16:13:26 +00:00
John McCall 46669c0996 Document the ns_returns_retained, ns_consumed, etc. attributes.
llvm-svn: 124176
2011-01-25 04:26:21 +00:00
John McCall 4bb483629f Change the wording of the bad-decl-for-attribute warning and error
to make it clear that we're talking about the declarations and not the types.

llvm-svn: 124175
2011-01-25 03:51:08 +00:00