Commit Graph

671 Commits

Author SHA1 Message Date
Steve Naroff
f9e7c90129 Only have the rewriter produce a file when there are no errors.
llvm-svn: 48926
2008-03-28 22:26:09 +00:00
Steve Naroff
60a9ef67e2 Add some of Ted's recent work to the VC++ project file.
Fix a couple bozo bugs in the rewriter.

llvm-svn: 48903
2008-03-27 22:59:54 +00:00
Steve Naroff
00a317694b Collect all the preamble code and don't insert it until the end.
llvm-svn: 48899
2008-03-27 22:29:16 +00:00
Ted Kremenek
30560caa3d For HTMLDiagnostics, when emitting the name of the directory, substitute the current working directory for "."
llvm-svn: 48888
2008-03-27 17:25:28 +00:00
Ted Kremenek
561dfe3153 Add html::EscapeText for std::string; use this function to escape text in message bubbles.
llvm-svn: 48884
2008-03-27 17:15:29 +00:00
Ted Kremenek
ed9f054a9c Don't emit any timings for GRSimple if the CFG is not going to be built.
llvm-svn: 48882
2008-03-27 17:14:42 +00:00
Ted Kremenek
8d5491f40c Output directory as well as file name.
llvm-svn: 48870
2008-03-27 07:39:04 +00:00
Ted Kremenek
8cc4842a76 Added <h3> tag in HTML file output that contains the name of the source file.
llvm-svn: 48869
2008-03-27 07:35:49 +00:00
Ted Kremenek
6efb026623 Added "HTMLDiagnostic", a generic DiagnosticClient (that also implements PathDiagnostic)
so that all diagnostics can be piped to HTML files instead of as text diagnostics using --html-diags.

llvm-svn: 48865
2008-03-27 06:17:42 +00:00
Ted Kremenek
c875201ee1 Fixed copy-paste error.
llvm-svn: 48863
2008-03-27 05:52:45 +00:00
Steve Naroff
65838bb2d5 Add a couple files to VC++ project and cleanup an "#if 0".
llvm-svn: 48748
2008-03-24 22:03:25 +00:00
Andrew Lenharth
10051b97fd debian amd64 testing
llvm-svn: 48745
2008-03-24 21:39:05 +00:00
Andrew Lenharth
d8cde6f45d debian ia32 testing
llvm-svn: 48742
2008-03-24 21:25:48 +00:00
Chris Lattner
97d496c182 Teach the rewriter how to respect the -o option.
llvm-svn: 48669
2008-03-22 00:08:40 +00:00
Ted Kremenek
bc24962566 Added HTML highlighting for ranges.
llvm-svn: 48572
2008-03-19 23:55:53 +00:00
Ted Kremenek
1651b7cd2d Misc. cleanups to HTML printing: make code rendered using tables; add
better div positioning for messages.

llvm-svn: 48555
2008-03-19 21:59:05 +00:00
Ted Kremenek
216624ce58 Initial experimentation with adding boxed "annotations" to HTMLized source.
llvm-svn: 48540
2008-03-19 07:53:42 +00:00
Ted Kremenek
966da4acc3 Moved generation of html header/footer with builtin CSS to the rewriter library.
llvm-svn: 48537
2008-03-19 06:14:37 +00:00
Ted Kremenek
3f8392626b More cleanups to the HTML rewriter (with line formatting), with better
pretty-printing of line numbers.

llvm-svn: 48533
2008-03-19 05:07:26 +00:00
Ted Kremenek
5ddff02861 More cleanups to HTML rewriter API: remove the InsertTag method; was too complicated
and clients can achieve a cleaner design just by inserting tags directly.  Reserve
the "html" namespace for meta-level operations (e.g., escaping text, etc.)

llvm-svn: 48524
2008-03-19 01:30:02 +00:00
Ted Kremenek
8800ae68a0 More HTML rewriter cleanups. Preliminary CSS support in code pretty-printing.
llvm-svn: 48518
2008-03-18 23:55:46 +00:00
Ted Kremenek
5792cebb08 Some cleanups to the HTMLRewrite API. Added support for printing out line
numbers (more work to be done on aesthetics).

llvm-svn: 48512
2008-03-18 23:08:51 +00:00
Ted Kremenek
b0c409a235 Added HTML pretty-printer.
llvm-svn: 48507
2008-03-18 22:21:07 +00:00
Ted Kremenek
7dcc82220e Added the beginning of a set of rewriter functions for pretty-printing source
code as HTML.  Added a new driver option "--emit-html" to dump the source
of the main input file as HTML.

llvm-svn: 48505
2008-03-18 21:19:49 +00:00
Steve Naroff
327f0f4c3a Fix <rdar://problem/5716940> rewriter generates invalid C code when no selector found.
llvm-svn: 48479
2008-03-18 02:02:04 +00:00
Steve Naroff
034bcb5bfa Wrap up __NSConstantStringImpl (the replacement for __builtin___CFStringMakeConstantString).
llvm-svn: 48477
2008-03-18 01:47:18 +00:00
Chris Lattner
5bb4ee20cd clean up iteration over propertydecls.
llvm-svn: 48435
2008-03-17 01:24:41 +00:00
Chris Lattner
ed0e16404c clean up property memory allocation to move it into the ast classes
like the rest of the classes.

llvm-svn: 48434
2008-03-17 01:19:02 +00:00
Chris Lattner
41eec3d097 make property addition work list all other "add" methods. Do
the allocation in the class, not in sema.

llvm-svn: 48433
2008-03-16 21:23:50 +00:00
Chris Lattner
8d1c04f53a Convert more counts to be zero based instead of -1 based, make them unsigned.
llvm-svn: 48429
2008-03-16 21:08:55 +00:00
Chris Lattner
acc04a9261 minor cleanups, make getNumInstanceMethods always return unsigned.
llvm-svn: 48423
2008-03-16 20:19:15 +00:00
Chris Lattner
011b0f5c5a Make the parameter count of ObjCMethodDecl unsigned, you
can't have negative arguments.

llvm-svn: 48407
2008-03-16 01:07:14 +00:00
Chris Lattner
ee1284a6e2 switch the rest of the C decl classes to do their
allocation through ASTContext.

llvm-svn: 48403
2008-03-16 00:16:02 +00:00
Chris Lattner
96c460d142 move the ASTContext argument to be first in the argument list of
all Create methods.

llvm-svn: 48398
2008-03-15 21:32:50 +00:00
Chris Lattner
5072bae709 Switch over functiondecl. This makes it obvious that the ASTContext
argument to Create should be first, not last.

llvm-svn: 48397
2008-03-15 21:24:04 +00:00
Chris Lattner
4b08ca8f2e switch the VarDecl allocation model to go through ASTContext.
llvm-svn: 48396
2008-03-15 21:10:16 +00:00
Chris Lattner
a7b3287760 start switching decls over to using an allocator controlled by ASTContext.
Right now only some ctors are switched over.  I need to switch them all
over so I can change the dtor over.

This lets us experiment with region allocation and other things in the 
future.

llvm-svn: 48390
2008-03-15 06:12:44 +00:00
Steve Naroff
dad80ba9b1 Link against the correct ObjC string class (__CFConstantStringClassReference) and fix length computation (removing a FIXME).
llvm-svn: 48384
2008-03-15 01:36:04 +00:00
Steve Naroff
ce8e886731 Remove ObjC rewriter dependency on GCC's __builtin___CFStringMakeConstantString.
llvm-svn: 48383
2008-03-15 00:55:56 +00:00
Ted Kremenek
9abb59f9cc Emit warnings for undefined control-flow.
llvm-svn: 48368
2008-03-14 18:14:50 +00:00
Ted Kremenek
7b00d15bc5 Path-sensitive analyses no longer take a FunctionDecl, but any Decl representing
a block of "code".

Patched various ASTConsumers (such as ASTDumper) to have more support for
processing ObjCMethodDecl. CFGVisitor now builds CFGs for ObjCMethodDecls.

llvm-svn: 48363
2008-03-14 17:31:00 +00:00
Chris Lattner
e8ec280627 Only compute targetinfo once and don't leak it. Patch by Sam Bishop!
llvm-svn: 48358
2008-03-14 06:12:05 +00:00
Ted Kremenek
1fdd0a480e The LiveVariables analysis no longer requires a FunctionDecl&; this allows it
to be run on other declarations of blocks of code (e.g., Objective-C methods.)

llvm-svn: 48339
2008-03-13 16:55:07 +00:00
Ted Kremenek
b64d183803 Added bandaid support in CFG construction for ObjCForEachStmt and ObjCAtTryStmt:
we gracefully back out and return NULL for the CFG, allowing clients to skip
analyzing functions with these CFGs. We will add support later.

Modified base ASTConsumer "CFGVisitor" to detect when a CFG is not constructed
and to emit a warning.

llvm-svn: 48322
2008-03-13 03:04:22 +00:00
Steve Naroff
35cb7960e3 Two fixes to RewriteTest::RewriteObjCIvarRefExpr():
- For explicit ivar refers, make sure the cast is propagated to the AST.
- Don't free the base (since it is still in use).
This fixes the recent regression to test/Rewriter/objc-ivar-receiver-1.m.

llvm-svn: 48309
2008-03-12 23:15:19 +00:00
Steve Naroff
ffb5f9ad93 Minor aesthetic improvement (after I reviewed my last commit).
llvm-svn: 48304
2008-03-12 21:22:52 +00:00
Steve Naroff
9f33bd2c34 Avoid using the "unnamed struct field" extension (enabled with -fms-extensions). This feature/extension silently does the wrong thing in g++. As far as I can tell, g++ simply throws the field away entirely (note that it works fine with gcc). Since I am now always casting the object (for other reasons), accessing protected/public fields simply requires the cast refer to the defining class. This solution is simpler all around (thanks to Chris for suggesting it).
llvm-svn: 48302
2008-03-12 21:09:20 +00:00
Steve Naroff
b327e49047 Use the "used" attribute. Without it, g++ removes all the meta-data:-( This doesn't happen when compiling straight C code.
llvm-svn: 48287
2008-03-12 17:18:30 +00:00
Steve Naroff
5d5efca405 -Add missing visitor for ObjCIvarRefExpr.
-Wrap objc runtime calls with "extern "C"" (for now).

llvm-svn: 48284
2008-03-12 13:19:12 +00:00
Steve Naroff
251084d03e Remove more dependencies on C "flexible array member" idiom (when generating meta-data).
llvm-svn: 48271
2008-03-12 01:06:30 +00:00
Steve Naroff
dc5b6b2e5d Make ivar rewrite C++ friendly (since C++ forces a unified namespace for typedefs/structures). The previous version of the rewriter generated both a type def and structure def for each class (which doesn't fly in C++).
llvm-svn: 48266
2008-03-12 00:25:36 +00:00
Steve Naroff
0b844f053f Make "super" rewrite for class methods C++ friendly (follow-up from last commit).
llvm-svn: 48235
2008-03-11 18:14:26 +00:00
Steve Naroff
17978c4dcb Make "super" rewrite C++ friendly (since it doesn't support Compound Literals).
llvm-svn: 48230
2008-03-11 17:37:02 +00:00
Steve Naroff
c5b9cc70ce Generate meta-data in a C++ compatible way (remove 2 dependencies on C "flexible array member" idiom and perform some extra casts).
llvm-svn: 48202
2008-03-11 00:12:29 +00:00
Steve Naroff
14a0746b13 Missed a couple "_IMPL" suffixes.
llvm-svn: 48191
2008-03-10 23:33:22 +00:00
Steve Naroff
a1e115ee57 Fix dangling pointer and give the implementation struct for a class a unique name.
llvm-svn: 48190
2008-03-10 23:16:54 +00:00
Steve Naroff
945a3b145a Pass LangOptions to RewriteTest().
llvm-svn: 48172
2008-03-10 20:43:59 +00:00
Chris Lattner
0d799d3957 Add some missing #includes for GCC mainline, patch by Shantonu Sen!
llvm-svn: 48153
2008-03-10 17:04:53 +00:00
Chris Lattner
6af064641f Fix a ted-o
llvm-svn: 48089
2008-03-09 05:25:01 +00:00
Chris Lattner
22ad07ca07 simplify triple processing code now that there can be only one arch specified.
llvm-svn: 48066
2008-03-09 01:35:13 +00:00
Ted Kremenek
2bdd77696e Added --trim-path-graph to the driver to trim paths from the ExplodedGraph
that are not related to error nodes.

Fixed bug where we did not detect some NULL dereferences.

Added "ExplodedGraph::Trim" to trim all nodes that cannot transitively reach
a set of provided nodes.

Fixed subtle bug in ExplodedNodeImpl where we could create predecessor
iterators that included the mangled "sink" bit.  The better fix is to integrate
this bit into the void* for the wrapped State, not the NodeGroups representing
a node's predecessors and successors.

llvm-svn: 48036
2008-03-07 22:58:01 +00:00
Ted Kremenek
ea6507fe04 Added boilerplate to execute the CF reference count checker (which isn't yet implemented).
llvm-svn: 47982
2008-03-06 00:08:09 +00:00
Chris Lattner
37e0587839 remove the source location arguments to various target query methods.
llvm-svn: 47954
2008-03-05 18:54:05 +00:00
Chris Lattner
855d024a83 Remove the first layer of support for "portability" warnings. This is
theoretically useful, but not useful in practice.  It adds a bunch of 
complexity, and not much value.  It's best to nuke it.  One big advantage
is that it means the target interfaces will soon lose their SLoc arguments
and target queries can never emit diagnostics anymore (yay).  Removing this
also simplifies some of the core preprocessor which should make it slightly
faster.

Ted, I didn't simplify TripleProcessor, which can now have at most one
triple, and can probably just be removed.  Please poke at it when you have
time.

llvm-svn: 47930
2008-03-05 01:18:20 +00:00
Chris Lattner
028d6d5792 avoid a warning.
llvm-svn: 47839
2008-03-03 05:57:43 +00:00
Chris Lattner
184adbfe5b Find clang headers in the clang headers dir, search it before
the system headers dir.  This produces an annoying warning:
clang.cpp:883: warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object

I'm not sure how to remove it. :(

llvm-svn: 47836
2008-03-03 03:16:03 +00:00
Chris Lattner
c1bc541323 Add support for the CPATH, C_INCLUDE_PATH, CPLUS_INCLUDE_PATH,
OBJC_INCLUDE_PATH, and OBJCPLUS_INCLUDE_PATH environment variables.
Patch by Sam Bishop!

llvm-svn: 47785
2008-03-01 08:07:28 +00:00
Chris Lattner
bb7bc8d4f0 fix an interaction between -isystem . and isysroot.
llvm-svn: 47646
2008-02-26 23:46:22 +00:00
Chris Lattner
eb85ab44f2 convert tabs to spaces, patch by Mike Stump!
llvm-svn: 47560
2008-02-25 21:04:36 +00:00
Chris Lattner
cb0d62c70d enable digraphs for C94, thanks to Neil for pointing this out.
llvm-svn: 47543
2008-02-25 04:01:39 +00:00
Ted Kremenek
c77f34daad Modified clang driver option -dump-live-variables to (optionally) use the
--analyze-function option to analyze specific functions.

llvm-svn: 47498
2008-02-22 20:13:09 +00:00
Ted Kremenek
88329bf0ea clang driver options --dump-cfg and --view-cfg now (optionally) use the
--analyze-function option to dump/view the CFGs of specific functions.

llvm-svn: 47497
2008-02-22 20:00:31 +00:00
Ted Kremenek
76c03b4a55 When running the GRSimpleVals analysis, skip functions that do not
appear in a file.

llvm-svn: 47491
2008-02-22 19:10:58 +00:00
Ted Kremenek
dbb1a3724c For now, --grsimple skips analyzing functions in header files.
llvm-svn: 47303
2008-02-19 02:33:31 +00:00
Ted Kremenek
0f7130adc4 --grsimple now reports the number of nodes in the ExplodedGraph for
an analyzed function.

GRExprEngine now records stores to "uninitialized lvalues" (which are sinks in
the ExplodedGraph).

llvm-svn: 47293
2008-02-19 00:22:37 +00:00
Ted Kremenek
86e793937a Running -grsimple now emits diagnostics about the time spent analyzing each function. Will
probably make this a separate command line option later.

Added "--analyze-function" option to the driver to (gradually) allow different
analyses to only be run on specific functions. Currently only --grsimple uses
this option.

llvm-svn: 47285
2008-02-18 21:21:23 +00:00
Eli Friedman
1d88371663 A couple of msvc compile fixes from the ml; I haven't tested with msvc,
but the fixes are reasonable.

llvm-svn: 47224
2008-02-16 23:17:23 +00:00
Lauro Ramos Venancio
10984b2ee9 Set Ubuntu 7.10 c++ include path.
llvm-svn: 47186
2008-02-15 22:36:38 +00:00
Ted Kremenek
e161afc4dd Added --grsimple-view option to clang driver; this is the same as
--grsimple except that it visualizes the ExplodedGraph using dot and
outputs the current function being analyzed.  --grsimple is now silent
except when it emits diagnostics.

llvm-svn: 47146
2008-02-15 00:35:38 +00:00
Ted Kremenek
d3122cb83c Renamed GRConstants => GRSimpleVals.
Moved driver logic for --grsimple to GRSimpleVals.cpp.

llvm-svn: 47137
2008-02-14 22:36:46 +00:00
Steve Naroff
bff738543d Move policy on unnamed fields (a Microsoft extension) from Parser::ParseStructDeclaration() to the driver.
llvm-svn: 46974
2008-02-11 22:40:08 +00:00
Steve Naroff
5a858df0b3 Fix http://llvm.org/bugs/show_bug.cgi?id=2013.
llvm-svn: 46972
2008-02-11 22:17:33 +00:00
Steve Naroff
a369922449 A bunch-o changes to fix <rdar://problem/5716046> incomplete implementation of ObjC class warning is incomplete
As part of this fix, I made a low-level change to the text diagnostics machinery (to basically avoid printing duplicate source lines/carets when you have multiple diagnostics that refer to the same exact place). For now, this only happens with we don't have a source range (could be extended to support source ranges as well). 

llvm-svn: 46897
2008-02-08 22:06:17 +00:00
Anders Carlsson
5c6c05956e Put back the top-level asm code; all tests pass now.
llvm-svn: 46868
2008-02-08 00:33:21 +00:00
Anders Carlsson
0fae4f56df Back out 46855 for now, it causes test failures on Darwin.
llvm-svn: 46867
2008-02-08 00:23:11 +00:00
Anders Carlsson
bcc3a4bf64 Handle top-level asm declarations.
llvm-svn: 46855
2008-02-07 17:19:11 +00:00
Ted Kremenek
d74da0838f Added proof-of-concept NULL pointer diagnostics to GRConstants.
Modified the driver to pass the Diagnostic object to GRConstants.

llvm-svn: 46847
2008-02-07 06:33:19 +00:00
Steve Naroff
b2c80c7c7b Implement -fms-extensions. This allows us to fuzzy parse non-standard MS constructs used in "windows.h".
llvm-svn: 46838
2008-02-07 03:50:06 +00:00
Eli Friedman
1242fff6ec Make sure to propagate qualifiers through the member operator.
llvm-svn: 46830
2008-02-06 22:48:16 +00:00
Chris Lattner
adf1f51fc5 move the codegen ASTConsumer out of the driver into libcodegen,
eliminating a bunch of forwarding methods and generally 
simplifying things.

llvm-svn: 46792
2008-02-06 02:01:47 +00:00
Chris Lattner
b5eda6253b pull .ll and .bc writing out of the ASTConsumer destructors into some top
level code in clang.  This is a cleanup, but does implement "-o" for 
-emit-llvm.  One effect of this is that "clang foo.c -emit-llvm" will now
emit into foo.ll instead of stdout.  Use "clang foo.c -emit-llvm -o -" or 
"clang < foo.c -emit-llvm" to get the old behavior.

llvm-svn: 46791
2008-02-06 01:42:25 +00:00
Chris Lattner
8082d870bd rename ASTSTreamer.{h|cpp} -> ParseAST.{h|cpp}
llvm-svn: 46786
2008-02-06 00:23:21 +00:00
Chris Lattner
b1537ebdd4 rewrite some of the type refinement code to eliminate dangling pointers
simplify the code and generally make it more robust.

llvm-svn: 46745
2008-02-05 08:06:13 +00:00
Chris Lattner
3ac9699c44 Fix PR1966 by ignoring non-error diagnostics from system headers even if they are
*mapped* onto errors.

llvm-svn: 46686
2008-02-03 09:00:04 +00:00
Steve Naroff
e6b7ffd073 Minor API cleanup...
llvm-svn: 46649
2008-02-01 22:08:12 +00:00
Steve Naroff
d9dc63f2c5 Remove temporary workaround (thanks to Ted for fixing ObjCAtCatchStmt so quickly:-).
llvm-svn: 46648
2008-02-01 21:51:39 +00:00
Steve Naroff
edb5bc6f09 Fix two rewriter bugs with @catch.
- Support @catch(...), rather than crash:-)
- Make sure all catch bodies get rewritten. This "fix" is really a workaround until the iterator for the "try" AST is fixed. Will fix this in a separate commit.

llvm-svn: 46644
2008-02-01 20:02:07 +00:00
Chris Lattner
9cc55f5b1f add some helper methods for removing and replacing text, this makes the
rewriter more robust.

llvm-svn: 46622
2008-01-31 19:51:04 +00:00
Chris Lattner
1780a85602 Add a new InsertText method that does the check to see if the insertion was valid. This
fixes crashes where the insertion point was in a macro.  Instead of crashing, we want
to emit a warning.

llvm-svn: 46621
2008-01-31 19:42:41 +00:00
Chris Lattner
187f626a7c move a large method out of line
llvm-svn: 46620
2008-01-31 19:38:44 +00:00