Commit Graph

2421 Commits

Author SHA1 Message Date
Hans Wennborg 9112ac2136 Turn error about fastcall variadic function into warning in MS mode (PR12535)
MSVC allows this and silently falls back to __cdecl for variadic functions.
This patch turns Clang's error into a warning in MS mode and adds a test
to make sure we generate correct code.

Differential Revision: http://llvm-reviews.chandlerc.com/D1861

llvm-svn: 192240
2013-10-08 21:52:56 +00:00
Ted Kremenek db49a5df47 Split test to test -Wshadow with emmintrin.h more portable.
llvm-svn: 192144
2013-10-08 00:03:41 +00:00
Ted Kremenek 854cc293a7 Suppress useless -Wshadow warning when using _mm* macros from emmintrin.h
Fixes <rdar://problem/10679282>.

I'm not completely satisfied with this patch.  Sprinkling "diagnostic ignored"
_Pragmas throughout this file is gross, but I couldn't suppress
it for the entire file.

llvm-svn: 192143
2013-10-07 23:51:11 +00:00
Matthew Curtis 274a9cc84b Gracefully (and correctly) handle init of multiple union members
We now emit warnings when doing so and code generation is consistent
with GCC. Note that the C99 spec is unclear as to the precise
behavior.

See also ...
Bug:
  http://llvm.org/bugs/show_bug.cgi?id=16644 and

cfe-dev discussion:
  http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-September/031918.html

llvm-svn: 191890
2013-10-03 12:14:24 +00:00
Tim Northover a484bc00ff Implement ARM GNU-style interrupt attribute
This attribute allows users to use a modified C or C++ function as an ARM
exception-handling function and, with care, to successfully return control to
user-space after the issue has been dealt with.

rdar://problem/14207019

llvm-svn: 191769
2013-10-01 14:34:25 +00:00
Rafael Espindola 900485ab5f Don't pass -print-stats to the driver, it is a -cc1 option only.
llvm-svn: 191376
2013-09-25 15:21:56 +00:00
Richard Smith 541b38be7b Switch the semantic DeclContext for a block-scope declaration of a function or
variable from being the function to being the enclosing namespace scope (in
C++) or the TU (in C). This allows us to fix a selection of related issues
where we would build incorrect redeclaration chains for such declarations, and
fail to notice type mismatches.

Such declarations are put into a new IdentifierNamespace, IDNS_LocalExtern,
which is only found when searching scopes, and not found when searching
DeclContexts. Such a declaration is only made visible in its DeclContext if
there are no non-LocalExtern declarations.

llvm-svn: 191064
2013-09-20 01:15:31 +00:00
Eli Friedman 626956111d Add specific warning flags for GNU ext in Sema.
This patch adds the following, more specific warning flags:

gnu-anonymous-struct
gnu-compound-literal-initializer
gnu-empty-struct
gnu-flexible-array-initializer
gnu-flexible-array-union-member
gnu-folding-constant
redeclared-class-member
gnu-redeclared-enum
gnu-union-cast
gnu-variable-sized-type-not-at-end

Patch by Peter Lewis.

llvm-svn: 190972
2013-09-18 23:23:17 +00:00
Stepan Dyatkovskiy b88c30facd Recommited:
Fix for PR16752. Second commit.

PR16752: 'mode' attribute for unusual targets doesn't work properly
Description:
Troubles could be happened due to some assumptions in handleModeAttr function (see SemaDeclAttr.cpp).
For example, it assumes that 32 bit integer is 'int', while it could be 16 bit only.
Instead of asking target: 'which type do you want to use for int32_t ?' it just hardcodes general opinion. That doesn't looks pretty correct.
Please consider the next solution:
1. In Basic/TargetInfo add getIntTypeByWidth and getRealTypeByWidth methods. Methods asks target for proper type for given bit width.
2. Fix handleModeAttr according to new methods in TargetInfo.

Fixes:
1st Commit (Done): Add new methods for TargetInfo:
     getRealTypeByWidth and getIntTypeByWidth
  for ASTContext names are almost same(invokes new methods from TargetInfo):
     getIntTypeForBitwidth and getRealTypeForBitwidth

2nd Commit (Current): Fix SemaDeclAttr, handleModeAttr function.

Also test/Sema/attr-mode.c was fixed. 'XC' mode test was disabled for PPC64 machines.

llvm-svn: 190926
2013-09-18 09:08:52 +00:00
Hal Finkel c4d7c82c7f Add the intrinsic __builtin_convertvector
LLVM supports applying conversion instructions to vectors of the same number of
elements (fptrunc, fptosi, etc.) but there had been no way for a Clang user to
cause such instructions to be generated when using builtin vector types.

C-style casting on vectors is already defined in terms of bitcasts, and so
cannot be used for these conversions as well (without leading to a very
confusing set of semantics). As a result, this adds a __builtin_convertvector
intrinsic (patterned after the OpenCL __builtin_astype intrinsic). This is
intended to aid the creation of vector intrinsic headers that create generic IR
instead of target-dependent intrinsics (in other words, this is a generic
_mm_cvtepi32_ps). As noted in the documentation, the action of
__builtin_convertvector is defined in terms of the action of a C-style cast on
each vector element.

llvm-svn: 190915
2013-09-18 03:29:45 +00:00
David Majnemer fab61e95f3 ffreestanding shouldn't effect main() on win32
llvm-svn: 190824
2013-09-16 23:59:35 +00:00
Aaron Ballman 6e2dd7b553 Updated the way the ownership attributes are semantically diagnosed. Added test cases for the semantics checks.
llvm-svn: 190802
2013-09-16 18:11:41 +00:00
Amara Emerson 8c3de546d6 Add error checking to reject neon_vector_type attribute on targets without NEON.
Patch by Artyom Skrobov.

llvm-svn: 190801
2013-09-16 18:07:35 +00:00
Aaron Ballman d6600a5b9b Updated the PCS calling convention to use the new checkStringLiteralArgument helper function.
llvm-svn: 190710
2013-09-13 17:48:25 +00:00
Benjamin Kramer a9dfa9280e As Aaron pointed out it's simpler to reject wide string availability attr messages in the parser.
llvm-svn: 190706
2013-09-13 17:31:48 +00:00
Benjamin Kramer ca9fe1453f Guard availability and thread safety attributes against wide strings.
Found by inspection.

llvm-svn: 190701
2013-09-13 16:30:12 +00:00
Aaron Ballman c12aaff2cb The cleanup attribute no longer uses an unresolved, simple identifier as its argument. Instead, it takes an expression that is fully resolved.
llvm-svn: 190476
2013-09-11 01:37:41 +00:00
Richard Smith 84c6b3d293 PR5683: Issue a warning when subtracting pointers to types of zero size, and
treat such subtractions as being non-constant. Patch by Serge Pavlov! With a
few tweaks by me.

llvm-svn: 190439
2013-09-10 21:34:14 +00:00
Aaron Ballman 8ee40b7264 Attribute tablegen now understands that attribute arguments can be optional. This allows for automated checking of the number of arguments expected vs number of arguments given for attributes. Greatly reduces the amount of manual checking required.
llvm-svn: 190368
2013-09-09 23:33:17 +00:00
Benjamin Kramer 7037021e78 Sema: Don't crash on visibility attributes with an identifier argument.
PR17105.

llvm-svn: 190312
2013-09-09 15:08:57 +00:00
Aaron Ballman 60f62ad3d3 Removing the endian attribute and updating associated test cases. This functionality was never completely implemented, and this is an improvement over silently eating the attribute.
llvm-svn: 190303
2013-09-09 12:57:20 +00:00
Aaron Ballman 00e99966c4 Consolidating the notion of a GNU attribute parameter with the attribute argument list.
llvm-svn: 189711
2013-08-31 01:11:41 +00:00
Charles Davis b5a214e4f3 Add ms_abi and sysv_abi attribute handling.
Based on a patch by Benno Rice!

llvm-svn: 189644
2013-08-30 04:39:01 +00:00
Reid Kleckner 78af0708b7 Delete CC_Default and use the target default CC everywhere
Summary:
Makes functions with implicit calling convention compatible with
function types with a matching explicit calling convention.  This fixes
things like calls to qsort(), which has an explicit __cdecl attribute on
the comparator in Windows headers.

Clang will now infer the calling convention from the declarator.  There
are two cases when the CC must be adjusted during redeclaration:
1. When defining a non-inline static method.
2. When redeclaring a function with an implicit or mismatched
convention.

Fixes PR13457, and allows clang to compile CommandLine.cpp for the
Microsoft C++ ABI.

Excellent test cases provided by Alexander Zinenko!

Reviewers: rsmith

Differential Revision: http://llvm-reviews.chandlerc.com/D1231

llvm-svn: 189412
2013-08-27 23:08:25 +00:00
David Majnemer ee7e86c08f Typo.
llvm-svn: 188996
2013-08-22 10:04:41 +00:00
Dmitri Gribenko 56fde96610 gnu-flags.c test: relax the check a bit
This tests warning flags, so no need to test for specific alignment which is
platform-dependent.

llvm-svn: 188993
2013-08-22 08:13:43 +00:00
David Majnemer a39da8e236 Analysis: Make %I in printf more reasonable, add more tests
llvm-svn: 188992
2013-08-22 07:53:21 +00:00
Eli Friedman 5ba37d5282 Split isFromMainFile into two functions.
Basically, isInMainFile considers line markers, and isWrittenInMainFile
doesn't.  Distinguishing between the two is useful when dealing with
files which are preprocessed files or rewritten with -frewrite-includes
(so we don't, for example, print useless warnings).

llvm-svn: 188968
2013-08-22 00:27:10 +00:00
David Majnemer 3cba495abc Analysis: Add support for MS specific printf format specifiers
Summary: Adds support for %I, %I32 and %I64.

Reviewers: hans, jordan_rose, rnk, majnemer

Reviewed By: majnemer

CC: cfe-commits, cdavis5x

Differential Revision: http://llvm-reviews.chandlerc.com/D1456

llvm-svn: 188937
2013-08-21 21:54:46 +00:00
Richard Sandiford 4633cd7b08 Tweak gnu-flags.c test for z, where globals have 2-byte alignment by default
llvm-svn: 188905
2013-08-21 16:37:37 +00:00
Eli Friedman 85698c8d7b Remove Extension warning for GNU local labels.
We generally don't warn about extensions involving keywords reserved
for the implementation, so we shouldn't warn here either: the
standard doesn't require it, and it doesn't provide useful information
to the user.

llvm-svn: 188840
2013-08-20 22:44:32 +00:00
Eli Friedman 571c3ae7d6 Add more specific flags for misc GNU extensions.
This adds the following as subgroups of -Wgnu: -Wgnu-alignof-expression,
-Wgnu-case-range, -Wgnu-complex-integer, -Wgnu-conditional-omitted-operand,
-Wgnu-empty-initializer, -Wgnu-label-as-value, -Wgnu-local-label,
and -Wgnu-statement-expression,

Patch by Peter Lewis.

llvm-svn: 188839
2013-08-20 22:44:28 +00:00
Eli Friedman 4628cf763b Handle init lists and _Atomic fields.
Fixes PR16931.

llvm-svn: 188718
2013-08-19 22:12:56 +00:00
Richard Smith f9b1510576 Refactor all diagnosing of TypoCorrections through a common function, in
preparation for teaching this function how to diagnose a correction that
includes importing a module.

llvm-svn: 188602
2013-08-17 00:46:16 +00:00
Richard Smith 1c34fb78e7 Fix implementation of C11 6.2.7/4 and C++11 [dcl.array]p3:
When a local extern declaration redeclares some other entity, the type of that
entity is merged with the prior type if the prior declaration is visible (in C)
or is declared in the same scope (in C++).

 - Make LookupRedeclarationWithLinkage actually work in C++, use it in the right
   set of cases, and make it track whether it found a shadowed declaration.
 - Track whether we found a declaration in the same scope (for C++) including
   across serialization and template instantiation.

llvm-svn: 188307
2013-08-13 18:18:50 +00:00
Rafael Espindola 71eccb39b8 Fix alignof computation of large arrays on x86_64.
We were exposing the extra alignment given to large arrays. The new behavior
matches gcc, which is a good thing since this is a gcc extension.

Thanks to Joerg Sonnenberger for noticing it.

While at it, centralize the method description in the .h file.

llvm-svn: 187999
2013-08-08 19:53:46 +00:00
Richard Trieu 493df1a14f Emit an error for enum increments and decrements in C++ mode.
Fixes PR16394.

llvm-svn: 187955
2013-08-08 01:50:23 +00:00
Tim Northover 2fe823a6c3 AArch64: initial NEON support
Patch by Ana Pazos

- Completed implementation of instruction formats:
AdvSIMD three same
AdvSIMD modified immediate
AdvSIMD scalar pairwise

- Completed implementation of instruction classes
(some of the instructions in these classes
belong to yet unfinished instruction formats):
Vector Arithmetic
Vector Immediate
Vector Pairwise Arithmetic

- Initial implementation of instruction formats:
AdvSIMD scalar two-reg misc
AdvSIMD scalar three same

- Intial implementation of instruction class:
Scalar Arithmetic

- Initial clang changes to support arm v8 intrinsics.
Note: no clang changes for scalar intrinsics function name mangling yet.

- Comprehensive test cases for added instructions
To verify auto codegen, encoding, decoding, diagnosis, intrinsics.

llvm-svn: 187568
2013-08-01 09:23:19 +00:00
Aaron Ballman 9744ffd652 err_attribute_missing_parameter_name has been replaced by err_attribute_argument_type.
llvm-svn: 187420
2013-07-30 14:29:12 +00:00
Aaron Ballman 9d695091fd Replacing err_attribute_argument_not_int with err_attribute_not_type_attr
llvm-svn: 187419
2013-07-30 14:10:17 +00:00
Aaron Ballman 3bf758cd65 err_attribute_not_string has been subsumed by err_attribute_argument_type.
llvm-svn: 187400
2013-07-30 01:31:03 +00:00
Aaron Ballman be50eb86e6 Refactor some attributes to use checkFunctionOrMethodArgumentIndex instead of using custom logic. No functional changes intended.
llvm-svn: 187398
2013-07-30 00:48:57 +00:00
David Blaikie 4bc4751755 Remove assert header dependency in test
llvm-svn: 187387
2013-07-29 22:37:42 +00:00
David Blaikie 021221db7c Support for Thread Safety Analysis in C
Patch by Ethan Jackson.

llvm-svn: 187365
2013-07-29 18:24:03 +00:00
Eli Friedman efe9fa62f5 Tighten type-checking for vector attributes.
Based on patch by Yunzhong Gao.

llvm-svn: 187176
2013-07-26 00:53:47 +00:00
Aaron Ballman ba50af8f73 Removing a number of individual run lines and replacing them with single line test cases. This reduces the number of test runs, provides the same coverage, and allows us to test that the attribute names are included in the diagnostic.
llvm-svn: 186982
2013-07-23 19:37:19 +00:00
Aaron Ballman b7243381c2 Added the attribute name to the err_attribute_wrong_number_arguments diagnostic for clarity; updated almost all of the affected test cases.
Thanks to Fariborz Jahanian for the suggestion!

llvm-svn: 186980
2013-07-23 19:30:11 +00:00
Aaron Ballman bcee83e99d Removed a redundant diagnostic and replaced it with a more standard one. Added a test case for the diagnostic.
llvm-svn: 186942
2013-07-23 14:54:24 +00:00
Aaron Ballman 7ced167a09 Correcting the NSObject and Overloadable attribute diagnostics so that the count reported matches reality.
llvm-svn: 186936
2013-07-23 12:13:14 +00:00
Eli Friedman 088d39afc6 Integers which are too large should be an error.
Switch some warnings over to errors which should never have been warnings
in the first place.  (Also, a minor fix to the preprocessor rules for
integer literals while I'm here.)

llvm-svn: 186903
2013-07-23 00:25:18 +00:00
Enea Zaffanella c7cb48c4b9 Fixed implementation of C89 6.5.7 p3.
Warning should be emitted only for InitListExpr nodes.

llvm-svn: 186859
2013-07-22 19:10:20 +00:00
Aaron Ballman bf5cf8c6ea This test was missing its -verify argument.
llvm-svn: 186847
2013-07-22 17:55:04 +00:00
Enea Zaffanella 1aac546d31 Implement the part of C89 6.5.7 p3 requiring a constant initializer list
when initializing aggregate/union types, no matter if static or not.

llvm-svn: 186817
2013-07-22 10:58:26 +00:00
Aaron Ballman d7b6459f80 Test contents were somehow duplicated, resulting in any testcase that fails automatically failing twice. Removing the duplicates.
llvm-svn: 186590
2013-07-18 17:41:26 +00:00
Aaron Ballman 8b8ebdd9dd Removed a parameter from handleAttrWithMessage to make it more consistent with other attribute handlers, as well as other attribute error messages. Added missing test cases for the unavailable attribute, and updated the deprecated test case.
llvm-svn: 186578
2013-07-18 13:13:52 +00:00
Eli Friedman 4c27ac2348 Make Expr::isConstantInitializer match IRGen.
Sema needs to be able to accurately determine what will be
emitted as a constant initializer and what will not, so
we get accurate errors in C and accurate -Wglobal-constructors
warnings in C++.  This makes Expr::isConstantInitializer match
CGExprConstant as closely as possible.

llvm-svn: 186464
2013-07-16 22:40:53 +00:00
Tim Northover 6aacd49094 ARM: implement low-level intrinsics for the atomic exclusive operations.
This adds three overloaded intrinsics to Clang:
    T __builtin_arm_ldrex(const volatile T *addr)
    int __builtin_arm_strex(T val, volatile T *addr)
    void __builtin_arm_clrex()

The intent is that these do what users would expect when given most sensible
types. Currently, "sensible" translates to ints, floats and pointers.

llvm-svn: 186394
2013-07-16 09:47:53 +00:00
Serge Pavlov dfdb731967 Limit number of bits in size representation so that bit size fit 64 bits.
This fixes PR8256 and some others.

llvm-svn: 186385
2013-07-16 07:14:18 +00:00
Eli Friedman e7b8aa9417 Merge attributes on typedef decls.
Not completely sure this is right, but it's clearly better than what
we did before this commit (effectively dropping the attribute).

<rdar://problem/14413117>

llvm-svn: 186373
2013-07-16 02:07:49 +00:00
Eli Friedman e6d3395d78 Fix Sema for compares with _Atomic vars.
Use UsualArithmeticConversions unconditionally in analysis of
comparisons and conditional operators: the method performs
the usual arithmetic conversions if both sides are arithmetic, and
usual unary conversions if they are not.  This is just a cleanup
for conditional operators; for comparisons, it fixes the issue that
we would try to check isArithmetic() on an atomic type.

Also, fix GetExprRange() in SemaChecking.cpp so it deals with variables
of atomic type correctly.

Fixes PR15537.

llvm-svn: 185857
2013-07-08 20:20:06 +00:00
David Majnemer ea5092a3b0 Sema: Do not merge new decls with invalid, old decls
Sema::MergeFunctionDecl attempts merging two decls even if the old decl
is invalid.  This can lead to interesting circumstances where we
successfully merge the decls but the result makes no sense.

Take the following for example:

template <typename T>
int main(void);

int main(void);

Sema will not consider these to be overloads of the same name because
main can't be overloaded, which means that this must be a redeclaration.

In this case the templated decl is compatible with the non-templated
decl allowing the Sema::CheckFunctionDeclaration machinery to move on
and do bizarre things like setting the previous decl of a non-templated
decl to a templated decl!

The way I see it, we should just bail from MergeFunctionDecl if the old
decl is invalid.

This fixes PR16531.

llvm-svn: 185779
2013-07-07 23:49:50 +00:00
Roman Divacky 4575c64f9d Add test for r185584.
llvm-svn: 185668
2013-07-04 21:29:24 +00:00
Rafael Espindola 925213b0fa Add 'not' to commands that are expected to fail.
This is at least good documentation, but also opens the possibility of
using pipefail.

llvm-svn: 185652
2013-07-04 16:16:58 +00:00
Richard Smith 6d6676b9d1 Add test for PR4997. This has been fixed for a while.
llvm-svn: 185614
2013-07-04 04:10:46 +00:00
Roman Divacky b6debb6ab8 Add support for TF/TC modes available on eg. PowerPC64.
llvm-svn: 185578
2013-07-03 20:48:06 +00:00
Richard Smith e3dbfe04b7 Teach -Wunsequenced that the side-effects of a function evaluation are sequenced
before the value computation of the result. In C, this is implied by there being
a sequence point after their evaluation, and in C++, it's implied by the
side-effects being sequenced before the expressions and statements in the
function body.

llvm-svn: 185282
2013-06-30 10:40:20 +00:00
Richard Smith ac974a3c76 Reinstate r185229, reverted in r185256, with a tweak: further ignore the
standard's rule that an extern "C" declaration conflicts with any entity in the
global scope with the same name. Now we only care if the global scope entity is
a variable declaration (and so might have the same mangled name as the extern
"C" declaration). This has been reported as a standard defect.

Original commit message:

PR7927, PR16247: Reimplement handling of matching extern "C" declarations
across scopes.

When we declare an extern "C" name that is not a redeclaration of an entity in
the same scope, check whether it redeclares some extern "C" entity from another
scope, and if not, check whether it conflicts with a (non-extern-"C") entity in
the translation unit.

When we declare a name in the translation unit that is not a redeclaration,
check whether it conflicts with any extern "C" entities (possibly from other
scopes).

llvm-svn: 185281
2013-06-30 09:48:50 +00:00
Timur Iskhodzhanov 32d1e73023 Revert r185229 as it breaks compilation of <windows.h>
llvm-svn: 185256
2013-06-29 08:38:42 +00:00
Richard Smith 902befa277 PR7927, PR16247: Reimplement handling of matching extern "C" declarations
across scopes.

When we declare an extern "C" name that is not a redeclaration of an entity in
the same scope, check whether it redeclares some extern "C" entity from another
scope, and if not, check whether it conflicts with a (non-extern-"C") entity in
the translation unit.

When we declare a name in the translation unit that is not a redeclaration,
check whether it conflicts with any extern "C" entities (possibly from other
scopes).

llvm-svn: 185229
2013-06-28 22:03:51 +00:00
Richard Smith 83e37bee44 PR16467: Teach -Wunsequenced that in C11 (unlike C++11), an assignment's
side-effect is not sequenced before its value computation. Also fix a
mishandling of ?: expressions where the condition is constant that was
exposed by the tests for this.

llvm-svn: 185035
2013-06-26 23:16:51 +00:00
Richard Smith 71bdbb0101 Make this test properly test both things it's trying to test.
llvm-svn: 184887
2013-06-25 22:37:05 +00:00
Richard Smith ef87be3a62 Fix null pointer dereference if we redeclare an unprototyped function. Patch by
WenHan Gu!

llvm-svn: 184875
2013-06-25 20:34:17 +00:00
Reid Kleckner 8a36502a60 [AST] Introduce a new DecayedType sugar node
The goal of this sugar node is to be able to look at an arbitrary
FunctionType and tell if any of the parameters were decayed from an
array or function type.  Ultimately this is necessary to implement
Microsoft's C++ name mangling scheme, which mangles decayed arrays
differently from normal pointers.

Reviewers: rsmith

Differential Revision: http://llvm-reviews.chandlerc.com/D1014

llvm-svn: 184763
2013-06-24 17:51:48 +00:00
Dmitri Gribenko 02489eb406 Comment parsing: allow "\param ..." to describe variadic arguments
Original patch by Fariborz Jahanian; extended by me.

Fixes rdar://14124644

llvm-svn: 184688
2013-06-24 04:41:32 +00:00
Dmitri Gribenko 761f801cb2 Documentation parsing: recognize \relates, \related, \relatesonly, \relatedonly
so that -Wdocumentation-unknown-command does not warn on these commands.
Fixes PR16092.

llvm-svn: 184676
2013-06-23 23:33:14 +00:00
Dmitri Gribenko d666293435 Comment parsing: followup to r184610: allow multiple \returns
Remove unneeded member in CommentSema, add a test for the XML schema (the
schema already allowed multiple paragraphs in <ResultDiscussion>, but there
were no tests for that), fix HTML generation (it is not allowed to have <p>
inside <dl>).

llvm-svn: 184652
2013-06-22 23:03:37 +00:00
Fariborz Jahanian fb6f6f61ca [document parsing]: Allow multiple adjacent \return and the like
commands. Render them properly in XML output.
// rdar://14207725

llvm-svn: 184610
2013-06-21 23:49:29 +00:00
Nico Weber 95296d4a16 Fix a crash with __flaot128 noticed by Eli.
llvm-svn: 184498
2013-06-20 23:30:30 +00:00
Nico Weber e1687c5e25 Lazily provide a __float128 dummy type in -std=gnu++11 mode.
This is needed to parse libstdc++ 4.7's type_traits, see PR13530.

llvm-svn: 184476
2013-06-20 21:44:55 +00:00
Fariborz Jahanian c0607ed68b documentation parsing: patch to make @class work for
class templates; and similarly, @function  works for 
function templates. // rdar://14124702

llvm-svn: 184329
2013-06-19 18:08:03 +00:00
NAKAMURA Takumi dc2e2fb9ce Revert r184249, "doc. parsing: Allow parameter name "..." for variadic functions/methods."
It crashes in the case;

/// Without any "param"s in the description.
int printf(const char *format, ...);

llvm-svn: 184283
2013-06-19 06:58:14 +00:00
Fariborz Jahanian 5222608310 doc. parsing: Allow parameter name "..." for variadic functions/methods.
// rdar://14124644

llvm-svn: 184249
2013-06-18 22:40:39 +00:00
Eli Friedman 0e5d677fc3 Correctly compute the index of the first string format argument when deciding
whether to emit a -Wformat-security warning.  <rdar://problem/14178260>.

llvm-svn: 184214
2013-06-18 18:10:01 +00:00
Bob Wilson 87b3a189ef size_t on Darwin AAPCS targets is "unsigned long". <rdar://problem/14136459>
Some embedded targets use ARM's AAPCS with iOS header files that define size_t
as unsigned long, which conflicts with the usual AAPCS definition of size_t
as unsigned int.

llvm-svn: 184171
2013-06-18 05:36:04 +00:00
Serge Pavlov f7c1a2152a Clean up empty struct/union recognition.
Make use of getTypeSizeInChars to detect structs/unions of zero size. It allows
more accurate detection of types of zero size. It however has a side effect -
sequence of used types may change, that is why the test 'override-layout' was
modified.

llvm-svn: 184088
2013-06-17 17:18:51 +00:00
Rafael Espindola 3b3a166ce6 Allow clang to build __clear_cache on ARM.
__clear_cache is special. It needs no signature, but is a real function in
compiler_rt or libgcc.

Patch by Andrew Turner.

llvm-svn: 183926
2013-06-13 18:34:17 +00:00
Richard Smith ab341c62b3 More for PR12457: fix handling of __builtin_isinf_sign and test.
llvm-svn: 183890
2013-06-13 06:31:13 +00:00
Richard Smith 8889a3d3b5 Towards PR12457: constant expression evaluation support for __builtin_parity{,l,ll}, __builtin_ffs{,l,ll}, and __builtin_fpclassify.
llvm-svn: 183889
2013-06-13 06:26:32 +00:00
Richard Smith 80b3c8e32f Fix part of PR12457. Patch by Justin Bogner!
llvm-svn: 183886
2013-06-13 05:04:16 +00:00
Richard Smith 8ca78a16f4 Add -Wdeprecated warnings and fixits for things deprecated in C++11:
- 'register' storage class
 - dynamic exception specifications

Only the former check is enabled by default for now (the latter might be quite noisy).

llvm-svn: 183881
2013-06-13 02:02:51 +00:00
Eli Friedman 6cc05f7f01 Tweak r183791 so we don't print a note without a source location.
llvm-svn: 183803
2013-06-11 22:26:34 +00:00
Reid Kleckner 88709c6952 Add a test case for blocks taking an array typedef
r183614 was failing because va_list on some platforms is defined in a
similar manner.  This test fails on Windows with r183614 applied.

llvm-svn: 183617
2013-06-08 18:51:21 +00:00
Reid Kleckner 17aeeeb311 Revert "[Sema] Make FunctionType's TSI use unadjusted argument types"
This reverts commit r183614.

It broke test/Sema/block-printf-attribute-1.c on non-Windows platforms,
and the fix is not trivial.

llvm-svn: 183616
2013-06-08 18:19:52 +00:00
Reid Kleckner 4c124ffd5b [Sema] Make FunctionType's TSI use unadjusted argument types
This helps preserve the type-as-written in the AST, which we need for
MSVC mangling.  In particular, we need to preserve the types of array
parameters in function pointer types.

The essence of this change is:
-  QualType ArgTy = Param->getType();
+  QualType ArgTy = Param->getTypeSourceInfo()->getType();

... followed by the adjustment in ActOnFunctionDeclarator().

Differential Revision: http://llvm-reviews.chandlerc.com/D883

llvm-svn: 183614
2013-06-08 17:28:56 +00:00
Serge Pavlov 89578fd439 Recognition of empty structures and unions is moved to semantic stage
Differential Revision: http://llvm-reviews.chandlerc.com/D586

llvm-svn: 183609
2013-06-08 13:29:58 +00:00
David Majnemer 6a42665f9f Revert "Properly consider the range of enum for range comparisons in C mode"
The approach r183084 took was wrong, back it out.

llvm-svn: 183575
2013-06-07 22:07:20 +00:00
Joey Gouly 1ba2733e2c Fix a crash with -Wassign-enum, where we didn't adjust the APInt type of the
constant. Also fix some spelling mistakes and formatting issues.

Reviewed by Richard Smith over IRC.

Fixes PR15069.

llvm-svn: 183409
2013-06-06 13:48:00 +00:00
Hans Wennborg 15439bcf79 Disallow reinterpret_cast from pointer to bool on Windows
This became allowed by accident in r131201, but triggers an assert.
That patch added an exception to allow conversion from pointers to
narrow integral types for MSVC compatibility. However, a pointer can
already be converted to bool in a civilized manner; allowing conversion
via reinterpret_cast is a bad idea.

Fixes PR16222.

llvm-svn: 183394
2013-06-06 09:16:36 +00:00
David Majnemer 3fbb763a92 Properly consider the range of enum for range comparisons in C mode
In some cases, clang applies the C++ rules for computing the range of a
value when said value is an enum.

Instead, apply C semantics when in C mode.

llvm-svn: 183084
2013-06-02 08:11:22 +00:00
Benjamin Kramer 4d5bae1679 Testcase for r183015.
I hate svn add.

llvm-svn: 183019
2013-05-31 17:01:30 +00:00
Argyrios Kyrtzidis 0f6d5ca0bf Fix potential infinite loop when iterating over redeclarations of an ObjMethodDecl, resulting from invalid code.
Check for invalid decls in ObjCMethodDecl::getNextRedeclaration(); otherwise if we start from an invalid redeclaration
of an @implementation we would move to the @interface and not reach the original declaration again.

Fixes rdar://14024851

llvm-svn: 182951
2013-05-30 18:53:21 +00:00
Ted Kremenek e3dc7f74be Split off casts to void* for -Wint-to-pointer-cast to subgroup -Wint-to-void-pointer-cast.
This change is motivated from user feedback that some APIs use
void* as an opaque "context" object that may not really be a pointer.
Such users want an ability to turn off the warning for casts
to void* while preserving the warning for other cases.

Implements <rdar://problem/14016721>.

llvm-svn: 182884
2013-05-29 21:50:46 +00:00
Fariborz Jahanian 615de765ab Patch to issue error when target of MacOS and iOS
does not support large load/store of atomic objects.
// rdar://13973577

llvm-svn: 182781
2013-05-28 17:37:39 +00:00
Nico Weber 9eea764a1f Warn on va_start() when called with a reference parameter.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdf 18.7p3
explicitly calls this (and some other things) out as undefined.

Also move 2 other existing warnings behind the new -Wvarargs flag.

llvm-svn: 182694
2013-05-24 23:31:57 +00:00
Aaron Ballman 317a77f1c7 Adding in parsing and the start of semantic support for __sptr and __uptr pointer type qualifiers. This patch also fixes the correlated __ptr32 and __ptr64 pointer qualifiers so that they are truly type attributes instead of declaration attributes.
For more information about __sptr and __uptr, see MSDN: http://msdn.microsoft.com/en-us/library/aa983399.aspx

Patch reviewed by Richard Smith.

llvm-svn: 182535
2013-05-22 23:25:32 +00:00
Fariborz Jahanian 04eb8abba9 doc. parsing. HeaderDoc documentaton allows use of
@class command on an @interface declaration. Turn off
the warning for this case. // rdar://13927330

llvm-svn: 182334
2013-05-20 23:40:39 +00:00
Reid Kleckner 52d598e242 Warn on and drop dllimport attrs from variable definitions
AsmPrinter::EmitLinkage() does not handle dllimport linkage.  The LLVM
verifier should also be fixed to reject this.

llvm-svn: 182320
2013-05-20 21:53:29 +00:00
Richard Trieu 388a33f3a3 Return QualType() when a too large array is attempting to be created. This
prevents further errors and some overflows in size calculations.
One overflow was previously triggering an assert.

llvm-svn: 181970
2013-05-16 01:46:09 +00:00
Hans Wennborg 8f62c5ca22 Better diagnostics for string initialization.
This commit improves Clang's diagnostics for string initialization.
Where it would previously say:

  /tmp/a.c:3:9: error: array initializer must be an initializer list
  wchar_t s[] = "Hi";
          ^
  /tmp/a.c:4:6: error: array initializer must be an initializer list or string literal
  char t[] = L"Hi";
       ^

It will now say

  /tmp/a.c:3:9: error: initializing wide char array with non-wide string literal
  wchar_t s[] = "Hi";
          ^
  /tmp/a.c:4:6: error: initializing char array with wide string literal
  char t[] = L"Hi";
       ^

As a bonus, it also fixes the fact that Clang would previously reject
this valid C11 code:

  char16_t s[] = u"hi";
  char32_t t[] = U"hi";

because it would only recognize the built-in types for char16_t and
char32_t, which do not exist in C.

llvm-svn: 181880
2013-05-15 11:03:04 +00:00
Richard Trieu 1c6f15d755 Move a test that requires 64-bit mode to a separate test with a triple in
the run line.

llvm-svn: 181854
2013-05-15 00:44:06 +00:00
Richard Trieu 04d2d94762 When computing the size of large arrays, use char units instead of bits.
This prevents an overflow and assertion when the number of bits cannot be
stored in 64-bits.

llvm-svn: 181839
2013-05-14 21:59:17 +00:00
Rafael Espindola 0633865e5b Really fix the declaration of __clear_cache.
When I tested gcc's behaviour before, I forgot the extern "C", so it
would warn when the types *did* match.

So in the end
* __clear_cache takes two void pointers.
* aarch64 was correct before.
* libgcc's manual is wrong.
* this patch fixes arm.

llvm-svn: 181810
2013-05-14 18:06:10 +00:00
Rafael Espindola 2219fc5821 Fix __clear_cache on ARM.
Current gcc's produce an error if __clear_cache is anything but

__clear_cache(char *a, char *b);

It looks like we had just implemented a gcc bug that is now fixed.

llvm-svn: 181784
2013-05-14 12:45:47 +00:00
Tim Northover c28380a094 AArch64: add test for updated __clear_cache definition
llvm-svn: 181765
2013-05-14 08:37:13 +00:00
Fariborz Jahanian 096f7c1e05 Objective-C error recovery. This patch makes a quick
recovery form duplicate method definition error thus
preventing doc parsing to loop trying to find comment
for the invalid redefinition in a previous declaration.
// rdar://13836387

llvm-svn: 181710
2013-05-13 17:27:00 +00:00
Hans Wennborg 0d81e01916 Add support for __wchar_t in -fms-extensions mode.
MSVC provides __wchar_t. This is the same as the built-in wchar_t type
from C++, but it is also available with -fno-wchar and in C.

The commit changes ASTContext to have two different types for this:

  - WCharTy is the built-in type used for wchar_t in C++ and __wchar_t.

  - WideCharTy is the type of a wide character literal. In C++ this is
    the same as WCharTy, and in C  it is an integer type compatible with
    the type in <stddef.h>.

This fixes PR15815.

llvm-svn: 181587
2013-05-10 10:08:40 +00:00
Ben Langmuir 3b4c30b7e7 CodeGen for CapturedStmts
EmitCapturedStmt creates a captured struct containing all of the captured
variables, and then emits a call to the outlined function.  This is similar in
principle to EmitBlockLiteral.

GenerateCapturedFunction actually produces the outlined function.  It is based
on GenerateBlockFunction, but is much simpler.  The function type is determined
by the parameters that are in the CapturedDecl.

Some changes have been added to this patch that were reviewed as part of the
serialization patch and moving the parameters to the captured decl.

Differential Revision: http://llvm-reviews.chandlerc.com/D640

llvm-svn: 181536
2013-05-09 19:17:11 +00:00
Fariborz Jahanian 0321b8ffd6 [doc parsing]: make single character command impostures
warn in pedantic mode.

llvm-svn: 181523
2013-05-09 17:18:52 +00:00
Fariborz Jahanian e46dd48e9f [doc parsing]: don't attempt to fix single character
commands (\t \n are common). \\ rdar://12381408 

llvm-svn: 181517
2013-05-09 16:22:31 +00:00
Fariborz Jahanian aa9b280c79 [doc parsing]: Also do typo correction for
dynamically registered commands. 
// rdar://12381408

llvm-svn: 181477
2013-05-08 22:14:28 +00:00
Fariborz Jahanian 6c7a16666d documentation parsing. Patch to do typo correction for
documentation commands. Patch was reviewed, along with
great suggestions for improvement, by Doug. 
// rdar://12381408

llvm-svn: 181458
2013-05-08 19:21:00 +00:00
John McCall d25db7ed0f Grab-bag of bit-field fixes:
- References to ObjC bit-field ivars are bit-field lvalues;
    fixes rdar://13794269, which got me started down this.
  - Introduce Expr::refersToBitField, switch a couple users to
    it where semantically important, and comment the difference
    between this and the existing API.
  - Discourage Expr::getBitField by making it a bit longer and
    less general-sounding.
  - Lock down on const_casts of bit-field gl-values until we
    hear back from the committee as to whether they're allowed.

llvm-svn: 181252
2013-05-06 21:39:12 +00:00
Richard Smith d74b1606a6 Fix assert if __extension__ or _Generic is used when initializing a char array from a string literal.
llvm-svn: 181174
2013-05-06 00:35:47 +00:00
Tim Northover 8ec8c4bf89 AArch64: teach Clang about __clear_cache intrinsic
libgcc provides a __clear_cache intrinsic on AArch64, much like it
does on 32-bit ARM.

llvm-svn: 181111
2013-05-04 07:15:13 +00:00
Fariborz Jahanian 5b637078e1 [Doc parsing] Provide diagnostics for unknown documentation
commands. // rdar://12381408

llvm-svn: 181071
2013-05-03 23:15:20 +00:00
Richard Smith 3b87038631 Fix PR15845: apparently MSVC does not support implicit int in C++ mode.
llvm-svn: 180822
2013-04-30 22:43:51 +00:00
Fariborz Jahanian 4289a5a429 c language: diagnose use of "[*]" on any array dimension
in the parameter of a function definition. Currently,
it crashes in irgen if it is on other than the 1st dimension.
// rdar://13705391

llvm-svn: 180732
2013-04-29 22:01:25 +00:00
Benjamin Kramer 7ee3b9c0e4 Reject asm output constraints that consist of modifiers only.
Fixes PR15759.

llvm-svn: 179756
2013-04-18 13:23:23 +00:00
Richard Trieu e089497121 Switch the note order for -Woverloaded-shift-op-parentheses so that the note
with the silence fix-it comes first.  This is more consistent with the rest
of the warnings in -Wparentheses.

llvm-svn: 179742
2013-04-18 01:04:37 +00:00
Richard Trieu cf2a4c0653 Update the -Wparentheses tests to check that fix-its are in the correct place.
llvm-svn: 179740
2013-04-18 00:56:23 +00:00
Fariborz Jahanian 799a4036da [document parsing]: When tag declaration (but not definition!)
is part of the decl-specifier-seq of some other declaration, 
it doesn't get comment. // rdar://12390371

llvm-svn: 179722
2013-04-17 21:05:20 +00:00
Andy Gibbs fcc699aee8 Extended VerifyDiagnosticConsumer to also verify source file for diagnostic.
VerifyDiagnosticConsumer previously would not check that the diagnostic and
its matching directive referenced the same source file.  Common practice was
to create directives that referenced other files but only by line number,
and this led to problems such as when the file containing the directive
didn't have enough lines to match the location of the diagnostic in the
other file, leading to bizarre file formatting and other oddities.

This patch causes VerifyDiagnosticConsumer to match source files as well as
line numbers.  Therefore, a new syntax is made available for directives, for
example:

// expected-error@file:line {{diagnostic message}}

This extends the @line feature where "file" is the file where the diagnostic
is generated.  The @line syntax is still available and uses the current file
for the diagnostic.  "file" can be specified either as a relative or absolute
path - although the latter has less usefulness, I think!  The #include search
paths will be used to locate the file and if it is not found an error will be
generated.

The new check is not optional: if the directive is in a different file to the
diagnostic, the file must be specified.  Therefore, a number of test-cases
have been updated with regard to this.

This closes out PR15613.

llvm-svn: 179677
2013-04-17 08:06:46 +00:00
Richard Trieu fe042e6aab Add warning group -Woverloaded-shift-op-parentheses to -Wparentheses. This
will fire on code such as:

  cout << x == 0;

which the compiler will intrepret as

  (cout << x) == 0;

This warning comes with two fixits attached to notes, one for parentheses to
silence the warning, and another to evaluate the comparison first.

llvm-svn: 179662
2013-04-17 02:12:45 +00:00
Tareq A. Siraj 6dfa25a19f Sema for Captured Statements
Add CapturedDecl to be the DeclContext for CapturedStmt, and perform semantic
analysis. Currently captures all variables by reference.

TODO: templates

Author: Ben Langmuir <ben.langmuir@intel.com>

Differential Revision: http://llvm-reviews.chandlerc.com/D433

llvm-svn: 179618
2013-04-16 19:37:38 +00:00
Jyotsna Verma e90fe76abd Remove setjmp.h header file from Sema/return.c test and include necessary
declarations explicitly in the test.

llvm-svn: 179604
2013-04-16 16:10:38 +00:00
Douglas Gregor 012efe22bc Fix PR4296: Add parser detection/error recovery for nested functions, from Serve Pavlov!
llvm-svn: 179603
2013-04-16 16:01:32 +00:00
Douglas Gregor 8997dac30a Fix handling of atomic shift operations, from Serge Pavlov.
llvm-svn: 179600
2013-04-16 15:41:08 +00:00
Richard Smith 5990db62f6 Local thread_local variables are implicitly 'static'. (This doesn't apply to _Thread_local nor __thread.)
llvm-svn: 179517
2013-04-15 08:33:22 +00:00
Richard Smith 774672e943 Properly check for a constant initializer for a thread-local variable.
llvm-svn: 179516
2013-04-15 08:07:34 +00:00
Richard Smith 6ea1a4d1dc Diagnose if a __thread or _Thread_local variable has a non-constant initializer
or non-trivial destructor.

llvm-svn: 179491
2013-04-14 20:11:31 +00:00
John McCall ad327cd214 Handle incompatible redeclarations of library builtins better.
Invalid redeclarations of valid explicit declarations shouldn't
take the same path as redeclarations of implicit declarations,
and invalid local extern declarations shouldn't foul things up
for everybody else.

llvm-svn: 179482
2013-04-14 08:50:55 +00:00
Richard Smith fd3834f7a1 Annotate flavor of TLS variable (statically or dynamically initialized) onto the AST.
llvm-svn: 179447
2013-04-13 02:43:54 +00:00
John McCall a4da323ee0 Don't replace an existing decl in the scope chains with its
local-extern redeclaration;  type refinements, default arguments,
etc. must all be locally scoped.

rdar://13535367

llvm-svn: 179430
2013-04-13 00:20:21 +00:00
Richard Smith b4a9e86877 Parsing support for thread_local and _Thread_local. We give them the same
semantics as __thread for now.

llvm-svn: 179424
2013-04-12 22:46:28 +00:00
Bob Wilson 2b59395d0e Define Neon intrinsics as "static inline" to avoid warning. rdar://13108414
We had been defining Neon intrinsics as "static" with always_inline attributes.
If you use them from an extern inline function, you get a warning, e.g.:

static function 'vadd_u8' is used in an inline function with external linkage

This change simply adds the inline keyword to avoid that warning.

llvm-svn: 179406
2013-04-12 20:17:20 +00:00
Jyotsna Verma 2147a3d039 Exclude test30 of Sema/return.c for Hexagon since setjmp.h include file
is unavailable for Hexagon.

llvm-svn: 179310
2013-04-11 18:56:34 +00:00
Richard Trieu c47f2d3ea3 Remove outdated run lines from tests.
These run lines originally tested that the fix-its were properly applied.
Originally, the fixits were attached to warnings and were applied by -fixit.
Now, the fixits are attached to notes, so nothing happens.  These run lines
still manage to pass since Clang will produce an empty output which gets piped
back to Clang.  Then Clang produces no error on an empty input.

llvm-svn: 179131
2013-04-09 22:06:27 +00:00
Benjamin Kramer 5c488ef85c Sema: Don't crash when trying to emit a warning for a duplicate value in an invalid enum.
Fixes PR15693. A null check on a pointer returned from cast<> is a very dubious
construct, do we have a checker for this somewhere?

llvm-svn: 178975
2013-04-07 14:10:40 +00:00
Richard Smith 86c0d06194 Fix 41 of the 61 tests which fail with modules enabled: we were computing and
caching the linkage for a declaration before we set up its redeclaration chain,
when determining whether a declaration could be a redeclaration of something
from an unimported submodule. We actually want to look at the declaration as if
it were not a redeclaration here, so compute the linkage but don't cache it.

llvm-svn: 178733
2013-04-04 01:51:11 +00:00
Andy Gibbs c804e08a67 Enable use of _Static_assert inside structs and unions in C11 mode (as per C11 6.7.2.1p1).
llvm-svn: 178632
2013-04-03 09:46:04 +00:00