Commit Graph

10352 Commits

Author SHA1 Message Date
Douglas Gregor f09935f16c Switch the clang-to-CIndex interface for code-completion to a binary format, for a massive speedup
llvm-svn: 90209
2009-12-01 05:55:20 +00:00
Eric Christopher c377c81dcf Update for llvm intrinsics change.
llvm-svn: 90208
2009-12-01 05:00:51 +00:00
Mike Stump 5406614be9 Much work on try/catch statement. WIP.
Highlights include:

  Fix __cxa_begin_catch so it now returns a value.
  Added getUnwindResumeOrRethrowFn helper to build up calls to
  _Unwind_Resume_or_Rethrow.
  Broke out object copying code into CopyObject from EmitCXXThrowExpr.
  Built up another version of CopyObject that can copy from memory for
  use in the catch parameter code.
  RTTI generation for type matching for catch.
  Code to check for the type match for catch.
  Code to generate the catch parameter, WIP, need make sure references
  and pointers and copy ctors work.

llvm-svn: 90205
2009-12-01 03:41:18 +00:00
Douglas Gregor 8f184a31d0 Eliminate warning in Release-Asserts mode. No functionality change
llvm-svn: 90204
2009-12-01 03:34:29 +00:00
Daniel Dunbar c70c39300f clang -cc1: Move CompilerInvocation deserialization into CompilerInvocation.cpp,
where it belongs.

llvm-svn: 90198
2009-12-01 03:16:53 +00:00
Ted Kremenek f8c12a3039 Allocate MultipleDC objects using the allocator associated with
ASTContext instead of malloc.  Besides reducing malloc traffic, this
also removes a source of memory leaks when using a BumpPtrAllocator
for the allocator of ASTContext.  There are still leaks when using
MallocAllocator because Decl::Destroy() isn't fully finished.

Fixes: <rdar://problem/7431556>
llvm-svn: 90174
2009-12-01 00:07:10 +00:00
John McCall f786fb13f5 Fix and test for a problem caught by the clang-on-clang buildbot: qualified
IDs in dependent contexts are not dependent if the context names a namespace.

llvm-svn: 90171
2009-11-30 23:50:49 +00:00
Anders Carlsson b1d3f7c909 Have ASTRecordLayout keep track of the key function, in preparation of fixing a synthetic ctor/dtor bug.
llvm-svn: 90168
2009-11-30 23:41:22 +00:00
John McCall 132f3133ae Remove all of Sema's explicit uses of OverloadedFunctionDecl except for
those associated with TemplateNames.

llvm-svn: 90162
2009-11-30 22:55:35 +00:00
John McCall 10eae1851d Eliminate the use of OverloadedFunctionDecl in member expressions.
Create a new UnresolvedMemberExpr for these lookups.  Assorted hackery
around qualified member expressions;  this will all go away when we
implement the correct (i.e. extremely delayed) implicit-member semantics.

llvm-svn: 90161
2009-11-30 22:42:35 +00:00
Fariborz Jahanian be64149749 More support for virtual destructor calls.
Fixes pr5619

llvm-svn: 90158
2009-11-30 22:07:18 +00:00
Anders Carlsson 26a807d37a When we're trying to define an implicit virtual destructor, make sure that we have a valid delete operator.
llvm-svn: 90156
2009-11-30 21:24:50 +00:00
Mike Stump 21d68e2435 Add const to accessors that don't modify the object.
llvm-svn: 90153
2009-11-30 20:10:58 +00:00
Mike Stump e5311b0d79 Reflow comments and fix 80-col violation.
llvm-svn: 90152
2009-11-30 20:08:49 +00:00
Anders Carlsson c920fa2a74 Fix an assert.
llvm-svn: 90149
2009-11-30 19:43:26 +00:00
Fariborz Jahanian 89b660c774 Fix a crash when ivar type is a __strong SEL. Fallout from
recent change to make SEL a builtin type (fixes radar 7425510).

llvm-svn: 90145
2009-11-30 18:43:52 +00:00
Benjamin Kramer 5f089128e9 Use StringRef in Attr constructors.
llvm-svn: 90140
2009-11-30 17:08:26 +00:00
Douglas Gregor 693ba203a1 Eliminate another VISIBILITY_HIDDEN
llvm-svn: 90139
2009-11-30 16:08:24 +00:00
Tobias Grosser 9fc223a6b1 Adapt to the DOTGraphTraits changes in LLVM.
llvm-svn: 90137
2009-11-30 14:16:05 +00:00
Daniel Dunbar a74f8ff15c Add CodeGenOptions::{SoftFloat,FloatABI}, and update the all the (far too many) places to use this instead of using the backend -soft-float and -float-abi= options.
llvm-svn: 90127
2009-11-30 08:42:00 +00:00
Daniel Dunbar 91dea8252a clang -cc1: Fix initialization of PreprocessorOptions::TokenCache.
llvm-svn: 90126
2009-11-30 08:41:42 +00:00
Daniel Dunbar 05762b1344 Add TextDiagnosticBuffer::FlushDiagnostics, for forwarding the buffered diagnostics to a different diagnostics engine.
llvm-svn: 90125
2009-11-30 08:41:34 +00:00
Daniel Dunbar 8c317acd2b clang -cc1: Fix -include-pch now that the test code is in clang-cc.
llvm-svn: 90124
2009-11-30 08:41:22 +00:00
Daniel Dunbar 599abb2d56 clang -cc1: Initialize LangOptions::{Optimize,NoInline}
llvm-svn: 90123
2009-11-30 08:41:13 +00:00
Daniel Dunbar 84bb793718 Always pass -fmessage-length using separate arguments.
llvm-svn: 90121
2009-11-30 08:40:54 +00:00
Daniel Dunbar 0429c5ef3a clang -cc1: Initialize LangOptions::DollarIdents correctly.
llvm-svn: 90120
2009-11-30 08:40:46 +00:00
Daniel Dunbar 2c11cd156e Don't try to generate common globals for C++ files, instead of depending on the FE to set NoCommon, and simplify CodeGenOptions initialization.
llvm-svn: 90119
2009-11-30 08:40:34 +00:00
Daniel Dunbar 8e70505692 Eliminate CodeGenOptions::TimePasses.
llvm-svn: 90118
2009-11-30 08:39:52 +00:00
Daniel Dunbar de18224d9c Eliminate CodeGenOptions::SimplifyLibCalls.
llvm-svn: 90117
2009-11-30 08:39:32 +00:00
Chris Lattner 710bb87147 Fix PR5633 by making the preprocessor handle the case where we can
stat a file but where mmaping it fails.  In this case, we emit an
error like:
t.c:1:10: fatal error: error opening file '../../foo.h'

instead of "cannot find file".

llvm-svn: 90110
2009-11-30 04:18:44 +00:00
Eli Friedman 03aa2f1262 Minor cleanup (no functionality change).
llvm-svn: 90105
2009-11-30 01:19:33 +00:00
Daniel Dunbar 0ac66427a9 clang -cc1: Use proper diagnostics for all parsing errors.
llvm-svn: 90100
2009-11-29 21:52:53 +00:00
Daniel Dunbar c76493a65d Don't pass false (default) for isVolatile parameter to CreateLoad.
llvm-svn: 90098
2009-11-29 21:23:36 +00:00
Daniel Dunbar 1dd0164bbe Explicitly use setVolatile instead of extra IRBuilder argument.
llvm-svn: 90095
2009-11-29 21:11:47 +00:00
Daniel Dunbar dacbe6bdcd Don't pass false (default) for isVolatile parameter to CreateStore.
llvm-svn: 90094
2009-11-29 21:11:41 +00:00
Daniel Dunbar fcb9caa772 Change CompilerInvocation::CreateFromArgs to report errors using a proper diagnostic engine.
- Clients that care about having the diagnostics output honor the user-controllable diagnostic options can buffer the diagnostics and issue them later.

llvm-svn: 90092
2009-11-29 20:58:50 +00:00
Daniel Dunbar ecd0444e8c Simplify.
llvm-svn: 90091
2009-11-29 20:58:39 +00:00
Daniel Dunbar 65ca1c6f02 Change CompilerInvocation::CreateFromArgs to take Argv0 and the address of main (or something in the main executable) so it can find the builtin compiler files.
llvm-svn: 90090
2009-11-29 20:58:32 +00:00
Benjamin Kramer b33a97c384 Remove useless c_str() calls in SemaCodeComplete.
llvm-svn: 90088
2009-11-29 20:18:50 +00:00
Benjamin Kramer ba9fd986eb Simplify code. No functionality change.
llvm-svn: 90087
2009-11-29 19:51:45 +00:00
Benjamin Kramer 6341553c93 Port BugReporter and BugType to StringRef.
llvm-svn: 90086
2009-11-29 18:27:55 +00:00
Benjamin Kramer ff3750f306 Kill some unnecessary calls to c_str().
llvm-svn: 90084
2009-11-29 18:03:28 +00:00
Nuno Lopes 0e5d13e025 remove stall comment
llvm-svn: 90080
2009-11-29 17:07:16 +00:00
Kovarththanan Rajaratnam 130f7f9629 Streamline Stmt::CollectingStats() and Decl::CollectingStats(). No functionality change.
llvm-svn: 90078
2009-11-29 14:54:35 +00:00
Kovarththanan Rajaratnam 09282c91d9 Don't call Decl::CollectingStats(false) and Stmt::CollectingStats(false). When called with false these functions return whether statistics are enabled. They don't change any state. Since we're not using the return value avoid calling them in the first place.
llvm-svn: 90077
2009-11-29 14:50:29 +00:00
Kovarththanan Rajaratnam 5505dff8af This patch moves the frontend timer from clang-cc into CompilerInstance.
CompilerInstance already contains various objects that are used
throughout the entire run.

Also addresses Daniels review comments in:

http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20091123/024508.html

llvm-svn: 90073
2009-11-29 09:57:35 +00:00
Alexis Hunt 3d221f2fce Add DeclarationName support for C++0x operator literals. They should now work as
function names outside of templates - they'll probably cause some damage there as
they're largely untested.

llvm-svn: 90064
2009-11-29 07:34:05 +00:00
Daniel Dunbar a1b02a2380 Move LLVM backend options to explicit clang-cc / clang -cc1 options, which we then manually pass to the command line library; eventually the latter grossness should be fixed by a real API when creating the target machine.
llvm-svn: 90063
2009-11-29 07:18:39 +00:00
Ted Kremenek 33e88a7be7 Fix null dereference in UndefResultChecker identified by running the analyzer over Postgresql.
llvm-svn: 90060
2009-11-29 06:37:44 +00:00
Daniel Dunbar 0317c4c5b7 Add clang -cc1 parsing for LangOptions.
- This is the last major parsing piece, main FIXMEs remain.

llvm-svn: 90059
2009-11-29 05:52:21 +00:00
Alexis Hunt 8818b42db0 Fix 80-cols violations
llvm-svn: 90057
2009-11-29 03:04:53 +00:00
Daniel Dunbar 5fe0866b9d clang-cc: Change -fsigned-char=0 to -fno-unsigned-char and pass -pic-level using separate args.
llvm-svn: 90054
2009-11-29 02:39:08 +00:00
Daniel Dunbar 75fa84ebc6 Change LangOptions::ObjCConstantStringClass to an std::string to avoid worrying about the lifetime.
llvm-svn: 90052
2009-11-29 02:38:47 +00:00
Daniel Dunbar 9eac065e67 Move MainFileName option variable into CodeGenOptions instead of LangOptions.
llvm-svn: 90051
2009-11-29 02:38:34 +00:00
Benjamin Kramer 337e3a5fea Remove remaining VISIBILITY_HIDDEN from anonymous namespaces.
llvm-svn: 90044
2009-11-28 19:45:26 +00:00
Benjamin Kramer 26222b666c Remove VISIBILITY_HIDDEN from lib/AST.
llvm-svn: 90043
2009-11-28 19:03:38 +00:00
Kovarththanan Rajaratnam 7632da4b8a This patch adds a PUNCTUATOR macro (specialization of TOK) in TokenKinds.def and makes use of it in tok::getTokenSimpleSpelling.
llvm-svn: 90042
2009-11-28 16:09:28 +00:00
Kovarththanan Rajaratnam 930de0aeaf Cleanup llvm/Support/Compiler.h include in header files
llvm-svn: 90040
2009-11-28 16:08:10 +00:00
Nuno Lopes baa1bc44af cleanup parsing of MS integer suffixes a little. this fixes PR5616
btw, I believe that isMicrosoftInteger can go away; it's not read anywhere

llvm-svn: 90036
2009-11-28 13:37:52 +00:00
Benjamin Kramer 4e75cd063f Cleanup includes and forward decls.
llvm-svn: 90034
2009-11-28 10:50:44 +00:00
Benjamin Kramer 16634c2c5a Remove VISIBILITY_HIDDEN from anonymous namespaces in libFrontend.
llvm-svn: 90033
2009-11-28 10:07:24 +00:00
Benjamin Kramer 435ef9b383 Remove unneeded includes.
llvm-svn: 90032
2009-11-28 09:41:31 +00:00
Kovarththanan Rajaratnam b1034f7a24 Don't call exit(). llvm::llvm_report_error() will do just that
llvm-svn: 90031
2009-11-28 09:11:46 +00:00
Alexis Hunt ed0530f694 Fix test and handle IK_LiteralOperatorId in a few more places.
llvm-svn: 90030
2009-11-28 08:58:14 +00:00
Kovarththanan Rajaratnam 65c6566b5b lib/Analysis: Remove VISIBILITY_HIDDEN from definitions in anonymous namespace
llvm-svn: 90028
2009-11-28 06:07:30 +00:00
Alexis Hunt 344585006c Add Parser support for C++0x literal operators ('operator "" i').
DeclarationName can't handle them yet, so right now Parser just errors out on them.

llvm-svn: 90027
2009-11-28 04:44:28 +00:00
Eli Friedman c9e3e6ff29 Tests now pass with the assertion.
llvm-svn: 90026
2009-11-28 03:35:45 +00:00
Eli Friedman 78910a508a Add a much more thorough test of casts to virtual bases, and fix
GetCXXBaseClassOffset to actually pass the test.

llvm-svn: 90025
2009-11-28 03:31:34 +00:00
Anders Carlsson 548cc9d143 We always want to create a virtual function pointer entry if the path from the derived return value to the base overridden return value contains a virtual base class.
llvm-svn: 90024
2009-11-28 03:03:52 +00:00
Anders Carlsson d598850203 Move the vtable builder to an anonymous namespace.
llvm-svn: 90021
2009-11-27 22:21:51 +00:00
Anders Carlsson a30c0d3ace Use a PointerIntPair for the PrimaryBaseInfo. Yay for clever LLVM data structures!
llvm-svn: 90020
2009-11-27 22:14:40 +00:00
Anders Carlsson 03ff379911 Add a new PrimaryBaseInfo struct that combines the record decl of a primary base with whether it's virtual or not.
llvm-svn: 90018
2009-11-27 22:05:05 +00:00
Anders Carlsson f942ee0297 Don't build the entire vtable when all we want is the index of a virtual method.
llvm-svn: 90017
2009-11-27 20:47:55 +00:00
Eli Friedman 7eb0ccaa58 Add case for CK_DerivedToBaseMemberPointer cast kind to
AggExprEmitter::VisitCastExpr.

llvm-svn: 89988
2009-11-27 04:46:20 +00:00
Eli Friedman e96f1d3b2f More work on ScalarExprEmitter::EmitCastExpr: for every cast kind, either
implement it explicitly or assert that it doesn't make sense for a scalar.
This caught a couple interesting issues: one, CK_BaseToDerivedMemberPointer
casts were getting silently miscompiled, and two, Sema was constructing some
strange implicit casts of type CK_UserDefinedConversion.

The change in SemaExprCXX makes sure the cast kinds are getting set correctly.

llvm-svn: 89987
2009-11-27 04:41:50 +00:00
Eli Friedman 0dfc6804ff Cleanup for ScalarExprEmitter::EmitCastExpr; no functional changes.
llvm-svn: 89986
2009-11-27 02:07:44 +00:00
Eli Friedman 250534cf9a Fix for PR5594: use EmitGlobalDefinition instead of EmitCXXDestructor so that
we check whether the vtable needs to be generated.

llvm-svn: 89984
2009-11-27 01:42:12 +00:00
Anders Carlsson 5a4f772bc8 Fix thinko.
llvm-svn: 89983
2009-11-27 01:26:58 +00:00
Anders Carlsson 859d7bf2f5 When adding an implicit destructor, make sure to mark it as virtual if it overrides existing destructors.
llvm-svn: 89967
2009-11-26 21:25:09 +00:00
Anders Carlsson e985faea49 Correctly find overridden destructors.
llvm-svn: 89966
2009-11-26 20:50:40 +00:00
Anders Carlsson 323bb04ef4 Lazily create the __cxa_pure_virtual reference.
llvm-svn: 89965
2009-11-26 19:54:33 +00:00
Anders Carlsson d420a31fe9 Use the new CovariantThunkAdjustment in the vtable builder.
Make the pure virtual methods map a set instead.

llvm-svn: 89961
2009-11-26 19:32:45 +00:00
Gabor Greif d2add35d9d typo
llvm-svn: 89949
2009-11-26 15:18:50 +00:00
Gabor Greif 40762fec73 issue a friendlier error if someone tries to send precompiled header to '-' (stdout)
this brings the error on
  clang -c foo.h -o -
closer to
  clang -c foo.h -o /dev/null

llvm-svn: 89948
2009-11-26 14:35:28 +00:00
Benjamin Kramer 334af99964 Remove dead forward declaration. Fix struct/class mismatch. Remove trailing whitespace.
llvm-svn: 89947
2009-11-26 13:09:03 +00:00
Daniel Dunbar 7ab5c491c1 Remove header which is bringing libAST in (on MSVC).
llvm-svn: 89946
2009-11-26 09:57:25 +00:00
Eli Friedman 4907c6f2ed Remove unused variable.
llvm-svn: 89945
2009-11-26 07:48:44 +00:00
Eli Friedman ffc066f4b9 Shortcut explicit calls to a trivial copy assignment operator.
llvm-svn: 89944
2009-11-26 07:45:48 +00:00
Eli Friedman 84a7e347bf Simplify and fix up the handling of implicit constructors, copy assignment
operators, and destructors.  Avoids generating declarations/definitions of
trivial constructors/destructors, and makes sure the trivial copy assignment
operator is generated when necessary.

llvm-svn: 89943
2009-11-26 07:40:08 +00:00
Ted Kremenek 2350e0c3ba Improve diagnostics in ReturnStackAddressChecker for returning a stack-allocated block. Implements the rest of <rdar://problem/7387385>.
llvm-svn: 89940
2009-11-26 07:14:50 +00:00
Eli Friedman d15eb34d4b Implement IRGen for MemberExpr referring to static member function.
llvm-svn: 89938
2009-11-26 06:08:14 +00:00
Anders Carlsson 6d771bcd09 Add a Thunk struct to the vtable builder.
llvm-svn: 89935
2009-11-26 03:25:13 +00:00
Eli Friedman cb422f1dbe Use the more general Evaluate infrastructure for folding constant DeclRefs
instead of checking explicitly for an EnumConstantDecl.  This folds references
to constant integer VarDecls, which has two benefits:

1. Slightly smaller emitted code from emitting a constant instead of a load,
and skipping emitting some constant globals.
2. Some code forgets to define static constant member variables; emitting a
load instead of the value in that case leads to a link error. (Such programs
are technically not well-formed, but in practice build with g++.)

llvm-svn: 89934
2009-11-26 03:22:21 +00:00
Anders Carlsson 2f87c4f1a5 Add a CovariantThunkAdjustment struct that represents the adjustments needed for a covariant thunk.
llvm-svn: 89933
2009-11-26 03:09:37 +00:00
Eli Friedman f873c2fb68 Slight tweak to the algorithm for getLinkage().
llvm-svn: 89932
2009-11-26 03:04:01 +00:00
Eli Friedman 8a5f75ed5d Use new getLinkage() method to correctly compute whether a variable has
internal linkage.  Fixes PR5433.

llvm-svn: 89931
2009-11-26 02:52:12 +00:00
Anders Carlsson abe274a8b0 Move the mangler into the CodeGen namespace. Change mangleThunk to take a ThunkAdjustment.
llvm-svn: 89930
2009-11-26 02:49:32 +00:00
Ted Kremenek f89dcdaf19 Add a PostVisitBlockExpr() method to RetainReleaseChecker to query for
the set of variables "captured" by a block.  Until the analysis gets
more sophisticated, for now we stop the retain count tracking of any
objects (transitively) referenced by these variables.

llvm-svn: 89929
2009-11-26 02:38:19 +00:00
Ted Kremenek 94f8c4a7d5 Teach RegionStoreManager::RemoveDeadBindings() about BlockDataRegions. Any VarRegion for a "captured" variable should also be considered live.
llvm-svn: 89928
2009-11-26 02:35:42 +00:00
Ted Kremenek 3378b610ae Add iterators to BlockDataRegion that allow clients to iterate over the VarRegions for "captured" variables for a block.
llvm-svn: 89927
2009-11-26 02:34:36 +00:00
Ted Kremenek 705fd953ef Added batch versions of GRState::scanReachableSymbols() so that clients can scan a collection of SVals or MemRegions all at once.
llvm-svn: 89926
2009-11-26 02:32:19 +00:00
Anders Carlsson c778540f9a Add a ThunkAdjustment struct which holds a non-virtual and a virtual adjustment offset. Start using it. General cleanup in Mangle.cpp.
llvm-svn: 89925
2009-11-26 02:32:05 +00:00
Ted Kremenek 0f5e6f8805 Enhance LiveVariables to understand that blocks can extend the liveness of a variable by "capturing" them in a BlockExpr.
This required two changes:

1) Added 'getReferencedgetReferencedBlockVars()' to AnalysisContext so
that clients can iterate over the "captured" variables in a block.

2) Modified LiveVariables to take an AnalysisContext& in its
constructor and to call getReferencedgetReferencedBlockVars() when it
processes a BlockExpr*.

llvm-svn: 89924
2009-11-26 02:31:33 +00:00
Daniel Dunbar e0d81f2237 Factor out a LangStandard class and coalesce the information about the standards into LangStandards.def
- I'd appreciate another pair of eyeballs to double check this.

llvm-svn: 89919
2009-11-26 02:14:31 +00:00
Daniel Dunbar 5337f0c842 Fix thinko (-fno-builtin != -nobuiltininc).
llvm-svn: 89918
2009-11-26 02:14:16 +00:00
Daniel Dunbar 81fe60b787 Add clang -cc1 parsing for preprocessor options.
llvm-svn: 89917
2009-11-26 02:14:07 +00:00
Daniel Dunbar cbc693579c Add clang -cc1 parsing for header search options.
llvm-svn: 89916
2009-11-26 02:13:54 +00:00
Douglas Gregor ff790f15c4 Refactor our handling of expression evaluation contexts, so that Sema
maintains a stack of evaluation contexts rather than having the parser
do it. This change made it simpler to track in which contexts
temporaries were created, so that we could...

"Forget" about temporaries created within unevaluated contexts, so
that we don't build a CXXExprWithTemporaries and, therefore, destroy
the integral-constness of our expressions. Fixes PR5609.

llvm-svn: 89908
2009-11-26 00:44:06 +00:00
Ted Kremenek 1646cf6d05 Add missing case in switch statement.
llvm-svn: 89903
2009-11-25 23:58:21 +00:00
Ted Kremenek b63ad7a6c1 Refine MemRegions for blocks. Add a new region called
'BlockDataRegion' to distinguish between the code associated with a
block (which is represented by 'BlockTextRegion') and an instance of a
block, which includes both code and data.  'BlockDataRegion' has an
associated LocationContext, which can be used to eventually model the
lifetime of a block object once LocationContexts can represent scopes
(and iterations around a loop, etc.).

llvm-svn: 89900
2009-11-25 23:53:07 +00:00
Ted Kremenek 80f70b54aa Remove recently added FIXME. The appropriate FIXME is already in MemRegionManager::getVarRegion().
llvm-svn: 89897
2009-11-25 23:30:34 +00:00
Fariborz Jahanian 04b258cc9e Allow user re-definition of SEL as well as accessing its fields.
This fixes pr5611.

llvm-svn: 89895
2009-11-25 23:07:42 +00:00
John Thompson 5bc5cbe2a2 Fix attribute between function decl ')' and '{' or '=0'
llvm-svn: 89894
2009-11-25 22:58:06 +00:00
Ted Kremenek a3d6e62003 Add FIXME.
llvm-svn: 89892
2009-11-25 22:41:34 +00:00
Douglas Gregor f73b282bf0 Implement the rules in C++ [basic.link] and C99 6.2.2 for computing
the linkage of a declaration. Switch the lame (and completely wrong)
NamedDecl::hasLinkage() over to using the new NamedDecl::getLinkage(),
along with the "can this declaration be a template argument?" check
that started all of this.

Fixes -fsyntax-only for PR5597.

llvm-svn: 89891
2009-11-25 22:24:25 +00:00
Ted Kremenek e6929ffc21 Add post-visit Checker support in GRExprEngine for BlockExpr.
llvm-svn: 89890
2009-11-25 22:23:25 +00:00
Ted Kremenek 70a8788368 Add a new RetainReleaseChecker class (that subclasses CheckerVisitor) to extend the functionality of the retain/release checker using the new Checker interface. Pieces of CFRefCount will gradually be migrated to this new class over time.
llvm-svn: 89889
2009-11-25 22:17:44 +00:00
Ted Kremenek 945422794b Move RegisterChecks() to the end of the file. No functionality change.
llvm-svn: 89888
2009-11-25 22:08:49 +00:00
Ted Kremenek de820039b6 Call GRExprEngine::setTransferFunctions() after registering all Checkers. This allows GRTransferFuncs::RegisterChecks() to always be called after all checkers have been registered.
llvm-svn: 89887
2009-11-25 21:58:39 +00:00
Ted Kremenek 916061f613 Consolidate logic in ActionInlineCall by having it call ActionGRExprEngine instead of replicating most of its logic (and missing pieces).
llvm-svn: 89886
2009-11-25 21:55:23 +00:00
Fariborz Jahanian f82ec6dd2f Better diagnostic on deleted constructor when no
initializer name is available.

llvm-svn: 89885
2009-11-25 21:53:11 +00:00
Ted Kremenek d0fe8047dd Make RegisterInternalChecks() part of GRExprEngine's private implementation by making it a static function within GRExprEngine.cpp.
llvm-svn: 89884
2009-11-25 21:51:20 +00:00
Ted Kremenek efb5003f95 Register internal checks with GRExprEngine when it is constructed, not manually in AnalysisConsumer.cpp.
llvm-svn: 89883
2009-11-25 21:45:48 +00:00
Ted Kremenek acdc817ed9 When dispatching to Checker objects in GRExprEngine::CheckerVisit(),
only stop processing the checkers after all the nodes for a current
check have been processed.  This (I believe) handles the case where
PredSet (the input nodes) contains more than one node due to state
bifurcation.  Zhongxing: can you review this?

llvm-svn: 89882
2009-11-25 21:40:22 +00:00
Douglas Gregor 5c80a27ba2 Implement support for default template arguments of function templates.
llvm-svn: 89874
2009-11-25 18:55:14 +00:00
Douglas Gregor ed5731f68a Diagnose ill-formed uses of default template arguments in
function templates (in C++98), friend function templates, and
out-of-line definitions of members of class templates.

Also handles merging of default template arguments from previous
declarations of function templates, for C++0x. However, we don't yet
make use of those default template arguments.

llvm-svn: 89872
2009-11-25 17:50:39 +00:00
Devang Patel 58bf6e1885 Use StringRef (again) in DebugInfo interface.
llvm-svn: 89867
2009-11-25 17:37:31 +00:00
Douglas Gregor 7fdcbaf291 Fix a thinko where we weren't always performing unary conversions on the switch condition, fixing PR5612
llvm-svn: 89864
2009-11-25 15:17:36 +00:00
Daniel Dunbar 44b36ee78c What the FIXMEs want, the FIXMEs shall have.
llvm-svn: 89861
2009-11-25 11:53:23 +00:00
Daniel Dunbar b8c2f7d950 Add an arg_iterator, for iterating over a subset of arguments in an ArgList.
llvm-svn: 89860
2009-11-25 11:33:30 +00:00
Daniel Dunbar 750246255d Fix some uses of fprintf/stderr without a prototype.
llvm-svn: 89858
2009-11-25 10:27:48 +00:00
Daniel Dunbar ad2278d74c Add clang -cc1 parsing for frontend options.
llvm-svn: 89856
2009-11-25 10:14:52 +00:00
Daniel Dunbar 9efcf351bd Add clang -cc1 parsing for preprocessor output options (-E).
llvm-svn: 89854
2009-11-25 10:14:37 +00:00
Daniel Dunbar 5bdd299bfd Don't pass -fexceptions=0 (it is the default).
llvm-svn: 89853
2009-11-25 10:14:30 +00:00
Edward O'Callaghan c92791193d Fix for Path::isSpecialFile to Path::isRegularFile API in rev 89765.
llvm-svn: 89849
2009-11-25 06:33:27 +00:00
Douglas Gregor 3ff3af4ff9 When the condition of a switch() statement is semantically invalid,
still parse the body of the switch to try to avoid spurious
diagnostics. Fixes PR5606.

llvm-svn: 89847
2009-11-25 06:20:02 +00:00
Douglas Gregor 0681a35f5f Don't crash when we re-use a template specialization node for an explicit instantiation. lib/Support/CommandLine.cpp is our test case
llvm-svn: 89845
2009-11-25 06:01:46 +00:00
Douglas Gregor 110755548b Refactor ActOnFinishSwitchStmt to simplify it further
llvm-svn: 89843
2009-11-25 05:02:21 +00:00
Douglas Gregor 852d53e712 Refactor ActOnFinishSwitchStmt to simplify and reduce nesting
llvm-svn: 89842
2009-11-25 04:55:54 +00:00
Alexis Hunt 54a0254887 Parse C++ member check attributes - base_check, hiding, and override.
The attributes are currently ignored.

llvm-svn: 89837
2009-11-25 04:20:27 +00:00
Anders Carlsson 82ba57c8f0 Add VTT parameter to base ctors/dtors with virtual bases. (They aren't used yet).
llvm-svn: 89835
2009-11-25 03:15:49 +00:00
Douglas Gregor 3d9e90ae3e Implement proper cleanup semantics for condition variables in for
statements, e.g., 

  for(; X x = X(); ) { ... }  

Daniel or Anders, please review!

llvm-svn: 89832
2009-11-25 01:51:31 +00:00
Ted Kremenek e6a2780c96 Add really basic support for blocks in the retain/release checker. For now, anytime we pass a tracked object to a block call we stop tracking it.
llvm-svn: 89831
2009-11-25 01:35:18 +00:00
Ted Kremenek 470bfa47db Allow building of CFGs for ASTs that contain BlockExprs.
llvm-svn: 89830
2009-11-25 01:34:30 +00:00
Ted Kremenek cfe223f637 Add transfer function support for BlockExpr.
llvm-svn: 89829
2009-11-25 01:33:13 +00:00
Ted Kremenek 10a50e7371 Split CodeTextRegion into FunctionTextRegion and BlockTextRegion. This a precursor to having basic static analysis support for blocks.
llvm-svn: 89828
2009-11-25 01:32:22 +00:00
Fariborz Jahanian 906d871e6c Some fancy footwork to move the decision on how
to build casted expression-list AST to Sema.

llvm-svn: 89827
2009-11-25 01:26:41 +00:00
Douglas Gregor 7bab5ff8e7 Eliminate CXXConditionDeclExpr with extreme prejudice.
All statements that involve conditions can now hold on to a separate
condition declaration (a VarDecl), and will use a DeclRefExpr
referring to that VarDecl for the condition expression. ForStmts now
have such a VarDecl (I'd missed those in previous commits).

Also, since this change reworks the Action interface for
if/while/switch/for, use FullExprArg for the full expressions in those
expressions, to ensure that we're emitting

Note that we are (still) not generating the right cleanups for
condition variables in for statements. That will be a follow-on
commit.

llvm-svn: 89817
2009-11-25 00:27:52 +00:00
Sebastian Redl d6f7850117 Have the parser tell sema whether a member declaration is a function definition. This allows sema to not emit spurious diagnostics in some invalid code.
llvm-svn: 89816
2009-11-24 23:38:44 +00:00
Ted Kremenek 1fc1f20efd For the nil-receiver checker, take into account the behavioral changes that got introduced in Mac OS X 10.5 and later, notably return values of double, float, etc., will not be garbage. Fixes <rdar://problem/6829160>.
llvm-svn: 89809
2009-11-24 22:48:18 +00:00
Ted Kremenek 005e8a06f2 Cleanups and fixes to the nil-receiver checker, some of it fallout the
initial transition of the nil-receiver checker to the Checker
interface as done in r89745.  Some important changes include:

1) We consolidate the BugType object used for nil receiver bug
reports, and don't include the type of the returned value in the
BugType (which would be wrong if a nil receiver bug was reported more
than once)

2) Added a new (temporary) flag to CheckerContext: DoneEvauating.
This is used by GRExprEngine when evaluating message expressions to
not continue evaluating the message expression if this flag is set.
This flag is currently set by the nil receiver checker.  This is an
intermediate solution to allow the nil-receiver checker to properly
work as a plug-in outside of GRExprEngine.  Basically, this flag
indicates that the entire message expression has been evaluated, not
just a precondition (which is what the nil-receiver checker does).
This flag *should not* be repurposed for general use, but just to pull
more things out of GRExprEngine that already in there as we devise a
better interface in the Checker class.

3) Cleaned up the logic in the nil-receiver checker, making the
control-flow a lot easier to read.

llvm-svn: 89804
2009-11-24 21:41:28 +00:00
Fariborz Jahanian 4fa66ce244 Refactor argument collection of constructor calls using
the common routine.

llvm-svn: 89802
2009-11-24 21:37:28 +00:00
Douglas Gregor 7f800f9d50 "Do" loops cannot have condition variables, so don't parse them.
llvm-svn: 89801
2009-11-24 21:34:32 +00:00
Douglas Gregor 680f861d74 Clean up the AST for while loops and fix several problems with
cleanups for while loops: 

1) Make sure that we destroy the condition variable of a while statement each time through the loop for, e.g.,

   while (shared_ptr<WorkInt> p = getWorkItem()) {
         // ...
         }

2) Make sure that we always enter a new cleanup scope for the body of the while loop, even when there is no compound expression, e.g.,

   while (blah)
     RAIIObject raii(blah+1);

llvm-svn: 89800
2009-11-24 21:15:44 +00:00
Anders Carlsson 3c9beab48a Handle references correctly when synthesizing copy constructors.
With this change, the clang-on-clang test result is now

Expected Passes    : 224
Unexpected Failures: 37

Which means that we can compile over 80% of clang with clang! :)

llvm-svn: 89799
2009-11-24 21:08:10 +00:00
John McCall 45b1a47a9c Fix some major problems dealing with dependently-qualified names in implicit
member-reference contexts.  Fixes some clang-on-clang asserts.

llvm-svn: 89796
2009-11-24 20:33:45 +00:00
Fariborz Jahanian 6f2d25e441 More cleanup of argument call collection.
llvm-svn: 89789
2009-11-24 19:27:49 +00:00
John McCall e66edc18ae Rip out TemplateIdRefExpr and make UnresolvedLookupExpr and
DependentScopeDeclRefExpr support storing templateids.  Unite the common   
code paths between ActOnDeclarationNameExpr and ActOnTemplateIdExpr.

This gets us to a point where we don't need to store function templates in
the AST using TemplateNames, which is critical to ripping out OverloadedFunction.

Also resolves a few FIXMEs.

llvm-svn: 89785
2009-11-24 19:00:30 +00:00
Anders Carlsson 3a202f601e Handle cases where we're constructing an array of objects and the constructor has default arguments.
llvm-svn: 89783
2009-11-24 18:43:52 +00:00
John McCall 847e2a10d6 Helper function for turning a TemplateName into a DeclarationName.
llvm-svn: 89782
2009-11-24 18:42:40 +00:00
Fariborz Jahanian 835026e9f1 Refactor collection of call arguments in common code.
Add support for variadic collection functions. More to do
here.

llvm-svn: 89781
2009-11-24 18:29:37 +00:00
Anders Carlsson 0b11a3ef71 GNUNullExpr is a valid sentinel even though it isn't of pointer type.
llvm-svn: 89778
2009-11-24 17:24:21 +00:00
Douglas Gregor dcf1962405 Explicitly store the condition variable within switch statements, and
make sure that this variable is destroyed when we exit the switch
statement.

llvm-svn: 89776
2009-11-24 17:07:59 +00:00
Anders Carlsson b9f96a3286 We always need to emit the base expression of a member expression, even when the member decl refers to an enum. Thanks to Eli for pointing this out!
llvm-svn: 89775
2009-11-24 16:57:33 +00:00
Anders Carlsson b7408b95ed Fix a crash when "instantiating" VarDecls that are neither type nor value dependent.
llvm-svn: 89774
2009-11-24 16:52:50 +00:00
Douglas Gregor 965f450d42 Introduce cleanup scopes for "if" statements in two places:
- Outside the "if", to ensure that we destroy the condition variable
    at the end of the "if" statement rather than at the end of the
    block containing the "if" statement.
  - Inside the "then" and "else" branches, so that we emit then- or
    else-local cleanups at the end of the corresponding block when the
    block is not a compound statement.

To make adding these new cleanup scopes easier (and since
switch/do/while will all need the same treatment), added the
CleanupScope RAII object to introduce a new cleanup scope and make
sure it gets cleaned up.

llvm-svn: 89773
2009-11-24 16:43:22 +00:00
Douglas Gregor 48a409eb39 Rename CleanupScope -> DelayedCleanupBlock. No functionality change.
llvm-svn: 89769
2009-11-24 16:21:10 +00:00
Douglas Gregor 0156d1c8db Un-break instantiation of if statements with conditional variables
llvm-svn: 89767
2009-11-24 16:07:02 +00:00
Edward O'Callaghan db521ec23b Fix for PR5568.
llvm-svn: 89766
2009-11-24 15:23:21 +00:00
Zhongxing Xu c2998766f0 We can remove this file now.
llvm-svn: 89751
2009-11-24 08:28:49 +00:00
Zhongxing Xu c6123a1a3c Refactor undefined result checker. This is the last one.
llvm-svn: 89750
2009-11-24 08:24:26 +00:00
Zhongxing Xu 9e200798c2 Refactor NilReceiverStructRet and NilReceiverLargerThanVoidPtrRet into
CallAndMessageChecker.

llvm-svn: 89745
2009-11-24 07:06:39 +00:00
Anders Carlsson 59486a2ddb Get rid of the ugly CGCXX names and replace them with CGClass, CGExprCXX and CGTemporaries.
llvm-svn: 89742
2009-11-24 05:51:11 +00:00
Anders Carlsson bd97548f35 When mangling a ctor/dtor we need to take into consideration whether it's a member template.
llvm-svn: 89741
2009-11-24 05:36:32 +00:00
Anders Carlsson 65e6d131f0 Set the template specialization kind before instantiating the function definition so that the function will have the right linkage.
llvm-svn: 89740
2009-11-24 05:34:41 +00:00
Eli Friedman fb8a93fe1d Teach Evaluate to handle member expressions referring to enum constants and
static member constants. No significant visible difference at the moment
because it conservatively assumes the base has side effects. I'm planning to
use this for CodeGen.

llvm-svn: 89738
2009-11-24 05:28:59 +00:00
Anders Carlsson 0ade9715f2 Ignore constructor member templates in CodeGenModule::EmitTopLevelDecl.
llvm-svn: 89737
2009-11-24 05:16:24 +00:00
Anders Carlsson 6445773279 It is common for vtables to contain pointers to functions that have either incomplete return types or incomplete argument types.
Handle this by returning the llvm::OpaqueType for those cases, which CodeGenModule::GetOrCreateLLVMFunction knows about, and treats as being an "incomplete function".

llvm-svn: 89736
2009-11-24 05:08:52 +00:00
Zhongxing Xu 72269ec8cb rename UndefinedArgChecker to CallAndMessageChecker.
llvm-svn: 89735
2009-11-24 04:45:44 +00:00
Zhongxing Xu da32375115 Rename: UndefinedArgChecker.cpp => CallAndMessageChecker.cpp
llvm-svn: 89734
2009-11-24 04:08:01 +00:00
Ted Kremenek c0229557dd Enhance null dereference diagnostics by indicating what variable (if any) was dereferenced. Addresses <rdar://problem/7039161>.
llvm-svn: 89726
2009-11-24 01:33:10 +00:00
Daniel Dunbar 8d731964d0 Sketch the rest of the clang -cc1 option definitions, aka fun with C-x C-(.
llvm-svn: 89721
2009-11-24 00:54:16 +00:00
Douglas Gregor 633caca353 Explicitly track the condition variable within an "if" statement,
rather than burying it in a CXXConditionDeclExpr (that occassionally
hides behind implicit conversions). Similar changes for
switch, while, and do-while will follow, then the removal of
CXXConditionDeclExpr. This commit is the canary.

llvm-svn: 89717
2009-11-23 23:44:04 +00:00
Daniel Dunbar 8a9fa3af69 Add clang -cc1 parsing of diagnostic options.
llvm-svn: 89716
2009-11-23 23:41:17 +00:00
Ted Kremenek b0c0b08c71 After performing a bounds check in ArrayBoundChecker, record the fact that a bounds check succeeded by transitioning the ExplodedGraph.
llvm-svn: 89712
2009-11-23 23:23:26 +00:00
Ted Kremenek f57351570e Clean up the Checker API a little more, resolving some hidden bugs
along the way.  Important changes:

1) To generate a sink node, use GenerateSink(); GenerateNode() is for
generating regular transitions.  This makes the API clearer and also
allows us to use the 'bool' option to GenerateNode() for a different
purpose.

2) GenerateNode() now automatically adds the generated node to the
destination ExplodedNodeSet (autotransition) unless the client
specifies otherwise with a bool flag.  Several checkers did not call
'addTransition()' after calling 'GenerateNode()', causing the
simulation path to be prematurely culled when a non-fail stop bug was
encountered.

3) Add variants of GenerateNode()/GenerateSink() that take neither a
Stmt* or a GRState*; most callers of GenerateNode() just pass in the
same Stmt* as provided when the CheckerContext object is created; we
can just use that the majority of the time.  This cleanup also allows
us to potentially coelesce the APIs for evaluating branches and
end-of-paths (which currently directly use builders).

4) addTransition() no longer needs to be called except for a few
cases.  We now have a variant of addTransition() that takes a
GRState*; this allows one to propagate the updated state without
caring about generating a new node explicitly.  This nicely cleaned up
a bunch of cases that called autoTransition() with a bunch of
conditional logic surround the call (that common logic has now been
swallowed up by addTransition() itself).

llvm-svn: 89707
2009-11-23 22:22:01 +00:00
Anders Carlsson f2e4f72f03 Don't try to treat an enum constant as an lvalue.
llvm-svn: 89705
2009-11-23 21:56:41 +00:00
Anders Carlsson 2e7bc11f11 Convert the && and || operands to bool using standard conversions. Fixes PR5593.
llvm-svn: 89704
2009-11-23 21:47:44 +00:00
Fariborz Jahanian d25c219475 Fixe a crash in encoding of SEL type caused by recent changes.
llvm-svn: 89696
2009-11-23 20:40:50 +00:00
Anders Carlsson 7fa434c2b8 Handle converting member pointers to bool.
llvm-svn: 89692
2009-11-23 20:04:44 +00:00
Fariborz Jahanian 3f21c159dc Fix a recent regression probably caused by addition of altivec-style
type-casts in the parser.

llvm-svn: 89691
2009-11-23 19:51:43 +00:00
Ted Kremenek b43737387b Provide out-of-line definition for destructor of Checker.
llvm-svn: 89688
2009-11-23 18:53:03 +00:00
Ted Kremenek 02d6aca867 Tweak UndefBranchChecker to register the most nested "undefined" expression with bugreporter::registerTrackNullOrUndefValue instead of the condition itself.
llvm-svn: 89682
2009-11-23 18:12:03 +00:00
Fariborz Jahanian 0afc555196 Make 'SEL' pointer to a builtin type and not an
objective-c pointer type. This was a serious mishap and
luckily, Ted's test caught that (and patch fixes the test case).

llvm-svn: 89680
2009-11-23 18:04:25 +00:00
Ted Kremenek d4dca6fde6 Cleanup title/description of "undefined branch" BugType and add some test cases for this check.
llvm-svn: 89679
2009-11-23 17:58:48 +00:00
Anders Carlsson 8c793172c2 Handle base-to-derived casts. Will land test case shortly.
llvm-svn: 89678
2009-11-23 17:57:54 +00:00
John Thompson d976d3e552 Put back hard-coded paths for win32 until I figure out what happened to failed tests.
llvm-svn: 89677
2009-11-23 17:49:27 +00:00
Sebastian Redl 22e2e5c423 Intercept sizeof and alignof references before they get into ASTContext methods. This fixes a crash when writing sizeof(Incomplete&), and lets ASTContext's methods do the right thing for CodeGen, which fixes PR5590.
llvm-svn: 89668
2009-11-23 17:18:46 +00:00
Rafael Espindola 962e518da2 Reorder the header search a bit so that it matches gcc exactly:
*) the ../backward dir is the last in libstdc++ to be searched
*) If compiling c++, the c++ headers are searched first

llvm-svn: 89661
2009-11-23 16:31:19 +00:00
Sebastian Redl a6602e9e2a Let using directives refer to namespace aliases. Fixes PR5479.
llvm-svn: 89657
2009-11-23 15:34:23 +00:00