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

31 Коммитов

Автор SHA1 Сообщение Дата
Richard Trieu b778305e95 Change the binary operator data recursive evaluator to not stop at the first
non-constant value encountered.  This allows the evaluator to deduce that
expressions like (x < 5 || true) is equal to true.  Previously, it would visit
x and determined that the entire expression is could not evaluated to a
constant.

This fixes PR12318.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153226 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-21 23:30:30 +00:00
Chad Rosier 7a0a31ce0c [frontend] Don't allow a mapping to a warning override an error/fatal mapping.
rdar://10736625

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149662 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-03 01:49:51 +00:00
Chandler Carruth d067c07c6c Fix the behavior of -Wignored-qualifiers on return type qualifiers in
several ways. We now warn for more of the return types, and correctly
locate the ignored ones. Also adds fix-it hints to remove the ignored
qualifiers. Fixes much of PR9058, although not all of it.

Patch by Hans Wennborg, a couple of minor style tweaks from me.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126321 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-23 18:51:59 +00:00
NAKAMURA Takumi eada35c933 test/Sema/return.c: Cygwin does not have _longjmp().
Although Cygwin-1.7 has _longjmp(), it would not be essential for this
to distinguish Cygwin's version with <cygwin/version.h>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116783 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-19 01:17:08 +00:00
Ted Kremenek 90b828aa27 Enhance -Wreturn-type to not warn when control-flow is most likely limited by a switch statement explicitly covering
all the cases for an enum value.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113450 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-09 00:06:07 +00:00
Anders Carlsson 5d1d7ae120 Get rid of the "functions declared 'noreturn' should have a 'void' result type" warning.
The rationale behind this is that it is normal for callback functions to have a non-void return type
and it should still be possible to mark them noreturn. (JavaScriptCore is a good example of this).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112918 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-03 00:25:02 +00:00
Ted Kremenek 58f281f7d5 Add warning for functions/blocks that have attribute 'noreturn' but return a non-void result. (<rdar://problem/7562925>)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111492 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-19 00:52:13 +00:00
Chandler Carruth 5495f37302 Wire up '-Wignored-qualifiers' to the warning on 'const' in 'const int f()'.
This flag and warning match GCC semantics. Also, move it to -Wextra as this is
a largely cosmetic issue and doesn't seem to mask problems. Subsequent fixes to
the tests which no longer by default emit the warning. Added explicit test
cases for both C and C++ behavior with the warning turned on.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108325 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-14 06:36:18 +00:00
Chris Lattner 184aa4e6de fix PR7280 by making the warning on code like this:
int test1() {
  return;
}

default to an error.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108108 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-11 23:34:02 +00:00
Ted Kremenek a8b48e4b68 Update test case.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100801 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-08 18:51:47 +00:00
Ted Kremenek c263704cb0 For forward-declared static inline functions, delay CFG-based warnings until we
encounter a definition.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99243 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-23 01:37:12 +00:00
Ted Kremenek d064fdc4b7 Only perform CFG-based warnings on 'static inline' functions that
are called (transitively) by regular functions/blocks within a
translation untion.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99233 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-23 00:13:23 +00:00
John McCall 0faede6f31 Improve the unused-value check to look into comma expressions and filter out
voids in sub-expressions.  Patch by Mike M!

Fixes PR4806.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98335 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-12 07:11:26 +00:00
Mike Stump 46171917dc Insulate these from changes to the default for -Wunreachable-code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94326 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-23 20:12:18 +00:00
Mike Stump 29da559b62 Revert r91073.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91629 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-17 22:14:41 +00:00
Daniel Dunbar 80737ad5e0 Update tests to use %clang instead of 'clang', and forcibly disable use of '
clang ' or ' clang -cc1 ' or ' clang-cc ' in test lines (by substituting them to
garbage).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91460 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-15 22:01:24 +00:00
Mike Stump c9875bfa6f Don't complain about falling off the end of a function with an asm
block, if the function is supposed to return a value as we don't know
exactly what the asm code does.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91073 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-10 22:57:48 +00:00
Daniel Dunbar 8ee15dc2e2 Use clang to run tests which include headers from the system.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89085 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 10:14:55 +00:00
John Thompson addb0f6958 Fix some Window-isms to get these tests to pass on Windows.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85450 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-29 00:10:42 +00:00
Mike Stump 87e5732f33 Be sure to turn on -fblocks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77406 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-29 00:17:20 +00:00
Mike Stump 4d9d51ae3b Add support for -Wmissing-noreturn.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77391 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-28 23:11:12 +00:00
Mike Stump e24aea225e Ensure we can work through typedefs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77265 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-27 22:25:19 +00:00
Mike Stump 773db1d4b5 Add knowledge about _longjmp being noreturn.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77254 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-27 21:45:16 +00:00
Mike Stump fd350b5b4a Add builtin knowledge about longjmp being noreturn. Add printing for
the noreturn attribute.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77253 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-27 21:33:40 +00:00
Mike Stump 0feecbb316 Add noreturn for exit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77237 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-27 19:14:18 +00:00
Chris Lattner 22bfc7bce3 add bugzilla #
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77183 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-27 04:49:58 +00:00
Mike Stump 2d3c191e1d Fix PR4624.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77176 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-27 00:44:23 +00:00
Mike Stump 2455636163 Add noreturn as a type attribute, handle printing for them and handle
calls to noreturn function pointers when CFG building.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77089 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-25 21:26:53 +00:00
Mike Stump b1682c50d2 Add warning for falling off the end of a function that should return a
value.  This is on by default, and controlled by -Wreturn-type (-Wmost
-Wall).  I believe there should be very few false positives, though
the most interesting case would be:

  int() { bar(); }

when bar does:

  bar() { while (1) ; }

Here, we assume functions return, unless they are marked with the
noreturn attribute.  I can envision a fixit note for functions that
never return normally that don't have a noreturn attribute to add a
noreturn attribute.

If anyone spots other false positives, let me know!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76821 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-22 23:56:57 +00:00
Steve Naroff 940ab971c5 Name the "return-type" DiagGroup and reference it in a few places.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70500 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-30 17:53:16 +00:00
Steve Naroff 2c0ccd0455 Warn about invalid return statements by default.
This fixes <rdar://problem/6839489> 10A345: Clang does not warm about mismatched returns (void return from a bool function)
 
Will implement -Wreturn-type, -Wno-return-type in another commit.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70492 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-30 16:01:26 +00:00