Commit Graph

28254 Commits

Author SHA1 Message Date
Fariborz Jahanian a533af7d98 Restore a test which I accientally overwrote in my last
patch.

llvm-svn: 124911
2011-02-04 23:30:23 +00:00
Fariborz Jahanian c9b7c209bb -Wselector should warn on implemented selectors only
when selector metadata is generated, which is triggered 
by at least on class implementation. This is to match gcc's
behavior. // rdar://8851684.

llvm-svn: 124909
2011-02-04 23:19:27 +00:00
John McCall 490112f7bf Assert during instantiation of blocks that we've captured everything that
we captured in the dependent case.

llvm-svn: 124887
2011-02-04 18:33:18 +00:00
Bob Wilson d1447c45fa Add better support for ARM EABI triples.
Patch by Renato Golin!

llvm-svn: 124878
2011-02-04 17:59:28 +00:00
Daniel Dunbar 80f787c1c1 Driver: Fix spurious warning (from -cc1) about unused -fapple-kext on C inputs.
llvm-svn: 124875
2011-02-04 17:24:47 +00:00
Daniel Dunbar 74c9ea6343 build: Prevent duplicate inclusion of Makefile.rules, which causes make to warn
like crazy.
 - How no one else is bothered by this I can't understand!

llvm-svn: 124873
2011-02-04 17:12:27 +00:00
Douglas Gregor a522693f66 Improve our handling of the current instantiation for qualified
id-expression, e.g., 

  CurrentClass<T>::member

Previously, if CurrentClass<T> was dependent and not complete, we
would treat it as a dependent-scoped declaration reference expression,
even if CurrentClass<T> referred to the current instantiation.

Fixes PR8966 and improves type checking of templates.

llvm-svn: 124867
2011-02-04 13:35:07 +00:00
Douglas Gregor 789adec6bd Before checking bitfield initialization, make sure that neither the
bit-field width nor the initializer value are type- or
value-dependent. Fixes PR8712.

llvm-svn: 124866
2011-02-04 13:09:01 +00:00
Douglas Gregor 125fa40c34 When calling a bound pointer to member function, check the
cv-qualifiers on the object against the cv-qualifiers on the member
function. Fixes PR8315.

llvm-svn: 124865
2011-02-04 12:57:49 +00:00
Douglas Gregor 4d5c297607 Tweak my fix for PR8748, and update the incorrect PR number in the test case.
llvm-svn: 124863
2011-02-04 12:22:53 +00:00
Douglas Gregor 87866ceda7 Implement proper (de-)serialization for explicit template argument
lists with zero template arguments. Fixes some seriously scary
crashers in C++ PCH.

llvm-svn: 124862
2011-02-04 12:01:24 +00:00
Douglas Gregor 5d8b8babd5 Fix test for previous commit
llvm-svn: 124861
2011-02-04 11:59:47 +00:00
Douglas Gregor 0fcaac9ef3 Fix a crash-on-invalid where we were trying to parse C++ constructs in
C, then hitting an assertion because C code shouldn't try to parse
optional nested-name-specifiers. Fixes PR9137.

llvm-svn: 124860
2011-02-04 11:57:16 +00:00
Ted Kremenek 05edf944c0 USRs for Objective-C methods use the USR of the @interface as their base, not the USR of the class category or extension.
llvm-svn: 124859
2011-02-04 07:13:40 +00:00
Ted Kremenek d68ec818c3 Downgrade error about attribute 'iboutlet' and 'ibaction' being applied to anything but a instance method to a warning.
llvm-svn: 124858
2011-02-04 06:54:16 +00:00
Douglas Gregor a99fb4c77d Tighten up the semantics of default template arguments, per C++0x
[temp.param]p9 and C++ DR226. Fixes PR8747.

llvm-svn: 124856
2011-02-04 04:20:44 +00:00
Douglas Gregor 8b481d8ac2 When a function template's template parameter has a default argument,
it's okay for the following template parameters to not have default
arguments (since those template parameters can still be
deduced). Also, downgrade the error about default template arguments
in function templates to an extension warning, since this is a
harmless C++0x extension.

llvm-svn: 124855
2011-02-04 03:57:22 +00:00
Daniel Dunbar 7aa71f9423 build: Add support for DISABLE_DEFAULT_STRICT_ALIASING, which does what one
might expect.

llvm-svn: 124848
2011-02-04 02:20:39 +00:00
Daniel Dunbar 5ad0d7edfa Fix 80-col violins.
llvm-svn: 124847
2011-02-04 02:20:34 +00:00
Fariborz Jahanian e28342c401 minor refactoring of -fapple-kext stuff.
llvm-svn: 124837
2011-02-04 00:32:39 +00:00
Fariborz Jahanian 7cadb2f65b What was I thinking?
llvm-svn: 124835
2011-02-04 00:08:13 +00:00
Fariborz Jahanian f7f04458b3 -fapple-kext cannot have 'weak' visibility in this
abi.

llvm-svn: 124834
2011-02-04 00:01:24 +00:00
Douglas Gregor 149239651d If any Fix-Its attached to a diagnostic have invalid source locations
or source locations that refer into a macro instantiation, delete all
of the Fix-Its on that diagnostic.

llvm-svn: 124833
2011-02-03 23:41:12 +00:00
Oscar Fuentes edeaf16f2c Moved here from LLVM Clang's configuration options and related macros.
llvm-svn: 124825
2011-02-03 22:48:20 +00:00
Argyrios Kyrtzidis 58f8b590e1 [analyzer] Fix a crash until we can handle temporary struct objects properly.
llvm-svn: 124822
2011-02-03 22:01:32 +00:00
Douglas Gregor 7c60768590 Add __has_feature() for each of the type traits
llvm-svn: 124820
2011-02-03 21:57:35 +00:00
Oscar Fuentes ce8661608b Optionally, Clang now builds using LLVM as an external library.
The user sets the variable CLANG_PATH_TO_LLVM_BUILD pointing to a LLVM
build directory or to a directory where LLVM was installed. When using
a non-installed LLVM build, it is necessary to set
CLANG_PATH_TO_LLVM_SOURCE as well.

llvm-svn: 124817
2011-02-03 20:57:53 +00:00
Fariborz Jahanian 7f6f81ba9b Clean up of -fapple-kext abi code. No change otherwise.
llvm-svn: 124807
2011-02-03 19:27:17 +00:00
Argyrios Kyrtzidis 7272d9cf36 Implement -Woverloaded-virtual.
The difference with gcc is that it warns if you overload virtual methods only if
the method doesn't also override any method. This is to cut down on the number of warnings
and make it more useful like reported here: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20423.
If we want to warn that not all overloads are overriden we can have an additional
warning like -Wpartial-override.

-Woverloaded-virtual, unlike gcc, is added to -Wmost. Addresses rdar://8757630.

llvm-svn: 124805
2011-02-03 18:01:15 +00:00
Douglas Gregor e664276bcf Teach SourceManager::getLocation() how to cope with a source file
whose inode has changed since the file was first created and that is
being seen through a different path name (e.g., due to symlinks or
relative path elements), such that its FileEntry pointer doesn't match
a known FileEntry pointer. Since this requires a system call (to
stat()), we only perform this deeper checking if we can't find the
file by comparing FileEntry pointers.

Also, add a micro-optimization where we don't bother to compute line
numbers when given the location (1, 1). This improves the
efficiency of clang_getLocationForOffset().
 

llvm-svn: 124800
2011-02-03 17:17:35 +00:00
Axel Naumann 6cff969eec Remove unnecessary RUN: directive.
llvm-svn: 124795
2011-02-03 14:05:55 +00:00
John McCall 2bd04c3114 More tweaks to the compatibility page.
llvm-svn: 124792
2011-02-03 11:29:18 +00:00
John McCall 93adb039b5 More minor documentation tweaks.
llvm-svn: 124791
2011-02-03 11:05:04 +00:00
John McCall 37d30c93ca Rework the __block jump-checking section, including a justification of
why this bug can go uncaught.

llvm-svn: 124790
2011-02-03 10:56:31 +00:00
John McCall 55199a63df Rework and embellish the C99 inline compatibility section.
llvm-svn: 124789
2011-02-03 10:16:40 +00:00
NAKAMURA Takumi 22ec6604f6 CMake: Fix test. CMake has not built unittests yet.
llvm-svn: 124787
2011-02-03 09:01:12 +00:00
John McCall 5f2d556a92 Capture a few implicit references to 'self'.
llvm-svn: 124786
2011-02-03 09:00:02 +00:00
John McCall f3a8860ee1 More capturing of 'this': implicit member expressions. Getting that
right for anonymous struct/union members led to me discovering some
seemingly broken code in that area of Sema, which I fixed, partly by  
changing the representation of member pointer constants so that    
IndirectFieldDecls aren't expanded.  This led to assorted cleanups with   
member pointers in CodeGen, and while I was doing that I saw some random
other things to clean up.                   

llvm-svn: 124785
2011-02-03 08:15:49 +00:00
Ted Kremenek 436cc8ffe7 Reenable -Wuninitialized warning for captured block variables.
llvm-svn: 124782
2011-02-03 06:51:50 +00:00
Rafael Espindola 2915731b6e Add test from PR9130.
llvm-svn: 124781
2011-02-03 06:36:50 +00:00
Rafael Espindola af5b92e8f7 Revert 124768.
This reopens PR99114, but that one at least can be avoided with an #include.
PR9130 cannot.

llvm-svn: 124780
2011-02-03 06:30:58 +00:00
Jeffrey Yasskin c7da993dee Add gTest unittests to clang, and write the first one.
This is the Makefile version only; the cmake implementation is coming soon.

llvm-svn: 124777
2011-02-03 04:51:52 +00:00
Rafael Espindola 5b55454065 Revert 124754 and 124760 as they made clang unusable in the presence of symbolic
links.

llvm-svn: 124776
2011-02-03 04:35:45 +00:00
Daniel Dunbar 9aa47fcb55 Frontend: Switch -header-include-file output to use unbuffered raw_ostreams with
the atomic writes option, since the intent is that this option be set for an
entire build, which may have any number of compiler instances writing to the
same output file.

llvm-svn: 124772
2011-02-03 03:45:00 +00:00
Anders Carlsson bac84bef65 Don't try to mark virtual members referenced for classes where the key function
is not defined in the current translation unit. Doing so lead to compile errors
such as PR9114.

Instead, when CodeGen is building the vtable, don't try to emit a definition
for functions that aren't marked used in the current translation unit.
Fixes PR9114.

llvm-svn: 124768
2011-02-03 02:08:44 +00:00
Francois Pichet 50a2e0e894 Fix Microsoft bit field problem. This resolves the Index\complete-exprs.c regression on Win32.
llvm-svn: 124767
2011-02-03 02:02:42 +00:00
Douglas Gregor 8c0577faf3 Improve the performance of filename canonicalization by avoiding
redundant searches in the string. No functionality change.

llvm-svn: 124760
2011-02-03 00:18:12 +00:00
Ted Kremenek b3dbe28e31 Based on user feedback, swap -Wuninitialized diagnostics to have the warning refer to the bad use, and the note to the variable declaration.
llvm-svn: 124758
2011-02-02 23:35:53 +00:00
Fariborz Jahanian 0c12ed1429 -fapple-kext, elimination of all direct calls to virtual dtors.
llvm-svn: 124757
2011-02-02 23:12:46 +00:00
Devang Patel 84ffdd9ba3 Emit debug info for template value parameters.
llvm-svn: 124756
2011-02-02 22:36:18 +00:00
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