Commit Graph

10352 Commits

Author SHA1 Message Date
Daniel Dunbar f680e7d855 Kill a few more random stderr uses.
llvm-svn: 90441
2009-12-03 09:14:02 +00:00
Daniel Dunbar 7230fa5630 Convert ABIArgInfo::dump to raw_ostream.
llvm-svn: 90440
2009-12-03 09:13:49 +00:00
Daniel Dunbar f5bda7b5eb Use llvm_report_error instead of fprintf + assert + exit.
llvm-svn: 90438
2009-12-03 09:13:36 +00:00
Daniel Dunbar 7554699afa Fix CompilerInstance::createOutputFile to use proper diagnostics, and (try to) update all clients to be able to handle failure.
llvm-svn: 90437
2009-12-03 09:13:30 +00:00
Daniel Dunbar 692bc47d25 Remove an unnecessary (I believe) exit() on error.
llvm-svn: 90436
2009-12-03 09:13:19 +00:00
Daniel Dunbar 34a96c842a Convert StmtDumper to raw_ostream. I forget why.
llvm-svn: 90435
2009-12-03 09:13:13 +00:00
Daniel Dunbar 3b95148ce1 Switch PCHReader::getOriginalSourceFile to use proper diagnostics.
llvm-svn: 90434
2009-12-03 09:13:06 +00:00
Daniel Dunbar acadc55d4e Fix BackendConsumer to use proper diagnostics.
llvm-svn: 90433
2009-12-03 09:12:54 +00:00
Ted Kremenek 5bee5c4ff0 Add value invalidation logic for block-captured variables. Conceptually invoking a block (without specific reasoning of what the block does) can invalidate any value to it by reference when the block was created.
llvm-svn: 90431
2009-12-03 08:25:47 +00:00
Ted Kremenek 4a815fc82e Make BlockDataRegion::referenced_vars_iterator an actual class that enforces that all MemRegions iterated over are VarRegions.
llvm-svn: 90430
2009-12-03 08:09:21 +00:00
Anders Carlsson c6089fda20 Attempt to fix the MSVC build.
llvm-svn: 90427
2009-12-03 07:30:40 +00:00
Daniel Dunbar 19a30ca8c0 Fix layering violation by moving Analysis/CallGraph to Index
llvm-svn: 90424
2009-12-03 07:20:04 +00:00
Daniel Dunbar 215ca5f199 clang-cc: Honor -help and -version when using new style option parsing.
llvm-svn: 90422
2009-12-03 07:01:58 +00:00
Daniel Dunbar 65b9952c2e Add OptTable::PrintHelp.
llvm-svn: 90420
2009-12-03 07:01:38 +00:00
Daniel Dunbar 6048e7fdc0 Add clang -cc1 support for -remap-file.
llvm-svn: 90414
2009-12-03 05:11:16 +00:00
Daniel Dunbar da7a52289f Add clang -cc1 -load option.
llvm-svn: 90413
2009-12-03 05:11:05 +00:00
Eli Friedman 4039f35344 Fix thunk generation for thunks with a parameter with reference type.
llvm-svn: 90412
2009-12-03 04:49:52 +00:00
Eli Friedman 551fe84d0e Minor cleanup.
llvm-svn: 90411
2009-12-03 04:27:05 +00:00
John McCall 6e9f8f6374 Honor using declarations in overload resolution. Most of the code for
overloaded-operator resolution is wildly untested, but the parallel code for
methods seems to satisfy some trivial tests.

Also change some overload-resolution APIs to take a type instead of an expression,
which lets us avoid creating a spurious CXXThisExpr when resolving implicit
member accesses.

llvm-svn: 90410
2009-12-03 04:06:58 +00:00
Mike Stump e2d4a2c3a8 Add support for thunking dtors. Oh why does this make my head hurt?
llvm-svn: 90409
2009-12-03 03:47:56 +00:00
Mike Stump 2842b4cf86 Reflow.
llvm-svn: 90407
2009-12-03 03:40:14 +00:00
Anders Carlsson dabfa3cd8b Revert r90402 for now, virt.cpp is failing.
llvm-svn: 90406
2009-12-03 03:28:24 +00:00
Ted Kremenek e5716cbae7 Add batch version of 'StoreManager::InvalidateRegion()' for invalidating multiple regions as once. After adopting this in the CFRefCount::EvalCall(), we see a reduction in analysis time of 1.5% when analyzing all of SQLite3.
llvm-svn: 90405
2009-12-03 03:27:11 +00:00
Anders Carlsson e692f7c309 Use Eli's ComputeThunkAdjustment for calculating the return adjustment.
llvm-svn: 90402
2009-12-03 03:15:31 +00:00
Anders Carlsson 5f91fd64b6 Add CodeGenModule::ComputeThunkAdjustment, which Eli wrote.
llvm-svn: 90401
2009-12-03 03:06:55 +00:00
Anders Carlsson 80bc5d5d04 Remove the index from the Thunk struct.
llvm-svn: 90400
2009-12-03 02:41:55 +00:00
Anders Carlsson 29a1f751b3 Change the Thunks map to use the vtable index as the key.
llvm-svn: 90399
2009-12-03 02:39:59 +00:00
Anders Carlsson 0e1e7632bc Add the global decl to the Thunk struct.
llvm-svn: 90398
2009-12-03 02:36:40 +00:00
Anders Carlsson 9f98f7a9e5 Remove unused struct fields.
llvm-svn: 90397
2009-12-03 02:34:59 +00:00
Anders Carlsson 657f139abe Delay computing the return adjustments for covariant thunks until when they are added to the vtable.
llvm-svn: 90396
2009-12-03 02:32:59 +00:00
Anders Carlsson 2ca285fc5c No need to create the covariant thunk in both places now.
llvm-svn: 90394
2009-12-03 02:22:59 +00:00
Anders Carlsson 1157e8fc68 Whoops, forgot to save :)
llvm-svn: 90393
2009-12-03 02:20:26 +00:00
Anders Carlsson 06c14b6f65 Remove the index field from the CovariantThunk structure.
llvm-svn: 90392
2009-12-03 02:16:14 +00:00
Anders Carlsson 73295f96c5 Change the CovariantThunk map to use the vtable index as its key.
llvm-svn: 90391
2009-12-03 02:12:03 +00:00
Anders Carlsson c38b40a709 Store a GlobalDecl in the return adjustment.
llvm-svn: 90387
2009-12-03 02:03:29 +00:00
Anders Carlsson 2bd3c0fa34 Do not include the 'this' pointer adjustment in the covariant return type. Instead, store it in the (now oddly named) Thunks map.
llvm-svn: 90386
2009-12-03 01:58:20 +00:00
Anders Carlsson ca1bf68cfb Move VtableBuilder::OverrideMethod out of line in preparation of other changes to it. No functionality change.
llvm-svn: 90382
2009-12-03 01:54:02 +00:00
Daniel Dunbar 59203007ac Fix ASTUnit to allows require a (persistent) Diagnostic object be provided; propogate and simplify.
llvm-svn: 90379
2009-12-03 01:45:44 +00:00
Ted Kremenek 5ef26fb4fd Add 'has_feature(cxx_exceptions)' to allow code to determine via preprocessor logic if C++ exceptions are enabled.
llvm-svn: 90378
2009-12-03 01:34:15 +00:00
Mike Stump 26ada867ba Remove untrue statement.
llvm-svn: 90377
2009-12-03 01:34:13 +00:00
Ted Kremenek c3fe01943f Rename has_feature(rtti) to has_feature(cxx_rtti) for clarity.
llvm-svn: 90376
2009-12-03 01:31:28 +00:00
Mike Stump 59daccda08 Note a failure I saw from the g++ testsuite:
FAIL: g++.old-deja/g++.mike/eh23.C (test for excess errors)

llvm-svn: 90374
2009-12-03 01:22:05 +00:00
Ted Kremenek 4bc256ec9d Add "has_feature" support for C++ RTTI.
llvm-svn: 90368
2009-12-03 01:02:35 +00:00
John McCall 800538253d Stop stripping UnresolvedUsingDecls out of LookupResults that have other
results in them (which we were doing intentionally as a stopgap).  Fix
an DeclContext lookup-table ordering problem which was causing UsingDecls to
show up incorrectly when looking for ordinary results.  And oh hey
Clang-Code-Syntax passes now.

llvm-svn: 90367
2009-12-03 00:58:24 +00:00
Ted Kremenek f66b72094a Add a heuristic to the dead stores checker to prune dead stores for variables annotated with '__block'. This is overly conservative, but now the analyzer doesn't report dead stores for variables that can be updated by a block call.
llvm-svn: 90364
2009-12-03 00:46:16 +00:00
Sebastian Redl 79eba1ca3b Introduce the notion of literal types, as specified in C++0x.
llvm-svn: 90361
2009-12-03 00:13:20 +00:00
Eli Friedman 37e4c41283 Work-in-progress: teach mangler how to mangle thunks for destructors.
llvm-svn: 90360
2009-12-03 00:03:05 +00:00
Mike Stump 2d52ce5f94 Cleanups on exceptional edges don't work at all, yet. This doesn't
catch very many of them and if we caught all of them, the errors would
be annoying.  I'm working on this next.  WIP.

llvm-svn: 90358
2009-12-02 23:46:02 +00:00
Mike Stump 90990965e0 Add a cleanup scope for each catch clause.
llvm-svn: 90357
2009-12-02 23:37:16 +00:00
Mike Stump a68e2a2967 Add missing branch to exit. Seemingly obvious when I look at the
code, but to track this down was laborious.

llvm-svn: 90356
2009-12-02 23:28:08 +00:00
Douglas Gregor c8c44b5d67 Improve source location information for C++ member initializers in a
constructor, by keeping the DeclaratorInfo* rather than just the type
and a single location.

llvm-svn: 90355
2009-12-02 22:36:29 +00:00
Daniel Dunbar a18f9580e4 ASTUnit: Explicitly track whether the ASTUnit came from an actual AST or not.
llvm-svn: 90349
2009-12-02 21:47:43 +00:00
Daniel Dunbar 4897349a79 ASTUnit: Fix initialization of OnlyLocalDecls variable, and honor UseBumpAllocator.
llvm-svn: 90348
2009-12-02 21:47:32 +00:00
Eli Friedman d4df7753d2 Fix for PR5522 and PR5666: fix a bunch of mangling issues with extern variables
and funcctions declared locally within a function.

llvm-svn: 90344
2009-12-02 20:32:49 +00:00
John McCall 5af0450a67 Use a more rigorous definition of 'class member'. I don't have any evidence
that this was causing a problem, but it could have.

llvm-svn: 90343
2009-12-02 20:26:00 +00:00
John McCall 1a49e9dc87 Recognize that EnumConstantDecls can be found by lookup and are not instance
members.  Fixes PR5667.

llvm-svn: 90341
2009-12-02 19:59:55 +00:00
Mike Stump 9732915bf9 Pull the terminate handler up so that we can use it for the catch
parameter setup code and set up the catch parameter setup code to
protect that code with terminate.

llvm-svn: 90340
2009-12-02 19:53:57 +00:00
Mike Stump 8a96d3a355 Turn off for now.
llvm-svn: 90339
2009-12-02 19:50:41 +00:00
Mike Stump ae1b85d984 Put the Builder classes into the anonymous namespace.
llvm-svn: 90335
2009-12-02 19:07:44 +00:00
Mike Stump c01c2b87e8 Change rtti/Rtti to RTTI, as it is an acronym.
llvm-svn: 90334
2009-12-02 18:57:08 +00:00
Mike Stump d6eb364b31 Rename CGRtti.cpp to CGRTTI.cpp.
llvm-svn: 90331
2009-12-02 18:32:08 +00:00
Mike Stump a9a590cd12 Avoid warning for getTerminateFn defined but not used.
llvm-svn: 90330
2009-12-02 18:20:18 +00:00
Douglas Gregor 407e2124bf Extend -remap-file=from;to to permit mapping from a non-existent
file. This is accomplished by introducing the notion of a "virtual"
file into the file manager, which provides a FileEntry* for a named
file whose size and modification time are known but which may not
exist on disk.

Added a cute little test that remaps both a .c file and a .h file it
includes to alternative files.

llvm-svn: 90329
2009-12-02 18:12:28 +00:00
Anders Carlsson f98849eb8a In Sema, whenever we think that a function is going to cause a vtable to be generated, we mark any virtual implicit member functions as referenced.
llvm-svn: 90327
2009-12-02 17:15:43 +00:00
Douglas Gregor 6ae34abd1b Move file-remapping logic into InitPreprocesor. No functionality change
llvm-svn: 90322
2009-12-02 16:32:41 +00:00
John McCall 3d988d9042 r90313, in which OverloadedFunctionDecl is removed and never spoken of again.
llvm-svn: 90313
2009-12-02 08:47:38 +00:00
Daniel Dunbar a8a509376c Fix ASTUnit::getOriginalSourceFileName() when using ASTUnit's derived from
source files.

llvm-svn: 90311
2009-12-02 08:44:16 +00:00
Daniel Dunbar 7afbb8c08c ASTUnit: Don't create an LLVMContext, it shouldn't be needed.
llvm-svn: 90310
2009-12-02 08:43:56 +00:00
John McCall 67c0087074 Rip out the last remaining implicit use of OverloadedFunctionDecl in Sema:
LookupResult::getAsSingleDecl() is no more.  Shift Sema::LookupSingleName to
return null on overloaded results.

llvm-svn: 90309
2009-12-02 08:25:40 +00:00
Mike Stump a510597ef9 terminate doesn't throw.
llvm-svn: 90308
2009-12-02 08:18:09 +00:00
Douglas Gregor d062bff7ee Introduce a new clang-cc option
-remap-file=from;to

which takes the file "from" and transparently replaces its contents
with the contents of the file "to" from the source manager's
perspective. This is the moral equivalent of

  cp from saved
  cp to from
  <call clang>
  cp saved from
  rm saved

without all of the pesky file copying.

llvm-svn: 90307
2009-12-02 08:08:39 +00:00
John McCall d28ae27d8d Push overloaded function templates through the parser using a totally different
leaked data structure than before.  This kills off the last remaining 
explicit uses of OverloadedFunctionDecl in Sema.                                         

llvm-svn: 90306
2009-12-02 08:04:21 +00:00
Mike Stump 33270211a0 More exception handling improvements... WIP.
Highlights include:

  Add a helper to generate __cxa_free_exception and _ZSt9terminatev.
  Add a region to handle EH object deallocation for ctor failures for throw.
  Add a terminate handler for __cxa_end_catch.
  A framework for adding cleanup actions for the exceptional edges only.

llvm-svn: 90305
2009-12-02 07:41:41 +00:00
Eli Friedman 6393aac45e Fix another "operator delete missing" crash: make sure we don't check
isVirtual() before we've actually calculated whether the destructor is
virtual.

llvm-svn: 90303
2009-12-02 07:16:50 +00:00
Eli Friedman 81bce6b05e Make sure to call AddOverriddenMethods for implicit copy assignment operators;
it's rare, but possible, for the difference to be significant.

llvm-svn: 90301
2009-12-02 06:59:20 +00:00
Douglas Gregor 53ad6b94b0 Extend the source manager with the ability to override the contents of
files with the contents of an arbitrary memory buffer. Use this new
functionality to drastically clean up the way in which we handle file
truncation for code-completion: all of the truncation/completion logic
is now encapsulated in the preprocessor where it belongs
(<rdar://problem/7434737>).

llvm-svn: 90300
2009-12-02 06:49:09 +00:00
Zhongxing Xu af35329f71 Hard bifurcate the state into nil receiver and non-nil receiver, so that
we don't need to use the DoneEvaluation hack when check for 
ObjCMessageExpr.

PreVisitObjCMessageExpr() only checks for undefined receiver or arguments.

Add checker interface EvalNilReceiver(). This is a 'once-and-done' interface.

llvm-svn: 90296
2009-12-02 05:49:12 +00:00
Douglas Gregor 2a1b691622 Eliminate the unnecessary FirstFID cache variable from the source manager's ContentCache
llvm-svn: 90294
2009-12-02 05:34:39 +00:00
John McCall cd4b47747b Stop trying to analyze class-hierarchies for dependently-scoped id-expressions;
there's nothing interesting we can say now that we're correctly not requiring
the qualifier to name a known base class in dependent contexts.

Require scope specifiers on member access expressions to name complete types
if they're not dependent;  delay lookup when they are dependent.

Use more appropriate diagnostics when qualified implicit member access
expressions find declarations from unrelated classes.

llvm-svn: 90289
2009-12-02 03:53:29 +00:00
Daniel Dunbar 55a17b66cd Add ASTUnit::LoadFromCommandLine, which creates an ASTUnit out of a list of
(clang/driver) command line arguments (including the source file).
 - The arguments are expected to include the source file.

 - The idea is that even though this is a somewhat odd API, its the form which
   many tools can most easily use (for example, by interposing with the compiler).

Also, switch index-test's -ast-from-source to use this entry point, and provide
a -arg command line argument which can be used to test that the command line
arguments are handled correctly.

llvm-svn: 90288
2009-12-02 03:23:45 +00:00
Daniel Dunbar 120c77e4e9 Driver: Add Command::Creator member variable, which tracks the tool that was
used to create a particular command.

llvm-svn: 90287
2009-12-02 03:23:25 +00:00
Fariborz Jahanian 037bcb5be3 Added an assert.
llvm-svn: 90285
2009-12-01 23:35:33 +00:00
Fariborz Jahanian 4d9ab43f23 Fix a code gen. crash synthesizing a destructor.
Fixes pr5660.

llvm-svn: 90283
2009-12-01 23:18:25 +00:00
Daniel Dunbar 465f4c4867 In SourceManager::isBeforeInTranslationUnit, if we are trying to compare two source locations with no common ancestor in the include stack, determine order by assuming memory buffers preceed files, and then that FileIDs are created in order.
The later assumption is patently false, but this was already broken -- this situation is conceptually impossible, my feeling is we should fix SourceManager and friends to make it impossible in practice as well. However, we need to fix PR5662 and perhaps some other things involving memory buffers first. In the short term I'm pretty sure this is reliable.

Chris, Argiris, is this going to break anything that wasn't already broken?

llvm-svn: 90280
2009-12-01 23:07:57 +00:00
Chris Lattner ed3b360290 pass the reason for failure up from MemoryBuffer and report it
in diagnostics when we fail to open a file.  This allows us to
report things like:

$ clang test.c -I.
test.c:2:10: fatal error: error opening file './foo.h': Permission denied
#include "foo.h"
         ^

llvm-svn: 90276
2009-12-01 22:52:33 +00:00
Eli Friedman b2b120f664 Make EmitStoreOfScalar generate a more sane representation of boolean stores.
"Fixes" PR5645.

llvm-svn: 90272
2009-12-01 22:31:51 +00:00
John McCall a6d407c296 Fix IsProvablyNotDerivedFrom to always use record definitions when available.
Gets clang-on-clang passing again.

llvm-svn: 90270
2009-12-01 22:28:41 +00:00
Ted Kremenek 117e472b52 Provide the correct vector size for referenced variables.
llvm-svn: 90267
2009-12-01 22:12:34 +00:00
John McCall 2d74de9632 Rework how we support C++ implicit member accesses. If we can resolve an
implicit member access to a specific declaration, go ahead and create
it as a DeclRefExpr or a MemberExpr (with implicit CXXThisExpr base) as
appropriate.  Otherwise, create an UnresolvedMemberExpr or
DependentScopeMemberExpr with a null base expression.

By representing implicit accesses directly in the AST, we get the ability
to correctly delay the decision about whether it's actually an instance
member access or not until resolution is complete.  This permits us
to correctly avoid diagnosing the 'problem' of 'MyType::foo()'
where the relationship to the type isn't really known until instantiation.

llvm-svn: 90266
2009-12-01 22:10:20 +00:00
Daniel Dunbar d2f8be3629 ASTUnit: Make sure to preserve the TargetInfo for later use.
llvm-svn: 90263
2009-12-01 21:57:33 +00:00
Daniel Dunbar ec5f8ae6a8 Add {ExternalSemaSource,SemaConsumer}::ForgetSema callback, and update PCHReader
to use it so it at least won't try to access Sema once it is gone.

llvm-svn: 90261
2009-12-01 21:57:20 +00:00
Rafael Espindola f8a04a1d6e Exit the command line into <built-in> instead of going directly from the command line to the input file.
We passed <built-in> on the way in, so we should pass it again on the way out.

llvm-svn: 90250
2009-12-01 18:28:16 +00:00
Fariborz Jahanian a6227fd896 (objc2 nonfragile-abi specific). If the translation unit includes an implementation
of a subclass (direct or indirect) of a weak_import root class, emit a weak reference 
for the root class's metaclass (should complete radar 6815425).

llvm-svn: 90249
2009-12-01 18:25:24 +00:00
Ted Kremenek d3a241a9c6 Fix early-return logic in scanReachableSymbols() to match the rest of the recursive logic in the methods of ScanReachableSymbols.
llvm-svn: 90245
2009-12-01 17:50:25 +00:00
Daniel Dunbar 4886c8154d Convert Diagnostic::getCustomDiagID to take a StringRef.
llvm-svn: 90244
2009-12-01 17:42:06 +00:00
Douglas Gregor 6be3de3fa7 Funtion templates and function template specializations do not
override virtual functions. Also, eliminate a (now redundant) call to
AddOverriddenMethods.

llvm-svn: 90242
2009-12-01 17:35:23 +00:00
Douglas Gregor 21920e3758 Move the checking of overridden virtual functions into the code path
common to both parsing and template instantiation, so that we'll find
overridden virtuals for member functions of class templates when they
are instantiated. 

Additionally, factor out the checking for pure virtual functions, so
that it will be executed both at parsing time and at template
instantiation time. 

These changes fix PR5656 (for real), although one more tweak
w.r.t. member function templates will be coming along shortly.

llvm-svn: 90241
2009-12-01 17:24:26 +00:00
Douglas Gregor e7488b904c Don't automatically assume that an id-expression refers to a
ValueDecl, because that isn't always the case in ill-formed
code. Diagnose a common mistake (forgetting to provide a template
argument list for a class template, PR5655) and dyn_cast so that we
handle the general problem of referring to a non-value declaration
gracefully.

llvm-svn: 90239
2009-12-01 16:58:18 +00:00
Douglas Gregor f107aa63ee An inherited virtual (where "virtual" wasn't written explicitly) can
be defined as pure. Fixes PR5656.

llvm-svn: 90237
2009-12-01 16:18:00 +00:00
Daniel Dunbar 764c082027 Add ASTUnit::LoadFromCompilerInvocation, which does what it says.
Also, add an -ast-from-source option to index-test which allows index-test to
run on source files directly.

llvm-svn: 90223
2009-12-01 09:51:01 +00:00