Commit Graph

1581 Commits

Author SHA1 Message Date
John McCall e155a3d8aa __builtin_va_list is void* on ARM, not char*.
rdar://problem/9391966

llvm-svn: 131080
2011-05-09 02:19:37 +00:00
Chad Rosier f897d3b88b Fixed test case asserts due to checkin of r130710.
llvm-svn: 130720
2011-05-02 20:39:21 +00:00
Ted Kremenek b5fabb2f9f Convert assertion in memset checking to a runtime check (because real code may provide a deviant definition of memset).
llvm-svn: 130368
2011-04-28 01:38:02 +00:00
John Wiegley 1c0675e155 Parsing/AST support for Structured Exception Handling
Patch authored by Sohail Somani.

Provide parsing and AST support for Windows structured exception handling.

llvm-svn: 130366
2011-04-28 01:08:34 +00:00
Argyrios Kyrtzidis ae40e4e10e Gcc pads the size of an array using the alignment of its elements.
The size of the array may not be aligned according to alignment of its elements if an alignment attribute is
specified in a typedef. Fixes rdar://8665729 & http://llvm.org/PR5637.

llvm-svn: 130242
2011-04-26 21:05:39 +00:00
Fariborz Jahanian 6b4e26bee2 Add ms_struct attribute on record typee
(and ignore it for now) - wip.

llvm-svn: 130224
2011-04-26 17:54:40 +00:00
Argyrios Kyrtzidis a9b630e4d7 Emit a -Wnull-dereference warning for "*null" not just "*null = something". Addresses rdar://9269271.
llvm-svn: 130207
2011-04-26 17:41:22 +00:00
Ted Kremenek 8dcc466886 When generating printf fixits, preserve the original formating for unsigned integers (e.g., 'x', 'o').
llvm-svn: 130164
2011-04-25 22:32:59 +00:00
Fariborz Jahanian 743dda49d9 Recognize gcc's ms_struct pragma (and ignore for now).
This is wip.

llvm-svn: 130138
2011-04-25 18:49:15 +00:00
Eli Friedman ea7b85bfe0 PR4304: Add warning for designators in strict c89 mode.
llvm-svn: 130117
2011-04-24 22:14:22 +00:00
Chandler Carruth b009b14971 There were some frustrating problems with the implementation of
-Wwrite-strings. First and foremost, once the positive form of the flag
was passed, it could never be disabled by passing -Wno-write-strings.
Also, the diagnostic engine couldn't in turn use -Wwrite-strings to
control diagnostics (as GCC does) because it was essentially hijacked to
drive the language semantics.

Fix this by giving CC1 a clean '-fconst-strings' flag to enable
const-qualified strings in C and ObjC compilations. Corresponding
'-fno-const-strings' is also added. Then the driver is taught to
introduce '-fconst-strings' in the CC1 command when '-Wwrite-strings'
dominates.

This entire flag is basically GCC-bug-compatibility driven, so we also
match GCC's bug where '-w' doesn't actually disable -Wwrite-strings. I'm
open to changing this though as it seems insane.

llvm-svn: 130051
2011-04-23 06:30:43 +00:00
Argyrios Kyrtzidis ad8b4d402e For -Wlogical-op-parentheses, point at '&&', not '||'. Fixes rdar://9125333.
llvm-svn: 130009
2011-04-22 19:16:27 +00:00
Argyrios Kyrtzidis 1618023018 We regard a function as 'unused' from the codegen perspective, so our warnings diverge from
gcc's unused warnings which don't get emitted if the function is referenced even in an unevaluated context
(e.g. in templates, sizeof, etc.). Also, saying that a function is 'unused' because it won't get codegen'ed
is somewhat misleading.

- Don't emit 'unused' warnings for functions that are referenced in any part of the user's code.
- A warning that an internal function/variable won't get emitted is useful though, so introduce
  -Wunneeded-internal-declaration which will warn if a function/variable with internal linkage is not
  "needed" ('used' from the codegen perspective), e.g:

  static void foo() { }

  template <int>
  void bar() {
    foo();
  }

test.cpp:1:13: warning: function 'foo' is not needed and will not be emitted
static void foo() { }
            ^

Addresses rdar://8733476.

llvm-svn: 129794
2011-04-19 19:51:10 +00:00
Peter Collingbourne 133587f08b Add a new expression classification, CL_AddressableVoid
CL_AddressableVoid is the expression classification used for void
expressions whose address can be taken, i.e. the result of [], *
or void variable references in C, as opposed to things like the
result of a void function call.

llvm-svn: 129783
2011-04-19 18:51:51 +00:00
Matt Beaumont-Gay ceb763e23a Fix line endings
llvm-svn: 129740
2011-04-19 00:23:31 +00:00
Ted Kremenek 1551d55295 Improve diagnostics on GNU attributes by warning about attributes that should have no arguments or parameters. Patch by Michael Han!
llvm-svn: 129560
2011-04-15 05:49:29 +00:00
Peter Collingbourne 3d9cbdc3e6 C1X: implement static asserts
llvm-svn: 129555
2011-04-15 00:35:57 +00:00
Peter Collingbourne 9114759641 C1X: implement generic selections
As an extension, generic selection support has been added for all
supported languages.  The syntax is the same as for C1X.

llvm-svn: 129554
2011-04-15 00:35:48 +00:00
Chandler Carruth 016ef400c4 Enhance the diagnostic for literal float -> int conversions to suggest
rewriting the literal when the value is integral. It is not uncommon to
see code written as:

  const int kBigNumber = 42e5;

Without any real awareness that this is no longer an ICE. The note helps
automate and ease the process of fixing code that violates the warning.

llvm-svn: 129243
2011-04-10 08:36:24 +00:00
Chandler Carruth 42983aef34 Switch 'is possibly uninitialized' to 'may be uninitialized' based on
Chris's feedback.

llvm-svn: 129127
2011-04-08 06:47:15 +00:00
Chandler Carruth 278f89732f Now that the analyzer is distinguishing between uninitialized uses that
definitely have a path leading to them, and possibly have a path leading
to them; reflect that distinction in the warning text emitted.

llvm-svn: 129126
2011-04-08 06:33:38 +00:00
Chandler Carruth 78c7e34485 Commit a bit of a hack to fully handle the situation where variables are
marked explicitly as uninitialized through direct self initialization:

  int x = x;

With r128894 we prevented warnings about this code, and this patch
teaches the analysis engine to continue analyzing subsequent uses of
'x'. This should wrap up PR9624.

There is still an open question of whether we should suppress the
maybe-uninitialized warnings resulting from variables initialized in
this fashion. The definitely-uninitialized uses should always be warned.

llvm-svn: 128932
2011-04-05 21:36:30 +00:00
Chandler Carruth b5d4831f83 Fix PR9624 by explicitly disabling uninitialized warnings for direct self-init:
int x = x;

GCC disables its warnings on this construct as a way of indicating that
the programmer intentionally wants the variable to be uninitialized.
Only the warning on the initializer is turned off in this iteration.

This makes the code a lot more ugly, but starts commenting the
surprising behavior here. This is a WIP, I want to refactor it
substantially for clarity, and to determine whether subsequent warnings
should be suppressed or not.

llvm-svn: 128894
2011-04-05 17:41:31 +00:00
Ted Kremenek 378819342e Fix PR 9626 (duplicated self-init warnings under -Wuninitialized) with numerous CFG and UninitializedValues analysis changes:
1) Change the CFG to include the DeclStmt for conditional variables, instead of using the condition itself as a faux DeclStmt.
2) Update ExprEngine (the static analyzer) to understand (1), so not to regress.
3) Update UninitializedValues.cpp to initialize all tracked variables to Uninitialized at the start of the function/method.
4) Only use the SelfReferenceChecker (SemaDecl.cpp) on global variables, leaving the dataflow analysis to handle other cases.

The combination of (1) and (3) allows the dataflow-based -Wuninitialized to find self-init problems when the initializer
contained control-flow.

llvm-svn: 128858
2011-04-04 23:29:12 +00:00
Ted Kremenek b8d8c4ec56 -Wuninitialized: use "self-init" warning when issue uninitialized values warnings from the dataflow analysis that include within the initializer of a variable.
llvm-svn: 128843
2011-04-04 20:56:00 +00:00
Ted Kremenek 35d800c39f -Wuninitialized: don't issue fixit for initializer if a variable declaration already has an initializer.
llvm-svn: 128838
2011-04-04 19:43:57 +00:00
Ted Kremenek 99a337eed0 When emitting a "too many arguments to function call..." error, also include a note with a location for the function prototype.
llvm-svn: 128833
2011-04-04 17:22:27 +00:00
Ted Kremenek 77361761fb -Wuninitialized should not warn about variables captured by blocks as byref.
Note this can potentially be enhanced to detect if the __block variable
is actually written by the block, or only when the block "escapes" or
is actually used, but that requires more analysis than it is probably worth
for this simple check.

llvm-svn: 128681
2011-03-31 22:32:41 +00:00
Anton Yartsev 530deb9a39 AltiVec vector comparison logic now affect only vectors of fundamental AltiVec vector types. It fixes bug 9347.
llvm-svn: 128381
2011-03-27 15:36:07 +00:00
Anton Yartsev 28ccef788b supported: AltiVec vector initialization with a single literal according to PIM section 2.5.1 - after initialization all elements have the value specified by the literal
llvm-svn: 128375
2011-03-27 09:32:40 +00:00
Douglas Gregor 7735c53664 Test attribute merging for the availability attribute.
llvm-svn: 128334
2011-03-26 10:47:34 +00:00
Douglas Gregor 7ab142b55a Extend the new 'availability' attribute with support for an
'unavailable' argument, which specifies that the declaration to which
the attribute appertains is unavailable on that platform.

llvm-svn: 128329
2011-03-26 03:35:55 +00:00
Ted Kremenek dcc4c38970 Fix CFG-construction bug when run from AnalysisBasedWarnings::IssueWarnings() where block-level expressions that need
to be recorded in the Stmt*->CFGBlock* map were not always done so.  Fixes <rdar://problem/9171946>.

llvm-svn: 128170
2011-03-23 21:33:21 +00:00
Fariborz Jahanian 16f92ce539 Support for Transparent unions used as overloadable
function parameter. // rdar:// 9129552
and PR9406.

llvm-svn: 128159
2011-03-23 19:50:54 +00:00
Douglas Gregor 20b2ebd785 Implement a new 'availability' attribute, that allows one to specify
which versions of an OS provide a certain facility. For example,

  void foo()
  __attribute__((availability(macosx,introduced=10.2,deprecated=10.4,obsoleted=10.6)));

says that the function "foo" was introduced in 10.2, deprecated in
10.4, and completely obsoleted in 10.6. This attribute ties in with
the deployment targets (e.g., -mmacosx-version-min=10.1 specifies that
we want to deploy back to Mac OS X 10.1). There are several concrete
behaviors that this attribute enables, as illustrated with the
function foo() above:

  - If we choose a deployment target >= Mac OS X 10.4, uses of "foo"
    will result in a deprecation warning, as if we had placed
    attribute((deprecated)) on it (but with a better diagnostic)
  - If we choose a deployment target >= Mac OS X 10.6, uses of "foo"
    will result in an "unavailable" warning (in C)/error (in C++), as
    if we had placed attribute((unavailable)) on it
  - If we choose a deployment target prior to 10.2, foo() is
    weak-imported (if it is a kind of entity that can be weak
    imported), as if we had placed the weak_import attribute on it.

Naturally, there can be multiple availability attributes on a
declaration, for different platforms; only the current platform
matters when checking availability attributes.

The only platforms this attribute currently works for are "ios" and
"macosx", since we already have -mxxxx-version-min flags for them and we
have experience there with macro tricks translating down to the
deprecated/unavailable/weak_import attributes. The end goal is to open
this up to other platforms, and even extension to other "platforms"
that are really libraries (say, through a #pragma clang
define_system), but that hasn't yet been designed and we may want to
shake out more issues with this narrower problem first.

Addresses <rdar://problem/6690412>.

As a drive-by bug-fix, if an entity is both deprecated and
unavailable, we only emit the "unavailable" diagnostic.

llvm-svn: 128127
2011-03-23 00:50:03 +00:00
John McCall 92d627e1b0 Fix an error with the declaration of block parameters that depend
on previous block parameters that crept in as part of my captures
work a month or so ago.

llvm-svn: 128121
2011-03-22 23:15:50 +00:00
John McCall aa01737782 Warn about unused declaration-specifiers on tag declarations.
llvm-svn: 128118
2011-03-22 23:00:04 +00:00
Ted Kremenek 97d8d03855 Make test more portable.
llvm-svn: 127799
2011-03-17 04:16:45 +00:00
Ted Kremenek c15a4e4b37 Extend -Wuninitialized to support vector types.
llvm-svn: 127794
2011-03-17 03:06:11 +00:00
Ted Kremenek 61c74a1423 Rename -Wuninitialized-maybe to -Wconditional-uninitialized.
llvm-svn: 127793
2011-03-17 03:06:07 +00:00
Ted Kremenek 6cd0187718 Remove warning for null characters in CFString literals. Clang handles them just fine, and GCC 4.2 doesn't warn here either.
We added this warning back in 2007 when we were comparing against GCC 4.0.

llvm-svn: 127704
2011-03-15 21:18:52 +00:00
Ted Kremenek ea6c20adaf Take 2: merge -Wuninitialized-experimental into -Wuninitialized. Only *must-be-uninitialized* warnings are reported, with *maybe-uninitialized* under a separate flag. I await any fallout/comments/feedback, although hopefully this will produce no noise for users.
llvm-svn: 127670
2011-03-15 05:22:33 +00:00
Ted Kremenek c8c4e5f371 Split warnings from -Wuninitialized-experimental into "must-be-initialized" and "may-be-initialized" warnings, each controlled by different flags.
llvm-svn: 127666
2011-03-15 04:57:38 +00:00
Ted Kremenek 792798549f Remove old UninitializedValues analysis.
llvm-svn: 127656
2011-03-15 03:17:01 +00:00
Douglas Gregor 364f7db063 When we're determining whether to complain about a conversion from one
enumeration type to another in C, classify enumeration constants as if
they had the type of their enclosing enumeration. Fixes
<rdar://problem/9116337>.

llvm-svn: 127514
2011-03-12 00:14:31 +00:00
NAKAMURA Takumi 4e8c365e9a include/clang/Basic/BuiltinsX86.def: __builtin_ia32_crc32**() should be defined to take unsigned args and to return unsigned value.
mingw-w64's intrin.h declares __builtin_ia32_crc32**() as external.

llvm-svn: 127329
2011-03-09 12:00:19 +00:00
Carl Norum 58d489fc6e Fix tests to account for new warning "expected ';' at end of declaration list". Sorry, folks!
llvm-svn: 127188
2011-03-07 22:57:45 +00:00
John McCall 80ee5963fd Pretty up the wrong-number-of-arguments-for-attribute diagnostic by
using a custom plural form.  Split out the range diagnostics as their
own message.

llvm-svn: 126840
2011-03-02 12:15:05 +00:00
Ted Kremenek e96dad9544 Don't warn about unused values in ternary ?: expressions unless both the LHS and RHS are "unused" (side-effect free).
Patch by Justin Bogner!  Fixes PR 8282.

llvm-svn: 126779
2011-03-01 20:34:48 +00:00
Ted Kremenek 26bbc3d494 Don't warning about shifting by too many bits in dead code.
llvm-svn: 126770
2011-03-01 19:13:22 +00:00