Commit Graph

9582 Commits

Author SHA1 Message Date
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 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
Benjamin Kramer 2c9a91c290 Silence warning.
llvm-svn: 86719
2009-11-10 21:29:56 +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
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 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
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
Zhongxing Xu f9667229a1 Ignore parentheses when check the type of the expr.
llvm-svn: 86677
2009-11-10 08:33:44 +00:00
Zhongxing Xu 537db5d652 SizeofPointerChecker: Many false positives have the form 'sizeof *p'.
This is reasonable because people know what they are doing when they 
intentionally dereference the pointer.
So now we only emit warning when a pointer variable is use literally.

llvm-svn: 86673
2009-11-10 07:52:53 +00:00
Mike Stump d846d0825b Add vtable caching to prevent multiple vtables for the same class from
being generated.

Add the most derived vtable pointer to the VTT.

llvm-svn: 86671
2009-11-10 07:44:33 +00:00
John McCall f6c8a4ef1f Fix unqualified lookup through using directives.
This is a pretty minimal test case;  I'll make a better one later.

llvm-svn: 86669
2009-11-10 07:01:13 +00:00
Anders Carlsson ace5d07e50 When trying to assign a regular string literal to an Objective-C 'id' type or a pointer to an NSString, emit a code insertion hint that turns it into an Objective-C string. For example:
@class NSString;

@interface Test
+ (void)test:(NSString *)string;
@end

void g(NSString *a);

void f() {
  NSString *a = "Foo";
  g("Foo");
  [Test test:"Foo"];
}

will produce

t.m:10:17: warning: incompatible pointer types initializing 'char [4]', expected 'NSString *'
  NSString *a = "Foo";
                ^~~~~
                @
t.m:11:5: warning: incompatible pointer types passing 'char [4]', expected 'NSString *'
  g("Foo");
    ^~~~~
    @
t.m:12:14: warning: incompatible pointer types sending 'char [4]', expected 'NSString *'
  [Test test:"Foo"];
             ^~~~~
             @
3 diagnostics generated.

llvm-svn: 86665
2009-11-10 04:46:30 +00:00
Zhongxing Xu 456706c205 Now we can safely use the argument expression's source range.
llvm-svn: 86663
2009-11-10 04:22:08 +00:00
Zhongxing Xu 9a7448ceef SizeofPointerChecker: If an explicit type specifier is used, do not issue warnings.
llvm-svn: 86662
2009-11-10 04:20:20 +00:00
Anders Carlsson 1566eb5a26 Use PP.getLocForEndOfToken as suggested by John.
llvm-svn: 86661
2009-11-10 03:32:44 +00:00
Zhongxing Xu 77c470e8c7 Use the source range of the whole sizeof expression, otherwise it crashes when
the argument is not an expression.

llvm-svn: 86660
2009-11-10 03:27:00 +00:00
Anders Carlsson 0b8ea554e5 If a function with a default argument is redefined and the new function also has a defualt argument then add a fixit hint that removes the default argument. Fixes PR5444.
llvm-svn: 86659
2009-11-10 03:24:44 +00:00
Zhongxing Xu 80bbc6d138 Refine PointerSubChecker: compare the base region instead of the original
region, so that arithmetic within a memory chunk is allowed.

llvm-svn: 86652
2009-11-10 02:37:53 +00:00
Mike Stump 9f23a149cb Be sure to clear out VCall when we clear out VCalls.
Start implementing VTTs.  WIP.

llvm-svn: 86650
2009-11-10 02:30:51 +00:00
Zhongxing Xu f8f3f9ddbc Rename: StripCasts describes what it does better.
getBaseRegion will be used in another method.

llvm-svn: 86649
2009-11-10 02:17:20 +00:00
Mike Stump 3b9176985d Finish off mangling for the VTT.
llvm-svn: 86647
2009-11-10 01:58:37 +00:00
Mike Stump ef15744092 Add mangling for the construction vtable.
llvm-svn: 86643
2009-11-10 01:41:59 +00:00
Jeffrey Yasskin 612e38026a Fix clang's use of DenseMap iterators after r86636 fixed their constness.
Patch by Victor Zverovich!

llvm-svn: 86638
2009-11-10 01:17:45 +00:00
Daniel Dunbar 69914f4134 Switch to getFileOrSTDIN().
llvm-svn: 86632
2009-11-10 00:46:19 +00:00
Douglas Gregor 983136e3a1 Move all of the type-printing logic to its own C++ source file
llvm-svn: 86629
2009-11-10 00:39:07 +00:00
Daniel Dunbar 4df9aa2388 Privatize InitHeaderSearch, this functionality is only exposed via
ApplyHeaderSearchOptions now.

llvm-svn: 86617
2009-11-09 23:02:47 +00:00
Mike Stump 68ec7ee0e8 Enable the use of the new llvm objectsize intrinsic.
llvm-svn: 86607
2009-11-09 22:40:09 +00:00
Fariborz Jahanian a44e8d85a7 Further change in a comment.
llvm-svn: 86599
2009-11-09 22:28:08 +00:00
Fariborz Jahanian 3fe453c48c Removed a FIXME on nested type specifier warning.
llvm-svn: 86598
2009-11-09 22:25:11 +00:00
Fariborz Jahanian b98dade25b Changed error for nested type qualifier mismatch to
warning, to match gcc. It used to be warning, so
better keep it a warning (it broke a certain project).

llvm-svn: 86597
2009-11-09 22:16:37 +00:00
Douglas Gregor 4ef1d400d9 Make sure that Type::getAs<ArrayType>() (or Type::getAs<subclass of
ArrayType>()) does not instantiate. Update all callers that used this
unsafe feature to use the appropriate ASTContext::getAs*ArrayType method.

llvm-svn: 86596
2009-11-09 22:08:55 +00:00
Ted Kremenek dd51f7cca2 Remove stale FIXME.
llvm-svn: 86595
2009-11-09 21:56:44 +00:00
Douglas Gregor 8caea94c74 Make sure that we look into nested, transparent declaration contexts
when looking for a name within a given DeclContext. Now enumerators
will show up in code-completion results.

llvm-svn: 86591
2009-11-09 21:35:27 +00:00
Fariborz Jahanian facfdd4d93 For array pointee type, get its cvr qualifier from
its element type. Fixes pr5432.

llvm-svn: 86587
2009-11-09 21:02:05 +00:00
Benjamin Kramer 382414d519 Fix build after r86579.
llvm-svn: 86584
2009-11-09 20:14:44 +00:00
Douglas Gregor 1bc688dc60 Make sure that we instantiate default function arguments for an
overloaded operator(). 

llvm-svn: 86581
2009-11-09 19:27:57 +00:00
Eli Friedman 9cf6b59400 Add additional note to mark the cause of synthesized constructors. Mark
declaration invalid if the constructor can't be properly built.  Addresses
remaining review comments from Fariborz for r86500.

llvm-svn: 86579
2009-11-09 19:20:36 +00:00
Douglas Gregor 36d7c5f29b Improve instantiation of default template arguments for nested
templates. The instantiation of these default arguments must be (and
now, is) delayed until the template argument is actually used, at
which point we substitute all levels of template arguments
concurrently.

llvm-svn: 86578
2009-11-09 19:17:50 +00:00
Eli Friedman e4310c8273 Add support for cdecl attribute. (As far as I know, it doesn't affect CodeGen
unless we start implementing command-line switches which override the default
calling convention, so the effect is mostly to silence unknown attribute
warnings.)

llvm-svn: 86571
2009-11-09 18:38:53 +00:00
Anders Carlsson 69999d9c23 __uint128_t is indeed an unsigned integer type. Fixes PR5435.
llvm-svn: 86561
2009-11-09 17:34:18 +00:00
Douglas Gregor d3d9306275 When transforming an InitListExpr, if we already computed a non-dependent type for the InitListExpr, keep it
llvm-svn: 86559
2009-11-09 17:16:50 +00:00
Zhongxing Xu ab0e27ff0c Add check for pointer arithmetic on non-array variables.
llvm-svn: 86538
2009-11-09 13:23:31 +00:00
Zhongxing Xu d6e7f9d4b2 Add check for obsolete function call of getpw().
llvm-svn: 86537
2009-11-09 12:19:26 +00:00
Zhongxing Xu d09b22aa5a remove redundant file name in CMakeLists.txt.
llvm-svn: 86536
2009-11-09 09:35:41 +00:00
Zhongxing Xu 08670a89aa update CMakeList.txt
llvm-svn: 86535
2009-11-09 09:32:38 +00:00
Daniel Dunbar 53272bbf40 Update CMake
llvm-svn: 86533
2009-11-09 08:13:45 +00:00
Zhongxing Xu f69973c858 Add comments.
llvm-svn: 86532
2009-11-09 08:13:04 +00:00
Zhongxing Xu f06c684a33 Add checker for CWE-588: Attempt to Access Child of a Non-structure Pointer.
llvm-svn: 86529
2009-11-09 08:07:38 +00:00
Daniel Dunbar 65c0db98ab Update CMake
llvm-svn: 86528
2009-11-09 08:04:31 +00:00
Zhongxing Xu 85000203bb Put all long strings in 80-col.
llvm-svn: 86527
2009-11-09 07:29:39 +00:00
Zhongxing Xu 6c306c8b89 Add checker for CWE-587: Assignment of a Fixed Address to a Pointer.
llvm-svn: 86523
2009-11-09 06:52:44 +00:00
Zhongxing Xu 86b1e01c13 Add checker for CWE-469: Use of Pointer Subtraction to Determine Size. This
checker does not build sink nodes. Because svaluator computes an unknown value
for the subtraction now.

llvm-svn: 86517
2009-11-09 05:34:10 +00:00
Eli Friedman cc522d9ab3 Rearrange function to avoid recursive use-after-free.
llvm-svn: 86516
2009-11-09 05:07:37 +00:00
Eli Friedman a72bf0fae8 Explicitly note that pre-inc/dec lvalues are not supported yet, so that it
doesn't crash.  (Such expressions are valid in C++, but not in C.)

llvm-svn: 86513
2009-11-09 04:20:47 +00:00
Eli Friedman cb29876839 Add hack to make the given testcase work. As far as I can tell, this change is
reasonably safe, but it doesn't seem like the right solution.

llvm-svn: 86508
2009-11-09 03:59:26 +00:00
Zhongxing Xu 0f92ec6ebd Add a test case for CWE-467, and simplify the wording of the warning.
llvm-svn: 86504
2009-11-09 02:28:12 +00:00
Daniel Dunbar 11c08c8e5b Rename areAllFields32Or64BitBasicType to canExpandIndirectArgument to closer match what it is semantically used for.
Also, fix a major bug where fields from a C++ struct might be dropped -- the expand action doesn't handle them correctly yet.

llvm-svn: 86502
2009-11-09 01:33:53 +00:00
Eli Friedman 96c0a3e6c2 Remove a useless variable that got left behind.
llvm-svn: 86501
2009-11-09 01:11:03 +00:00
Eli Friedman d7686ef31c Unify the codepaths used to verify base and member initializers for explicitly
and implicitly defined constructors.  This has a number of benefits:

1. Less code.

2. Explicit and implicit constructors get the same diagnostics.

3. The AST explicitly contains constructor calls from implicit default
constructors.  This allows handing some cases that previously weren't handled
correctly in IRGen without any additional code. Specifically, implicit default
constructors containing calls to constructors with default arguments are now
handled correctly.

llvm-svn: 86500
2009-11-09 01:05:47 +00:00
Eli Friedman fd8d4e1383 Fix use-after-free bug.
llvm-svn: 86485
2009-11-08 22:15:39 +00:00
Benjamin Kramer 489232c466 Update CMake file.
llvm-svn: 86479
2009-11-08 18:30:42 +00:00
Sebastian Redl 14236c8e82 Special-case default argument expression in instantiation. This should fix PR4301. Doug, please double-check my assumptions. Read the PR for more details.
llvm-svn: 86465
2009-11-08 13:56:19 +00:00
Zhongxing Xu b0a05f7ca1 Add a checker for CWE-467: Use of sizeof() on a Pointer Type.
llvm-svn: 86464
2009-11-08 13:10:34 +00:00
Sebastian Redl afb8be743d When checking the namespace of a redeclaration or definition, look through linkage specs. Fixes PR5430.
llvm-svn: 86461
2009-11-08 11:36:54 +00:00
Sebastian Redl 3752e1dbb4 Don't reprocess non-dependent initializers of non-dependent VarDecls. Fixes PR5426.
llvm-svn: 86460
2009-11-08 10:16:43 +00:00
Edward O'Callaghan 932c32043a Fix for FreeBSD toolchain in regards to CPP, Credit to Roman Divacky.
llvm-svn: 86459
2009-11-08 10:13:36 +00:00
Daniel Dunbar 7e215ea165 Add clarifying parens.
llvm-svn: 86457
2009-11-08 09:46:46 +00:00
Alexis Hunt 6f3de50ca7 Test commit - minor terminology change to my recent patch suggested by John McCall
llvm-svn: 86442
2009-11-08 07:46:34 +00:00
Douglas Gregor 4100db6174 Always make sure we're using an unqualified type when building a
constructor name.  Fixes PR5418.

llvm-svn: 86441
2009-11-08 07:12:55 +00:00
Anders Carlsson 5bbdc9f857 Handle member expressions where the member declaration is actually a static variable. Fixes PR5392.
llvm-svn: 86414
2009-11-07 23:16:50 +00:00
Anders Carlsson ea4c30b39a More LValue related code cleanup.
llvm-svn: 86413
2009-11-07 23:06:58 +00:00
Anders Carlsson 2ff6395ddc More cleanup, the code is much easier to follow now.
llvm-svn: 86412
2009-11-07 22:53:10 +00:00
Anders Carlsson 6eee97276b Reduce nesting, no functionality change.
llvm-svn: 86411
2009-11-07 22:46:42 +00:00
Anders Carlsson 03f83e58f7 We only need to call SetObjCNonGC for local variables. No functionality change.
llvm-svn: 86410
2009-11-07 22:43:34 +00:00
Anders Carlsson 509850ebec Change EmitPointerToDataMemberLValue to take a FieldDecl. No intended functionality change.
llvm-svn: 86407
2009-11-07 22:00:15 +00:00
Fariborz Jahanian d7aa9d8a63 Patch to gives an error that at least points users in the direction of the error, rather
than an error about incompatible types. Patch by Sean Hunt.

llvm-svn: 86402
2009-11-07 20:20:40 +00:00
Chris Lattner 5c67237ff6 teach the various targets what native integer types they have.
llvm-svn: 86395
2009-11-07 18:59:41 +00:00
Douglas Gregor 358e7745ed Cope with calls to operator() templates. Fixes PR5419.
llvm-svn: 86387
2009-11-07 17:23:56 +00:00
Chris Lattner 15275e55ce add missing #include
llvm-svn: 86368
2009-11-07 09:22:46 +00:00
John McCall b61e9d03c1 Support -Wshorten-64-to-32 for integer types only, which seems to satisfy the
core requirements.  Fixes rdar://problem/6389954

llvm-svn: 86364
2009-11-07 09:03:53 +00:00
John McCall b397956338 Improve -Wconversion by permitting binary operations on values of the target
type (or smaller) to stay "closed" within the type.

llvm-svn: 86356
2009-11-07 08:15:46 +00:00
Anders Carlsson f5dc6fa252 Don't treat variables with non-trivial ctors or dtors as unused. Fixes PR5407.
llvm-svn: 86352
2009-11-07 07:26:56 +00:00
Anders Carlsson 2889e0e72c Cleanup, no functionality change.
llvm-svn: 86351
2009-11-07 07:18:14 +00:00
Anders Carlsson c0a3561f0f Always mangle functions with special names. Fixes PR5420.
llvm-svn: 86350
2009-11-07 07:15:03 +00:00
Anders Carlsson 3d70975917 When instantiating a field decl, make sure to clone its attributes. With this change FileCheck no longer crashes when it's run without any arguments.
llvm-svn: 86344
2009-11-07 06:07:58 +00:00
Ted Kremenek 975a119f31 Use SaveAndRestore to simplify logic in LiveVariables::runOnAllBlocks(). Patch by Kovarththanan Rajaratnam!
llvm-svn: 86343
2009-11-07 05:57:35 +00:00
Daniel Dunbar 8ec8804de1 Switch clang-cc to use ApplyHeaderSearchOptions, and fix a thinko.
llvm-svn: 86341
2009-11-07 04:58:12 +00:00
Anders Carlsson ce21431fc4 When looking up and adding substitutions to the substitution table, make sure to always use the canonical declaration. With tihs change, FileCheck compiles and links but crashes during startup.
llvm-svn: 86339
2009-11-07 04:26:04 +00:00
Daniel Dunbar 08d5669b01 Add HeaderSearchOptions class, for packaging the information needed to
initialize HeaderSearch. Not used yet.

llvm-svn: 86338
2009-11-07 04:20:50 +00:00
Daniel Dunbar ec87991c8f Lift InitHeaderSearch::AddEnvVarPaths logic higher.
llvm-svn: 86337
2009-11-07 04:20:39 +00:00
Daniel Dunbar 6dc9638153 Formatting fixes.
llvm-svn: 86336
2009-11-07 04:20:25 +00:00