Commit Graph

17546 Commits

Author SHA1 Message Date
John McCall b0e419e34d Add <foo> = [<bar> nextObject] to the -Widiomatic-parentheses category,
and give that category an explicit test.  Generalize the internal diagnostic
name.

llvm-svn: 86905
2009-11-12 00:06:05 +00:00
Douglas Gregor c998409cce Remove an overly-eager assertion when replacing tokens with an
annotation token, because some of the tokens we're annotating might
not be in the set of cached tokens (we could have consumed them
unconditionally).

Also, move the tentative parsing from ParseTemplateTemplateArgument
into the one caller that needs it, improving recovery.

llvm-svn: 86904
2009-11-12 00:03:40 +00:00
Daniel Dunbar 732ef8aefd Tweak PCH -include handling to make sure it matches the name as would be present
in the predefines buffer.

llvm-svn: 86903
2009-11-11 23:58:53 +00:00
John Thompson 92ebab90fe Fix clang executable path for Windows
llvm-svn: 86896
2009-11-11 23:11:14 +00:00
Douglas Gregor adee3e3b22 Template argument deduction for template template parameters. This
permits, among other things, ripping apart and reconstructing
templates via partial specialization:

  template<typename T> 
  struct DeepRemoveConst { typedef T type; };

  template<typename T>
  struct DeepRemoveConst<const T> {
    typedef typename DeepRemoveConst<T>::type type;
  };

  template<template<typename> class TT, typename T>
  struct DeepRemoveConst<TT<T> > {
    typedef TT<typename DeepRemoveConst<T>::type> type;
  };

Also, fix a longstanding thinko in the code handling partial ordering
of class template partial specializations. We were performing the
second deduction without clearing out the results of the first
deduction. It's amazing we got through so much code with such a
horrendous error :(

llvm-svn: 86893
2009-11-11 23:06:43 +00:00
John McCall 5055e4cdfd Fix PR 5422: handle lvalue results when evaluating 'based' ptrtoints as part of
the -Wconversion check.

llvm-svn: 86891
2009-11-11 22:52:37 +00:00
Fariborz Jahanian d708eb6b6a Make test more platform independent.
llvm-svn: 86890
2009-11-11 22:49:09 +00:00
Fariborz Jahanian c3091c9118 Make test more platform independent (per Sebastian's comment).
llvm-svn: 86888
2009-11-11 22:45:41 +00:00
Fariborz Jahanian 13e0c90fc1 writable atomic property's setter/getter must be in 'lock' step of
either both synthesized or bith user defined. 
Implements radar 6557233.

llvm-svn: 86887
2009-11-11 22:40:11 +00:00
Douglas Gregor 84d49a2085 Improve diagnostics when a default template argument does not match
with its corresponding template parameter. This can happen when we
performed some substitution into the default template argument and
what we had doesn't match any more, e.g.,

  template<int> struct A;
  template<typename T, template<T> class X = A> class B;

  B<long> b;

Previously, we'd emit a pretty but disembodied diagnostic showing how
the default argument didn't match the template parameter. The
diagnostic was good, but nothing tied it to the *use* of the default
argument in "B<long>". This commit fixes that.

Also, tweak the counting of active template instantiations to avoid
counting non-instantiation records, such as those we create for
(surprise!) checking default arguments, instantiating default
arguments, and performing substitutions as part of template argument
deduction.

llvm-svn: 86884
2009-11-11 21:54:23 +00:00
Daniel Dunbar 2856ae444b Always initialize the header search object as part of InitializePreprocessor;
not doing this has little to no utility.

llvm-svn: 86883
2009-11-11 21:44:42 +00:00
Daniel Dunbar 0c6c930f05 Allow Preprocessor to take ownership of the HeaderSearch object. I think it should probably always own the header search object, but I'm not sure...
llvm-svn: 86882
2009-11-11 21:44:21 +00:00
Daniel Dunbar 55b781f85e Sink AttachDependencyFileGen into CreatePreprocessor.
llvm-svn: 86881
2009-11-11 21:44:00 +00:00
Daniel Dunbar 89d1fdff65 Add DependencyOutputOptions to wrap -M... options, and propogate to
CompilerInvocation and clang-cc.

llvm-svn: 86880
2009-11-11 21:43:12 +00:00
Mike Stump fd84d6d808 Fix ctor vtable name. WIP.
llvm-svn: 86879
2009-11-11 20:32:03 +00:00
Mike Stump eac4559790 Push ctor vtable construction down further. WIP.
llvm-svn: 86878
2009-11-11 20:26:26 +00:00
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
Daniel Dunbar 045c92f812 Replace startsWith functions with StringRef.
llvm-svn: 86774
2009-11-11 00:52:00 +00:00
Mike Stump 8b2d2d0707 Stub out most of the VTT building code. WIP.
llvm-svn: 86772
2009-11-11 00:35:07 +00:00
John McCall caef2448da Create a new Scope when parsing a declaration with a C++ scope specifier.
llvm-svn: 86764
2009-11-11 00:21:18 +00:00
Daniel Dunbar 93097b3906 Add Diagnostic::Report method for reporting diagnostics without a location.
llvm-svn: 86760
2009-11-10 23:55:23 +00:00
Daniel Dunbar de02f63945 PreprocessorOptions: Get rid of unnecessary 'isPTH' flag for include entries.
llvm-svn: 86757
2009-11-10 23:53:43 +00:00
Fariborz Jahanian 4e088941ad Diagnose illegally typed operator new/new[].
llvm-svn: 86755
2009-11-10 23:47:18 +00:00
Devang Patel af993bf5cc Attach location info with llvm.dbg.declare.
llvm-svn: 86750
2009-11-10 23:07:24 +00:00
Ted Kremenek 0b61a805b9 Add FIXIT hint for -Wsemicolon-before-method-body
llvm-svn: 86746
2009-11-10 22:55:49 +00:00
Eli Friedman d76f438369 Revert r86741; it doesn't handle virtual bases correctly.
llvm-svn: 86745
2009-11-10 22:48:10 +00:00
Eli Friedman 0960059c0c Minor optimization to skip null check in generated code where it isn't
necessary.

llvm-svn: 86741
2009-11-10 22:42:26 +00:00
Eli Friedman 3ad2645430 Fix for PR5454: make sure to use the right block as the predecessor in the
generated PHI node for the null check of a new operator.

llvm-svn: 86738
2009-11-10 22:39:09 +00:00
Ted Kremenek 42855f2043 Shuffle order of warning declarations (alphabetize).
llvm-svn: 86733
2009-11-10 22:22:50 +00:00
Ted Kremenek f9a28abe8d Make -Wsemicolon-before-method-body opt-in (and part of -Wextra). Addresses <rdar://problem/7381735>.
llvm-svn: 86731
2009-11-10 22:16:29 +00:00
Daniel Dunbar 47ea8628a5 Decouple more of clang-cc by moving ImplicitP[CT]H options into
PreprocessorOptions.

Global variables used as [in] [out] parameters considered harmful.

llvm-svn: 86728
2009-11-10 22:09:38 +00:00
Ted Kremenek 4a720a363c Update CMake file.
llvm-svn: 86721
2009-11-10 21:38:41 +00:00
Benjamin Kramer aed9a1aadb Add newline at EOF.
llvm-svn: 86720
2009-11-10 21:33:20 +00:00
Benjamin Kramer 2c9a91c290 Silence warning.
llvm-svn: 86719
2009-11-10 21:29:56 +00:00
Dan Gohman ad5ef3d70f Use #include <stdio.h> when using fprintf and stderr.
llvm-svn: 86717
2009-11-10 21:21:27 +00:00
Daniel Dunbar f89a32ac45 clang-cc: Start moving "pure" option handling to Options.cpp, to separate it
from the logic part of clang-cc, and to enforce limited scoping.

llvm-svn: 86711
2009-11-10 19:51:53 +00:00
Daniel Dunbar d96cd43f13 clang-cc: Sink more options inside codegenopts namespace.
llvm-svn: 86710
2009-11-10 19:51:46 +00:00
Daniel Dunbar a35a2cb56b Change LangOpts initialization to directly test the code generation options,
instead of reproducing their logic.

llvm-svn: 86709
2009-11-10 19:51:33 +00:00
Douglas Gregor b53edfb8dc Improve parsing of template arguments to lay the foundation for
handling template template parameters properly. This refactoring:

  - Parses template template arguments as id-expressions, representing
    the result of the parse as a template name (Action::TemplateTy)
    rather than as an expression (lame!).

  - Represents all parsed template arguments via a new parser-specific
    type, ParsedTemplateArgument, which stores the kind of template
    argument (type, non-type, template) along with all of the source
    information about the template argument. This replaces an ad hoc
    set of 3 vectors (one for a void*, which was either a type or an
    expression; one for a bit telling whether the first was a type or
    an expression; and one for a single source location pointing at
    the template argument).

  - Moves TemplateIdAnnotation into the new Parse/Template.h. It never
    belonged in the Basic library anyway.

llvm-svn: 86708
2009-11-10 19:49:08 +00:00
Fariborz Jahanian dc21610419 Changed a variable name to match what it represents
(Ted's feedback).

llvm-svn: 86702
2009-11-10 19:31:09 +00:00
Fariborz Jahanian 1254a0978c This patch implements Code gen. for destruction of
global array of objects.

llvm-svn: 86701
2009-11-10 19:24:06 +00:00
Ted Kremenek ba64574c9a CIndex: Only display diagnostics to llvm::errs() when the client has set the 'displayDiagnostics' option to 1 in clang_createIndex(). This fixes <rdar://problem/7370691>.
llvm-svn: 86700
2009-11-10 19:18:52 +00:00
Mike Stump b47222144b Only generate a VTT for classes that need a VTT.
llvm-svn: 86699
2009-11-10 19:13:04 +00:00
Daniel Dunbar f76c9d270a Driver: Run 'clang' in C++ mode based on the name it was invoked by. We match
anything that ends with ++ or ++-FOO (e.g., c++, clang++, clang++-1.1) as being
a "C++ compiler".

This allows easy testing of the C++ compiler by 'ln -s clang clang++', or by 'cp
clang clang++'.

Based on patch by Roman Divacky.

llvm-svn: 86697
2009-11-10 18:47:41 +00:00
Daniel Dunbar ef2919f1fa Factor out parts of InitializeCompileOptions that depend on the LangOptions.
llvm-svn: 86696
2009-11-10 18:47:35 +00:00
Daniel Dunbar be50f5ab9d Localize -disable-llvm-optzns handling to BackendConsumer::CreatePasses.
- This is conceptually better since the only thing we want this option to do is
   preserve the internal module as constructed by IRgen, before running any
   passes.

 - This also fixes bugs in -disable-llvm-optzns handling with regards to debug
   info.

llvm-svn: 86691
2009-11-10 17:50:53 +00:00
Daniel Dunbar ede182ef05 clang-cc: Start sinking (CodeGen) options into namespaces to limit their scope.
llvm-svn: 86690
2009-11-10 17:50:42 +00:00
Daniel Dunbar 68ac06142b Cleanup some clang-cc FIXMEs
llvm-svn: 86686
2009-11-10 16:23:44 +00:00
Daniel Dunbar 754c11ec48 Add CompileOptions to CompilerInvocation.
llvm-svn: 86685
2009-11-10 16:19:45 +00:00
John McCall b8be78b753 Fix a similar problem with qualified lookup through using directives,
although in this case we probably just run a risk of duplicating work;
I can't think of how this could cause a bug.

llvm-svn: 86680
2009-11-10 09:25:37 +00:00
John McCall 9757d0363d Make a somewhat more convincing test case for unqualified lookup through
using directives, and fix a bug thereby exposed:  since we're playing
tricks with pointers, we need to make certain we're always using the same 
pointers for things.
Also tweak an existing error message.

llvm-svn: 86679
2009-11-10 09:20:04 +00:00