Commit Graph

46 Commits

Author SHA1 Message Date
Daniel Dunbar 8654638b23 Frontend: Change FrontendAction::BeginSourceFile to take the input kind instead of an IsAST bool.
llvm-svn: 105578
2010-06-07 23:23:06 +00:00
Daniel Dunbar 9b491e79fc Frontend: Lift InputKind enumeration to top level.
llvm-svn: 105577
2010-06-07 23:22:09 +00:00
Dan Gohman cab4933f95 MemoryBuffer::getSTDIN may return a null pointer if an error occurs.
llvm-svn: 104856
2010-05-27 17:33:40 +00:00
Douglas Gregor f64acca2f5 Only enable code patterns (e.g., try { statements } catch (...) {
statements }) in the code-completion results if explicitly requested.

llvm-svn: 104637
2010-05-25 21:41:55 +00:00
Douglas Gregor 2d2d90750c Once we've emitted a fatal diagnostic, keep counting errors but with a
separate count of "suppressed" errors. This way, semantic analysis
bits that depend on the error count to determine whether problems
occured (e.g., some template argument deduction failures, jump-scope
checking) will not get confused.

The actual problem here is that a missing #include (which is a fatal
error) could cause the jump-scope checker to run on invalid code,
which it is not prepared to do. Trivial fix for both
<rdar://problem/7775941> and <rdar://problem/7775709>.

llvm-svn: 101297
2010-04-14 22:19:45 +00:00
Chris Lattner 198cb4df6e Instead of counting totally diagnostics, split the count into a count
of errors and warnings.  This allows us to emit something like this:

2 warnings and 1 error generated.

instead of:

3 diagnostics generated.

This also stops counting 'notes' because they are just follow-on information
about the previous diag, not a diagnostic in themselves.

llvm-svn: 100675
2010-04-07 18:47:42 +00:00
Douglas Gregor 7f95d26e53 Make Diagnostic reference-counted, which is simpler than juggling
maybe-ownership vs. ownership.

llvm-svn: 100498
2010-04-05 23:52:57 +00:00
Douglas Gregor 171b780c91 Teach Clang's -cc1 option -print-stats to print LLVM statistics.
llvm-svn: 99894
2010-03-30 17:33:59 +00:00
Daniel Dunbar 1c201fbf73 clang -cc1: Kill off -empty-input only, and replace with -init-only which is an
actual action.
 - This is easier to use, and more reliable for timing the thing this was
   actually meant to be useful for.

llvm-svn: 98978
2010-03-19 19:44:04 +00:00
Douglas Gregor 7f6d60dcc2 Optionally store a PreprocessingRecord in the preprocessor itself, and
tie its creation to a CC1 flag -detailed-preprocessing-record.

llvm-svn: 98963
2010-03-19 16:15:56 +00:00
Kovarththanan Rajaratnam eeed0cc32d Simplify error path using OwningPtr
llvm-svn: 98722
2010-03-17 09:47:30 +00:00
Kovarththanan Rajaratnam 9ff84d9c27 Simplify ProcessWarningOptions since it can't fail
llvm-svn: 98721
2010-03-17 09:36:02 +00:00
Kovarththanan Rajaratnam 4a94ba56f1 Issue a proper diagnostic if we couldn't open dump file
llvm-svn: 98719
2010-03-17 09:24:48 +00:00
Douglas Gregor 00a0cf70d9 Don't consume tokens past the end-of-file in an @interface. Fixes
<rdar://problem/7735566>.

llvm-svn: 98613
2010-03-16 06:04:47 +00:00
Douglas Gregor e0fbb83b8b Give SourceManager a Diagnostic object with which to report errors,
and start simplifying the interfaces in SourceManager that can fail.

llvm-svn: 98594
2010-03-16 00:06:06 +00:00
Kovarththanan Rajaratnam 1c558cd773 Lowercase for consistency
llvm-svn: 97878
2010-03-06 12:07:48 +00:00
Douglas Gregor 33cdd81064 Rework how CIndex handles diagnostics. Rather than using a callback,
we attach diagnostics to translation units and code-completion
results, so they can be queried at any time.

To facilitate this, the new StoredDiagnostic class stores a diagnostic
in a serializable/deserializable form, and ASTUnit knows how to
capture diagnostics in this stored form. CIndex's CXDiagnostic is a
thin wrapper around StoredDiagnostic, providing a C interface to
stored or de-serialized diagnostics.

I've XFAIL'd one test case temporarily, because currently we end up
storing diagnostics in an ASTUnit that's never returned to the user
(because it contains errors). I'll introduce a temporary fix for this
soon; the real fix will be to allow us to return and query invalid ASTs.

llvm-svn: 96592
2010-02-18 18:08:43 +00:00
Daniel Dunbar e922d9bdf0 CompilerInstance: Move LLVMContext member out of constructor.
llvm-svn: 96314
2010-02-16 01:54:47 +00:00
Daniel Dunbar 6824225465 CompilerInstance: Change to not contain the CompilerInvocation object.
This allows clients to install their own CompilerInvocation object, which is
important for clients that may wish to create references to things like
LangOptions whose lifetime will extend past that of the CompilerInstance.

llvm-svn: 94923
2010-01-30 21:47:07 +00:00
Douglas Gregor ac0605e927 Introduce serialization and deserialization of diagnostic information
so that CIndex can report diagnostics through the normal mechanisms
even when executing Clang in a separate process. This applies both
when performing code completion and when using ASTs as an intermediary
for clang_createTranslationUnitFromSourceFile().

The serialized format is not perfect at the moment, because it does
not encapsulate macro-instantiation information. Instead, it maps all
source locations back to the instantiation location. However, it does
maintain source-range and fix-it information. To get perfect fidelity
from the serialized format would require serializing a large chunk of
the source manager; at present, it isn't clear if this code will live
long enough for that to matter.

llvm-svn: 94740
2010-01-28 06:00:51 +00:00
Fariborz Jahanian 3f7b8b274d Predefine __weak attribute when doing objective-c
rewriting for any target. (refixes radar 7530235).

llvm-svn: 93331
2010-01-13 18:51:17 +00:00
Daniel Dunbar 4f2bc55d4e cc1: Factor out CompilerInstance::ExecuteAction which has the majority of the
clang -cc1 logic for running an action against a set of options.
 - This should make it easier to build tools that have a clang -cc1 like
   interface, but aren't actually part of clang -cc1.

llvm-svn: 93282
2010-01-13 00:48:06 +00:00
Daniel Dunbar 520d1e6c6b Update docs/comments/utils/examples to refer to clang -cc1 instead of clang-cc.
llvm-svn: 91176
2009-12-11 23:04:35 +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
Douglas Gregor 6ae34abd1b Move file-remapping logic into InitPreprocesor. No functionality change
llvm-svn: 90322
2009-12-02 16:32:41 +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
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
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
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
Daniel Dunbar 2eaef18e76 Fix refactoro, clang-cc wasn't properly reporting errors when opening an output file failed.
llvm-svn: 89502
2009-11-20 22:32:38 +00:00
Daniel Dunbar d6ea9028e7 Simplify PreprocessorOptions, it doesn't need abstracted field access.
llvm-svn: 89047
2009-11-17 05:52:41 +00:00
Daniel Dunbar 1b39a2edff Shuffle VerifyDiagnosticsClient API to be less fragile.
llvm-svn: 88765
2009-11-14 07:53:24 +00:00
Daniel Dunbar 409e890f8d Add CompilerInstance::InitializeSourceManager.
llvm-svn: 88764
2009-11-14 07:53:04 +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 56d9c293db Add ASTConsumer to CompilerInstance.
llvm-svn: 88743
2009-11-14 02:47:17 +00:00
Daniel Dunbar e01dc86d2a Move CompilerInstance::set* methods out-of-line.
llvm-svn: 88731
2009-11-14 01:20:40 +00:00
Daniel Dunbar 420b0f1bd8 Add CompilerInstance utility functions for creating output files.
llvm-svn: 88667
2009-11-13 18:32:08 +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 f7093b5ae8 Add CodeCompletion consumer to CompilerInvocation.
llvm-svn: 87100
2009-11-13 09:36:05 +00:00
Daniel Dunbar 599313ef94 Add CompilerInstance::createPCHExternalASTSource.
llvm-svn: 87097
2009-11-13 08:21:10 +00:00
Daniel Dunbar df3e30c41c Add ASTContext to CompilerInstance.
llvm-svn: 87095
2009-11-13 08:20:47 +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 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 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