Commit Graph

2060 Commits

Author SHA1 Message Date
Fariborz Jahanian b1885425c4 c: warn when an integer value comparison with an
integral expression have the obvious result.
Patch reviewed by John McCall off line.
// rdar://12202422

llvm-svn: 164143
2012-09-18 17:37:21 +00:00
Ted Kremenek 97c5a1e735 Per discussion on cfe-dev, remove -Wunique-enums entirely. There
is no compelling argument that this is a generally useful warning,
and imposes a strong stylistic argument on code beyond what it was
intended to find warnings in.

llvm-svn: 164083
2012-09-18 00:41:42 +00:00
Dmitri Gribenko 49fdf8d3f5 Comment parsing: don't treat typedef to a typedef to a function as a
'function-like' type that can be annotated with \param.

Thanks to Eli Friedman for noticing!

llvm-svn: 163985
2012-09-15 21:13:36 +00:00
Richard Smith e00921a0a4 const _Atomic(T) is not an atomic type, so do not allow it as the type 'A' in
C11 7.17's atomic operations. GNU's __atomic_* builtins do allow const-qualified
atomics, though (!!) so don't restrict those.

llvm-svn: 163964
2012-09-15 06:09:58 +00:00
Dmitri Gribenko 578865b73c Comment parsing: support the "\invariant" command.
llvm-svn: 163905
2012-09-14 15:37:29 +00:00
Dmitri Gribenko b37d5e8a95 Comment parsing: handle \deprecated command. It is a block command, but it
should be fine to use it without further explanations in the attached
paragraph, so the warning about empty paragraph was turned off for it.

llvm-svn: 163836
2012-09-13 20:36:01 +00:00
Jordan Rose 4c266aa371 Format strings: offer a fixit for Darwin's %D/%U/%O to ISO %d/%u/%o.
<rdar://problem/12061922>

llvm-svn: 163772
2012-09-13 02:11:15 +00:00
Jordan Rose 510260c2bf Format strings: %D, %U, and %O are valid on Darwin (same as %d, %u, %o).
These will warn under -Wformat-non-iso, and will still be rejected
outright on other platforms.

<rdar://problem/12061922>

llvm-svn: 163771
2012-09-13 02:11:03 +00:00
NAKAMURA Takumi fcd16e36c8 clang/test: [PR8833] Introduce the feature "LP64" to suppress LLP64-incompatible tests.
I think some of them could be rewritten to fit also LLP64.

llvm-svn: 163699
2012-09-12 10:45:40 +00:00
Ted Kremenek 7979ccf35a Teach -Wuninitialized to recognize __attribute__((analyzer_noreturn))
for halting the propagation of uninitialized value tracking along
a path.  Unlike __attribute__((noreturn)), this attribute (which
is used by clients of the static analyzer) can be used to annotate
functions that essentially never return, but in rare cares may be
allowed to return for (special) debugging purposes.  This attribute
has been shown in reducing false positives in the static analyzer
by pruning false postives, and is equally applicable here.

Handling this attribute in the CFG itself is another option, but
this is not something all clients (e.g., possibly -Wunreachable-code)
would want to see.

Addresses <rdar://problem/12281583>.

llvm-svn: 163681
2012-09-12 05:53:43 +00:00
Dmitri Gribenko 9304d86329 Comment parsing: handle non-builtin commands correctly. After semantic
analysis registers a command, it becomes a "known" command for the lexer, since
it has an ID.  Having this freedom of choice to register a command is a good
thing since BriefParser does not need this.

But the parser should still invoke the correct semantic analysis method
(actOnUnknownCommand) in this case.

llvm-svn: 163646
2012-09-11 19:22:03 +00:00
NAKAMURA Takumi e06bc926bb clang/test/Sema/format-strings-scanf.c: Relax a couple of expressions with expected-warning-re to let matched for Win32 targets.
- format specifies type 'wchar_t **' (aka 'int **') but the argument has type 'float *'
- format specifies type 'wchar_t **' (aka 'unsigned short **') but the argument has type 'float *'

llvm-svn: 163468
2012-09-08 12:06:00 +00:00
Jordan Rose 2f9cc04251 Format strings: suggest %lld instead of %qd and %Ld with -Wformat-non-iso.
As a corollary to the previous commit, even when an extension is
available, we can still offer a fixit to the standard modifier.

llvm-svn: 163453
2012-09-08 04:00:12 +00:00
Jordan Rose 92303592c3 Format strings: %Ld isn't available on Darwin or Windows.
This seems to be a GNU libc extension; we offer a fixit to %lld on
these platforms.

<rdar://problem/11518237>

llvm-svn: 163452
2012-09-08 04:00:03 +00:00
Fariborz Jahanian 66c93f443d c: make __attribute__((unused)) transitive.
Don't warn if annotated decl is used inside another
   unused. // rdar://12233989

llvm-svn: 163329
2012-09-06 16:43:18 +00:00
Fariborz Jahanian aaf376b4dd c error recovery. treat an invalid redeclaration
of a c-function for what it is. Otherwise, this func
is treated as an overloadable c-function resulting in
a crash much later. // rdar://11743706

llvm-svn: 163224
2012-09-05 17:52:12 +00:00
Richard Trieu 73e306e548 Add -Wduplicate-enum warning. Clang will emit this warning when an implicitly
initiated enum constant has the same value as another enum constant.

For instance:
enum test { A, B, C = -1, D, E = 1 };
Clang will warn that:
 A and D both have value 0
 B and E both have value 1

A few exceptions are made to keep the noise down.  Enum constants which are
initialized to another enum constant, or an enum constant plus or minus 1 will
not trigger this warning.  Also, anonymous enums are not checked.

llvm-svn: 162938
2012-08-30 20:32:24 +00:00
Eli Friedman 448ce40426 Fix a crash in type merging with enum types.
llvm-svn: 162886
2012-08-30 00:44:15 +00:00
Hans Wennborg fa4e41f73c Move the test for PR13720 from Sema/init.c to Sema/thread-specifier.c.
Can't use __thread in init.c because it doesn't have a triple.

llvm-svn: 162836
2012-08-29 09:04:10 +00:00
Hans Wennborg 299f50b4e8 The address of a TLS var is not compile-time constant (PR13720)
This makes Clang produce an error for code such as:

  __thread int x;
  int *p = &x;

The lvalue of a thread-local variable cannot be evaluated at compile
time.

llvm-svn: 162835
2012-08-29 08:44:49 +00:00
Rafael Espindola 3dd531dbd4 Fix for assertion when solving unresolved templates.
Patch by Magee, Josh.

llvm-svn: 162737
2012-08-28 04:13:54 +00:00
Dmitri Gribenko 219bd1554f Comment diagnostics: for unresolved parameters, do not suggest parameter fixit
with parameter that is documented.

Fixes PR13670, <rdar://problem/12155840>.

llvm-svn: 162570
2012-08-24 17:45:39 +00:00
Ted Kremenek 64fea5fc8f Teach CFG that 'if (x & 0)' and 'if (x * 0)' is an unfeasible branch.
Fixes <rdar://problem/11005770>.

llvm-svn: 162545
2012-08-24 07:42:09 +00:00
Dmitri Gribenko 907f6b8c06 Comment semantic analysis: treat function typedefs as functions so that one can
use \param and \returns in documentation.

Fixes PR13533.

llvm-svn: 162507
2012-08-24 00:05:30 +00:00
Dmitri Gribenko 107618a6cb Comment parsing: parse "<blah" as an HTML tag only if "blah" is a known tag
name.  This should reduce the amount of warning false positives about bad HTML
in comments when the comment author intended to put a reference to a template.
This change will also enable us parse the comment as intended in these cases.

Fixes part 1 of PR13374.

llvm-svn: 162407
2012-08-22 22:56:08 +00:00
Fariborz Jahanian f85f338634 c: privide deprecated warning when __private_extern__ storage
specifier is unsed in a declaration; as it may not make the symbol
local to linkage unit as intended. Suggest using "hidden" visibility 
attribute instead. // rdar://7703982

llvm-svn: 162138
2012-08-17 21:44:55 +00:00
Fariborz Jahanian 3a4b644982 make this test case 64bit test. It fails due to
'int' vs. 'long' issue with i386.

llvm-svn: 162125
2012-08-17 20:23:06 +00:00
Fariborz Jahanian 91f548b04b c: implement gcc's -Wbad-function-cast which warns
on unsafe cast of a c-function call. This is
a C-only option.

llvm-svn: 162109
2012-08-17 17:22:34 +00:00
Benjamin Kramer 0e72d5c3e5 Define __builtin_ffs[ll] with a signed argument instead of unsigned.
GCC documents these as unsigned, but defines them as signed.

llvm-svn: 162106
2012-08-17 16:39:13 +00:00
Dmitri Gribenko e4a5a90e8d Add support for "type safety" attributes that allow checking that 'void *'
function arguments and arguments for variadic functions are of a particular
type which is determined by some other argument to the same function call.

Usecases include:
* MPI library implementations, where these attributes enable checking that
  buffer type matches the passed MPI_Datatype;
* for HDF5 library there is a similar usecase as MPI;
* checking types of variadic functions' arguments for functions like
  fcntl() and ioctl().

llvm-svn: 162067
2012-08-17 00:08:38 +00:00
Eric Christopher 9e49188a01 Add a missing 'break' to ensure that we reject inline assembly
constraints we don't recognize.

llvm-svn: 162064
2012-08-16 23:50:41 +00:00
Dmitri Gribenko 4ae66a31fe Attaching comments to declarations: parse the comment in context of the
declaration it was attached to.

llvm-svn: 162033
2012-08-16 18:19:43 +00:00
Matt Beaumont-Gay 22be8d5ab8 Allow 'static' and type qualifiers in K&R parameter type lists.
llvm-svn: 161980
2012-08-15 19:53:19 +00:00
Fariborz Jahanian 05f4e7181a Patch to warn about __private_extern__ on tentative definitions
as it does something unexpected (but gcc compatible).
Suggest use of __attribute__((visibility("hidden")))
on declaration instead. // rdar://7703982

llvm-svn: 161972
2012-08-15 18:42:26 +00:00
Hans Wennborg 420052640f Check for improper use of 'static' and type qualifiers in array
declarators.

They are only allowed for function parameters, and then only on the
outermost array type derivation.

llvm-svn: 161934
2012-08-15 07:42:30 +00:00
Dmitri Gribenko b261088a61 Attaching comments to redeclarations: fix wrong assumptions
The reason for the recent fallout for "attaching comments to any redeclaration"
change are two false assumptions:
(1) a RawComment is attached to a single decl (not true for 'typedef struct X *Y'
    where we want the comment to be attached to both X and Y);
(2) the whole redeclaration chain has only a single comment (obviously false, the
    user can put a separate comment for each redeclaration).

To fix (1) I revert the part of the recent change where a 'Decl*' member was
introduced to RawComment.  Now ASTContext has a separate DenseMap for mapping
'Decl*' to 'FullComment*'.

To fix (2) I just removed the test with this assumption.  We might not parse
every comment in redecl chain if we already parsed at least one.

llvm-svn: 161878
2012-08-14 17:17:18 +00:00
Benjamin Kramer 833fb9f7e3 Fix horribly broken sema of __attribute__((pcs())).
llvm-svn: 161863
2012-08-14 13:13:47 +00:00
Fariborz Jahanian 7513fa346c c: small refactoring of checking for __attribute__(const))
per Richard's comment.

llvm-svn: 161786
2012-08-13 21:15:02 +00:00
Fariborz Jahanian 794ae1ea77 c: make __has_attribute(const) work for const
function attribute. // rdar://10253857

llvm-svn: 161767
2012-08-13 18:04:58 +00:00
Douglas Gregor 35ceb27fa4 When looking for the comment associated with a declaration, adjust the
'templated' declaration for a function or class template to refer to
the function or class template itself, to which the documentation will
be attached. Fixes PR13593.

llvm-svn: 161762
2012-08-13 16:37:30 +00:00
Eli Friedman 89b1f2c7e1 Handle deprecation diagnostics correctly for C struct fields and Objective-C properties/ivars. <rdar://problem/6642337>.
llvm-svn: 161534
2012-08-08 23:04:35 +00:00
Eli Friedman 971bfa11c6 Unify the codepaths for emitting deprecation warnings. The test changes are just to account for us emitting notes more consistently.
llvm-svn: 161528
2012-08-08 21:52:41 +00:00
Anna Zaks 13b0857ad0 Address code review comments for Wstrncat-size warning (r161440).
llvm-svn: 161527
2012-08-08 21:42:23 +00:00
Eli Friedman 0415f3e138 Don't add attributes for "#pragma pack" and friends to tag declarations which
are not definitions. This follows the behavior of both gcc and earlier
versions of clang. Regression from r156531.  <rdar://problem/12048621>.

llvm-svn: 161523
2012-08-08 21:08:34 +00:00
Eli Friedman ecffd83c85 Get rid of an early return in Sema::ActOnFields which doesn't make sense anymore.
Fixes a crash (<rdar://problem/11067144>), and generally seems to improve
recovery in other cases.

llvm-svn: 161474
2012-08-08 04:39:56 +00:00
Dmitri Gribenko 740c0fbe0e libclang API for comment-to-xml conversion.
The implementation also includes a Relax NG schema and tests for the schema
itself.  The schema is used in c-index-test to verify that XML documents we
produce are valid.  In order to do the validation, we add an optional libxml2
dependency for c-index-test.

Credits for CMake part go to Doug Gregor.  Credits for Autoconf part go to Eric
Christopher.  Thanks!

llvm-svn: 161431
2012-08-07 17:54:38 +00:00
Hans Wennborg abc1e22d65 Properly check length modfiers for %n in format strings.
llvm-svn: 161408
2012-08-07 09:13:19 +00:00
Hans Wennborg b1ab2a84f0 Remove ScanfArgType and bake that logic into ArgType.
This is useful for example for %n in printf, which expects
a pointer to int with the same logic for checking as %d
would have in scanf.

llvm-svn: 161407
2012-08-07 08:59:46 +00:00
Dmitri Gribenko 5ec0c7536a Comment diagnostics: warn on duplicate \brief and \return commands.
Doxygen manual claims that multiple \brief or \returns commands will be merged
together, but actual behavior is different (second \brief command becomes a
part of a discussion, second \returns becomes a "Returns: blah" paragraph on
its own).  Anyway, it seems to be a bad idea to use multiple \brief or \returns
commands in a single command.

llvm-svn: 161325
2012-08-06 17:08:27 +00:00
Dmitri Gribenko 558babc53b Comment diagnostics: \return in void function: specialize diagnostic text for
ObjC methods.

llvm-svn: 161324
2012-08-06 16:29:26 +00:00
Dmitri Gribenko 6430583017 Comment diagnostics: warn if \returns is used in a non-function comment or if
the function returns void.

llvm-svn: 161261
2012-08-03 21:15:32 +00:00
Dmitri Gribenko baeb60e919 Comments: handle template paramter documentation in alias-declaration
templates.

llvm-svn: 161215
2012-08-02 21:36:57 +00:00
Dmitri Gribenko 7f4b3773be Attaching comments to declarations: handle using-declaration.
llvm-svn: 161211
2012-08-02 20:49:51 +00:00
Hans Wennborg db7a78c211 test/Sema/tls.c: don't use -verify to check if TLS is supported
Use "%clang_cc1" vs "not %clang_cc1" instead.
Also use -fsyntax-only.

llvm-svn: 161165
2012-08-02 09:04:56 +00:00
Dmitri Gribenko b0ddb66a8d Comment diagnostics fixit tests: move exected-warning constructs from the
comment being tested.

llvm-svn: 161144
2012-08-01 23:29:52 +00:00
Dmitri Gribenko fae2e4ed0a Comment diagnostics: add tests for \tparam fixits.
llvm-svn: 161142
2012-08-01 23:27:13 +00:00
Hans Wennborg 1241731803 TLS is not supported on OpenBSD
This fixes PR13502 and adds a test to keep track of which
targets support TLS and which do not.

llvm-svn: 161124
2012-08-01 18:53:19 +00:00
Dmitri Gribenko 34df220410 Comment parsing: add support for \tparam command on all levels.
The only caveat is renumbering CXCommentKind enum for aesthetic reasons -- this
breaks libclang binary compatibility, but should not be a problem since API is
so new.

This also fixes PR13372 as a side-effect.

llvm-svn: 161087
2012-07-31 22:37:06 +00:00
Hans Wennborg 16250c7c18 -Wformat: better handling of qualifiers on pointer arguments
Warn about using pointers to const-qualified types as arguments to
scanf. Ignore the volatile qualifier when checking if types match.

llvm-svn: 161052
2012-07-31 16:37:47 +00:00
Matt Beaumont-Gay 5c8de784f6 Do not warn on correct use of the '%n' format specifier.
While '%n' can be used for evil in an attacker-controlled format string, there
isn't any acute danger in using it in a literal format string with an argument
of the appropriate type.

llvm-svn: 160984
2012-07-30 20:21:58 +00:00
Dmitri Gribenko 1ba47ca4b5 Comment parser: don't crash on a completely empty \param followed by a block
command

llvm-svn: 160975
2012-07-30 18:05:28 +00:00
Hans Wennborg ebcd1c7ca2 Make -Wformat check the argument type for %n.
This makes Clang check that the corresponding argument for "%n" in a
format string is a pointer to int.

llvm-svn: 160966
2012-07-30 17:11:32 +00:00
Hans Wennborg 08574d3559 Make -Wformat walk the typedef chain when looking for size_t, etc.
Clang's -Wformat fix-its currently suggest using "%zu" for values of
type size_t (in C99 or C++11 mode). However, for a type such as
std::vector<T>::size_type, it does not notice that type is actually
typedeffed to size_t, and instead suggests a format for the underlying
type, such as "%lu" or "%u".

This commit makes the format string fix mechanism walk the typedef chain
so that it notices if the type is size_t, even if that isn't "at the
top".

llvm-svn: 160886
2012-07-27 19:17:46 +00:00
Ted Kremenek 875a402dc3 Turn -Wobjc-root-class on by default. <rdar://problem/11203649>.
llvm-svn: 160707
2012-07-25 07:26:32 +00:00
Dmitri Gribenko 3c54128715 Comment parsing tests: fix test
llvm-svn: 160700
2012-07-24 21:56:59 +00:00
Jordan Rose 68449acea4 Add __has_feature(attribute_availability_with_message).
This tests for the ability to include a "message" field in availability
attributes, like so:

  extern void ATSFontGetName(const char *oName)
    __attribute__((availability(macosx,introduced=8.0,deprecated=9.0,
                                message="use CTFontCopyFullName")));

This was actually supported in Clang 3.1, but we got a request for a
__has_feature so that header files can use this more safely. It's
unfortunate that the 3.1 release doesn't include this, however.

<rdar://problem/11886458>

llvm-svn: 160699
2012-07-24 21:55:34 +00:00
Dmitri Gribenko 5b8a1d4854 Comment diagnostics tests: add a function with zero arguments, for completeness.
llvm-svn: 160697
2012-07-24 21:46:24 +00:00
Dmitri Gribenko 8f0f1b0c41 Comment diagnostics: add warning for multiple \param commands with duplicate
parameter names.

llvm-svn: 160696
2012-07-24 21:44:16 +00:00
Richard Smith f676e45e5f When a && or || appears as the condition of a ?:, perform appropriate
short-circuiting when building the CFG. Also be sure to skip parens before
checking for the && / || special cases. Finally, fix some crashes in CFG
printing in the presence of calls to destructors for array of array of class
type.

llvm-svn: 160691
2012-07-24 21:02:14 +00:00
Nick Lewycky 085970736f Emit debug info for dynamic initializers. Permit __attribute__((nodebug)) on
variables that have static storage duration, it removes debug info on the
emitted initializer function but not all debug info about this variable.

llvm-svn: 160659
2012-07-24 01:40:49 +00:00
Sylvestre Ledru 830885ca64 Fix a typo (the the => the)
llvm-svn: 160622
2012-07-23 08:59:39 +00:00
Dmitri Gribenko 66a00c765f Fix PR13411: Comment parsing: failed assertion on unterminated verbatim block.
The assertion was wrong in case we have a verbatim block without a closing
command.

Also add tests for closing command name in a verbatim block, since now it can
be empty in such cases.

llvm-svn: 160568
2012-07-20 20:18:53 +00:00
Dmitri Gribenko 7b2ca3e80b Fix ParagraphComment::isWhitespace(): a paragraph without a non-whitespace
TextComment node was considered whitespace even if it contained other child
nodes.

llvm-svn: 160474
2012-07-19 00:01:56 +00:00
Eli Friedman 4eafb6b77b Don't treat overflow in floating-point conversions as a hard error in constant evaluation. <rdar://problem/11874571>.
llvm-svn: 160394
2012-07-17 21:03:05 +00:00
Fariborz Jahanian 268fec1e2e Issue warning when assigning out-of-range integer values to enums.
Due to performance cost, this is an opt-in option placed
under -Wassign-enum. // rdar://11824807

llvm-svn: 160382
2012-07-17 18:00:08 +00:00
Richard Smith b21dd02e61 Uninitialized variables: two little changes:
* Treat compound assignment as a use, at Jordy's request.
 * Always add compound assignments into the CFG, so we can correctly diagnose the use in 'return x += 1;'

llvm-svn: 160334
2012-07-17 01:27:33 +00:00
Richard Smith 6376d1fd9c -Wuninitialized: Split the classification of DeclRefExprs as initialization or
use out of TransferFunctions, and compute it in advance rather than on-the-fly.

This allows us to handle compound assignments with DeclRefExprs on the RHS
correctly, and also makes it trivial to treat const& function parameters as not
initializing the argument. The patch also makes both of those changes.

llvm-svn: 160330
2012-07-17 00:06:14 +00:00
Rafael Espindola faf556b745 Without this patch clang warns on
struct __attribute__((visibility("hidden"))) zed {
};
struct __attribute__((visibility("hidden"))) zed;

Which is a bit silly and got a lot noisier now that we correctly handle
visibility pragmas. This patch fixes that and also has some extra quality
improvements:

* We now produce an error instead of a warning for

struct __attribute__((visibility("hidden"))) zed {
};
struct __attribute__((visibility("default"))) zed;

* The "after definition" warning now points to the new attribute that is
  ignored instead of pointing to the declaration.

llvm-svn: 160227
2012-07-15 01:33:40 +00:00
Ted Kremenek b50e716bac Refine CFG so that '&&' and '||' don't lead to extra confluence points when used in a branch, but
instead push the terminator for the branch down into the basic blocks of the subexpressions of '&&' and '||'
respectively.  This eliminates some artifical control-flow from the CFG and results in a more
compact CFG.

Note that this patch only alters the branches 'while', 'if' and 'for'.  This was complex enough for
one patch.  The remaining branches (e.g., do...while) can be handled in a separate patch, but they
weren't immediately tackled because they were less important.

It is possible that this patch introduces some subtle bugs, particularly w.r.t. to destructor placement.
I've tried to audit these changes, but it is also known that the destructor logic needs some refinement
in the area of '||' and '&&' regardless (i.e., their are known bugs).

llvm-svn: 160218
2012-07-14 05:04:10 +00:00
Dmitri Gribenko e7bb944c85 Attaching comments to declarations during parsing: handle more Objective-C declarations.
llvm-svn: 160156
2012-07-13 01:06:46 +00:00
Dmitri Gribenko e00ffc7bb8 Comment parsing: repaint the bikesched: rename 'HTML open tags' to 'HTML start tags' and 'HTML close tags' to 'HTML end tags' according to HTML spec.
llvm-svn: 160153
2012-07-13 00:44:24 +00:00
Dmitri Gribenko 9460fbf219 Make concepts of optional and forbidden end tags separate. Thanks Jordan for pointing this!
llvm-svn: 160149
2012-07-12 23:37:09 +00:00
Dmitri Gribenko f26054f0fb Enable comment parsing and semantic analysis to emit diagnostics. A few
diagnostics implemented -- see testcases.

I created a new TableGen file for comment diagnostics,
DiagnosticCommentKinds.td, because comment diagnostics don't logically
fit into AST diagnostics file.  But I don't feel strongly about it.

This also implements support for self-closing HTML tags in comment
lexer and parser (for example, <br />).

In order to issue precise diagnostics CommentSema needs to know the
declaration the comment is attached to.  There is no easy way to find a decl by 
comment, so we match comments and decls in lockstep: after parsing one
declgroup we check if we have any new, not yet attached comments.  If we do --
then we do the usual comment-finding process.

It is interesting that this automatically handles trailing comments.
We pick up not only comments that precede the declaration, but also
comments that *follow* the declaration -- thanks to the lookahead in
the lexer: after parsing the declgroup we've consumed the semicolon
and looked ahead through comments.

Added -Wdocumentation-html flag for semantic HTML errors to allow the user to 
disable only HTML warnings (but not HTML parse errors, which we emit as
warnings in -Wdocumentation).

llvm-svn: 160078
2012-07-11 21:38:39 +00:00
Nico Weber b8124d1af1 Rename -Wself-assign-memvar to -Wself-assign-field to improve local consistency a bit.
(cf -Wunused-private-field and several other existing -field diagnostics.)

llvm-svn: 159633
2012-07-03 02:03:06 +00:00
Richard Smith b721e301df -Wuninitialized: assume that an __attribute__((returns_twice)) function might
initialize any variable. This is extremely conservative, but is sufficient for
now.

llvm-svn: 159620
2012-07-02 23:23:04 +00:00
Jordan Rose 58d547200e Add support for the C11 _Alignof keyword.
This behaves like the existing GNU __alignof and C++11 alignof keywords;
most of the patch is simply adding the third token spelling to various places.

llvm-svn: 159494
2012-06-30 21:33:57 +00:00
Nico Weber 33fd523df1 Warn on self-assignment to member variables. PR13104.
llvm-svn: 159394
2012-06-28 23:53:12 +00:00
Nico Weber 606cef46e3 Give L__FUNCTION__ the right type in templates. PR13206.
llvm-svn: 159171
2012-06-25 22:34:48 +00:00
Nico Weber 1598289c72 Add tests that I wrote for r159060 but forgot to `svn add`.
llvm-svn: 159170
2012-06-25 22:30:41 +00:00
Hans Wennborg 9dfcc10f9a Add triple to test/Sema/attr-tls_model.c
Not all targets support __thread variables.

llvm-svn: 159080
2012-06-23 13:16:37 +00:00
Hans Wennborg d3b01bc7c6 Support the tls_model attribute (PR9788)
This adds support for the tls_model attribute. This allows the user to
choose a TLS model that is better than what LLVM would select by
default. For example, a variable might be declared as:

  __thread int x __attribute__((tls_model("initial-exec")));

if it will not be used in a shared library that is dlopen'ed.

This depends on LLVM r159077.

llvm-svn: 159078
2012-06-23 11:51:46 +00:00
Dmitri Gribenko b31fe09b0f Mark Doxygen warnings DefaultIgnore.
llvm-svn: 159026
2012-06-22 20:19:59 +00:00
Dmitri Gribenko 052f60d384 Add a warning about almost-Doxygen trailing comments: //< and /*< ... */
llvm-svn: 159001
2012-06-22 16:02:55 +00:00
Jordan Rose 815fe26ed3 Don't warn for -Wstatic-in-inline if the used function is also inline.
Also, don't warn if the used function is __attribute__((const)), in which case
it's not supposed to use global variables anyway.

The inline-in-inline thing is a heuristic, and one that's possibly incorrect
fairly often because the function being inlined could definitely use global
variables. However, even some C standard library functions are written using
other (trivial) static-inline functions in the headers, and we definitely don't
want to be warning on that (or on anything that /uses/ these trivial inline
functions). So we're using "inlined" as a marker for "fairly trivial".

(Note that __attribute__((pure)) does /not/ guarantee safety like ((const),
because ((const)) does not guarantee that global variables are not being used,
and the warning is about globals not being shared across TUs.)

llvm-svn: 158898
2012-06-21 05:54:50 +00:00
Jordan Rose dc753b625f Reword -Winternal-linkage-in-inline, and rename it to -Wstatic-in-inline.
Now that this is a C-only warning, we can use "static" instead of "internal
linkage", which is a term developers are probably more familiar with.
This makes for a better warning message. The warning name was changed to match,
since "internal linkage" is not mentioned in the warning text anymore.

llvm-svn: 158853
2012-06-20 21:09:10 +00:00
Aaron Ballman 478faed4b0 Reapplying the changes from r158717 as they were rolled back to avoid merge conflicts from a separate problematic patch.
llvm-svn: 158750
2012-06-19 22:09:27 +00:00
Jakob Stoklund Olesen e1c0ae6fda Revert r158700 and dependent patches r158716, r158717, and r158731.
The original r158700 caused crashes in the gcc test suite,
g++.abi/vtable3a.C among others. It also caused failures in the libc++
test suite.

llvm-svn: 158749
2012-06-19 21:48:43 +00:00
Aaron Ballman 38c9ad9e72 Improves parsing and semantic analysis for MS __declspec attributes. This includes support for the align (which fixes PR12631).
llvm-svn: 158717
2012-06-19 13:49:26 +00:00
Jordan Rose 8cea63c5cd Change -Winternal-linkage-in-inline from ExtWarn to Warning in C++.
Per post-commit review, it's not appropriate to use ExtWarn in C++, because
we can't prove that the inline function will actually be defined in more than
one place (and thus we can't prove that this violates the ODR).

This removes the warning entirely from uses in the main source file in C++.

llvm-svn: 158689
2012-06-18 23:58:49 +00:00
Jordan Rose 28cd12f265 Support -Winternal-linkage-in-inline in C++ code.
This includes treating anonymous namespaces like internal linkage, and allowing
const variables to be used even if internal. The whole thing's been broken out
into a separate function to avoid nested ifs.

llvm-svn: 158683
2012-06-18 22:09:19 +00:00