Граф коммитов

10723 Коммитов

Автор SHA1 Сообщение Дата
Douglas Gregor 95ea45072a Fix an incorrect warning about explicit template specializations for
nested types, from Michael Han!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132431 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-01 22:37:07 +00:00
Argyrios Kyrtzidis aa37f7a875 XFAIL the test on windows.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132426 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-01 21:52:17 +00:00
Ted Kremenek 9277bea0e6 Rename -Wunknown-attributes to -Wattributes to match GCC.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132422 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-01 20:09:40 +00:00
Douglas Gregor 3617e198aa The expression in a noexcept exception-specification is a
constant-expression, and, therefore, an unevaluated operand. Make it
so.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132400 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-01 15:55:51 +00:00
Douglas Gregor 17e37c7959 Implement comparisons between nullptr and Objective-C object
pointers. Fixes PR10052.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132397 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-01 15:12:24 +00:00
Nick Lewycky 8d7946151c Even a return statement of an expression with a dependent type in a void
function might need to clean up its temporaries. Fixes PR10057.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132390 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-01 07:44:31 +00:00
Argyrios Kyrtzidis b68ffb107a [PCH] Be conservative and check all the files the PCH references to see if
a file was modified since the time the PCH was created.

The parser is not fit to deal with stale PCHs, too many invariants do not hold up. rdar://9530587.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132389 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-01 05:43:53 +00:00
Francois Pichet b474603632 Microsoft friend acting as a forward declaration; try#2. Now only 2 lines.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132387 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-01 04:14:20 +00:00
Manuel Klimek 5e2ff962a4 Fix test breakage due to example not being built.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132376 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-01 00:18:08 +00:00
Manuel Klimek 64cbdf3709 This patch implements an AST matching framework that allows to write
tools that match on the C++ ASTs. The main interface is in ASTMatchers.h,
an example implementation of a tool that removes redundant .c_str() calls
is in the example RemoveCStrCalls.cpp.

Various contributions:
Zhanyong Wan, Chandler Carruth, Marcin Kowalczyk, Wei Xu, James Dennett.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132374 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-31 23:49:32 +00:00
Devang Patel d65e091631 Fix test, check for stable strings in the output.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132370 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-31 22:37:03 +00:00
Francois Pichet 5aecb786a3 Revert 132332 (Microsoft friend as a forward declaration), John McCall pointed out a better/simpler way to do it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132369 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-31 22:36:05 +00:00
Devang Patel c478f21820 List objective-c ineterfaces as public types in dwarf debug info output.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132361 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-31 21:18:50 +00:00
Devang Patel 1c29652fbc List c++ class type as public type in dwarf debug info output.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132357 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-31 20:46:46 +00:00
Sean Hunt eea06c609b Ensure we enter an unevaluated context when instantiating a noexcept
expression. Fixes bug raised by hhinnant to cfe-dev

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132350 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-31 19:54:49 +00:00
Francois Pichet 8adc227de9 For compatibility with MSVC, a friend declaration also act as a forward declaration if the tag name is not already declared. The tag name is declared in the next outermost non record scope.
Example:

class A {
  friend class B;
  B* b;
};
B* global_b;


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132332 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-31 11:44:00 +00:00
Nick Lewycky 8155910a19 Whenever we instantiate a static data member, make sure to define any new
vtables! Fixes PR10020

This also allows us to revert the part of r130023 which added a big loop around
the template instantiation.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132331 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-31 07:58:42 +00:00
Galina Kistanova cca1ea7a69 Now with the right line endings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132330 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-31 07:19:08 +00:00
Chandler Carruth 0683a1418b Expand the coverage of the warning for constants on the RHS of logical operands:
return f() || -1;

where the user meant to write '|'.

This bootstraps without any additional warnings.

Patch by Richard Trieu.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132327 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-31 05:41:42 +00:00
Galina Kistanova ef4b1984be Just one for now to see how it will fly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132321 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-31 00:34:37 +00:00
Galina Kistanova 065063bdf4 Preparations for separating target-specific clang tests.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132319 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-31 00:29:49 +00:00
Richard Trieu 1838ca5618 Add a new warning on NULL pointer constant to integer conversion.
This path was reviewed by Chandler Carruth at http://codereview.appspot.com/4538074/



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132297 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-29 19:59:02 +00:00
John McCall 93c332a8ba Convert Clang over to resuming from landing pads with llvm.eh.resume.
It's quite likely that this will explode, but I need to know how. :)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132269 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-28 21:13:02 +00:00
Eli Friedman 460980d3b9 Add unnamed_addr to internal globals which are only used as an operand to memcpy. (Spotted by looking at IR.)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132226 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-27 22:32:55 +00:00
Eli Friedman b0dd6702ab Match llvm-gcc's string literals alignment by forcing alignment on string literals to 1. This can significantly impact the size of the string data, and as far as I know, the alignment doesn't help performance. rdar://9078969 .
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132223 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-27 22:13:20 +00:00
Eli Friedman addd80d1c8 Back out r132209; it's breaking nightly tests.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132219 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-27 21:32:17 +00:00
Douglas Gregor f61103ef33 Clean up my changes to jump-diagnostic handling for local variables of
class type (or array thereof), eliminating some redundant checks
(thanks Eli!) and adding some tests where the behavior differs in
C++98/03 vs. C++0x.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132218 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-27 21:28:00 +00:00
John McCall 0903421e36 Implement a new, much improved version of the cleanup hack. We just need
to be careful to emit landing pads that are always prepared to handle a
cleanup path.  This is correct mostly because of the fix to the LLVM
inliner, r132200.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132209 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-27 20:01:14 +00:00
Douglas Gregor e413516d0e Update the jump-scope checker for local variables with initializers,
so that it looks at the initializer of a local variable of class type
(or array thereof) to determine whether it's just an implicit
invocation of the trivial default constructor. Fixes PR10034.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132191 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-27 16:05:29 +00:00
Chandler Carruth e4d645cbe0 Enhance Clang to start instantiating static data member definitions
within class templates when they are necessary to complete the type of
the member. The canonical example is code like:

  template <typename T> struct S {
    static const int arr[];
    static const int x;
    static int f();
  };

  template <typename T> const int S<T>::arr[] = { 1, 2, 3 };
  template <typename T> const int S<T>::x = sizeof(arr) / sizeof(arr[0]);
  template <typename T> int S<T>::f() { return x; }

  int x = S<int>::f();

We need to instantiate S<T>::arr's definition to pick up its initializer
and complete the array type. This involves new code to specially handle
completing the type of an expression where the type alone is
insufficient. It also requires *updating* the expression with the newly
completed type. Fortunately, all the other infrastructure is already in
Clang to do the instantiation, do the completion, and prune out the
unused bits of code that result from this instantiation.

This addresses the initial bug in PR10001, and will be a step to
fleshing out other cases where we need to work harder to complete an
expression's type. Who knew we still had missing C++03 "features"?

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132172 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-27 01:33:31 +00:00
Douglas Gregor f968d83747 Objective-C doesn't consider the use of incomplete types as method
parameter types to be ill-formed. However, it relies on the
completeness of method parameter types when producing metadata, e.g.,
for a protocol, leading IR generating to crash in such cases.

Since there's no real way to tighten down the semantics of Objective-C
here without breaking existing code, do something safe but lame:
suppress the generation of metadata when this happens.

Fixes <rdar://problem/9123036>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132171 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-27 01:19:52 +00:00
Richard Trieu bb6a5677fb Change the include stack of "instantiated from" notes to fall under the control of f/fno-diagnostics-show-note-include-stack flags. This should help with reducing diagnostic spew from macros instantiations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132143 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-26 20:49:16 +00:00
Richard Trieu f858bd817e Add a fix-it and better error recovery for improperly nested namespaces. This will give a better error message for cases such as "namespace foo::bar::baz {}" and a suggested fix-it of "namespace foo { namespace bar { namespace baz {} } }"
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132138 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-26 20:11:09 +00:00
Ted Kremenek f13654600b Tighen analyzer diagnostics w.r.t ObjC/CF leaks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132130 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-26 18:45:44 +00:00
Sean Hunt 9ae60d54e4 Implement a new warning for when adding a default argument to a method
makes it into a special member function. This is very bad and can lead
to all sorts of nastiness including implicit member functions violating
the One Definition Rule. This should probably be made ill-formed in a
later version of the standard, but for now we'll just warn.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132104 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-26 01:26:05 +00:00
Eli Friedman 55d484802f Skip extra copy from aggregate where it isn't necessary; rdar://problem/8139919 . This shouldn't make much of a difference at -O3, but should substantially reduce the number of generated memcpy's at -O0.
Originally r130717, but was backed out due to an ObjC regression.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132102 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-26 00:10:27 +00:00
Ted Kremenek e5cfd52a3a static analyzer: when conservatively evaluating functions, don't invalidate the values of globals when the called function is strlen.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132100 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-25 23:57:29 +00:00
Sean Hunt 8271317491 Update our diagnostics to properly account for move operations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132096 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-25 23:16:36 +00:00
Francois Pichet 563a645de8 Add support for Microsoft __if_exists, __if_not_exists extension at class scope.
Example:

typedef int TYPE;
class C {
  __if_exists(TYPE) {
     TYPE a;
  }
  __if_not_exists(TYPE) {
     this will never be parsed.
  }
};


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132052 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-25 10:19:49 +00:00
Ted Kremenek d1e015eb44 Teach analyzer about cf_returns_not_retained for C functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132049 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-25 06:29:39 +00:00
Ted Kremenek d368d71169 Enhance retain/release checker to flag warnings when functions returning CG types do not follow the Core Foundation naming conventions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132048 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-25 06:19:45 +00:00
Sean Hunt ca63c20034 Implement a new type node, UnaryTransformType, designed to represent a
type that turns one type into another. This is used as the basis to
implement __underlying_type properly - with TypeSourceInfo and proper
behavior in the face of templates.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132017 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-24 22:41:36 +00:00
Nick Lewycky cd583ff142 Fix Darwin test for r132006.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132013 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-24 22:18:08 +00:00
Ted Kremenek 29c9e62f41 Add explicit CFG support for ignoring static_asserts.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132001 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-24 20:41:31 +00:00
Argyrios Kyrtzidis 6f0074ae2f Add new warning that warns when invoking 'delete' on a polymorphic, non-final, class without a virtual destructor.
Patch by Matthieu Monrocq!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131989 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-24 19:53:26 +00:00
Douglas Gregor 63fe6814f3 Implement the initial part of C++0x [expr.const]p2, which specifies
that the unevaluated subexpressions of &&, ||, and ? : are not
considered when determining whether the expression is a constant
expression. Also, turn the "used in its own initializer" warning into
a runtime-behavior warning, so that it doesn't fire when a variable is
used as part of an unevaluated subexpression of its own initializer.

Fixes PR9999.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131968 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-24 16:02:01 +00:00
Chandler Carruth 1f8f2d52ff Fix a bug in -Wundefined-reinterpret-cast where we failed to look
through sugared types when testing for TagTypes. This was the actual
cause of the only false positive in Clang+LLVM.

Next evaluation will be over a much larger selection of code including
large amounts of open source code.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131957 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-24 07:43:19 +00:00
Francois Pichet 0f161593b3 MSVC doesn't do any validation regarding exception specification.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131950 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-24 02:11:43 +00:00
Devang Patel 1ebb6f29ed Test case for r131940.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131941 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-24 00:22:40 +00:00
Sean Hunt 2545ce1c76 Delete the extraneous return statement that was causing my earlier
issues and also add a test.

We should now handle defaulted members of templates properly. No
comment as to whether or not this also holds for templated functions,
but defaulting those is kind of insane.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131938 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-23 23:56:01 +00:00