Commit Graph

9513 Commits

Author SHA1 Message Date
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