Commit Graph

17840 Commits

Author SHA1 Message Date
Daniel Dunbar 409e890f8d Add CompilerInstance::InitializeSourceManager.
llvm-svn: 88764
2009-11-14 07:53:04 +00:00
Eli Friedman a9ea959d04 PR5462: Don't run off the edge of the argument array for vararg handling
when there are more parameters in the prototype than arguments to the call.

llvm-svn: 88759
2009-11-14 04:43:10 +00:00
Daniel Dunbar 6c39d457fa Update FixIt tests to make it more obvious they use a separate mode.
llvm-svn: 88758
2009-11-14 04:39:42 +00:00
Daniel Dunbar 10563ea92e Turn -fixit it back into a mode, but make -fixit-at imply that mode this time
(instead of running it with arbitrary consumers).
 - Also, turn any -fixit-at lookup failure into an error.

llvm-svn: 88757
2009-11-14 04:39:29 +00:00
Eli Friedman b774685c08 Fix a couple of tests.
llvm-svn: 88756
2009-11-14 04:23:25 +00:00
Eli Friedman b572c92674 PR5483: Generate missing form of destructor when it is virtual. (Someone
more familiar with this stuff should double-check that there isn't some more
general rule; this is purely from inspecting g++ output.)

llvm-svn: 88755
2009-11-14 04:19:37 +00:00
Eli Friedman c9827d1ad3 Fix for PR5489: don't skip the complete type requrirement for variable
definitions just because the type happens to be an array type.

llvm-svn: 88752
2009-11-14 03:40:14 +00:00
Douglas Gregor bf3f322034 When type-checking a static cast (or the static_cast part of a C-style
cast) that is converting to a class type, enumerate its constructors
as in any other direct initialization. This ensures that we get the
proper conversion sequence.

llvm-svn: 88751
2009-11-14 03:27:21 +00:00
Daniel Dunbar 50ec0da0e1 Switch -verify implementation to use VerifyDiagnosticClient.
- Not tested, but -verify with multiple inputs should work now.

llvm-svn: 88750
2009-11-14 03:24:39 +00:00
Daniel Dunbar 9d5118a69c Fix broken tests, exposed by improved -verify.
llvm-svn: 88749
2009-11-14 03:24:04 +00:00
Daniel Dunbar 348185548e Add VerifyDiagnosticsClient, to replace old -verify.
- This reimplements -verify as just another DiagnosticClient, which buffers the diagnostics and checks them when the source file is complete. There are some hacks to make this work, but they are all internal, and this exposes a better external interface.

 - This also tweaks a few things:
   o Errors are now just regular diagnostics.
   o Frontend diagnostics are now caught (for example, errors in command line arguments), although there isn't yet a way to specify that they are expected. That would be nice though.

 - Not yet used.

llvm-svn: 88748
2009-11-14 03:23:19 +00:00
Anders Carlsson 654e5c7cf8 Diagnose ambiguity of operator delete and operator delete[]. Sebastian, please review.
llvm-svn: 88747
2009-11-14 03:17:38 +00:00
Daniel Dunbar e598a56d30 Pass Preprocessor through DiagnosticClient::BeginSourceFile.
llvm-svn: 88744
2009-11-14 02:48:04 +00:00
Daniel Dunbar 56d9c293db Add ASTConsumer to CompilerInstance.
llvm-svn: 88743
2009-11-14 02:47:17 +00:00
Fariborz Jahanian da2efb091d Generate the old API when sending message to super
in a category implementation (objc 32bit api related).

llvm-svn: 88741
2009-11-14 02:18:31 +00:00
Anders Carlsson 52ce3bbf57 Handle CXXDefaultArgExprs in EmitLValue. Fixes PR5484.
llvm-svn: 88735
2009-11-14 01:51:50 +00:00
Douglas Gregor ffe14e3712 If we attempt to add a constructor template specialization that looks
like a copy constructor to the overload set, just ignore it. This
ensures that we don't try to use such a constructor as a copy
constructor *without* triggering diagnostics at the point of
declaration.

Note that we *do* diagnose such copy constructors when explicitly
written by the user (e.g., as an explicit specialization).

llvm-svn: 88733
2009-11-14 01:20:54 +00:00
Daniel Dunbar bf410c6fc2 Add static version of Preprocessor::getSpelling.
llvm-svn: 88732
2009-11-14 01:20:48 +00:00
Daniel Dunbar e01dc86d2a Move CompilerInstance::set* methods out-of-line.
llvm-svn: 88731
2009-11-14 01:20:40 +00:00
Ted Kremenek 1a0dd2e30b Move definition of GRExprEngine::ProcessEndPath() out-of-line.
llvm-svn: 88729
2009-11-14 01:05:20 +00:00
Mike Stump 2ec5dd7160 Mangling support for typeinfo names.
llvm-svn: 88726
2009-11-14 00:14:13 +00:00
Douglas Gregor ff7028a55e Revert r88718, which does NOT solve the constructor-template-as-copy-constructor issue. Big thanks to John for finding this
llvm-svn: 88724
2009-11-13 23:59:09 +00:00
Mike Stump c5a332cefb Handle descructor printing better.
llvm-svn: 88723
2009-11-13 23:45:53 +00:00
Douglas Gregor 2bb756a3be Template argument deduction of a non-type template parameter from a
template argument.

llvm-svn: 88722
2009-11-13 23:45:44 +00:00
Douglas Gregor 5f235a21eb A constructor template cannot be instantiated to a copy
constructor. Make sure that such declarations can never be formed.

llvm-svn: 88718
2009-11-13 23:14:53 +00:00
Mike Stump 559387fe8b Also track address points for primaries bases.
llvm-svn: 88717
2009-11-13 23:13:20 +00:00
Fariborz Jahanian ebea005812 Code gen. For virtual destructor call on array objects
(still part of pr5472).

llvm-svn: 88712
2009-11-13 22:29:45 +00:00
Mike Stump 2fb78c0250 More VTT and constructor vtable testcases from recent work.
llvm-svn: 88710
2009-11-13 22:12:05 +00:00
Mike Stump 3693652378 Add more testcase for construction vtables and VTTs.
llvm-svn: 88702
2009-11-13 21:55:26 +00:00
Mike Stump 464de23b72 Add some more VTT testcases.
llvm-svn: 88699
2009-11-13 21:40:38 +00:00
Eli Friedman 6f04b1e605 Obvious fix for PR5474.
llvm-svn: 88696
2009-11-13 21:23:46 +00:00
Fariborz Jahanian f75c1f7a73 Fixes a code gen. bug for array delete operator call
int 32bit abi (pr5472 related).

-This line, and those below, will be ignored--

M    lib/CodeGen/CGCXXExpr.cpp

llvm-svn: 88695
2009-11-13 21:20:14 +00:00
Anders Carlsson bdd124036d Clear temporaries in more places.
llvm-svn: 88687
2009-11-13 20:11:49 +00:00
Ted Kremenek 9430bf20ff Remove test case's dependency on header file.
llvm-svn: 88685
2009-11-13 20:03:22 +00:00
Ted Kremenek e5e977013c Add two new test cases for the Malloc/Free checker. Both have to do with
storing malloc'ed memory to global storage.

llvm-svn: 88684
2009-11-13 20:00:28 +00:00
Ted Kremenek c2675568a1 Add test case that shows a leak we don't catch.
llvm-svn: 88683
2009-11-13 19:53:32 +00:00
Mike Stump e56213fc1e Add a testcase for the recent VTT work.
llvm-svn: 88681
2009-11-13 19:36:46 +00:00
Fariborz Jahanian 6814eaa2cc Code gen for arrady delete operator. Fixes pr5472.
llvm-svn: 88680
2009-11-13 19:27:47 +00:00
Anders Carlsson 1fe64cb059 Fix bug Doug noticed.
llvm-svn: 88679
2009-11-13 19:21:49 +00:00
Daniel Dunbar dd6e6918e6 Add test for expr.delete p5, with a FIXME.
llvm-svn: 88678
2009-11-13 19:13:56 +00:00
Devang Patel b40f295037 Do not store DIDescriptor directly into a container. Store MDNode directly, through TrackingVH.
llvm-svn: 88677
2009-11-13 19:10:24 +00:00
Mike Stump 88fc7d4202 This falls into the category of stupid pet tricks. I hate to do this,
but this is necessary to continue work on virtual vtables.  We don't
want to penalize virtual table building testcases, just because
complex virtual conversions don't yet work.

llvm-svn: 88676
2009-11-13 18:53:35 +00:00
Ken Dyck 8d6d4b84e2 add missing slashes to separator line; also testing commit access
llvm-svn: 88675
2009-11-13 18:50:18 +00:00
Ted Kremenek 9f2ee2bb26 Use 'eq' operator, and enable regular experimental checks when --experimental-checks is passed to scan-build.
llvm-svn: 88673
2009-11-13 18:49:48 +00:00
Ted Kremenek 4ef13f8ac9 Add clang-cc option "--analyzer-experimental-internal-checks". This
option enables new "internal" checks that will eventually be turned on
by default but still require broader testing.

llvm-svn: 88671
2009-11-13 18:46:29 +00:00
Douglas Gregor 379d84b7ed When performing copy initialization (= "implicit conversion", here) to
a class type from itself or a derived class thereof, enumerate
constructors and permit user-defined conversions to the arguments of
those constructors. This fixes the wacky implicit conversion sequence
used in std::auto_ptr's lame emulation of move semantics.

llvm-svn: 88670
2009-11-13 18:44:21 +00:00
Douglas Gregor 07eae02fc7 When transforming an expression statement (e.g., for template
instantiation), be sure to finish the expression statement by
providing a FullExprArg, making sure that temporaries get
destroyed. Fixes an obscure failure when parsing
llvm/LinkAllPasses.h.

llvm-svn: 88668
2009-11-13 18:34:26 +00:00
Daniel Dunbar 420b0f1bd8 Add CompilerInstance utility functions for creating output files.
llvm-svn: 88667
2009-11-13 18:32:08 +00:00
Anders Carlsson fb4dda4fed Instead of storing CXXMethodDecls in the vtable builder, store GlobalDecls so we can represent both the complete and deleting destructors. Also, when encountering a destructor decl, emit entries for both the complete and deleting destructors. Mike, please review.
With this change, FileCheck builds and runs the clang test suite without failures!

llvm-svn: 88663
2009-11-13 17:08:56 +00:00
Anders Carlsson 97df0b40c3 Don't bind arguments to temporaries if the argument has a reference type.
llvm-svn: 88662
2009-11-13 17:04:35 +00:00
Daniel Dunbar 045f917edc Remove local splitLines reimplementation.
llvm-svn: 88661
2009-11-13 16:46:11 +00:00
Daniel Dunbar 566eeb2da5 Add output file list to CompilerInstance, so that it can track them instead of
forcing all clients to do it.

llvm-svn: 87103
2009-11-13 10:37:48 +00:00
Daniel Dunbar ac28c38737 clang-cc: Move output file initialization closer to use.
llvm-svn: 87102
2009-11-13 10:18:59 +00:00
Daniel Dunbar 39991862e1 Simplify, in anticipation of introducing explicit action instances.
llvm-svn: 87101
2009-11-13 09:57:06 +00:00
Daniel Dunbar f7093b5ae8 Add CodeCompletion consumer to CompilerInvocation.
llvm-svn: 87100
2009-11-13 09:36:05 +00:00
Daniel Dunbar 242ea9a05a Rework Sema code completion interface.
- Provide Sema in callbacks, instead of requiring it in constructor. This
   eliminates the need for a factory function. Clients now just pass the object
   to consume the results in directly.

 - CodeCompleteConsumer is cheap to construct, so building it whenever we are
   doing code completion is reasonable.

Doug, please review.

llvm-svn: 87099
2009-11-13 08:58:20 +00:00
Daniel Dunbar 599313ef94 Add CompilerInstance::createPCHExternalASTSource.
llvm-svn: 87097
2009-11-13 08:21:10 +00:00
Daniel Dunbar adf6c242a0 Add CompilerInstance::has* methods for testing if the instance has a particular
subobject.

llvm-svn: 87096
2009-11-13 08:20:57 +00:00
Daniel Dunbar df3e30c41c Add ASTContext to CompilerInstance.
llvm-svn: 87095
2009-11-13 08:20:47 +00:00
Zhongxing Xu c7460964ac Malloc checker basically works now.
llvm-svn: 87094
2009-11-13 07:48:11 +00:00
Zhongxing Xu c4902a52a0 Hook up Malloc checker.
llvm-svn: 87093
2009-11-13 07:25:27 +00:00
Zhongxing Xu a4276b091d Check in a new interface of Checker, which will soon be used.
llvm-svn: 87092
2009-11-13 06:53:04 +00:00
Zhongxing Xu 0320ad28c7 GRStateManager::CurrentStmt is not used. Remove it.
llvm-svn: 87091
2009-11-13 06:04:01 +00:00
Daniel Dunbar 7d75afc56a Add CompilerInstance::createDiagnostics, and move clang-cc to it.
clang-cc.cpp is now under 1k lines, if anyone is counting.

llvm-svn: 87090
2009-11-13 05:52:34 +00:00
Daniel Dunbar 210a80086b Add a FIXME.
llvm-svn: 87089
2009-11-13 05:52:19 +00:00
Daniel Dunbar aaa148fd36 Add Preprocessor to CompilerInstance, and move clang-cc CreatePreprocessor to
CompilerInstance::createPreprocessor.

llvm-svn: 87088
2009-11-13 05:52:11 +00:00
Daniel Dunbar 1b4441915a Wherein the TargetInfo argument to Preprocessor is made 'const' and propogated.
llvm-svn: 87087
2009-11-13 05:51:54 +00:00
Zhongxing Xu 1721ef7a53 Include header for printf.
llvm-svn: 87086
2009-11-13 05:46:16 +00:00
Rafael Espindola 46129b0934 Use StringRef::split instead of SplitString.
llvm-svn: 87085
2009-11-13 05:13:58 +00:00
Anders Carlsson e828c36933 Add a special BuildVirtualCall that's going to be used for building calls to destructors. This is needed because when compiling:
struct A {
	virtual ~A();
};

void f(A* a) {
	delete a;
}

A's deleting destructor should be called.

llvm-svn: 87083
2009-11-13 04:45:41 +00:00
Anders Carlsson 78cfaa9e56 Fix two bugs with temporaries:
1. For 

A f() {
	return A();
}

we were incorrectly calling the A destructor on the returned object.

2. For

void f(A);
void g() {
	A a;
	f(a);
}

we were incorrectly not calling the copy constructor.

llvm-svn: 87082
2009-11-13 04:34:45 +00:00
Anders Carlsson 87f84c1e72 Move GlobalDecl to its own file. Also add DenseMapInfo traits.
llvm-svn: 87081
2009-11-13 04:25:07 +00:00
Daniel Dunbar 546a676ae5 Add {File,Source}Manager to CompilerInstance.
llvm-svn: 87079
2009-11-13 04:12:06 +00:00
Daniel Dunbar 636404a330 Add CompilerInstance, and starting moving clang-cc to it.
- The design philosophy is in the CompilerInstance doxyment, if you don't agree
   with it now would be a good time to speak up.

llvm-svn: 87078
2009-11-13 03:51:44 +00:00
Ted Kremenek 2466e0d92f Only flush plist diagnostics once.
llvm-svn: 87073
2009-11-13 03:14:14 +00:00
Ted Kremenek da00234109 Fix recently introduced use-after-free error reported in <rdar://problem/7387478>.
llvm-svn: 87072
2009-11-13 03:02:57 +00:00
Mike Stump fa81808a11 Refine construction vtables; they don't include bits that don't have
virtual bases unless they are morally virtual.

llvm-svn: 87071
2009-11-13 02:35:38 +00:00
Mike Stump 653d0b99df Refine the construction vtables with respect to offsets. WIP.
llvm-svn: 87067
2009-11-13 02:13:54 +00:00
Daniel Dunbar 27b19dc1b5 Move input kind identification (-x) into FrontendOptions.
llvm-svn: 87066
2009-11-13 02:06:12 +00:00
Ted Kremenek 3c55718016 Pull static variable within function (for slightly faster startup time).
llvm-svn: 87065
2009-11-13 01:58:01 +00:00
Mike Stump 83066c8dee Allow the tracking of address points for construction vtables as well.
llvm-svn: 87063
2009-11-13 01:54:23 +00:00
Ted Kremenek a2968e59e3 retain/release checker: refactor some of the summary lookup logic for instance method summaries. No real functionality change, but it paves the way for new enhancements.
llvm-svn: 87062
2009-11-13 01:54:21 +00:00
Ted Kremenek aedb7434c8 Add clang-cc option "-analyzer-experimental-checks" to enable experimental path-sensitive checks. The idea is to separate "barely working" or "skunkworks" checks from ones that should always run. Later we need more fine-grain checker control.
llvm-svn: 87053
2009-11-13 01:15:47 +00:00
Daniel Dunbar 1e886ebe8c Move -target-{triple,abi} options into FrontendOptions.
llvm-svn: 87051
2009-11-13 01:02:19 +00:00
Daniel Dunbar 4a1f60f777 Move code completion options to clang-cc
llvm-svn: 87050
2009-11-13 01:02:10 +00:00
Chris Lattner 956d71a63a add a fixme, inheriting from PointerIntPair is gross :)
llvm-svn: 87048
2009-11-13 00:57:01 +00:00
Daniel Dunbar a5c3d989fb Move FixItAtLocations into FrontendOptions
llvm-svn: 87046
2009-11-12 23:52:56 +00:00
Daniel Dunbar eb51586a85 clang-cc: Keep Verbose option with HeaderSearchOptions, for now.
llvm-svn: 87045
2009-11-12 23:52:46 +00:00
Daniel Dunbar f996c05d74 Add FrontendOptions, and starting moving clang-cc to it.
llvm-svn: 87044
2009-11-12 23:52:32 +00:00
Mike Stump 2b34bc5a96 Refine which vtbl is refernced in VTTs.
llvm-svn: 87043
2009-11-12 23:36:21 +00:00
Mike Stump ca0de33113 Refine offsets into vtables for the VTT.
llvm-svn: 87041
2009-11-12 23:14:15 +00:00
Mike Stump 8677bc27bf Refine vtable pointers for secondary vtables inside VTTs to point to
the right base vtable.  WIP.

llvm-svn: 87039
2009-11-12 22:56:32 +00:00
Douglas Gregor 9533e2803f We need the definition of NamedDecl in DeclContextInternals.h, since Clang is type-checking the template definition more thoroughly
llvm-svn: 87037
2009-11-12 22:12:17 +00:00
Mike Stump 2cefe38365 Fix the offset calculations for non-virtual bases with overrides.
Refine the VTT entries for virtual bases to refer to the complete
object's vtable instead of constructor vtables.

Refine the AddressPoint calculations for VTT entries for virtual bases.

llvm-svn: 87021
2009-11-12 20:47:57 +00:00
Fariborz Jahanian eb80c98a72 Fix a code gen bug in i386-apple-darwin (objc fragile abi), sending
message to 'super'. Fixes radar 7205866.

llvm-svn: 87017
2009-11-12 20:14:24 +00:00
Daniel Dunbar b0a1942196 Spell empty StringRef correctly (0 is a null StringRef, which is not the same).
llvm-svn: 87011
2009-11-12 18:40:12 +00:00
Douglas Gregor 49ba3cabdd Recognize (and check) pointer-to-member template arguments that are
non-type template parameters or constants of pointer-to-member
type. Once checked, be sure to retain those pointer-to-member
constants as expressions if they are dependent, or as declarations if
they are not dependent.

llvm-svn: 87010
2009-11-12 18:38:13 +00:00
Devang Patel 94f798c079 "Attach debug info with llvm instructions" mode was enabled a month ago. Now make it permanent and remove old way of inserting intrinsics to encode debug info for locations and types.
llvm-svn: 87007
2009-11-12 18:21:39 +00:00
Devang Patel 6e98d7af22 Use getNameAsCString() instead of getName().data()
llvm-svn: 87001
2009-11-12 17:49:47 +00:00
Douglas Gregor 4e948ce769 When instantiating a reference to a non-type template parameter of pointer to
member type (e.g., T Class::*Member), build a pointer-to-member
constant expression. Previously, we we just building a simple
declaration reference expression, which meant that the expression was
not treated as a pointer to member.

llvm-svn: 87000
2009-11-12 17:40:13 +00:00
Chandler Carruth bc55fe26c6 Move CompileOptions -> CodeGenOptions, and sink it into the CodeGen library.
This resolves the layering violation where CodeGen depended on Frontend.

llvm-svn: 86998
2009-11-12 17:24:48 +00:00
Anders Carlsson 9a1cd87d17 Set CK_BaseToDerived in TryStaticDowncast.
llvm-svn: 86996
2009-11-12 16:53:16 +00:00
Douglas Gregor 6051c8d344 Give CanQual<T> an implicit conversion to bool, so that it can be used
in "if" statements like:

  if (CanQual<ReferenceType> RefType = T.getAs<ReferenceType>())

Thanks to Clang for pointing out this mistake :)

llvm-svn: 86995
2009-11-12 16:49:45 +00:00
Anders Carlsson a70ad93f8a Add a CK_BaseToDerived cast kind.
llvm-svn: 86994
2009-11-12 16:43:42 +00:00
Douglas Gregor 19ac2d6494 When comparing template parameter lists, distinguish between three cases:
- Comparing template parameter lists to determine if we have a redeclaration
  - Comparing template parameter lists to determine if we have equivalent
    template template parameters
  - Comparing template parameter lists to determine whether a template 
    template argument is valid for a given template template parameter.

Previously, we did not distinguish between the last two cases, which
got us into trouble when we were looking for exact type matches
between the types of non-type template parameters that were dependent
types. Now we do, so we properly delay checking of template template
arguments until instantiation time.

Also, fix an accidental fall-through in a case statement that was
causing crashes.

llvm-svn: 86992
2009-11-12 16:20:59 +00:00
Daniel Dunbar 068ae76e02 Disallow FIX-ITs when generating code.
llvm-svn: 86990
2009-11-12 15:42:53 +00:00
Douglas Gregor ef986e8fc3 Improve source-location information for implicitly-generated member call expressions
llvm-svn: 86989
2009-11-12 15:31:47 +00:00
Daniel Dunbar 91cd960d50 clang-cc: Coalesce frontend options further.
llvm-svn: 86988
2009-11-12 15:23:20 +00:00
Benjamin Kramer 1eb8569bcb Fix MSVC build.
llvm-svn: 86983
2009-11-12 12:30:05 +00:00
Zhongxing Xu c6d9292197 update CMakefile
llvm-svn: 86979
2009-11-12 08:39:33 +00:00
Zhongxing Xu 88cca6b085 Add boilerplate logic for a malloc/free checker.
llvm-svn: 86978
2009-11-12 08:38:56 +00:00
Chris Lattner 55c9877b66 Generalize stdint.h for non-8-bit-multiple types, patch by
Ken Dyck!

"This adds definitions for types of 8-bit multiples
from 8 to 64 to stdint.h and rationalizes the selection of types 
for the exact-width definitions in InitPreprocessor.cpp."

llvm-svn: 86977
2009-11-12 08:08:27 +00:00
Chris Lattner 0fb5bbd401 do not store wchar/char16/char32/intmax width/alignment info
into TargetInfo, just derive this based on the underlying type.
This prevents them from getting out of synch, patch by Ken Dyck!

llvm-svn: 86976
2009-11-12 08:04:33 +00:00
Daniel Dunbar 4c0e8274e9 Move warning options into DiagnosticOptions.
llvm-svn: 86968
2009-11-12 07:28:44 +00:00
Daniel Dunbar 71ed08ba39 Avoid comparing string literals.
llvm-svn: 86967
2009-11-12 07:28:29 +00:00
Daniel Dunbar 8fd69a09cc Move dump-build-information option into DiagnosticOptions.
llvm-svn: 86966
2009-11-12 07:28:21 +00:00
Daniel Dunbar ec256a921f clang-cc: Factor CreateDiagnosticEngine out of main.
llvm-svn: 86963
2009-11-12 06:48:31 +00:00
Daniel Dunbar 0d1defd4cd clang-cc: -fixit is actually option, not an action, although its use with non
-fsyntax-only is probably untested.

llvm-svn: 86962
2009-11-12 06:48:24 +00:00
Daniel Dunbar 723e74ab75 Simplify.
llvm-svn: 86961
2009-11-12 06:48:17 +00:00
Ted Kremenek 6c37c5c356 PthreadLockChecker doesn't need PreVisitCallExpr() yet. All the current logic should be done in PostVisitCallExpr()
llvm-svn: 86959
2009-11-12 06:26:58 +00:00
Ted Kremenek d48568f641 Add most of the boilerplate logic for a simple pthread_mutux_lock() -> pthread_mutex_unlock() checker. We need to add a visitor method to Checker for handling dead symbols in order to detect locks that are not unlocked.
llvm-svn: 86958
2009-11-12 06:17:47 +00:00
Ted Kremenek 386a2a52d3 Remove obsolete 'struct NullDerefTag'.
llvm-svn: 86957
2009-11-12 06:16:18 +00:00
Rafael Espindola f401fa0386 Use the --with-c-include-dirs configure option.
llvm-svn: 86956
2009-11-12 05:48:41 +00:00
Ted Kremenek a971afb90f Enhance Checker class (and GRExprEngine) to support PostVisitation for CallExprs. No clients (yet).
llvm-svn: 86949
2009-11-12 04:35:08 +00:00
Ted Kremenek 8f6c4e8617 Remove GRExprEngine::EvalCall(). It had a single callsite in GRExprEngine, and was easily inlined.
llvm-svn: 86948
2009-11-12 04:16:35 +00:00
John McCall 84c16cf824 Random const correctness, and incidentally use computeDeclContext when building
a using declaration.

llvm-svn: 86942
2009-11-12 03:15:40 +00:00
Daniel Dunbar 2940303363 Move TokenCache option to PreprocessorOptions.
llvm-svn: 86940
2009-11-12 02:53:59 +00:00
Daniel Dunbar 1a54e3fbb9 Switch PTHManager to using diagnostics for most errors.
Also, always give errors on a token-cache PTH failure.

llvm-svn: 86939
2009-11-12 02:53:48 +00:00
Daniel Dunbar 51637a9ba4 Simplify.
llvm-svn: 86938
2009-11-12 02:53:34 +00:00
Daniel Dunbar 1619831fde clang-cc: Refactor ParseInputFollow to clearly split on the two primary cases,
when we are running an AST consumer and when we are just running the
preprocessor or parser alone.

llvm-svn: 86937
2009-11-12 02:53:27 +00:00
Daniel Dunbar 4806f2ea48 clang-cc: Factor ReadPCHFile out of ProcessInputFile.
llvm-svn: 86936
2009-11-12 02:53:20 +00:00
Daniel Dunbar 92641dca86 Simplify.
llvm-svn: 86935
2009-11-12 02:53:13 +00:00
Daniel Dunbar 7336edd8b2 clang-cc: Unify InitializeSourceManager calls.
llvm-svn: 86934
2009-11-12 02:53:06 +00:00
Zhongxing Xu 383c273966 Make StoreManager::getSizeInElements() always return DefinedOrUnknownSVal.
llvm-svn: 86932
2009-11-12 02:48:32 +00:00
John McCall 495922cb6a Note to self: don't leave debugging statements in the code for four hours.
llvm-svn: 86931
2009-11-12 02:10:34 +00:00
Daniel Dunbar f7316732b8 clang-cc: Move non-Consumer action handling to common location, to expose the massive amount of redundancy we have introduced through blind copy-and-paste.
llvm-svn: 86922
2009-11-12 01:36:27 +00:00
Daniel Dunbar f4408a29e1 Fix PCH/preprocess test to be more useful, and unbreak -E mode with implicit
PCH, which I broke.

llvm-svn: 86921
2009-11-12 01:36:20 +00:00
Devang Patel 7bdf096f8d Do not use StringRef while using DebugInfo interface.
llvm-svn: 86915
2009-11-12 00:51:46 +00:00
Douglas Gregor dd6c0356ba Improve recovery in a wonky case where one tries to specialize a
template template parameter.

When building a template-id type, check whether the template-name
itself is dependent (even if the template arguments are not!) and
handle it as a template-id type.

llvm-svn: 86913
2009-11-12 00:46:20 +00:00
Daniel Dunbar 0cfa3c4875 Fix Makefile dependency bug with out-of-dir builds.
llvm-svn: 86912
2009-11-12 00:41:49 +00:00
Daniel Dunbar d8ff51bf49 Fix test portability.
llvm-svn: 86911
2009-11-12 00:41:41 +00:00
Daniel Dunbar a970d39ebf Tweak AnalyzerOptions for consistency, and make sure default constructed object
is sane.

llvm-svn: 86908
2009-11-12 00:24:35 +00:00
Daniel Dunbar 39b6e2a0fd Tweak formatting.
llvm-svn: 86907
2009-11-12 00:24:28 +00:00
Daniel Dunbar e6de40e747 Move AnalyzerOptions into CompilerInvocation.
llvm-svn: 86906
2009-11-12 00:24:10 +00:00
John McCall b0e419e34d Add <foo> = [<bar> nextObject] to the -Widiomatic-parentheses category,
and give that category an explicit test.  Generalize the internal diagnostic
name.

llvm-svn: 86905
2009-11-12 00:06:05 +00:00
Douglas Gregor c998409cce Remove an overly-eager assertion when replacing tokens with an
annotation token, because some of the tokens we're annotating might
not be in the set of cached tokens (we could have consumed them
unconditionally).

Also, move the tentative parsing from ParseTemplateTemplateArgument
into the one caller that needs it, improving recovery.

llvm-svn: 86904
2009-11-12 00:03:40 +00:00
Daniel Dunbar 732ef8aefd Tweak PCH -include handling to make sure it matches the name as would be present
in the predefines buffer.

llvm-svn: 86903
2009-11-11 23:58:53 +00:00
John Thompson 92ebab90fe Fix clang executable path for Windows
llvm-svn: 86896
2009-11-11 23:11:14 +00:00
Douglas Gregor adee3e3b22 Template argument deduction for template template parameters. This
permits, among other things, ripping apart and reconstructing
templates via partial specialization:

  template<typename T> 
  struct DeepRemoveConst { typedef T type; };

  template<typename T>
  struct DeepRemoveConst<const T> {
    typedef typename DeepRemoveConst<T>::type type;
  };

  template<template<typename> class TT, typename T>
  struct DeepRemoveConst<TT<T> > {
    typedef TT<typename DeepRemoveConst<T>::type> type;
  };

Also, fix a longstanding thinko in the code handling partial ordering
of class template partial specializations. We were performing the
second deduction without clearing out the results of the first
deduction. It's amazing we got through so much code with such a
horrendous error :(

llvm-svn: 86893
2009-11-11 23:06:43 +00:00
John McCall 5055e4cdfd Fix PR 5422: handle lvalue results when evaluating 'based' ptrtoints as part of
the -Wconversion check.

llvm-svn: 86891
2009-11-11 22:52:37 +00:00
Fariborz Jahanian d708eb6b6a Make test more platform independent.
llvm-svn: 86890
2009-11-11 22:49:09 +00:00
Fariborz Jahanian c3091c9118 Make test more platform independent (per Sebastian's comment).
llvm-svn: 86888
2009-11-11 22:45:41 +00:00
Fariborz Jahanian 13e0c90fc1 writable atomic property's setter/getter must be in 'lock' step of
either both synthesized or bith user defined. 
Implements radar 6557233.

llvm-svn: 86887
2009-11-11 22:40:11 +00:00
Douglas Gregor 84d49a2085 Improve diagnostics when a default template argument does not match
with its corresponding template parameter. This can happen when we
performed some substitution into the default template argument and
what we had doesn't match any more, e.g.,

  template<int> struct A;
  template<typename T, template<T> class X = A> class B;

  B<long> b;

Previously, we'd emit a pretty but disembodied diagnostic showing how
the default argument didn't match the template parameter. The
diagnostic was good, but nothing tied it to the *use* of the default
argument in "B<long>". This commit fixes that.

Also, tweak the counting of active template instantiations to avoid
counting non-instantiation records, such as those we create for
(surprise!) checking default arguments, instantiating default
arguments, and performing substitutions as part of template argument
deduction.

llvm-svn: 86884
2009-11-11 21:54:23 +00:00
Daniel Dunbar 2856ae444b Always initialize the header search object as part of InitializePreprocessor;
not doing this has little to no utility.

llvm-svn: 86883
2009-11-11 21:44:42 +00:00
Daniel Dunbar 0c6c930f05 Allow Preprocessor to take ownership of the HeaderSearch object. I think it should probably always own the header search object, but I'm not sure...
llvm-svn: 86882
2009-11-11 21:44:21 +00:00
Daniel Dunbar 55b781f85e Sink AttachDependencyFileGen into CreatePreprocessor.
llvm-svn: 86881
2009-11-11 21:44:00 +00:00
Daniel Dunbar 89d1fdff65 Add DependencyOutputOptions to wrap -M... options, and propogate to
CompilerInvocation and clang-cc.

llvm-svn: 86880
2009-11-11 21:43:12 +00:00
Mike Stump fd84d6d808 Fix ctor vtable name. WIP.
llvm-svn: 86879
2009-11-11 20:32:03 +00:00
Mike Stump eac4559790 Push ctor vtable construction down further. WIP.
llvm-svn: 86878
2009-11-11 20:26:26 +00:00
Ted Kremenek 7cf8238291 Remove some stale ErrorNodes variables in GRExprEngine and the old buffer overflow logic in GRExprEngineInternalChecks.cpp.
llvm-svn: 86877
2009-11-11 20:16:36 +00:00
Chandler Carruth 062c291949 After drinking caffeine, add the two files missing from the previous submit.
Sorry about that.

llvm-svn: 86869
2009-11-11 19:43:37 +00:00
Douglas Gregor eebed72fbb Move handling of template parameter packs out of the
template-type-parameter specific template argument checking code and
up to the template argument checking loop. In theory, this should make
variadic templates work better; in practice, they don't well enough
for us to care anyway (YET!), so this is mostly a re-organization to
simplify CheckTemplateArgument.

llvm-svn: 86868
2009-11-11 19:41:09 +00:00
Douglas Gregor da0fb53c16 Refactoring of template-argument checking code to reduce nesting,
increase sanity. No intended functionality change.

llvm-svn: 86866
2009-11-11 19:31:23 +00:00
Douglas Gregor e62e6a0191 Before checking a template template argument against its corresponding
template template parameter, substitute any prior template arguments
into the template template parameter. This, for example, allows us to
properly check the template template argument for a class such as:

  template<typename T, template<T Value> class X> struct Foo;

The actual implementation of this feature was trivial; most of the
change is dedicated to giving decent diagnostics when this
substitution goes horribly wrong. We now get a note like:

  note: while substituting prior template arguments into template
      template parameter 'X' [with T = float]

As part of this change, enabled some very pedantic checking when
comparing template template parameter lists, which shook out a bug in
our overly-eager checking of default arguments of template template
parameters. We now perform only minimal checking of such default
arguments when they are initially parsed.

llvm-svn: 86864
2009-11-11 19:13:48 +00:00
Chandler Carruth 5375309250 Move the ManagerRegistry to the Analysis library to resolve the layering violation.
llvm-svn: 86863
2009-11-11 19:10:59 +00:00
Devang Patel 5348515193 Do not eagerly set stop point for arguments. This misleads the debugger in identifying beginning of function body. Instead, create new location to attach with llvm.dbg.declare. This location is only used to find the context of the variable by the code generator, and it is not used to emit line number info.
llvm-svn: 86862
2009-11-11 19:10:19 +00:00
Fariborz Jahanian 03f62ed9bb Value initialize non-class array members in ctor's
initializer list. Fixes PR5463.

llvm-svn: 86849
2009-11-11 17:55:25 +00:00
Ted Kremenek 91989d166a Split buffer overflow test case into two test cases, removing out logic that was commented out.
llvm-svn: 86845
2009-11-11 17:17:06 +00:00
Douglas Gregor 38fee967ae Instantiation of template template parameters for nested templates, e.g.,
template<typename T>
  struct X {
    template<template<T Value> class Y> struct Inner;
  };

llvm-svn: 86844
2009-11-11 16:58:32 +00:00
Douglas Gregor 120635bc9c Fix speculative parsing of dependent template names in
nested-name-specifiers so that they don't gobble the template name (or
operator-function-id) unless there is also a
template-argument-list. For example, given

  T::template apply

we would previously consume both "template" and "apply" as part of
parsing the nested-name-specifier, then error when we see that there
is no "<" starting a template argument list. Now, we parse such
constructs tentatively, and back off if the "<" is not present. This
allows us to parse dependent template names as one would use them for,
e.g., template template parameters:

  template<typename T, template<class> class X = T::template apply>
    struct MetaSomething;

Also, test default arguments for template template parameters.

llvm-svn: 86841
2009-11-11 16:39:34 +00:00
Zhongxing Xu b166712d02 Add undefined array subscript checker.
llvm-svn: 86837
2009-11-11 13:42:54 +00:00
Zhongxing Xu 83c4374e72 Remove the old out-of-bound checking code.
llvm-svn: 86836
2009-11-11 12:52:39 +00:00
Zhongxing Xu 4f7759a339 Reimplement out-of-bound array access checker with the new checker interface.
Now only one test case is XFAIL'ed.

llvm-svn: 86834
2009-11-11 12:33:27 +00:00
Zhongxing Xu 3ef93badbe ReturnPointerRangeChecker: use StripCasts() instead of checking for zero index
explicitly.

Fix 80-col violations.

llvm-svn: 86833
2009-11-11 11:55:54 +00:00
Daniel Dunbar f580187aed Simplify.
llvm-svn: 86830
2009-11-11 10:22:48 +00:00
Daniel Dunbar 559f7a5c3c Fix unsafe use of StringRef I introduced.
llvm-svn: 86829
2009-11-11 10:10:25 +00:00
Daniel Dunbar 22bdabf05f Add PreprocessorOutputOptions to CompilerInvocation, and move initialization to
clang-cc/Options.cpp

llvm-svn: 86828
2009-11-11 10:07:44 +00:00
Daniel Dunbar 531f6c662b Add PreprocessorOutputOptions, for things like -dM, -C, -CC which control -E
mode.

llvm-svn: 86827
2009-11-11 10:07:22 +00:00
Daniel Dunbar 979586e755 Simplifiy target feature handling by coalescing all the logic into
InitializeCompileOptions.

llvm-svn: 86826
2009-11-11 09:38:56 +00:00
Daniel Dunbar eced7e065f Minor formatting tweaks.
llvm-svn: 86825
2009-11-11 09:38:42 +00:00
Daniel Dunbar 759cab9a54 clang-cc: Refactor some -fixit-at handling.
llvm-svn: 86824
2009-11-11 09:38:35 +00:00
Daniel Dunbar d0c3bb0df2 Allow TextDiagnosticPrinter to have optional ownership of its output stream.
llvm-svn: 86823
2009-11-11 09:38:24 +00:00
Daniel Dunbar 23ede2d9d1 Update CMake.
llvm-svn: 86822
2009-11-11 08:14:02 +00:00
Daniel Dunbar d2cfa0111c clang-cc: Move InitializeAnalyzerOptions into Options.cpp
llvm-svn: 86821
2009-11-11 08:13:55 +00:00
Daniel Dunbar ef0147c0e9 clang-cc: Start coalescing "frontend" options.
llvm-svn: 86820
2009-11-11 08:13:47 +00:00
Daniel Dunbar dcd40fb95f clang-cc: Move InitializeDiagnosticOptions to Options.cpp
llvm-svn: 86819
2009-11-11 08:13:40 +00:00
Daniel Dunbar f527a12e47 clang-cc: Move HeaderSearchOptions to Options.cpp
llvm-svn: 86818
2009-11-11 08:13:32 +00:00
Daniel Dunbar b6bac22d02 Turn LoggingDiagnosticClient into a more general ChainedDiagnosticClient and
move to libFrontend.

llvm-svn: 86817
2009-11-11 08:13:24 +00:00
Daniel Dunbar 84dfbfde26 clang-cc: Move InitializeLangOptions to Options.cpp.
Also, inline InitializeLanguageStandard into InitializeLangOptions; this code
needs to be refactored but the current division doesn't make any sense.

llvm-svn: 86816
2009-11-11 07:26:12 +00:00
Daniel Dunbar f0f6f0efb0 Inline some trivial functions.
llvm-svn: 86815
2009-11-11 07:26:02 +00:00
Ted Kremenek 04552cbef0 CastToStructChecker: use 'isStructureType()' instead of 'isRecordType()' to determine if a pointer is casted to a struct pointer. This fixes an observed false positive when a value is casted to a union.
llvm-svn: 86813
2009-11-11 06:43:42 +00:00
Ted Kremenek 55d59bf785 Fix display of "ANALYZE" statements in AnalysisConsumer by correctly resetting the flag indicating that the current Decl* has not yet been displayed. Also move this out of AnalysisManager, since AnalysisManager should not handle text output to the user.
llvm-svn: 86812
2009-11-11 06:28:42 +00:00
Daniel Dunbar 999215c8c8 clang-cc: Move InitializePreprocessorOptions to Options.cpp
llvm-svn: 86811
2009-11-11 06:10:03 +00:00
Ted Kremenek 4325315935 Remove public headers for UndefinedArgChecker, AttrNonNullChecker, and BadCallChecker, making their implementations completely private.
llvm-svn: 86809
2009-11-11 05:50:44 +00:00
Daniel Dunbar de142beafb clang-cc: Simplify this code, now that predefines handling is uniform in the
PCH/-E and PCH/not--E cases.

llvm-svn: 86808
2009-11-11 05:33:31 +00:00
Daniel Dunbar 000c4ffd16 Redo how PCH handles its implicit include. Instead of treating this specially in
the front-end (as far as the preprocessor goes), follow the usual logic of
inserting the (original include path) name into the predefines buffer. This
pushes the responsibility for handling this to PCH instead of the front-end.  In
PCH this requires being a little more clever when we diff the predefines
buffers.

Neither of these solutions are particularly great, I think what we eventually
should do is something like gcc where we insert a special marker to indicate the
PCH file, but then run the preprocessor as usual. This would be clearer and
would allow us to drop the overly clever predefines handling.

llvm-svn: 86806
2009-11-11 05:29:04 +00:00
Daniel Dunbar 499baed8a8 More StringRef simplification to PCHValidator::ReadPredefinesBuffer.
llvm-svn: 86805
2009-11-11 05:26:28 +00:00
Daniel Dunbar 775f18520c And now a test fix in +Asserts mode, which I broke.
llvm-svn: 86801
2009-11-11 03:48:34 +00:00
Daniel Dunbar 568e302a7f Fix some tests in -Asserts mode.
- FileCheck is a *huuuuge* improvement here.

 - Still feels like we could use a better tool for this though, either teach
   llvm-dis to spit out the FileCheck syntax, or provide another tool to turn a
   .ll into a "matchable" input.

 - Also on my Christmas list is better FileCheck diagnostics with missing
   variables or mismatches.

llvm-svn: 86800
2009-11-11 03:48:26 +00:00
Daniel Dunbar 8665c7e39d Rewrite splitLines using StringRef; this is much simpler, and also now avoids
tons of std::string trashing. I plan to move this and other fun string munging
utilities to a StringRefExtras.h at some point if no one beats me to it.

On a synthetic benchmark on x86_64, llvm-gcc actually generates code thats 10%
faster using the StringRef version. gcc miscompiles the synthetic benchmark,
which I'm crossing my fingers and hoping won't happen here. clang compiles the
sythetic benchmark correctly (wootness), but the StringRef version is
slower. Silly clang.

llvm-svn: 86799
2009-11-11 03:45:59 +00:00
Ted Kremenek 5e1f78aeb1 Refactor DereferenceChecker to use only the new Checker API instead of
the old builder API.  This percolated a bunch of changes up to the
Checker class (where CheckLocation has been renamed VisitLocation) and
GRExprEngine.  ProgramPoint now has the notion of a "LocationCheck"
point (with PreLoad and PreStore respectively), and a bunch of the old
ProgramPoints that are no longer used have been removed.

llvm-svn: 86798
2009-11-11 03:26:34 +00:00
John McCall 7e1d6d78d5 Preserve source locations when building offsetof expressions featuring
anonymous members.  Partial fix for PR 5390.

llvm-svn: 86796
2009-11-11 03:23:23 +00:00
Mike Stump c7b9f5e762 More VTT work. We now track offsets and use the ctor vtable builder
interface.  WIP.

llvm-svn: 86793
2009-11-11 03:08:24 +00:00
Mike Stump 4e16d05dc4 Fixup spacing.
llvm-svn: 86792
2009-11-11 02:49:00 +00:00
John McCall 0506e4af2c Apparently the following idiom is specifically encouraged:
if (self = [super init])
Recognize it and only warn if -Wparentheses is explicitly enabled.

llvm-svn: 86790
2009-11-11 02:41:58 +00:00
Fariborz Jahanian e6c8112572 Avoid generating additional destructor(s) for initialized constructed
objects.

llvm-svn: 86778
2009-11-11 01:13:34 +00:00
Douglas Gregor 9167f8bbd5 Introduce a new representation for template template
parameters. Rather than storing them as either declarations (for the
non-dependent case) or expressions (for the dependent case), we now
(always) store them as TemplateNames. 

The primary change here is to add a new kind of TemplateArgument,
which stores a TemplateName. However, making that change ripples to
every switch on a TemplateArgument's kind, also affecting
TemplateArgumentLocInfo/TemplateArgumentLoc, default template
arguments for template template parameters, type-checking of template
template arguments, etc.

This change is light on testing. It should fix several pre-existing
problems with template template parameters, such as:
  - the inability to use dependent template names as template template
  arguments
  - template template parameter default arguments cannot be
  instantiation

However, there are enough pieces missing that more implementation is
required before we can adequately test template template parameters. 

llvm-svn: 86777
2009-11-11 01:00:40 +00:00
Daniel Dunbar 3618834da8 Recognize -fsyntax-only as a "consumer only" action.
llvm-svn: 86776
2009-11-11 00:54:56 +00:00
Daniel Dunbar 20a682de6b StringRefify some PCH interfaces.
llvm-svn: 86775
2009-11-11 00:52:11 +00:00
Daniel Dunbar 045c92f812 Replace startsWith functions with StringRef.
llvm-svn: 86774
2009-11-11 00:52:00 +00:00
Mike Stump 8b2d2d0707 Stub out most of the VTT building code. WIP.
llvm-svn: 86772
2009-11-11 00:35:07 +00:00
John McCall caef2448da Create a new Scope when parsing a declaration with a C++ scope specifier.
llvm-svn: 86764
2009-11-11 00:21:18 +00:00
Daniel Dunbar 93097b3906 Add Diagnostic::Report method for reporting diagnostics without a location.
llvm-svn: 86760
2009-11-10 23:55:23 +00:00
Daniel Dunbar de02f63945 PreprocessorOptions: Get rid of unnecessary 'isPTH' flag for include entries.
llvm-svn: 86757
2009-11-10 23:53:43 +00:00
Fariborz Jahanian 4e088941ad Diagnose illegally typed operator new/new[].
llvm-svn: 86755
2009-11-10 23:47:18 +00:00
Devang Patel af993bf5cc Attach location info with llvm.dbg.declare.
llvm-svn: 86750
2009-11-10 23:07:24 +00:00
Ted Kremenek 0b61a805b9 Add FIXIT hint for -Wsemicolon-before-method-body
llvm-svn: 86746
2009-11-10 22:55:49 +00:00
Eli Friedman d76f438369 Revert r86741; it doesn't handle virtual bases correctly.
llvm-svn: 86745
2009-11-10 22:48:10 +00:00
Eli Friedman 0960059c0c Minor optimization to skip null check in generated code where it isn't
necessary.

llvm-svn: 86741
2009-11-10 22:42:26 +00:00
Eli Friedman 3ad2645430 Fix for PR5454: make sure to use the right block as the predecessor in the
generated PHI node for the null check of a new operator.

llvm-svn: 86738
2009-11-10 22:39:09 +00:00
Ted Kremenek 42855f2043 Shuffle order of warning declarations (alphabetize).
llvm-svn: 86733
2009-11-10 22:22:50 +00:00
Ted Kremenek f9a28abe8d Make -Wsemicolon-before-method-body opt-in (and part of -Wextra). Addresses <rdar://problem/7381735>.
llvm-svn: 86731
2009-11-10 22:16:29 +00:00
Daniel Dunbar 47ea8628a5 Decouple more of clang-cc by moving ImplicitP[CT]H options into
PreprocessorOptions.

Global variables used as [in] [out] parameters considered harmful.

llvm-svn: 86728
2009-11-10 22:09:38 +00:00
Ted Kremenek 4a720a363c Update CMake file.
llvm-svn: 86721
2009-11-10 21:38:41 +00:00
Benjamin Kramer aed9a1aadb Add newline at EOF.
llvm-svn: 86720
2009-11-10 21:33:20 +00:00
Benjamin Kramer 2c9a91c290 Silence warning.
llvm-svn: 86719
2009-11-10 21:29:56 +00:00
Dan Gohman ad5ef3d70f Use #include <stdio.h> when using fprintf and stderr.
llvm-svn: 86717
2009-11-10 21:21:27 +00:00
Daniel Dunbar f89a32ac45 clang-cc: Start moving "pure" option handling to Options.cpp, to separate it
from the logic part of clang-cc, and to enforce limited scoping.

llvm-svn: 86711
2009-11-10 19:51:53 +00:00
Daniel Dunbar d96cd43f13 clang-cc: Sink more options inside codegenopts namespace.
llvm-svn: 86710
2009-11-10 19:51:46 +00:00
Daniel Dunbar a35a2cb56b Change LangOpts initialization to directly test the code generation options,
instead of reproducing their logic.

llvm-svn: 86709
2009-11-10 19:51:33 +00:00
Douglas Gregor b53edfb8dc Improve parsing of template arguments to lay the foundation for
handling template template parameters properly. This refactoring:

  - Parses template template arguments as id-expressions, representing
    the result of the parse as a template name (Action::TemplateTy)
    rather than as an expression (lame!).

  - Represents all parsed template arguments via a new parser-specific
    type, ParsedTemplateArgument, which stores the kind of template
    argument (type, non-type, template) along with all of the source
    information about the template argument. This replaces an ad hoc
    set of 3 vectors (one for a void*, which was either a type or an
    expression; one for a bit telling whether the first was a type or
    an expression; and one for a single source location pointing at
    the template argument).

  - Moves TemplateIdAnnotation into the new Parse/Template.h. It never
    belonged in the Basic library anyway.

llvm-svn: 86708
2009-11-10 19:49:08 +00:00
Fariborz Jahanian dc21610419 Changed a variable name to match what it represents
(Ted's feedback).

llvm-svn: 86702
2009-11-10 19:31:09 +00:00
Fariborz Jahanian 1254a0978c This patch implements Code gen. for destruction of
global array of objects.

llvm-svn: 86701
2009-11-10 19:24:06 +00:00
Ted Kremenek ba64574c9a CIndex: Only display diagnostics to llvm::errs() when the client has set the 'displayDiagnostics' option to 1 in clang_createIndex(). This fixes <rdar://problem/7370691>.
llvm-svn: 86700
2009-11-10 19:18:52 +00:00
Mike Stump b47222144b Only generate a VTT for classes that need a VTT.
llvm-svn: 86699
2009-11-10 19:13:04 +00:00
Daniel Dunbar f76c9d270a Driver: Run 'clang' in C++ mode based on the name it was invoked by. We match
anything that ends with ++ or ++-FOO (e.g., c++, clang++, clang++-1.1) as being
a "C++ compiler".

This allows easy testing of the C++ compiler by 'ln -s clang clang++', or by 'cp
clang clang++'.

Based on patch by Roman Divacky.

llvm-svn: 86697
2009-11-10 18:47:41 +00:00
Daniel Dunbar ef2919f1fa Factor out parts of InitializeCompileOptions that depend on the LangOptions.
llvm-svn: 86696
2009-11-10 18:47:35 +00:00
Daniel Dunbar be50f5ab9d Localize -disable-llvm-optzns handling to BackendConsumer::CreatePasses.
- This is conceptually better since the only thing we want this option to do is
   preserve the internal module as constructed by IRgen, before running any
   passes.

 - This also fixes bugs in -disable-llvm-optzns handling with regards to debug
   info.

llvm-svn: 86691
2009-11-10 17:50:53 +00:00
Daniel Dunbar ede182ef05 clang-cc: Start sinking (CodeGen) options into namespaces to limit their scope.
llvm-svn: 86690
2009-11-10 17:50:42 +00:00
Daniel Dunbar 68ac06142b Cleanup some clang-cc FIXMEs
llvm-svn: 86686
2009-11-10 16:23:44 +00:00
Daniel Dunbar 754c11ec48 Add CompileOptions to CompilerInvocation.
llvm-svn: 86685
2009-11-10 16:19:45 +00:00
John McCall b8be78b753 Fix a similar problem with qualified lookup through using directives,
although in this case we probably just run a risk of duplicating work;
I can't think of how this could cause a bug.

llvm-svn: 86680
2009-11-10 09:25:37 +00:00
John McCall 9757d0363d Make a somewhat more convincing test case for unqualified lookup through
using directives, and fix a bug thereby exposed:  since we're playing
tricks with pointers, we need to make certain we're always using the same 
pointers for things.
Also tweak an existing error message.

llvm-svn: 86679
2009-11-10 09:20:04 +00:00
Zhongxing Xu f9667229a1 Ignore parentheses when check the type of the expr.
llvm-svn: 86677
2009-11-10 08:33:44 +00:00
John McCall a31577ce9a Simple test case for [basic.lookup.udir].
llvm-svn: 86674
2009-11-10 07:56:40 +00:00
Zhongxing Xu 537db5d652 SizeofPointerChecker: Many false positives have the form 'sizeof *p'.
This is reasonable because people know what they are doing when they 
intentionally dereference the pointer.
So now we only emit warning when a pointer variable is use literally.

llvm-svn: 86673
2009-11-10 07:52:53 +00:00
Mike Stump d846d0825b Add vtable caching to prevent multiple vtables for the same class from
being generated.

Add the most derived vtable pointer to the VTT.

llvm-svn: 86671
2009-11-10 07:44:33 +00:00
John McCall f6c8a4ef1f Fix unqualified lookup through using directives.
This is a pretty minimal test case;  I'll make a better one later.

llvm-svn: 86669
2009-11-10 07:01:13 +00:00
Anders Carlsson ace5d07e50 When trying to assign a regular string literal to an Objective-C 'id' type or a pointer to an NSString, emit a code insertion hint that turns it into an Objective-C string. For example:
@class NSString;

@interface Test
+ (void)test:(NSString *)string;
@end

void g(NSString *a);

void f() {
  NSString *a = "Foo";
  g("Foo");
  [Test test:"Foo"];
}

will produce

t.m:10:17: warning: incompatible pointer types initializing 'char [4]', expected 'NSString *'
  NSString *a = "Foo";
                ^~~~~
                @
t.m:11:5: warning: incompatible pointer types passing 'char [4]', expected 'NSString *'
  g("Foo");
    ^~~~~
    @
t.m:12:14: warning: incompatible pointer types sending 'char [4]', expected 'NSString *'
  [Test test:"Foo"];
             ^~~~~
             @
3 diagnostics generated.

llvm-svn: 86665
2009-11-10 04:46:30 +00:00