Commit Graph

149 Commits

Author SHA1 Message Date
Nate Begeman 847bfbcaf0 Break out bool/true/false support into a LangOption
llvm-svn: 44164
2007-11-15 07:30:50 +00:00
Ted Kremenek 2272f72723 Added -Wfloat-equal option to the driver. This makes warnings about
floating point comparisons using == or != an opt-in rather than a default
warning.

Updated test case to use -Wfloat-equal.

llvm-svn: 44053
2007-11-13 18:37:02 +00:00
Chris Lattner 376cdaf50b Fix ownership model of ParseAST to allow the dtor of
ASTConsumer to process the AST before it is destroyed.
This allows elimination of HandleObjcMetaDataEmission.

llvm-svn: 43659
2007-11-03 06:24:16 +00:00
Steve Naroff aaba027717 Implement ObjC built-in types in MinimalAction.
This fixes the recent regression with selector-1.m and -parse-noop.

llvm-svn: 43575
2007-10-31 20:55:39 +00:00
Chris Lattner 4050f071e1 wean the diagnostics machinery off the preprocessor.
llvm-svn: 43085
2007-10-17 20:53:57 +00:00
Ted Kremenek 4e816133c8 Started work on clang object serialization. Experimental
serialization logic as well as driver code is now in
Driver/SerializationTest.cpp.  The status of this code is that it
should be used by no clients.

Added --test-pickling option to driver to run the serialization code.

Modified IdentifierInfo and IdentifierTable to have friend classes
that permit object serialization.  Such friendship may not be needed
in the final design.

llvm-svn: 43052
2007-10-16 23:37:27 +00:00
Anders Carlsson cbfc4b8824 Add support for Pascal strings.
llvm-svn: 42974
2007-10-15 02:50:23 +00:00
Chris Lattner e99c8329af add scafolding to play around with and bring up the code rewriter.
llvm-svn: 42855
2007-10-11 00:43:27 +00:00
Chris Lattner 3472aeedfd rename -parse-ast-view to -ast-view
llvm-svn: 42853
2007-10-11 00:37:43 +00:00
Chris Lattner 5e4c75f4ef rename -parse-ast-print to -ast-print
rename -parse-ast-dump to -ast-dump
remove -parse-ast, which is redundant with -fsyntax-only

llvm-svn: 42852
2007-10-11 00:18:28 +00:00
Chris Lattner 1f1b0dbc28 Make a significant change to invert the control flow handling
predefined macros.  Previously, these were handled by the driver,
now they are handled by the preprocessor.

Some fallout of this:

1. Instead of preprocessing two buffers (the predefines, then the 
   main source file)  we now start preprocessing the main source 
   file and inject the predefines as a "psuedo #include" from the
   main source file.
2. #1 allows us to nuke the Lexer::IsMainFile flag and simplify
   Preprocessor::isInPrimaryFile.
3. The driver doesn't have to know about standard #defines, the
   preprocessor knows, which is nice for people wanting to define
   their own drivers.
4. This allows us to put normal tokens in the predefine buffer,
   for example a definition for __builtin_va_list that is 
   target-specific, and a typedef for id in objc.

llvm-svn: 42818
2007-10-09 22:10:18 +00:00
Chris Lattner 3c69f12cbc convert driver over to use Token::is/isNot APIs. fwew, all done.
llvm-svn: 42800
2007-10-09 18:03:42 +00:00
Chris Lattner d1cdee7d1f Rename ASTStreamers.* -> ASTConsumers.*
llvm-svn: 42718
2007-10-07 06:04:32 +00:00
Chris Lattner b2d486a357 speed up clang startup another 28% by avoiding std::vector<std::string>
for holding builtin target-specific macros.

llvm-svn: 42689
2007-10-06 06:57:34 +00:00
Ted Kremenek 0883fd5817 Removed option "-parse-ast-check" from clang driver. This is now implemented
using "-parse-ast -verify".

Updated all test cases (using a sed script) that invoked -parse-ast-check to
now use -parse-ast -verify.

Fixed a bug where using "-verify" instead of "-parse-ast-check" would not
correctly create the DiagClient needed to accumulate diagnostics.

llvm-svn: 42365
2007-09-26 20:14:22 +00:00
Ted Kremenek a054c5bedd Moved "VerifyDiagnostics" variable declaration to right below ProgAction
declaration.  This is because this option is logically tightly connected
to the actions defined in ProgAction.

llvm-svn: 42364
2007-09-26 19:42:19 +00:00
Ted Kremenek 8742a45565 Refactored driver so that any action that is implemented using an
ASTConsumer can also be verified using the diagnostics checker.  From
the command line, users may activate diagnostic checking using the
"-verify" option.  For example, "clang -verify -warn-dead-stores"
checks if the warnings flagged by the dead store checker match those
in the comments.

Note that we still have the option "-parse-ast-check" for backwards
comptability with existing test cases.  This option is now equivalent to 
"-parse-ast -verify".

llvm-svn: 42362
2007-09-26 18:39:29 +00:00
Ted Kremenek 558be36672 Added "CheckASTConsumer", a function that generalizes
"CheckDiagnostics" (used for -parse-ast-check) to check the
diagnostics of any ASTConsumer.

Reimplemented CheckDiagnostics to use CheckASTConsumer instead.

Added driver option -warn-dead-stores-check, which checks the
diagnostics generated by the DeadStores checker.  This is implemented
using CheckASTConsumer.111

llvm-svn: 42310
2007-09-25 18:37:20 +00:00
Ted Kremenek 2826f6e63f Changed command line options "-check-dead-stores" and
"-check-uninit-values" to "-warn-dead-stores" and
"-warn-uninit-values"

llvm-svn: 42307
2007-09-25 18:05:45 +00:00
Ted Kremenek 66d130a584 Added support to clang driver to view ASTs using GraphViz. This
functionality is still preliminary.

llvm-svn: 42152
2007-09-19 21:29:43 +00:00
Ted Kremenek fb5c46c740 Made driver flag --check-uninit-values more self-explanatory.
llvm-svn: 42062
2007-09-17 21:21:20 +00:00
Ted Kremenek 7e61e81bbf UninitialuzedValues now only tracks BlockVarDecls; obviating false positives with
globals and function parameters.

llvm-svn: 42055
2007-09-17 20:49:30 +00:00
Chris Lattner 7ea6ca70f5 switch the llvm emitter to ASTConsumer interface.
llvm-svn: 42013
2007-09-16 19:46:59 +00:00
Chris Lattner 254987c411 switch the various CFG-based stuff over to using ASTConsumer interface,
this eliminates their dependence on the preprocessor and eliminates some
duplicated code.

llvm-svn: 41993
2007-09-15 23:21:08 +00:00
Chris Lattner 09c39db0c4 convert ast printer and dumper ocver to ASTConsumer interface,
genericizing them and eliminating boilerplate code.

llvm-svn: 41992
2007-09-15 23:02:28 +00:00
Chris Lattner 75e0c8cf4c add a new ASTConsumer consumer to simplify stuff in the driver.
Switch -parse-ast over to it.

llvm-svn: 41991
2007-09-15 22:56:56 +00:00
Ted Kremenek 6dc7b11d32 Added "Dead Stores", a flow-sensitive checker that checks for stores
to variables that are no longer live.  This analysis is built on top
of CFGs and the LiveVariables analysis.

changes to driver:
 added driver option "-check-dead-stores" to run the analysis

llvm-svn: 41754
2007-09-06 23:00:42 +00:00
Ted Kremenek 3f8ed2653c LiveVariables:
- Finished 99% of analysis logic.  Probably a few bugs.
 - Added querying functions to query liveness.
 - Added better pretty printing of liveness.
 - Added better bookkeeping of per-variable liveness information.
 - Added LiveVariablesAuditor interface, which allows "lazy" querying
   of intra-basic block liveness information.

Driver:
 - Minor cleanups involved in dumping liveness information.

llvm-svn: 41753
2007-09-06 21:26:58 +00:00
Ted Kremenek b56a990955 Added an early implementation of Live-Variables analysis built on
source-level CFGs.  This code may change significantly in the near
future as we explore different means to implement dataflow analyses.

Added a driver option, -dump-live-variables, to view the output of
live variable analysis.  This output is very ALPHA; it will be improved shortly.

llvm-svn: 41737
2007-09-06 00:17:54 +00:00
Ted Kremenek 4e5f99da6c Added GraphTraits to source-level CFGs (CFG and CFGBlock) to allow
(LLVM-provided) graph algorithms such as DFS and graph visualization
to work effortless on source-level CFGs.

Further cleanup on pretty printing of CFGs.  CFGBlock::dump and
CFGBlock::print now take the parent CFG as an argument.  This allows
CFGBlocks to print their own appropriate label indicating whether or
not they are the Entry/Exit/IndirectGotoBlock without the CFG::print
routine doing it instead.

Added Graphviz visualization for CFGs: CFG::viewCFG.  This employs the
GraphTraits just implemented.

Added "-view-cfg" mode the to clang driver.  This is identical to
"-dump-cfg" except that it calls Graphviz to visualize the CFGs
instead of dumping them to the terminal.

llvm-svn: 41580
2007-08-29 21:56:09 +00:00
Chris Lattner dd9a319158 Add isysroot support, patch by Keith Bauer
llvm-svn: 41455
2007-08-26 17:47:35 +00:00
Ted Kremenek 4aa1e8b3b8 Added CFG infrastructure (CFG.cpp and CFG.h) for clang ASTs.
Added builder code to translate ASTs to CFGs.  This currently supports
if, return, and non-control flow statements.

Added pretty-printer to debug CFGs.

Added a "-dump-cfg" option to the clang driver to dump CFGs for code
sent through the frontend.

llvm-svn: 41252
2007-08-21 21:42:03 +00:00
Chris Lattner cbe4f77c9e add a new AST dumper interface (E->dump()). This dumps out
the AST in a structural, non-pretty, form useful for understanding
the AST.  It isn't quite done yet, but is already somewhat useful.

For this example:

int test(short X, long long Y) {
  return X < ((100));
}

we get (with -parse-ast-dump):

int test(short X, long long Y)
(CompoundStmt 0x2905ce0
  (ReturnStmt 0x2905cd0
    (BinaryOperator 0x2905cb0 '<'
      (ImplicitCastExpr 0x2905ca0
        (DeclRefExpr 0x2905c20 Decl='X' 0x2905bb0))
      (ParenExpr 0x2905c80
        (ParenExpr 0x2905c60
          (IntegerLiteral 0x2905c40 100))))))

llvm-svn: 40954
2007-08-08 22:51:59 +00:00
Chris Lattner d956fcac86 GCC doesn't set __STDC_VERSION__ usually. It never sets it in
C++ mode, even gnu C++ mode.

llvm-svn: 40408
2007-07-22 22:11:35 +00:00
Chris Lattner 6b4db176ea when running in -E mode on multiple files, there is no reason to accumulate
fileid's and macroid's across files.  Clearing between files keeps the tables
smaller and slightly speeds up compilation.

llvm-svn: 40383
2007-07-22 06:05:44 +00:00
Chris Lattner 833894bcac Return an exit code of 1 if errors occur, not an exit code equal to the # errors :)
llvm-svn: 40189
2007-07-21 05:40:53 +00:00
Chris Lattner 146762e7a4 At one point there were going to be lexer and parser tokens.
Since that point is now long gone, we should rename LexerToken to
Token, as it is the only kind of token we have.

llvm-svn: 40105
2007-07-20 16:59:19 +00:00
Chris Lattner 539007a78a Add support for C++'0x keywords, patch by Doug Gregor
llvm-svn: 39897
2007-07-16 04:18:29 +00:00
Steve Naroff 4ae0ac6a06 Bug #:
Submitted by:
Reviewed by:
- Finished semantic analysis for vectors, added some diagnostics.
- Added AST for vectors (instantiation, installation into the decl).
- Fixed bug in ParseArraySubscriptExpr()...this crasher was introduced by me
when we added the range support.
- Turned pedantic off by default. Since vectors are gcc extensions, having
pedantic on by default was annoying. Turning it off by default is  also
consistent with gcc (but this wasn't my primary motivation).
- Tweaked some comments and diagnostics.

Note: The type checking code is still under construction (for vectors). This
will be my next check-in.

llvm-svn: 39715
2007-07-06 23:09:18 +00:00
Chris Lattner 23e6353835 Eliminate almost all of the redundancy Bill introduced.
llvm-svn: 39704
2007-06-28 04:54:17 +00:00
Chris Lattner af74985d71 Add a hack to fix a really subtle memory lifetime bug Bill introduced with his
recent changes.  carbon.h now preprocesses just fine.

llvm-svn: 39701
2007-06-28 04:10:04 +00:00
Chris Lattner a092b149bf rename LLVMDiagChecker.* -> DiagChecker.*
llvm-svn: 39690
2007-06-27 17:24:55 +00:00
Bill Wendling 52b0a4e84e Submitted by: Bill Wendling
Removed unnecessary typedef.

llvm-svn: 39686
2007-06-27 07:24:11 +00:00
Bill Wendling 469211a295 Submitted by: Bill Wendling
Reviewed by: Chris Lattner

- Added a new diagnostic client, TextDiagnosticBuffer. It buffers all
  reported diagnostics.
- Use the new diagnostic client to check that expected diagnostics are
  actually emitted. The way this is done is to put the expected
  diagnostic in a comment on the line you expect it to be emitted for.
  Like this:

    int X = A; // expected-warning {{blah}}

- Use -parse-ast-check to use this feature.

llvm-svn: 39678
2007-06-27 03:19:45 +00:00
Bill Wendling aec64c35f1 Submitted by: Bill Wendling
- Separate out the AST streamers from the clang.cpp file into their very
  own special files.

llvm-svn: 39676
2007-06-23 00:39:57 +00:00
Bill Wendling 26e1f8c05a Bug #:
Submitted by: Bill Wendling

- Convert std::cerr to using fprintf(stderr, ...) instead.

llvm-svn: 39675
2007-06-22 22:43:15 +00:00
Chris Lattner 23b7eb677d Finally bite the bullet and make the major change: split the clang namespace
out of the llvm namespace.  This makes the clang namespace be a sibling of
llvm instead of being a child.

The good thing about this is that it makes many things unambiguous.  The
bad things is that many things in the llvm namespace (notably data structures
like smallvector) now require an llvm:: qualifier.  IMO, libsystem and libsupport
should be split out of llvm into their own namespace in the future, which will fix
this issue.

llvm-svn: 39659
2007-06-15 23:05:46 +00:00
Bill Wendling 52d85bdd2b Submitted by: Bill Wendling
Reviewed by: Chris Lattner

- Refactor some code from main() and ProcessInputFile() so that it helps to
  decouple the initialization of the Preprocessor object from the
  diagnostic client.

llvm-svn: 39657
2007-06-15 21:20:00 +00:00
Bill Wendling da0c8a9641 Submitted by: Bill Wendling
Reviewed by: Chris Lattner

- Make the counting of errors and diagnostic messages sane. Place them into the
  Diagnostic class instead of in the DiagnosticClient class.

llvm-svn: 39615
2007-06-08 19:17:38 +00:00
Bill Wendling 37b1ddecf6 Submitted by: Bill Wendling
Reviewed by: Chris Lattner

- Separated out the diagnostic client from the clang driver. This is in
  preparation for creating a diagnostic client that will be used to check
  error and warning messages.

llvm-svn: 39603
2007-06-07 09:34:54 +00:00