Commit Graph

17480 Commits

Author SHA1 Message Date
Ted Kremenek 7cf8238291 Remove some stale ErrorNodes variables in GRExprEngine and the old buffer overflow logic in GRExprEngineInternalChecks.cpp.
llvm-svn: 86877
2009-11-11 20:16:36 +00:00
Chandler Carruth 062c291949 After drinking caffeine, add the two files missing from the previous submit.
Sorry about that.

llvm-svn: 86869
2009-11-11 19:43:37 +00:00
Douglas Gregor eebed72fbb Move handling of template parameter packs out of the
template-type-parameter specific template argument checking code and
up to the template argument checking loop. In theory, this should make
variadic templates work better; in practice, they don't well enough
for us to care anyway (YET!), so this is mostly a re-organization to
simplify CheckTemplateArgument.

llvm-svn: 86868
2009-11-11 19:41:09 +00:00
Douglas Gregor da0fb53c16 Refactoring of template-argument checking code to reduce nesting,
increase sanity. No intended functionality change.

llvm-svn: 86866
2009-11-11 19:31:23 +00:00
Douglas Gregor e62e6a0191 Before checking a template template argument against its corresponding
template template parameter, substitute any prior template arguments
into the template template parameter. This, for example, allows us to
properly check the template template argument for a class such as:

  template<typename T, template<T Value> class X> struct Foo;

The actual implementation of this feature was trivial; most of the
change is dedicated to giving decent diagnostics when this
substitution goes horribly wrong. We now get a note like:

  note: while substituting prior template arguments into template
      template parameter 'X' [with T = float]

As part of this change, enabled some very pedantic checking when
comparing template template parameter lists, which shook out a bug in
our overly-eager checking of default arguments of template template
parameters. We now perform only minimal checking of such default
arguments when they are initially parsed.

llvm-svn: 86864
2009-11-11 19:13:48 +00:00
Chandler Carruth 5375309250 Move the ManagerRegistry to the Analysis library to resolve the layering violation.
llvm-svn: 86863
2009-11-11 19:10:59 +00:00
Devang Patel 5348515193 Do not eagerly set stop point for arguments. This misleads the debugger in identifying beginning of function body. Instead, create new location to attach with llvm.dbg.declare. This location is only used to find the context of the variable by the code generator, and it is not used to emit line number info.
llvm-svn: 86862
2009-11-11 19:10:19 +00:00
Fariborz Jahanian 03f62ed9bb Value initialize non-class array members in ctor's
initializer list. Fixes PR5463.

llvm-svn: 86849
2009-11-11 17:55:25 +00:00
Ted Kremenek 91989d166a Split buffer overflow test case into two test cases, removing out logic that was commented out.
llvm-svn: 86845
2009-11-11 17:17:06 +00:00
Douglas Gregor 38fee967ae Instantiation of template template parameters for nested templates, e.g.,
template<typename T>
  struct X {
    template<template<T Value> class Y> struct Inner;
  };

llvm-svn: 86844
2009-11-11 16:58:32 +00:00
Douglas Gregor 120635bc9c Fix speculative parsing of dependent template names in
nested-name-specifiers so that they don't gobble the template name (or
operator-function-id) unless there is also a
template-argument-list. For example, given

  T::template apply

we would previously consume both "template" and "apply" as part of
parsing the nested-name-specifier, then error when we see that there
is no "<" starting a template argument list. Now, we parse such
constructs tentatively, and back off if the "<" is not present. This
allows us to parse dependent template names as one would use them for,
e.g., template template parameters:

  template<typename T, template<class> class X = T::template apply>
    struct MetaSomething;

Also, test default arguments for template template parameters.

llvm-svn: 86841
2009-11-11 16:39:34 +00:00
Zhongxing Xu b166712d02 Add undefined array subscript checker.
llvm-svn: 86837
2009-11-11 13:42:54 +00:00
Zhongxing Xu 83c4374e72 Remove the old out-of-bound checking code.
llvm-svn: 86836
2009-11-11 12:52:39 +00:00
Zhongxing Xu 4f7759a339 Reimplement out-of-bound array access checker with the new checker interface.
Now only one test case is XFAIL'ed.

llvm-svn: 86834
2009-11-11 12:33:27 +00:00
Zhongxing Xu 3ef93badbe ReturnPointerRangeChecker: use StripCasts() instead of checking for zero index
explicitly.

Fix 80-col violations.

llvm-svn: 86833
2009-11-11 11:55:54 +00:00
Daniel Dunbar f580187aed Simplify.
llvm-svn: 86830
2009-11-11 10:22:48 +00:00
Daniel Dunbar 559f7a5c3c Fix unsafe use of StringRef I introduced.
llvm-svn: 86829
2009-11-11 10:10:25 +00:00
Daniel Dunbar 22bdabf05f Add PreprocessorOutputOptions to CompilerInvocation, and move initialization to
clang-cc/Options.cpp

llvm-svn: 86828
2009-11-11 10:07:44 +00:00
Daniel Dunbar 531f6c662b Add PreprocessorOutputOptions, for things like -dM, -C, -CC which control -E
mode.

llvm-svn: 86827
2009-11-11 10:07:22 +00:00
Daniel Dunbar 979586e755 Simplifiy target feature handling by coalescing all the logic into
InitializeCompileOptions.

llvm-svn: 86826
2009-11-11 09:38:56 +00:00
Daniel Dunbar eced7e065f Minor formatting tweaks.
llvm-svn: 86825
2009-11-11 09:38:42 +00:00
Daniel Dunbar 759cab9a54 clang-cc: Refactor some -fixit-at handling.
llvm-svn: 86824
2009-11-11 09:38:35 +00:00
Daniel Dunbar d0c3bb0df2 Allow TextDiagnosticPrinter to have optional ownership of its output stream.
llvm-svn: 86823
2009-11-11 09:38:24 +00:00
Daniel Dunbar 23ede2d9d1 Update CMake.
llvm-svn: 86822
2009-11-11 08:14:02 +00:00
Daniel Dunbar d2cfa0111c clang-cc: Move InitializeAnalyzerOptions into Options.cpp
llvm-svn: 86821
2009-11-11 08:13:55 +00:00
Daniel Dunbar ef0147c0e9 clang-cc: Start coalescing "frontend" options.
llvm-svn: 86820
2009-11-11 08:13:47 +00:00
Daniel Dunbar dcd40fb95f clang-cc: Move InitializeDiagnosticOptions to Options.cpp
llvm-svn: 86819
2009-11-11 08:13:40 +00:00
Daniel Dunbar f527a12e47 clang-cc: Move HeaderSearchOptions to Options.cpp
llvm-svn: 86818
2009-11-11 08:13:32 +00:00
Daniel Dunbar b6bac22d02 Turn LoggingDiagnosticClient into a more general ChainedDiagnosticClient and
move to libFrontend.

llvm-svn: 86817
2009-11-11 08:13:24 +00:00
Daniel Dunbar 84dfbfde26 clang-cc: Move InitializeLangOptions to Options.cpp.
Also, inline InitializeLanguageStandard into InitializeLangOptions; this code
needs to be refactored but the current division doesn't make any sense.

llvm-svn: 86816
2009-11-11 07:26:12 +00:00
Daniel Dunbar f0f6f0efb0 Inline some trivial functions.
llvm-svn: 86815
2009-11-11 07:26:02 +00:00
Ted Kremenek 04552cbef0 CastToStructChecker: use 'isStructureType()' instead of 'isRecordType()' to determine if a pointer is casted to a struct pointer. This fixes an observed false positive when a value is casted to a union.
llvm-svn: 86813
2009-11-11 06:43:42 +00:00
Ted Kremenek 55d59bf785 Fix display of "ANALYZE" statements in AnalysisConsumer by correctly resetting the flag indicating that the current Decl* has not yet been displayed. Also move this out of AnalysisManager, since AnalysisManager should not handle text output to the user.
llvm-svn: 86812
2009-11-11 06:28:42 +00:00
Daniel Dunbar 999215c8c8 clang-cc: Move InitializePreprocessorOptions to Options.cpp
llvm-svn: 86811
2009-11-11 06:10:03 +00:00
Ted Kremenek 4325315935 Remove public headers for UndefinedArgChecker, AttrNonNullChecker, and BadCallChecker, making their implementations completely private.
llvm-svn: 86809
2009-11-11 05:50:44 +00:00
Daniel Dunbar de142beafb clang-cc: Simplify this code, now that predefines handling is uniform in the
PCH/-E and PCH/not--E cases.

llvm-svn: 86808
2009-11-11 05:33:31 +00:00
Daniel Dunbar 000c4ffd16 Redo how PCH handles its implicit include. Instead of treating this specially in
the front-end (as far as the preprocessor goes), follow the usual logic of
inserting the (original include path) name into the predefines buffer. This
pushes the responsibility for handling this to PCH instead of the front-end.  In
PCH this requires being a little more clever when we diff the predefines
buffers.

Neither of these solutions are particularly great, I think what we eventually
should do is something like gcc where we insert a special marker to indicate the
PCH file, but then run the preprocessor as usual. This would be clearer and
would allow us to drop the overly clever predefines handling.

llvm-svn: 86806
2009-11-11 05:29:04 +00:00
Daniel Dunbar 499baed8a8 More StringRef simplification to PCHValidator::ReadPredefinesBuffer.
llvm-svn: 86805
2009-11-11 05:26:28 +00:00
Daniel Dunbar 775f18520c And now a test fix in +Asserts mode, which I broke.
llvm-svn: 86801
2009-11-11 03:48:34 +00:00
Daniel Dunbar 568e302a7f Fix some tests in -Asserts mode.
- FileCheck is a *huuuuge* improvement here.

 - Still feels like we could use a better tool for this though, either teach
   llvm-dis to spit out the FileCheck syntax, or provide another tool to turn a
   .ll into a "matchable" input.

 - Also on my Christmas list is better FileCheck diagnostics with missing
   variables or mismatches.

llvm-svn: 86800
2009-11-11 03:48:26 +00:00
Daniel Dunbar 8665c7e39d Rewrite splitLines using StringRef; this is much simpler, and also now avoids
tons of std::string trashing. I plan to move this and other fun string munging
utilities to a StringRefExtras.h at some point if no one beats me to it.

On a synthetic benchmark on x86_64, llvm-gcc actually generates code thats 10%
faster using the StringRef version. gcc miscompiles the synthetic benchmark,
which I'm crossing my fingers and hoping won't happen here. clang compiles the
sythetic benchmark correctly (wootness), but the StringRef version is
slower. Silly clang.

llvm-svn: 86799
2009-11-11 03:45:59 +00:00
Ted Kremenek 5e1f78aeb1 Refactor DereferenceChecker to use only the new Checker API instead of
the old builder API.  This percolated a bunch of changes up to the
Checker class (where CheckLocation has been renamed VisitLocation) and
GRExprEngine.  ProgramPoint now has the notion of a "LocationCheck"
point (with PreLoad and PreStore respectively), and a bunch of the old
ProgramPoints that are no longer used have been removed.

llvm-svn: 86798
2009-11-11 03:26:34 +00:00
John McCall 7e1d6d78d5 Preserve source locations when building offsetof expressions featuring
anonymous members.  Partial fix for PR 5390.

llvm-svn: 86796
2009-11-11 03:23:23 +00:00
Mike Stump c7b9f5e762 More VTT work. We now track offsets and use the ctor vtable builder
interface.  WIP.

llvm-svn: 86793
2009-11-11 03:08:24 +00:00
Mike Stump 4e16d05dc4 Fixup spacing.
llvm-svn: 86792
2009-11-11 02:49:00 +00:00
John McCall 0506e4af2c Apparently the following idiom is specifically encouraged:
if (self = [super init])
Recognize it and only warn if -Wparentheses is explicitly enabled.

llvm-svn: 86790
2009-11-11 02:41:58 +00:00
Fariborz Jahanian e6c8112572 Avoid generating additional destructor(s) for initialized constructed
objects.

llvm-svn: 86778
2009-11-11 01:13:34 +00:00
Douglas Gregor 9167f8bbd5 Introduce a new representation for template template
parameters. Rather than storing them as either declarations (for the
non-dependent case) or expressions (for the dependent case), we now
(always) store them as TemplateNames. 

The primary change here is to add a new kind of TemplateArgument,
which stores a TemplateName. However, making that change ripples to
every switch on a TemplateArgument's kind, also affecting
TemplateArgumentLocInfo/TemplateArgumentLoc, default template
arguments for template template parameters, type-checking of template
template arguments, etc.

This change is light on testing. It should fix several pre-existing
problems with template template parameters, such as:
  - the inability to use dependent template names as template template
  arguments
  - template template parameter default arguments cannot be
  instantiation

However, there are enough pieces missing that more implementation is
required before we can adequately test template template parameters. 

llvm-svn: 86777
2009-11-11 01:00:40 +00:00
Daniel Dunbar 3618834da8 Recognize -fsyntax-only as a "consumer only" action.
llvm-svn: 86776
2009-11-11 00:54:56 +00:00
Daniel Dunbar 20a682de6b StringRefify some PCH interfaces.
llvm-svn: 86775
2009-11-11 00:52:11 +00:00