Commit Graph

16552 Commits

Author SHA1 Message Date
Douglas Gregor 06db9f50a2 Diagnose the declaration of explicit specializations after an implicit
instantiation has already been required. To do so, keep track of the
point of instantiation for anything that can be instantiated.

llvm-svn: 83890
2009-10-12 20:18:28 +00:00
Fariborz Jahanian e7196431c1 Handle built-in unary operators when reporting ambiguities.
wip - To prune excessive reporting.

llvm-svn: 83889
2009-10-12 20:11:40 +00:00
Anders Carlsson bcee4a7b6b Fix test.
llvm-svn: 83888
2009-10-12 20:06:34 +00:00
Anders Carlsson a1b54fdbe1 Even more devirtualization cleverness.
llvm-svn: 83886
2009-10-12 19:59:15 +00:00
Ted Kremenek a81b3256a4 Allow BumpVectorContext to conditionally own the underlying BumpPtrAllocator.
llvm-svn: 83884
2009-10-12 19:54:17 +00:00
Anders Carlsson 2a01709204 More devirtualization improvements.
llvm-svn: 83883
2009-10-12 19:51:33 +00:00
Anders Carlsson b61301f353 Devirtualize calls on temporaries. A().f() for example.
llvm-svn: 83882
2009-10-12 19:45:47 +00:00
Anders Carlsson d7432dfb0a Factor out devirtualization checking into a separate function and make it handle references correctly.
llvm-svn: 83880
2009-10-12 19:41:04 +00:00
Fariborz Jahanian 65694b413d Use CanQualType (instead of QualType) to store collection of visible
canonical conversion types.

llvm-svn: 83869
2009-10-12 18:36:50 +00:00
Fariborz Jahanian 574de2c5a4 If built-in operators could not be selected because of ambiguity in
user-defined type conversions, issue list of ambiguites in addition 
to the diagnostic. So, clang now issues the following:

b.cpp:19:19: error: left hand operand to ->* must be a pointer to class compatible with the right hand operand, but is 'struct C1'
        int i = c1->*pmf;
                ~~^
b.cpp:19:19: note: because of ambiguity in conversion of 'struct C1' to 'struct E *'
b.cpp:5:5: note: candidate function
    operator E*();
    ^
b.cpp:11:5: note: candidate function
    operator E*();
    ^

llvm-svn: 83862
2009-10-12 17:51:19 +00:00
Axel Naumann a7e200e6f7 Don't install Makefiles nor tablegen input in include/.
Fix exclusion of .tmp, which in turn enables installation of $(PROJ_OBJ_ROOT)/tools/clang/include/*.inc.

llvm-svn: 83855
2009-10-12 16:42:18 +00:00
Edward O'Callaghan e4ab8eacf7 Typo in AddGnuCPlusPlusIncludePaths.
llvm-svn: 83847
2009-10-12 12:02:47 +00:00
Anders Carlsson b5296558f1 If the base type of a member call is a record type we don't need to emit a virtual call.
llvm-svn: 83816
2009-10-11 23:55:52 +00:00
Benjamin Kramer bb0a07bf92 Remove dead variable.
llvm-svn: 83808
2009-10-11 22:57:54 +00:00
Benjamin Kramer 2e8301dd62 Add CGVtable.cpp to CMakeLists.
llvm-svn: 83800
2009-10-11 22:22:38 +00:00
Anders Carlsson 2bb27f53e0 Move the vtable builder to CGVtable.cpp, general cleanup.
llvm-svn: 83798
2009-10-11 22:13:54 +00:00
Anders Carlsson 2295f31810 Change mangleCXXVtable and mangleCXXRtti to take CXXRecordDecls instead of QualTypes.
llvm-svn: 83793
2009-10-11 21:24:51 +00:00
Benjamin Kramer 3ce29858e9 CMake mingw build fixes.
- llvm's libs must be linked after clang's
- libLLVMSystem depends on psapi on win32 (get_system_libs has it)
- CIndex builds successfully on mingw now

llvm-svn: 83773
2009-10-11 12:22:00 +00:00
Sebastian Redl 8046049942 This ought to complete exception spec support. Man, am I glad.
llvm-svn: 83767
2009-10-11 09:14:57 +00:00
Sebastian Redl 6e4c871855 Types appearing more than once in a spec shouldn't matter.
llvm-svn: 83766
2009-10-11 09:11:23 +00:00
Sebastian Redl 4915e63d3b Test exception spec compatibility on return type and parameters.
Along the way, use RequireCompleteType when testing exception spec types.
Separate all the ugly spec stuff into its own file.

llvm-svn: 83764
2009-10-11 09:03:14 +00:00
Zhongxing Xu b8edf2a4dd Introduces a new BindingVal which combines direct and
default binding for regions. This allows us to simply a lot of code. A
further simplification could be done is that many methods of
regionstore can only work on Store instead of GRState. 

llvm-svn: 83762
2009-10-11 08:08:02 +00:00
Anders Carlsson 6ce51fdf43 Move our (non-existing) RTTI emission code into CGRtti.cpp. No functionality change.
llvm-svn: 83732
2009-10-10 20:49:04 +00:00
Fariborz Jahanian 07ca72725a Generate weak read barriers when reading a weak __block
variable inside the block.

llvm-svn: 83729
2009-10-10 20:07:56 +00:00
Sebastian Redl 5d43164bc2 Implement the core checking for compatible exception specifications in assignment and initialization.
The exception specification of the assignee must be the same or a subset of the target. In addition, exception specifications on arguments and return types must be equivalent, but this is not implemented yet.
This currently produces two diagnostics for every invalid assignment/initialization, due to the diagnostic produced outside PerformImplicitConversion, e.g. in CheckSingleInitializer. I don't know how to suppress this; in any case I think it is the wrong place for a diagnostic, since there are other diagnostics produced inside the function. So I'm leaving it as it is for the moment.

llvm-svn: 83710
2009-10-10 12:04:10 +00:00
John McCall 6538c93050 Qualified lookup through using declarations. Diagnose a new type of ambiguity.
Split the various ambiguous result enumerators into their own enum.  Tests
for most of C++ [namespace.qual].

llvm-svn: 83700
2009-10-10 05:48:19 +00:00
Anders Carlsson c4859baea4 Check that the return type is complete when calling a member function.
llvm-svn: 83694
2009-10-10 00:06:20 +00:00
Anders Carlsson 1040f2e9db Add another test.
llvm-svn: 83693
2009-10-09 23:58:25 +00:00
Anders Carlsson 7f84ed9287 Add CheckCallReturnType and start using it for regular call expressions. This will improve error messages. For
struct B;

B f();

void g() {
f();
}

We now get

t.cpp:6:3: error: calling 'f' with incomplete return type 'struct B'
  f();
  ^~~
t.cpp:3:3: note: 'f' declared here
B f();
  ^
t.cpp:1:8: note: forward declaration of 'struct B'
struct B;
       ^

llvm-svn: 83692
2009-10-09 23:51:55 +00:00
Douglas Gregor b385b7c62e Dead Code Elimination
llvm-svn: 83686
2009-10-09 22:56:12 +00:00
Douglas Gregor 7d195b93d8 Add some FIXMEs
llvm-svn: 83685
2009-10-09 22:54:25 +00:00
Douglas Gregor 8413751fab Experimental, ultra-hacking Emacs minor mode for Clang-based code completion.
llvm-svn: 83681
2009-10-09 22:17:40 +00:00
Douglas Gregor 58acf32af2 Minor tweaks for code-completion:
- Filter out unnamed declarations
  - Filter out declarations whose names are reserved for the
  implementation (e.g., __bar, _Foo) 
  - Place OVERLOAD: or COMPLETION: at the beginning of each
  code-completion result, so we can easily separate them from other
  compilation results.

llvm-svn: 83680
2009-10-09 22:16:47 +00:00
Anders Carlsson 82a108b4ed Update Xcode project.
llvm-svn: 83679
2009-10-09 22:16:24 +00:00
Devang Patel 3028a43f57 Revert 83567.
llvm-svn: 83676
2009-10-09 22:06:15 +00:00
John McCall 9f3059a192 Refactor the LookupResult API to simplify most common operations. Require users to
pass a LookupResult reference to lookup routines.  Call out uses which assume a single
result.

llvm-svn: 83674
2009-10-09 21:13:30 +00:00
Douglas Gregor 7f34baeb4b When declaring a friend class template, we may end up finding an
injected-class-name (e.g., when we're referring to other
specializations of the current class template). Make sure that we see
the template rather than the injected-class-name. Fixes PR4768.

llvm-svn: 83672
2009-10-09 21:11:42 +00:00
Mike Stump 1ba6edb030 Efficiency refinements.
llvm-svn: 83666
2009-10-09 20:16:49 +00:00
Axel Naumann c5b2d917de Do not install CMakeLists.txt (nor any other txt files) into include/ subdirectories
llvm-svn: 83665
2009-10-09 20:03:20 +00:00
Mike Stump e752333c66 Push all the way out to 80.
llvm-svn: 83664
2009-10-09 19:42:16 +00:00
Axel Naumann 04ca7e181f Passing const Triple& is sufficient for AddDefaultSystemIncludePaths()
llvm-svn: 83663
2009-10-09 19:37:12 +00:00
Mike Stump fc8ff639cb Allow customization for the producer information in the debug output.
llvm-svn: 83659
2009-10-09 18:38:12 +00:00
Mike Stump 727170d2d8 Allow customization for the version line.
llvm-svn: 83652
2009-10-09 17:31:54 +00:00
Fariborz Jahanian 0fe5e0308e Produce good looking diagnostics on ambiguous built-in operators.
Now we produce things like:
bug1.cpp:21:11: error: use of overloaded operator '->*' is ambiguous
        int i = c->*pmf;        // expected-error {{use of overloaded operator '->*' is ambiguous}} \
                ~^  ~~~
bug1.cpp:21:11: note: built-in candidate operator ->* ('struct A volatile *', 'int const struct A::*')
bug1.cpp:21:11: note: built-in candidate operator ->* ('struct A volatile *', 'int restrict struct A::*')
...

Still need to look at an issue (indicated as FIXME in the test case).

llvm-svn: 83650
2009-10-09 17:09:58 +00:00
Fariborz Jahanian 4dc1246d87 Use the new API for applying the qualifiers on built-in '->*'
operator's types.

llvm-svn: 83648
2009-10-09 16:34:40 +00:00
Zhongxing Xu 9b6a9be301 Remove unused code.
llvm-svn: 83612
2009-10-09 02:24:00 +00:00
Zhongxing Xu e77cd12f10 Make the behavior explicit by not using the method call.
llvm-svn: 83611
2009-10-09 02:18:31 +00:00
Zhongxing Xu fd15882213 Remove unused code.
llvm-svn: 83610
2009-10-09 02:12:00 +00:00
Mike Stump 0d479e6653 Avoid warning.
llvm-svn: 83609
2009-10-09 01:25:47 +00:00
Fariborz Jahanian 29f9d39568 Improve on reporting ambiguity involving built-in candidates.
I still don't like it but it is improvement over what we had.

llvm-svn: 83603
2009-10-09 00:13:15 +00:00
Mike Stump acdc3158b3 Add a refactor pointer...
llvm-svn: 83599
2009-10-08 23:57:53 +00:00
Steve Naroff 3b08630b06 - Fixup SortCodeCompleteResult() to properly sort keywords on Mac OS (compare was system dependent). Worked on Linux, failed on Mac OS (which caused the recently added testcase to fail on Linux).
- Sort results in testcase.

llvm-svn: 83597
2009-10-08 23:45:10 +00:00
Mike Stump 904ad90bc8 Set up include paths for VC++ and Cygwin headers, along with the
existing MinGW headers, plus the newer 4.4.0 version.  Patch by John
Thompson.

llvm-svn: 83594
2009-10-08 23:29:47 +00:00
Mike Stump f8c1f0d1f0 Speed up testing by avoiding stdio.h, also helps testing on windows.
Patch by John Thompson.

llvm-svn: 83593
2009-10-08 23:05:06 +00:00
Mike Stump af9afe9bc9 "Someone pointed out that in my previous Targets.cpp patch I didn't
handle the long size difference for one of the Windows targets."  Patch
by John Thompson.

llvm-svn: 83592
2009-10-08 23:00:00 +00:00
Mike Stump c99c022841 This fixes support for complex literals, reworked to avoid a goto, and
to add a flag noting the presence of a Microsoft extension suffix (i8,
i16, i32, i64).  Patch by John Thompson.

llvm-svn: 83591
2009-10-08 22:55:36 +00:00
Douglas Gregor 1245e6ff69 Tests for C++ [expr], from James Porter!
llvm-svn: 83588
2009-10-08 22:38:14 +00:00
Mike Stump e07e33a196 Tolerate .exe on executables. Patch by John Thompson. Changed * to .* by me.
llvm-svn: 83586
2009-10-08 22:30:02 +00:00
Mike Stump 8409f9102b Tolerate .exe on executables. Patch by John Thompson.
llvm-svn: 83584
2009-10-08 22:25:29 +00:00
Fariborz Jahanian 8ae5b0a18b Fix up error reporting when object cannot be constructed
because of missing default constructor of a member.
Fixes pr5154.

llvm-svn: 83583
2009-10-08 22:15:49 +00:00
Douglas Gregor 01249503fe Installation of Clang libraries and headers, from Axel Naumann!
llvm-svn: 83582
2009-10-08 22:15:31 +00:00
Mike Stump 03686660b1 In VC++, the *printf functions put an extra "0" in the exponent part
of a floating point number.  This add regular expressions to account
for this.  Patch by John Thompson.

llvm-svn: 83581
2009-10-08 21:57:41 +00:00
Steve Naroff 936354c62a Add code completion support for ObjC property declarations/attributes.
llvm-svn: 83579
2009-10-08 21:55:05 +00:00
Mike Stump c2eeac617d Convert some tests to FileCheck to be more portable. Patch by John Thompson.
llvm-svn: 83578
2009-10-08 21:52:07 +00:00
Douglas Gregor 3beaf9bbcd Implement support for -Wunused-variable, from Oscar Bonilla!
llvm-svn: 83577
2009-10-08 21:35:42 +00:00
Douglas Gregor 18289eeb1d Fix an assertion in the XML output, from Olaf Krzikalla!
llvm-svn: 83576
2009-10-08 21:29:50 +00:00
Devang Patel abf71fa9fc Record location info before emiting alloca for arguments. This allows arguments to have proper location info.
llvm-svn: 83567
2009-10-08 18:53:37 +00:00
Fariborz Jahanian 03b4f666ed Implement [expr.mptr.oper]p6 for '->*' operator.
llvm-svn: 83562
2009-10-08 18:00:39 +00:00
Ted Kremenek 490b8c0f5b Remove use of std::ofstream in HTMLDiagnostics.cpp.
llvm-svn: 83560
2009-10-08 17:44:41 +00:00
Anders Carlsson a18ed9b113 If a global initializer has a non-trivial constructor or destructor, we never want to defer generation of it, even if it is declared static.
With this change we're finally able to compile and run the (infamous)

#include <string>
#include <iostream>

int main(int argc, char **argv) {
  std::cout << "Hello, World" << std::endl;
}

$ clang hello.cpp -lstdc++ -o hello
$ ./hello 
Hello, World

llvm-svn: 83559
2009-10-08 17:28:59 +00:00
Anders Carlsson 9776bd61bc Port test over to FileCheck.
llvm-svn: 83558
2009-10-08 17:22:47 +00:00
Anders Carlsson 3482b819db Mangle std::basic_ostream<char, std::char_traits<char>> as So.
llvm-svn: 83557
2009-10-08 17:20:26 +00:00
Douglas Gregor eeffde3a1d Add more testing for the properties of explicit specialization.
Also, eliminate a redundant diagnostic by marking a variable declared
with incomplete type as an invalid declaration.

llvm-svn: 83553
2009-10-08 16:41:22 +00:00
Fariborz Jahanian 4ff5f05782 Refactoring to further simplify collection of visible conversion
functions.

llvm-svn: 83552
2009-10-08 16:33:37 +00:00
Douglas Gregor 19c52729ed Don't complain about out-of-line explicit specializations of member
function and member function templates that are not definitions. Add
more tests to ensure that explicit specializations of member function
templates prevent instantiation.

llvm-svn: 83550
2009-10-08 15:54:21 +00:00
Douglas Gregor 1e9b25caf4 More testing for explicit specializations of member class templates
llvm-svn: 83548
2009-10-08 15:27:05 +00:00
Douglas Gregor bbe8f46621 Improve checking for specializations of member classes of class
templates, and keep track of how those member classes were
instantiated or specialized. 

Make sure that we don't try to instantiate an explicitly-specialized
member class of a class template, when that explicit specialization
was a declaration rather than a definition.

llvm-svn: 83547
2009-10-08 15:14:33 +00:00
Douglas Gregor 86d142a801 For instantiations of static data members of class templates, keep
track of the kind of specialization or instantiation. Also, check the
scope of the specialization and ensure that a specialization
declaration without an initializer is not a definition.

llvm-svn: 83533
2009-10-08 07:24:58 +00:00
Douglas Gregor c093c1de2b Make sure to set the template specialization kind of an explicit
template instantiation of a member function of a class template.
FIXME -= 2;

llvm-svn: 83520
2009-10-08 01:19:17 +00:00
Douglas Gregor f43472bd84 Compress storage for MemberSpecializationInfo into a single
pointer. Yay, PointerIntPair.

llvm-svn: 83512
2009-10-08 00:19:07 +00:00
Douglas Gregor e3dfd4826b Only perform an implicit instantiation of a function if its template
specialization kind is TSK_ImplicitInstantiation. Previously, we would
end up implicitly instantiating functions that had explicit
specialization declarations or explicit instantiation declarations
(with no corresponding definitions).

llvm-svn: 83511
2009-10-08 00:14:38 +00:00
Douglas Gregor d801b06232 Keep track of whether a member function instantiated from a member
function of a class template was implicitly instantiated, explicitly
instantiated (declaration or definition), or explicitly
specialized. The same MemberSpecializationInfo structure will be used
for static data members and member classes as well.

llvm-svn: 83509
2009-10-07 23:56:10 +00:00
John McCall c3987485f2 Refactoring around friend class templates. Better error message for friend enums.
Don't create a new declaration for friend classes if a declaration already exists.

llvm-svn: 83505
2009-10-07 23:34:25 +00:00
Douglas Gregor 5c0405d484 Type checking for specializations of member functions of class
templates. Previously, these weren't handled as specializations at
all. The AST for representing these as specializations is still a work
in progress.

llvm-svn: 83498
2009-10-07 22:35:40 +00:00
Anders Carlsson 6c966c458a Handle MemberExprs in ResolveAddressOfOverloadedFunction.
llvm-svn: 83495
2009-10-07 22:26:29 +00:00
John McCall fe8dc76f80 Dead code elimination.
llvm-svn: 83492
2009-10-07 22:04:40 +00:00
Fariborz Jahanian 3ee21f1b91 Fixes problem in finding visible convertion functions of a class
where matching conversion types in base classes were still visible.
Plus refactoring and cleanup.
Added a test case.

llvm-svn: 83485
2009-10-07 20:43:36 +00:00
Douglas Gregor 40fb74484e Diagnose explicit instantiations and specializations that occur in class scope
llvm-svn: 83473
2009-10-07 17:30:37 +00:00
Fariborz Jahanian ae01f78a31 When building candidate set for built-ins; when looking for
convesion functions, look in base classes to.
(Removes a FIXME).

llvm-svn: 83472
2009-10-07 17:26:09 +00:00
Douglas Gregor e4b05168f6 Class template partial specializations can be declared anywhere that
its definition may be defined, including in a class.

Also, put in an assertion when trying to instantiate a class template
partial specialization of a member template, which is not yet
implemented.

llvm-svn: 83469
2009-10-07 17:21:34 +00:00
Fariborz Jahanian 12df37c5d7 Removed couple of unnecessary canonicalization
per Doug's obsevation.

llvm-svn: 83464
2009-10-07 16:56:50 +00:00
Ted Kremenek 8c6066d021 Add 'template' keyword to disambiguate the use of a member template within a templated class. Hopefully this will please the buildbots.
llvm-svn: 83452
2009-10-07 06:20:14 +00:00
Ted Kremenek 7881ac97a5 Revert r83443.
llvm-svn: 83451
2009-10-07 03:21:11 +00:00
Anders Carlsson 1e39bd944b Mangle anonymous structs/unions correctly. Fixes PR5139.
llvm-svn: 83448
2009-10-07 01:45:02 +00:00
Mike Stump db9fca7735 Fixup pathnames.
llvm-svn: 83443
2009-10-07 01:11:54 +00:00
Anders Carlsson ff971e8bf4 Add a MangleContext and pass it to all mangle functions. It will be used for keeping state, such as identifiers assigned to anonymous structs as well as scope encoding.
llvm-svn: 83442
2009-10-07 01:06:45 +00:00
Douglas Gregor fbe6d079e2 More testing of explicit specializations
llvm-svn: 83440
2009-10-07 00:45:53 +00:00
Ted Kremenek c3661decc3 Change ExplodedNode to have its NodeGroups all BumpPtrAllocated, avoiding malloc() traffic when adding successors/predecessors to a node. This was done by introducing BumpVector, which is essentially SmallVector with all memory being BumpPtrAllocated (this can certainly be cleaned up or moved into llvm/ADT).
This change yields a 1.8% speed increase when running the analyzer (with -analyzer-store=region) on a small benchmark file.

llvm-svn: 83439
2009-10-07 00:42:52 +00:00
Ted Kremenek 3ea4ab8e79 Force a specific target triple in c-index-api-test.m, making the behavior of the test not be dependent on the host.
llvm-svn: 83438
2009-10-07 00:39:48 +00:00
Douglas Gregor 548886518d Refactor checking of the scope of explicit template specialization
declarations and explicit template instantiations, improving
diagnostics and making the code usable for function template
specializations (as well as class template specializations and partial
specializations). 

llvm-svn: 83436
2009-10-07 00:13:32 +00:00