Commit Graph

966 Commits

Author SHA1 Message Date
Chris Lattner 7459c86a29 simplify this code a bit more.
llvm-svn: 54864
2008-08-17 03:54:39 +00:00
Chris Lattner 068529a243 remove global variables for output stream.
llvm-svn: 54861
2008-08-17 03:12:02 +00:00
Chris Lattner b5a92f8648 Switch to shared raw_ostream code instead of having it be clang specific.
This also helps the eventual distcc project.

llvm-svn: 54858
2008-08-17 01:47:12 +00:00
Ted Kremenek e4d923383a Fix typo.
llvm-svn: 54774
2008-08-14 03:45:07 +00:00
Daniel Dunbar 3ad53483fb Add LangOptions::NeXTRuntime.
- Wired to -fnext-runtime and -fgnu-runtime options.
 - Defaults to GNU, no autoselection for NeXT.

Emit NeXT OBJC_IMAGE_INFO marker.

llvm-svn: 54651
2008-08-11 21:35:06 +00:00
Daniel Dunbar fb3043d627 Add -fexceptions to Driver
- Maps to LangOptions.Exceptions
 - Currently always off, should autoselect based on language.

Update CodeGen to set unwind attribute on functions definitions based
       on LangOptions.Exceptions.
 - Still need to set attributes appropriately on calls.

llvm-svn: 54643
2008-08-11 17:36:14 +00:00
Daniel Dunbar 221fa94e40 More #include cleaning
- Drop Expr.h,RecordLayout.h from ASTContext.h (for DeclBase.h and
   SourceLocation.h)
 - Move ASTContext constructor into implementation

llvm-svn: 54627
2008-08-11 04:54:23 +00:00
Nico Weber 4c3116437c * Remove isInSystemHeader() from DiagClient, move it to SourceManager
* Move FormatError() from TextDiagnostic up to DiagClient, remove now  
  empty class TextDiagnostic
* Make DiagClient optional for Diagnostic

This fixes the following problems:

* -html-diags (and probably others) does now output the same set of  
  warnings as console clang does
* nothing crashes if one forgets to call setHeaderSearch() on  
  TextDiagnostic
* some code duplication is removed

llvm-svn: 54620
2008-08-10 19:59:06 +00:00
Nico Weber e4919cc2bf Do not crash with -serialize.
This happened because seralization was done in the constructor, and at that time the TranslationUnit is no longer valid.

llvm-svn: 54618
2008-08-10 19:20:05 +00:00
Chris Lattner 6307f19726 rename PreDefinedExpr -> PredefinedExpr
llvm-svn: 54605
2008-08-10 01:53:14 +00:00
Nico Weber 7094a5bfa8 do not serialize invalid asts. this fixes bug #2637
llvm-svn: 54590
2008-08-09 18:32:11 +00:00
Ted Kremenek 6231e7e4ec Unbreak SerializationTest and the Rewriter by doing the work in HandleTranslationUnit instead of the destructor.
llvm-svn: 54513
2008-08-08 04:15:52 +00:00
Ted Kremenek dcb5e38927 ParseAST now never releases the passed ASTConsumer. This is the responsibility of the client.
The motivation is that clients may either:

(a) query the ASTConsumer object after AST parsing to collect data/etc.
(b) reuse the ASTConsumer.

llvm-svn: 54502
2008-08-08 02:46:37 +00:00
Ted Kremenek 59f3553392 Remove unneeded #includes.
llvm-svn: 54478
2008-08-07 18:14:04 +00:00
Ted Kremenek 6b515b5b34 Micro cleanups.
llvm-svn: 54477
2008-08-07 18:13:12 +00:00
Ted Kremenek 31691ae862 Fix --html-diags in driver by delaying the construction of an HTMLDiagnosticClient until after we have created the Preprocessor object.
llvm-svn: 54472
2008-08-07 17:49:57 +00:00
Matthijs Kooijman 8dab3eec81 Let LLVMCodeGenWriter forward all the methods defined in ASTConsumer, to
prevent unexpected surprises later on.

llvm-svn: 54469
2008-08-07 16:04:15 +00:00
Steve Naroff c884aa8e84 Fix for <rdar://problem/6113807> clang ObjC rewriter: crash rewriting attached file
While this is a safe rewriter fix, there is still a need for some discussion (see report for more info).

llvm-svn: 54412
2008-08-06 15:58:23 +00:00
Nico Weber b5fc3c300a add a libDriver, for now only move the text diangostics stuff from Driver to there
llvm-svn: 54383
2008-08-05 23:33:20 +00:00
Steve Naroff dd514e01f2 Finish fixing <rdar://problem/5929344> clang ObjC rewriter: "extern int __CFConstantStringClassReference[];" should be extern "C"
llvm-svn: 54367
2008-08-05 20:04:48 +00:00
Nuno Lopes d86aa9340d fix crash when printing diagnostics with tokens that span through more than one line
llvm-svn: 54365
2008-08-05 19:40:20 +00:00
Ted Kremenek 2c674f6dbb Refactored driver logic for CodeGen into LLVMCodeGenWriter. This ASTConsumer layers on top of LLVMCodeGen (another existing ASTConsumer) to emit bitcode files to disk. This layering takes this logic out of clang.cpp and puts it directly into the ASTConsumer interface. The benefit is that now --emit-llvm works with both serialized ASTs and regular source files.
llvm-svn: 54364
2008-08-05 18:50:11 +00:00
Steve Naroff 568bbf73b2 Fix <rdar://problem/6108119> clang ObjC rewriter: if no newline at end of input file, rewriter inserts #define on same line as closing brace
llvm-svn: 54363
2008-08-05 18:47:23 +00:00
Daniel Dunbar 1ff1d1fd51 Move AsmLabel into Declarator instead of just a parameter to
ActOnDeclarator.

llvm-svn: 54353
2008-08-05 16:28:08 +00:00
Daniel Dunbar 4983df37a7 Add more Parser/Sema support for GCC asm-label extension.
- ActOnDeclarator now takes an additional parameter which is the
   AsmLabel if used. Its unfortunate that this bubbles up this high,
   but we cannot just lump it in as an attribute without mistakenly
   *accepting* it as an attribute.
 - The actual asm-label itself is, however, encoded as an AsmLabelAttr
   on the FunctionDecl.
 - Slightly improved parser error recovery on malformed asm-labels.
 - CodeGen support still missing...

llvm-svn: 54339
2008-08-05 01:35:17 +00:00
Ted Kremenek 9898028742 Fix regression when invoking the MissingDealloc analysis: disable this check when in -fobjc-gc-only mode.
llvm-svn: 54319
2008-08-04 17:14:10 +00:00
Daniel Dunbar f4693e289a Add more output to clang -parse-print-callbacks
- Just added prints for all the action functions. Ideally this would
   be extended to print all the information for the actions.

llvm-svn: 54259
2008-08-01 00:41:12 +00:00
Ted Kremenek 8cf5045012 Fix regression in range highlighting in HTML output.
llvm-svn: 54181
2008-07-29 23:35:38 +00:00
Steve Naroff 873bd8497a Fix incomplete implementation for rewriting protocol refs.
<rdar://problem/6108127> clang ObjC rewriter: no translation of id <proto>

llvm-svn: 54163
2008-07-29 18:15:38 +00:00
Chris Lattner 3f6cd0bc76 remove some unneeded calls to getCanonicalType
llvm-svn: 54106
2008-07-26 22:36:27 +00:00
Chris Lattner f08932928c comment out #pragma mark and #warning directives.
llvm-svn: 54020
2008-07-25 16:37:06 +00:00
Chris Lattner b9c34de5c4 rewrite handling of the raw token stream in -rewrite-macros to lex
everything up front into a vector.  This makes it easier to scan around
the stream when needed.

llvm-svn: 54019
2008-07-25 16:29:12 +00:00
Steve Naroff 29788347b2 Fix RewriteObjC::RewriteObjCThrowStmt() to respect whitespace between the @ and throw.
This fixes <rdar://problem/5988388> clang ObjC rewriter: mystery 'w' inserted in exception throw.

llvm-svn: 54017
2008-07-25 15:41:30 +00:00
Steve Naroff 6c79f97037 Fix Sema::ActOnClassMessage() to pass through the identifier for "super".
This fixes a critical rewriter bug (<rdar://problem/6096760> clang ObjC rewriter: 'self' not expected value in class method called with 'super').

Also added a couple FIXME's since I'm not happy with my fix to Sema. It would be nicer if the super handling for class/instance messages was the same (based on PreDefinedExpr).

llvm-svn: 53994
2008-07-24 19:44:33 +00:00
Ted Kremenek 1c0c06bb9c "This patch adds paths for Fedora 9 in clang.cpp and support for two preprocessor options in ccc."
Patch by Zhongxing Xu!

llvm-svn: 53976
2008-07-24 03:49:15 +00:00
Ted Kremenek c99332c5a6 Modified HTMLDiagnostics to also perform syntax highlighting for errors in header files.
llvm-svn: 53965
2008-07-23 23:18:15 +00:00
Ted Kremenek 3b28f4911c Add prototype implementation of unused ivar check.
llvm-svn: 53942
2008-07-23 00:45:26 +00:00
Ted Kremenek 1f352db96a Moved registration of basic path-sensitive checks from GRSimpleVals.cpp to GRExprEngineInternalChecks.cpp.
llvm-svn: 53909
2008-07-22 16:21:24 +00:00
Chris Lattner 388f6e97e1 unindent this function by using an early exit, not functionality change.
llvm-svn: 53877
2008-07-21 21:33:21 +00:00
Chris Lattner 390d39ac7e move two more lists of protocols over to use ObjCList<ObjCProtocolDecl>,
simplifying code along the way and fixing a problem and memory leak or two.

llvm-svn: 53876
2008-07-21 21:32:27 +00:00
Steve Naroff f0ff879881 RewriteObjC::RewriteObjCForCollectionStmt() needs to handle bodies with a single statement.
Fixes <rdar://problem/6084870> clang ObjC rewriter: for-in enumeration in 1 line produces output with error.

llvm-svn: 53858
2008-07-21 18:26:02 +00:00
Chris Lattner d004505b74 introduce a new ObjCList templated class and start moving
various objc lists over to it.  First up, the protocol list 
on ObjCInterfaceDecl.

llvm-svn: 53856
2008-07-21 18:19:38 +00:00
Daniel Dunbar 155ed24359 Prevent clang from emitting output when input has errors
+ test case
<rdar://problem/6080040>
http://llvm.org/bugs/show_bug.cgi?id=2280

llvm-svn: 53756
2008-07-18 16:38:05 +00:00
Steve Naroff 97adf60418 RewriteObjC::SynthMessageExpr(): Fix super rewrite (a fairly recent regression).
Fixes <rdar://problem/6046663> clang ObjC rewriter: Regression in handling of 'super' in latest build.

llvm-svn: 53703
2008-07-16 22:35:27 +00:00
Steve Naroff d7ebc05476 Remove a FIXME from RewriteObjC::RewriteObjCSynchronizedStmt().
llvm-svn: 53696
2008-07-16 19:47:39 +00:00
Steve Naroff 8dd1525b9a RewriteObjC::Initialize(): add function decls used by @synchronized.
This fixes <rdar://problem/6040143> clang ObjC rewriter: @synchronized keyword inserts undeclared objc functions.

llvm-svn: 53695
2008-07-16 18:58:11 +00:00
Steve Naroff de7d0f69ba Two fixes:
- Make sure ObjCIvarDecl propagates the bitfield width.
- RewriteObjC::SynthesizeIvarOffsetComputation(): Avoid using the __OFFSETOF__ mumbo jumbo for bitfields (since it isn't legal C). This fixes <rdar://problem/5986079> clang ObjC rewriter: bitfields and ivar access don't mix.

llvm-svn: 53694
2008-07-16 18:22:22 +00:00
Steve Naroff ce2dca186b RewriteObjC::RewriteObjCTryStmt():Don't synthesize a catch begin if there are 0 catch clauses.
This fixes <rdar://problem/5987211> clang ObjC rewriter: @try / @finally block produces unbalanced output.

llvm-svn: 53679
2008-07-16 15:31:30 +00:00
Steve Naroff b067bbd019 Teach RewriteObjC::RewriteObjCMethodDecl() to deal with pointer to function return types.
This fixes <rdar://problem/6034961> clang ObjC rewriter: rewriting methods with function pointer return values does not work

llvm-svn: 53678
2008-07-16 14:40:40 +00:00
Ted Kremenek fd7efdf20d Provide an "Analysis Scope" for Analyses so checks can either be run on code declarations (bodies) or Objective-C @implementation blocks.
llvm-svn: 53584
2008-07-15 00:46:02 +00:00
Ted Kremenek 3063b73773 Break off declaration of Analysis enum into Analyses.def. The driver options in
clang.cpp now #include these definitions to create the command line options, and
AnalysisConsumer #includes this file to generate the switch statement to create
actions.

Renamed -check-objc-methodsigs to -warn-objc-methodsigs.

The "missing -dealloc" check is now optional: -warn-objc-missing-dealloc

llvm-svn: 53575
2008-07-14 23:41:13 +00:00
Ted Kremenek 3bfb314c25 Add new check: -check-objc-methodsigs. This check scans methods in
ObjCImplementationDecls and sees if a ancestor class defines a method with the
same selector but with a different type signature. Right now it just compares
return types, and mainly looks at differences in primitive values. The checking
will be expanded in the future.

llvm-svn: 53482
2008-07-11 22:40:47 +00:00
Ted Kremenek 79ab0fa913 In a report-XXXXX.html, make the title include the name of the file with the bug. Patch by Jean-Daniel Dupas!
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-July/002166.html

llvm-svn: 53184
2008-07-07 18:31:05 +00:00
Nuno Lopes 88b1d0ee42 add gentoo stable gcc headers path so that all tests pass here (CPATH isnt enough..)
llvm-svn: 53143
2008-07-05 17:15:18 +00:00
Ted Kremenek e66ca6f35a For the -dealloc checker, check the LangOptions to determine whether or not the code is compiled with GC.
llvm-svn: 53098
2008-07-03 14:35:01 +00:00
Ted Kremenek 1d3c797c90 Have BugReporter::getCFG and BugReporter::getLiveVariables returns pointers instead of references, because they can both fail
on functions we cannot construct full CFGs for yet.

llvm-svn: 53081
2008-07-03 05:26:14 +00:00
Ted Kremenek 0e7d25233e Added static analysis check to see if a subclass of NSObject implements -dealloc, and whether or not that implementation calls [super dealloc].
llvm-svn: 53075
2008-07-03 04:29:21 +00:00
Ted Kremenek c7efb536d5 Unify the code path for the Dead Stores checker to always use the BugReporter interface.
llvm-svn: 53054
2008-07-02 23:16:33 +00:00
Ted Kremenek b1d0118a1a Refactored some of the BugReporter interface so that data such as the ASTContext&, PathDiagnosticClient*, can be provided by an external source.
Split BugReporter into BugReporter and GRBugReporter so checkers not based on GRExprEngine can still use the BugReporter mechanism.

llvm-svn: 53048
2008-07-02 21:24:01 +00:00
Ted Kremenek 125d4a3b2d GRExprEngine now expects the LiveVariables information to be provided by its creator.
This allows an optimization in AnalysisConsumer where the same LiveVariables information is used between multiple analyses.

llvm-svn: 53046
2008-07-02 20:13:38 +00:00
Ted Kremenek d8ca1f6dd9 Added version of CheckDeadStores that accepts a client-provided LiveVariables object.
Modified the DeadStores logic in AnalysisConsumer.cpp to use the LiveVariables object created by the AnalysisManager.

llvm-svn: 53043
2008-07-02 18:39:20 +00:00
Ted Kremenek f992cfb4ab Moved logic for -dump-cfg and -view-cfg into AnalysisConsumer.
Renamed -dump-cfg to -cfg-dump, and -view-cfg to -cfg-view.  This naming better matches the same options for asts (e.g. -ast-dump).

llvm-svn: 53041
2008-07-02 18:23:21 +00:00
Ted Kremenek bdbe6130f4 Move -dump-live-variables logic to AnalysisConsumer.
llvm-svn: 53039
2008-07-02 18:11:29 +00:00
Ted Kremenek 71ac83246f Migrate CheckerConsumer diagnostics to the new AnalysisConsumer interface.
Remove CheckerConsumer.

llvm-svn: 53029
2008-07-02 16:49:11 +00:00
Ted Kremenek becec2cbbc Move logic for "-checker-simple" to the new AnalysisConsumer interface.
llvm-svn: 53028
2008-07-02 16:35:50 +00:00
Ted Kremenek 8e631a0267 Migrated driver logic for running the CF retain/release checker over to the new AnalysisConsumer interface.
llvm-svn: 53002
2008-07-02 00:44:58 +00:00
Ted Kremenek f0413bfcda Added AnalysisConsumer, a meta-level ASTConsumer class to drive various
analyses. This potentially is the primordial origins of a Clang-equivalent
"PassManager".

The new AnalysisConsumer interface allows multiple analyses to be run from a
single invocation of Clang.

Migrated the logic of "-warn-dead-stores" and "-warn-uninit-values" to use the
new AnalysisConsumer interface. The new interface results in a significant code
reduction to incorporate an analysis into the Driver.

Updated a test case to (correctly) acknowledge that it contains a dead store
(this check wasn't being performed because it was previously masked by
-warn-uninit-values).

llvm-svn: 52996
2008-07-02 00:03:09 +00:00
Matthijs Kooijman 0fb56e50b1 Make clang work on 32 bit powerpc linux.
Patch by Nick Lewycky!

llvm-svn: 52777
2008-06-26 08:39:30 +00:00
Matthijs Kooijman 70574af7d8 Link in LLVMAnalysis after LLVMCodeGen, since the latter depends on the former
since LLVM r52748.

llvm-svn: 52776
2008-06-26 08:37:29 +00:00
Chris Lattner d46944d639 a temporary minimal hack to get clang building after the getStringValue changes in llvm mainline.
llvm-svn: 52753
2008-06-26 04:05:20 +00:00
Ted Kremenek 675a6e6dfa Patch by Anders Bergh:
'There's not much to say about this patch, it just adds the Arch Linux
gcc 4.3.1 header paths for i686 and amd64. The patch was generated
using "svn diff" with clang at revision 52660. The paths aren't
distribution-specific, so they should work for all Linux distributions
using the default(?) names like "i686-pc-linux-gnu".'

llvm-svn: 52665
2008-06-24 03:33:47 +00:00
Chris Lattner 0f2b471730 Implement printing for ObjCClassDecl's, patch by Jean-Daniel Dupas!
llvm-svn: 52598
2008-06-21 21:40:20 +00:00
Chris Lattner a9b3cae8fd Switch 'super' from being a weird cast thing to being a predefined expr node.
Patch by David Chisnall with objc rewriter and stmtdumper updates from me.

llvm-svn: 52580
2008-06-21 18:04:54 +00:00
Ted Kremenek c64511152a Updated call to dead stores to use proper arguments.
llvm-svn: 52560
2008-06-20 21:55:29 +00:00
Chris Lattner 5696e7badf Change self/_cmd to be instances of ImplicitParamDecl instead of ParmVarDecl.
Patch by David Chisnall!

llvm-svn: 52422
2008-06-17 18:05:57 +00:00
Argyrios Kyrtzidis 351008da17 Allow -parse-noop -verify options to be used together.
llvm-svn: 52249
2008-06-13 12:15:34 +00:00
Argyrios Kyrtzidis 554a07bab3 -Changes to TagDecl:
Added TagKind enum.
  Added getTagKind() method.
  Added convenience methods: isEnum(), isStruct(), isUnion(), isClass().
-RecordDecl/CXXRecordDecl::Create() accept a TagKind enum instead of a DeclKind one.

llvm-svn: 52160
2008-06-09 23:19:58 +00:00
Eli Friedman 8233993fc6 Get -serialize working again, plus a bit of minor cleanup.
llvm-svn: 52152
2008-06-09 20:02:51 +00:00
Ted Kremenek 92611db88f Use a common SourceManager when processing multiple files. This allows us to cache the contents of source files already loaded from disk.
llvm-svn: 52066
2008-06-06 22:42:39 +00:00
Ted Kremenek 3ad519441f Fix crash when running with multiple source files. This can be improved.
llvm-svn: 52032
2008-06-06 01:47:30 +00:00
Ted Kremenek b147ad1051 Moved LangOptions from TranslationUnit to ASTContext. This induced a variety of cleanups in some ASTConsumers.
llvm-svn: 51943
2008-06-04 15:55:15 +00:00
Chris Lattner f4fee9e1e5 make rewrite macros insert a space when commenting out macros where the token didn't
lead with a space.

llvm-svn: 51896
2008-06-03 06:10:17 +00:00
Steve Naroff f611964230 Fix <rdar://problem/5976164> clang ObjC rewriter: for ... in enumeration inserts undeclared function (objc_enumerationMutation should be in preamble)
llvm-svn: 51880
2008-06-02 20:23:21 +00:00
Chris Lattner d3f3231a07 Two identifiers are not the same unless they have the same identifier info.
llvm-svn: 51827
2008-05-31 22:01:01 +00:00
Ted Kremenek 380df93fd6 Added "InitializeTU" to ASTConsumer. This is used by Sema::ParseAST to pass a
TranslationUnit object instead of an ASTContext. By default it calls
Initialize(ASTConstext& Context) (to match with the current interface used by
most ASTConsumers).

Modified the ObjC-Rewriter to use InitializeTU, and to tell the TranslationUnit
to not free its Decls.  This is a workaround for: <rdar://problem/5966749>

llvm-svn: 51825
2008-05-31 20:11:04 +00:00
Steve Naroff cd92aebd1f Fix <rdar://problem/5917992> clang ObjC rewriter: #end from #if statement lost in translation.
Some fancy footwork to accommodate embedded preprocessor directives within an interface.

llvm-svn: 51815
2008-05-31 14:15:04 +00:00
Steve Naroff 930e099b90 Fix <rdar://problem/5969777> clang ObjC rewriter: #imported file name mysteriously commented out
This fix involved tightening up needToScanForQualifiers(), which predated ObjCQualifiedIdType.
It also includes a minor tweak to the code that searches for the beginning of the qualified type. If the AST contained the correct beginning of the declaration (i.e. the beginning of the declaration specifiers), this code would be more robust. Since it doesn't, we apply an adhoc heuristic. Note that DeclSpec contains this info...we just don't propagate it to the AST (at present).

llvm-svn: 51812
2008-05-31 05:02:17 +00:00
Steve Naroff a6141f0780 Hack RewriteObjC::RewriteObjCStringLiteral() to include the filename in the generated code (replacing any non-alphanumeric characters with "_"). This allows header files to contain ObjCStringLiterals.
llvm-svn: 51811
2008-05-31 03:35:42 +00:00
Ted Kremenek a3774667d3 Correctly preserve the order between -F and -I options.
llvm-svn: 51803
2008-05-31 00:27:00 +00:00
Ted Kremenek 6bb6d9f197 Use llvm:🆑:desc for description of the -Wimplicit-function-declaration option.
Patch by Holger Schurig!

llvm-svn: 51774
2008-05-30 16:42:02 +00:00
Eli Friedman 35c01c6f2d Fix crash with -serialize (reported to cfe-dev). The issue was
essentially that we were destroying the declarations twice.

(Note that we don't use -serialize directly in the testsuite, only 
SerializeTest.)

llvm-svn: 51768
2008-05-30 11:28:30 +00:00
Chris Lattner 8c80070de2 Implement support for -w, which silences all warnings. PR2384.
llvm-svn: 51683
2008-05-29 15:36:45 +00:00
Chris Lattner 34873d2134 give location info to another paren expr.
llvm-svn: 51646
2008-05-28 16:38:23 +00:00
Chris Lattner 37f5b7d39c minor changes, collect the range of an expr before rewriting the subexprs
no functionality change.

llvm-svn: 51497
2008-05-23 20:40:52 +00:00
Steve Naroff fd16687b9a Make sure method definitions get output with -ast-dump.
llvm-svn: 51494
2008-05-23 18:50:58 +00:00
Ted Kremenek 0954b4564e Update driver include paths to work on darwin10.
llvm-svn: 51431
2008-05-22 15:26:22 +00:00
Dan Gohman 1627ae7c48 Explicitly #include Support/Streams.h when using llvm::cout and friends.
llvm-svn: 51391
2008-05-21 20:19:16 +00:00
Eli Friedman b158b4a47b Fix the destruction "properly" in the sense that we actually destroy the
ASTs.  This is a hack, but I haven't considered how we really 
want to do this.

llvm-svn: 51364
2008-05-21 05:33:10 +00:00
Steve Naroff ad91868aa6 Fix rewriter bug <rdar://problem/5929344> clang ObjC rewriter: "extern int __CFConstantStringClassReference[];" should be extern "C".
Have clang predefine OBJC_NEW_PROPERTIES (which is what gcc does).

llvm-svn: 51163
2008-05-15 21:12:10 +00:00
Chris Lattner 14196c099f Implement -rewrite-macros, which is a crazy macro expander that expands
macros but doesn't expand #includes, remove comments, remove #defines
etc.

For example:

----
#include <stdio.h>

#define bbaa
#define funclike(x) x "a" x "b" x

bbaa  bbaa

#if 1 
funclike("gar")
foo /*blah*/  bar
bar
#endif

#if 0
funclike()
#endif
----


rewrites to:

----
#include <stdio.h>

#define bbaa
#define funclike(x) x "a" x "b" x 

/*bbaa  bbaa*/

#if 1
 "gar" "a" "gar" "b" "gar"/*funclike*//*("gar")*/
foo /*blah*/  bar
bar
#endif

#if 0
/*funclike()*/
#endif
----

llvm-svn: 50925
2008-05-10 00:02:33 +00:00
Chris Lattner 664ef65981 make #if 0 code compile, even though it still isn't very useful.
llvm-svn: 50920
2008-05-09 22:43:24 +00:00
Steve Naroff d30f8c5b54 Fix <rdar://problem/5924225> clang ObjC rewriter: objc_exception_throw declaration in preamble does not match objc/objc-exception.h.
llvm-svn: 50915
2008-05-09 21:17:56 +00:00
Steve Naroff 2e4e385a58 Make sure the prototype for objc_msgSend_fpret() returns a double.
llvm-svn: 50873
2008-05-08 22:02:18 +00:00
Steve Naroff b1c02371cd Fix <rdar://problem/5879237> clang objc rewriter: ivars not accessible in structure generated for class
llvm-svn: 50862
2008-05-08 17:52:16 +00:00
Sanjiv Gupta 15cb669039 Added -g command line options to clang for generating source level debug information. This patch currently enables generation of line number debug information (stoppoints) and region begin/end debug information. The new files CGDebugInfo.h and CGDebugInfo.cpp implements the debug info manager class CGDebugInfo.
llvm-svn: 50848
2008-05-08 08:54:20 +00:00
Sanjiv Gupta cd13ef01a2 Remove the ending "." from clang options descriptions.
llvm-svn: 50847
2008-05-08 08:28:14 +00:00
Chris Lattner 3c04ff00c2 start implementation of a macro rewriter, this is currently just stubbed out.
llvm-svn: 50845
2008-05-08 06:52:13 +00:00
Steve Naroff 30ac2225ee Fix <rdar://problem/5887874> clang ObjC rewriter: Use a different name for 'offsetof' macro
llvm-svn: 50832
2008-05-07 21:23:49 +00:00
Fariborz Jahanian ec6e4c8096 This patch introduces declaration of getter methods for ObjC2's
properties. Couple of property tests will fail with this patch.
Will fix them next.

llvm-svn: 50818
2008-05-07 17:43:59 +00:00
Steve Naroff cab93d58c3 Fix <rdar://problem/5908598> clang ObjC rewriter: typo in #pragma at end
llvm-svn: 50790
2008-05-07 00:06:16 +00:00
Ted Kremenek e6d2419351 Improve HTMLDiagnostics by understanding the "Below" hint.
llvm-svn: 50783
2008-05-06 23:42:18 +00:00
Steve Naroff 29ce4e5d78 Fix <rdar://problem/5879237> clang objc rewriter: ivars not accessible in structure generated for class
llvm-svn: 50781
2008-05-06 23:20:07 +00:00
Fariborz Jahanian eeb7fae063 Print ObjC methods of ObjC classes.
llvm-svn: 50779
2008-05-06 23:14:25 +00:00
Steve Naroff ac81a5aad5 Fix <rdar://problem/5888515> clang ObjC rewriter: Use objc.h for declarations instead of putting them in the preamble?
llvm-svn: 50774
2008-05-06 22:45:19 +00:00
Steve Naroff 13e74879b0 Fix <rdar://problem/5881225> clang ObjC Rewriter: Protocol structure defined twice when two interfaces use it in same file
llvm-svn: 50767
2008-05-06 18:26:51 +00:00
Fariborz Jahanian 09367d68ff Patch to refactor setter/getter names of property attributes into Selector
(was IdentifierInfo * before). This will make method declartations whole
lot easier.

llvm-svn: 50747
2008-05-06 18:09:04 +00:00
Chris Lattner 00e2607de2 Add support for -Wimplicit-function-declaration, rdar://5907433
llvm-svn: 50672
2008-05-05 21:18:06 +00:00
Fariborz Jahanian 8d91686b0d percolate @optional/@required protocols down to ASTs for
properties declared in the protocol.

llvm-svn: 50662
2008-05-05 18:51:55 +00:00
Chris Lattner de977c0a5c Fix PR2281: these two warnings should be promoted to error on
pedantic error.  Perhaps I should add a class of 'extension' that is
'extension that warns by default', which would be cleaner.

llvm-svn: 50633
2008-05-04 23:52:02 +00:00
Ted Kremenek 5f56cbbf7d Output better paths to display in bug reports and compute a common
prefix for all files.

llvm-svn: 50592
2008-05-02 22:04:53 +00:00
Ted Kremenek 789942cfda When running the reference count checker twice (GC and non-GC mode), only emit
basic warnings (dead stores, null dereferences) on the first pass.

llvm-svn: 50584
2008-05-02 18:01:49 +00:00
Ted Kremenek b0f87c48cb added preliminary diagnostics in scan-build results to denote whether
a CF memory leak occurred with GC enabled, etc.

llvm-svn: 50507
2008-04-30 23:47:44 +00:00
Ted Kremenek 4d1f422c6f Provide the option to run the CF-retain checker in GC enabled mode.
The transfer functions for the checker don't do anything special yet in GC mode.

llvm-svn: 50394
2008-04-29 05:13:59 +00:00
Ted Kremenek d796c18d7b Add -fobjc-gc and -fobjc-gc-only options to the driver.
Add corresponding enum in LangOptions.

llvm-svn: 50387
2008-04-29 04:37:03 +00:00
Ted Kremenek 64fa3beccc Better handling for directory names in HTML diagnostics. Work in progress.
llvm-svn: 50234
2008-04-24 23:37:03 +00:00
Ted Kremenek 467297ab48 TranslationUnit now owns IdentifierTable, TargetInfo, and Selectors objects
when it is constructed via deserialization.  This is done by recording a flag
indicating that this is the case, and it deletes these objects by getting
the references stored in the ASTContext object.  This fixes some memory
leaks that occurs when we deserialize translation units from bitcode files.

The rationale between having TranslationUnit sometimes own these objects and
sometimes not is that a TranslationUnit object can be constructed from
state generated by the parser (Preprocessor; semantic analyzer, etc.), and thus
in these cases won't own the IdentifierTable or Selectors, etc.  During
deserialization, there is no Preprocessor, so somebody needs to own these
objects in order for them to be properly reclaimed.

llvm-svn: 50149
2008-04-23 16:25:39 +00:00
Fariborz Jahanian 6efdf1ddab Patch to build AST for property implementation declarations and
to print declaration from its AST.

llvm-svn: 50117
2008-04-23 00:06:01 +00:00
Ted Kremenek 9718c9e8ee PathDiagnosticClients now retain ownership of passed PathDiagnostics, requiring
them to not be stack-allocated.

HTMLDiagnostics now batches PathDiagnostics before emitting HTML in its dtor.
This is a workaround for a problem when we trampled the Preprocessor state
when highlighting macros (sometimes resulting in an assertion failure).

llvm-svn: 50102
2008-04-22 16:15:03 +00:00
Ted Kremenek 076d13387d html::EscapeText (using the Rewriter) now replaces tabs by default.
llvm-svn: 49982
2008-04-20 01:02:33 +00:00
Chris Lattner 1a44f7fce9 simplify the return of InitializePreprocessor to be bool instead of a fileid
llvm-svn: 49974
2008-04-19 23:25:44 +00:00
Chris Lattner ba1f37bfdf simplify ownership of the predefines buffer.
llvm-svn: 49973
2008-04-19 23:09:31 +00:00
Steve Naroff 472cf88ef2 Remove bogus cast (<rdar://problem/5874848> clang objc-rewriter: structure with list of protocols has wrong cast).
llvm-svn: 49935
2008-04-18 22:15:15 +00:00
Steve Naroff 24840f6748 Implement FIXME discoved by <rdar://problem/5874876> Rewriter: Explicit ivar refs outside a method are being rewritten
llvm-svn: 49932
2008-04-18 21:55:08 +00:00
Steve Naroff dcdcdcdfef Fix <rdar://problem/5874697> Rewriter: method arguments with complex types not being rewritten properly.
llvm-svn: 49925
2008-04-18 21:13:19 +00:00
Ted Kremenek 71c41d9561 Restore macro expansion for HTMLPrint by using the original Preprocessor.
This is a workaround until we figure out why a freshly create Preprocessor
doesn't expand macros from headers.

llvm-svn: 49897
2008-04-18 05:35:23 +00:00
Ted Kremenek 9e48b0c4ed Fixed range highlighting bug in HTML diagnostics.
llvm-svn: 49893
2008-04-18 05:01:33 +00:00
Ted Kremenek f42f3fb47d class Preprocessor: Now owns the "predefines" char*; it deletes [] it in its dstor.
clang.cpp: InitializePreprocessor now makes a copy of the contents of PredefinesBuffer and
  passes it to the preprocessor object.
  
clang.cpp: DriverPreprocessorFactory now calls "InitializePreprocessor" instead of this being done in main().

html::HighlightMacros() now takes a PreprocessorFactory, allowing it to conjure up a new
Preprocessor to highlight macros.

class HTMLDiagnostics now takes a PreprocessorFactory* that it can use for html::HighlightMacros().
Updated clients of HTMLDiagnostics to use this new interface.

llvm-svn: 49875
2008-04-17 22:31:54 +00:00
Chris Lattner 7c7e9b3bbe Handle text escaping (e.g. & -> &amp;) last, to avoid interactions between 'replace' operations and insert operations. This fixes a problem with "&;&" on line 666 of the gcc.c example I sent out.
llvm-svn: 49874
2008-04-17 22:24:51 +00:00
Ted Kremenek 306492d8cb Generate the Preprocessor using a local PreprocessorFactory object.
While this adds no extra functionality now, we will soon pass the
PreprocessorFactory object to some ASTConsumers.

llvm-svn: 49873
2008-04-17 21:38:34 +00:00
Ted Kremenek aabc986766 Temporarily disable macro expansion in the HTML output of HTMLDiagnostics to
avoid corrupting Preprocessor state.  Working on a fix.

llvm-svn: 49864
2008-04-17 18:39:57 +00:00
Ted Kremenek 8bb90b8152 HAve HTMLDiagnostics use html::HighlightRange to highlight message ranges.
llvm-svn: 49863
2008-04-17 18:37:23 +00:00
Fariborz Jahanian 8e36cddde0 Added property decl support for protocols.
Added assertion if unexpected property decls are found where they don't belong.
Consolidated property decl. printing by using a helper function.

llvm-svn: 49862
2008-04-17 18:25:18 +00:00
Nate Begeman 36c49278b5 Allow redirecting text diagnostic printer output to any llvm::OStream, rather
than hard coding llvm::cerr.

llvm-svn: 49860
2008-04-17 18:06:57 +00:00
Argyrios Kyrtzidis c3b69ae815 Addition of TranslationUnitDecl to the AST:
-Added TranslationUnitDecl class to serve as top declaration context
-ASTContext gets a TUDecl member and a getTranslationUnitDecl() function
-All ScopedDecls get the TUDecl as DeclContext when declared at global scope

llvm-svn: 49855
2008-04-17 14:40:12 +00:00
Fariborz Jahanian 9d981eb9ae This patch adds support for declaraing properties in categories,
just as they are declared in objc classes.

llvm-svn: 49817
2008-04-16 21:08:45 +00:00
Ted Kremenek 2e4d0ecaa3 Added fixme.
llvm-svn: 49797
2008-04-16 16:53:18 +00:00
Ted Kremenek f2e6fcf3bf Hook up HTMLDiagnostics to use Chris's new syntax highlighting. --html-diags
currently doesn't pass in the Preprocessor from the driver, so we don't get
syntax highlighting when we create HTMLDiagnostics in that way.

llvm-svn: 49796
2008-04-16 16:39:56 +00:00
Chris Lattner a5a75e7a10 split syntax highlighting of macros from keywords and comments,
allowing us to use a cheaper means to highlight keywords and making
it so that comments won't foul up macro expansions.

Start highlighting macro expansions.

llvm-svn: 49779
2008-04-16 06:32:08 +00:00
Chris Lattner 060d8aa2ed Add a mode of hackily syntax highlighting comments. This has a number of
problems, including the fact that it doesn't work well with multi-line 
comments due to Ted's crazy table.  However, that could be fixed, and it
does work with single-line ones :).

llvm-svn: 49778
2008-04-16 06:11:58 +00:00
Chris Lattner dffe0f7db5 Add -o support for -emit-html, make it not produce a file on an error.
llvm-svn: 49777
2008-04-16 05:21:09 +00:00
Ted Kremenek 088d12e741 Remove "--html-test" driver option and its corresponding code; all of this
functionality has been migrated into "--emit-html" and "--html-diags".

llvm-svn: 49776
2008-04-16 04:38:45 +00:00
Chris Lattner e4dd37ce0a speed up -emit-html in a release build by 6.5% by avoiding std::string.
llvm-svn: 49764
2008-04-16 03:46:57 +00:00
Steve Naroff 08899ff85d Remove FileVarDecl and BlockVarDecl. They are replaced by VarDecl::isBlockVarDecl() and VarDecl::isFileVarDecl().
This is a fairly mechanical/large change. As a result, I avoided making any changes/simplifications that weren't directly related. I did break two Analysis tests. I also have a couple FIXME's in UninitializedValues.cpp. Ted, can you take a look? If the bug isn't obvious, I am happy to dig in and fix it (since I broke it).

llvm-svn: 49748
2008-04-15 22:42:06 +00:00
Ted Kremenek 7d6219f501 For HTML diagnostics, output more information about a bug report.
llvm-svn: 49742
2008-04-15 21:25:08 +00:00
Ted Kremenek 044eb055af Handle "__private_extern__" storage class when printing FunctionDecls.
llvm-svn: 49706
2008-04-15 03:57:09 +00:00
Fariborz Jahanian 0152a1a5db New AST representation for each objc2's property declaration.
llvm-svn: 49699
2008-04-14 23:36:35 +00:00
Steve Naroff c5e5b38a8f Remove bogus token...
llvm-svn: 49695
2008-04-14 22:53:48 +00:00
Steve Naroff a8f0d12e81 Rename a file and update the Xcode project.
llvm-svn: 49693
2008-04-14 22:05:54 +00:00
Steve Naroff 1dc53ef494 Rename RewriteTest->RewriteObjC.
llvm-svn: 49692
2008-04-14 22:03:09 +00:00
Steve Naroff 4fff2a08aa Fix comment.
llvm-svn: 49688
2008-04-14 21:39:16 +00:00
Ted Kremenek d61ed3b6cb Use isFromMainFile instead of comparing FileIDs directly.
llvm-svn: 49687
2008-04-14 21:24:13 +00:00
Ted Kremenek 9569e57a50 Use SourceManager::isFromMainFile()
llvm-svn: 49685
2008-04-14 21:14:41 +00:00
Ted Kremenek 13ad6e1234 Convert over to new SourceManager::isFromMainFile() instead of doing direct
FileID comparison (fixes insidious corner case with chunks).

llvm-svn: 49684
2008-04-14 21:14:03 +00:00
Ted Kremenek bb2b224159 HTMLDiagnostics now uses the new "getCanonicalID()", "isFromMainFileID()" methods from
SourceManager when doing HTML pretty-printing.  This resolves an insidious bug when
presenting error reports that only occurred in large source files.

llvm-svn: 49683
2008-04-14 21:06:04 +00:00
Ted Kremenek 751d4d2d60 Added driver option "-checker-opt-analyze-headers" to force the static
analyzer to analyze functions declared in header files.

llvm-svn: 49675
2008-04-14 18:40:58 +00:00
Sam Bishop cb1a37b145 Handle -D and -U options in order, so that they can cancel each other out when
intermixed.

llvm-svn: 49645
2008-04-14 14:41:57 +00:00
Fariborz Jahanian 4572b45574 AST generation for objc2's property declarations.
llvm-svn: 49565
2008-04-11 23:40:25 +00:00
Chris Lattner 47fb9efa5d Fix rdar://5843510 don't assert and die when an invalid output
file is specified, print a happy little error message.

llvm-svn: 49518
2008-04-11 06:14:11 +00:00
Ted Kremenek 22bd628056 Fix some bonehead bugs in summary generation in CFRefCount.
llvm-svn: 49503
2008-04-10 22:58:08 +00:00
Ted Kremenek 4a78c3ae11 Refactored all logic to run the GRSimpleVals and CFRef checker into a common
code path in the clang driver.

Renamed options --grsimple to -checker-simple and -check-cfref to -checker-cfref.

llvm-svn: 49500
2008-04-10 22:16:52 +00:00
Ted Kremenek d4db4fa359 For -emit-html, use the Rewriter to expand tabs.
llvm-svn: 49409
2008-04-08 23:25:54 +00:00
Ted Kremenek 5f7ece0bff Don't expand tabs in EscapeText, but rather expand them when writing out
the HTML file.  This should reduce the amount of memory pressure on the
rewriter for files that have a lot of tabs.

llvm-svn: 49406
2008-04-08 22:37:58 +00:00
Ted Kremenek d8256ed2fe Improve range highlighting in HTMLDiagnostic to correctly highlight ranges
that span multiple lines by inserting multiple "</span>" and "<span>" tags.

llvm-svn: 49403
2008-04-08 21:29:14 +00:00
Chris Lattner 4fdfbf7b89 silence some warnings when assertions are disabled.
llvm-svn: 49372
2008-04-08 05:52:18 +00:00
Chris Lattner aa9c7aed0f Add support for C++ default arguments, and rework Parse-Sema
interaction for function parameters, fixing PR2046.

Patch by Doug Gregor!

llvm-svn: 49369
2008-04-08 04:40:51 +00:00
Chris Lattner 2163265b53 Fix rdar://5846705: "clang -E foo.c -o foo.i" should remove foo.i on error.
llvm-svn: 49368
2008-04-08 04:16:20 +00:00
Chris Lattner 0a5ff0d34a This patch contains these changes:
-Renamed ContextDecl -> DeclContext
-Removed DeclContext pointer from FieldDecl
-EnumDecl inherits from DeclContext, instead of TagDecl

Patch by Argiris Kirtzidis!

llvm-svn: 49261
2008-04-06 04:47:34 +00:00
Chris Lattner 9d51f2b9d4 Fix handling of implicit int, resolving PR2012 and reverting (and
subsuming) my patch for PR1999.

llvm-svn: 49251
2008-04-05 06:32:51 +00:00
Steve Naroff 4dbab8a49d Avoid implicitly including any header files (requested by ckane).
llvm-svn: 49241
2008-04-04 22:58:22 +00:00
Steve Naroff af91b9ae13 Rewrite @package (an ObjC 2.0 idiom).
llvm-svn: 49238
2008-04-04 22:34:24 +00:00
Steve Naroff eae91700de Fix MS-specific bug in RewriteTest::RewriteObjCMethodDecl().
llvm-svn: 49237
2008-04-04 22:23:44 +00:00
Chris Lattner c5ffed4a66 Introduce ContextDecl, patch by Argiris Kirtzidis!
-Added ContextDecl (no TranslationUnitDecl)
-ScopedDecl class has a ContextDecl member
-FieldDecl class has a ContextDecl member, so that a Field or a ObjCIvar can be traced back to their RecordDecl/ObjCInterfaceDecl easily
-FunctionDecl, ObjCMethodDecl, TagDecl, ObjCInterfaceDecl inherit from ContextDecl. With TagDecl as ContextDecl, enum constants have a EnumDecl as their context.
-Moved Decl class to a "DeclBase.h" along with ContextDecl class
-CurContext is handled by Sema

llvm-svn: 49208
2008-04-04 06:12:32 +00:00
Ted Kremenek b5c8225320 Use logical line number for BUGLINE.
llvm-svn: 49178
2008-04-03 17:55:57 +00:00
Ted Kremenek b73d6dda84 Added guard for printing out PathDiagnostics whose last element ends with
a piece with a SourceLocation that does not have a FileID.

llvm-svn: 49151
2008-04-03 07:13:10 +00:00
Sam Bishop 03e662d5be Call delete on the deserialized TranslationUnit object.
llvm-svn: 49136
2008-04-03 05:03:34 +00:00
Ted Kremenek 258493c188 Added path sequence numbers in HTML output of PathDiagnostics.
llvm-svn: 49116
2008-04-02 21:04:20 +00:00
Ted Kremenek 3276af4c1a Embed BUGLINE, BUGFILE, BUGPATHLENGTH in the emitted HTML file.
llvm-svn: 49114
2008-04-02 20:44:16 +00:00
Ted Kremenek 13c0885a8d Put "BUGDESC" comment tag on its own line.
llvm-svn: 49103
2008-04-02 18:03:20 +00:00
Ted Kremenek e6eed29125 Embed "DESC" tag in HTML reports.
llvm-svn: 49084
2008-04-02 07:04:46 +00:00
Chris Lattner 595cf9ff81 Update to match simplified llvm MemoryBuffer interfaces for files.
llvm-svn: 49042
2008-04-01 18:04:30 +00:00
Ted Kremenek a9590d1c0d Embed linkable IDs in message bubbles.
llvm-svn: 49005
2008-03-31 23:30:12 +00:00
Ted Kremenek 3bcfc6edc0 Better handling for tabs with message bubbles.
llvm-svn: 49001
2008-03-31 23:14:05 +00:00
Ted Kremenek 01fa5d2a1e When emitting HTML messages, take into account margin fusing due to tabs.
llvm-svn: 48998
2008-03-31 21:40:14 +00:00
Ted Kremenek c27815ca82 Inlined clang/Analysis/Analyses/GRSimpleVals.h into LocalCheckers.h and removed
GRSimpleVals.h

Added a PathDiagnosticClient option to the driver functions for the
CFRefCountChecker and the GRSimpleVals analysis. Both analyses now accept a "-o"
argument from the driver that specifies where HTML reports should be dumped.

llvm-svn: 48989
2008-03-31 18:26:32 +00:00
Ted Kremenek 9c7deb8d25 Disable timing diagnostics for GRSimpleVals.
llvm-svn: 48981
2008-03-31 16:00:32 +00:00
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