Commit Graph

11670 Commits

Author SHA1 Message Date
Reid Kleckner 899baf3625 Move the no-prototype calling conv check after decl merging
Now we don't warn on this code:
  void __stdcall f(void);
  void __stdcall f();

My previous commit regressed this functionality because I didn't update
the relevant test case which used a definition.

llvm-svn: 221188
2014-11-03 21:56:03 +00:00
Reid Kleckner 1eaa844f3e Don't diagnose no-prototype callee-cleanup function definitions
We already have a warning on the call sites of code like this:
  void f() { }
  void g() { f(1, 2, 3); }
t.c:2:21: warning: too many arguments in call to 'f'

We can limit ourselves to diagnosing unprototyped forward declarations
of f to cut down on noise.

llvm-svn: 221184
2014-11-03 21:24:50 +00:00
Fariborz Jahanian e3db7784b6 Further restrict issuance of 'override' warning if method
is argument to a macro which is defined in system header.

llvm-svn: 221172
2014-11-03 19:46:18 +00:00
Fariborz Jahanian d6efd3e0d0 This patch reverts r220496 which issues warning on comparing
parameters with nonnull attribute when comparison is always
true/false. Patch causes false positive when parameter is
modified in the function.

llvm-svn: 221163
2014-11-03 17:03:07 +00:00
Hans Wennborg 8313c76836 Don't allow dllimport/export on classes with internal linkage (PR21399)
Trying to import or export such classes doesn't make sense, and Clang
would assert trying to export vtables for them.

This is consistent with how we treat functions with internal linkage,
but it is stricter than MSVC so we may have to back down if it breaks
real code.

llvm-svn: 221160
2014-11-03 16:09:16 +00:00
Hans Wennborg 606bd6dcc5 Don't dllimport inline functions when targeting MinGW (PR21366)
It turns out that MinGW never dllimports of exports inline functions.
This means that code compiled with Clang would fail to link with
MinGW-compiled libraries since we might try to import functions that
are not imported.

To fix this, make Clang never dllimport inline functions when targeting
MinGW.

llvm-svn: 221154
2014-11-03 14:24:45 +00:00
Richard Trieu 46847425c5 Fix a bug where -Wuninitialized would skip arguments to a function call.
llvm-svn: 221030
2014-11-01 00:46:54 +00:00
Richard Trieu d4a0136002 Have -Wuninitialized catch uninitalized use in overloaded operator arguments.
llvm-svn: 221000
2014-10-31 21:10:22 +00:00
Fariborz Jahanian 6e21338abb C++-11 [qoi]. Do not warn on missing 'verride' on use of
macros in user code when macros themselves are defined
in a system header. rdar://18295240

llvm-svn: 220992
2014-10-31 19:56:27 +00:00
Bill Schmidt 691e01d94e [PowerPC] Initial VSX intrinsic support, with min/max for vector double
Now that we have initial support for VSX, we can begin adding
intrinsics for programmer access to VSX instructions.  This patch
performs the necessary enablement in the front end, and tests it by
implementing intrinsics for minimum and maximum using the vector
double data type.

The main change in the front end is to no longer disallow "vector" and
"double" in the same declaration (lib/Sema/DeclSpec.cpp), but "vector"
and "long double" must still be disallowed.  The new intrinsics are
accessed via vec_max and vec_min with changes in
lib/Headers/altivec.h.  Note that for v4f32, we already access
corresponding VMX builtins, but with VSX enabled we should use the
forms that allow all 64 vector registers.

The new built-ins are defined in include/clang/Basic/BuiltinsPPC.def.

I've added a new test in test/CodeGen/builtins-ppc-vsx.c that is
similar to, but much smaller than, builtins-ppc-altivec.c.  This
allows us to test VSX IR generation without duplicating CHECK lines
for the existing bazillion Altivec tests.

Since vector double is now legal when VSX is available, I've modified
the error message, and changed where we test for it and for vector
long double, since the target machine isn't visible in the old place.
This serendipitously removed a not-pertinent warning about 'long'
being deprecated when used with 'vector', when "vector long double" is
encountered and we just want to issue an error.  The existing tests
test/Parser/altivec.c and test/Parser/cxx-altivec.cpp have been
updated accordingly, and I've added test/Parser/vsx.c to verify that
"vector double" is now legitimate with VSX enabled.

There is a companion patch for LLVM.

llvm-svn: 220989
2014-10-31 19:19:24 +00:00
Craig Topper c79e5e3432 Remove StorageClass typedefs from VarDecl and FunctionDecl since StorageClass is in the clang namespace.
llvm-svn: 220956
2014-10-31 06:57:13 +00:00
Hans Wennborg ac6073bb1f Follow-up to r216619: use isCXXCLassMember() instead of trying to
check the context ourselves when selectively allowing late-added
dll attributes on unused free functions and variables (PR20746)

llvm-svn: 220874
2014-10-29 21:20:57 +00:00
Alexey Bataev 330de03083 Improved capturing variable-length array types in CapturedStmt.
An updated implemnentation of VLA types capturing based on previously committed solution for Lambdas.
This version captures the whole VLA type instead of particular variables which are part of VLA size expression and allows to use previusly calculated size of VLA type in captured regions. Required for OpenMP.
Differential Revision: http://reviews.llvm.org/D5099

llvm-svn: 220850
2014-10-29 12:21:55 +00:00
NAKAMURA Takumi 44d4d9a4cb Don't capture DeclRefExpr::getNameInfo().getInfo(). It returns reference in temporary object.
DeclarationNameInfo::getInfo() returns reference, but DeclRefExpr::getNameInfo() returns temporary DeclarationNameInfo().

It triggered a local crash for me.

  Failing Tests (1):
      Clang :: SemaTemplate/instantiate-overload-candidates.cpp

  Assertion failed!
  Program: bin\clang.EXE
  File: clang/lib/Basic/SourceManager.cpp, Line 822
  Expression: 0 && "Invalid SLocOffset or bad function choice"

llvm-svn: 220841
2014-10-29 08:11:47 +00:00
Fariborz Jahanian 9ad94aa280 Objective-C. revert patch for rdar://17554063.
llvm-svn: 220812
2014-10-28 18:28:16 +00:00
Fariborz Jahanian 214567ccfa [Objective-C]. revert r220740,r220727
llvm-svn: 220802
2014-10-28 17:26:21 +00:00
Fariborz Jahanian 992bdf1b45 Objective-C ARC [qoi]. Issue diagnostic if __bridge casting
to C type a collection literal. rdar://18768214

llvm-svn: 220727
2014-10-27 22:33:06 +00:00
Fariborz Jahanian f920a0aa26 c++11 patch to issue warning on missing 'override' on
overriding methods. Patch review by Richard Smith.
rdar://18295240

llvm-svn: 220703
2014-10-27 19:11:51 +00:00
Kaelyn Takata fe408a77f6 Wire up LookupMemberExpr to use the new TypoExpr.
This includes adding the new TypoExpr-based lazy typo correction to
LookupMemberExprInRecord as an alternative to the existing eager typo
correction.

llvm-svn: 220698
2014-10-27 18:07:46 +00:00
Kaelyn Takata 8363f04ee6 Add a callback for recovering using a typo correction.
Also keep track of the stack of Exprs visited during the tree transform
so the callback can be passed the parent of the TypoExpr.

llvm-svn: 220697
2014-10-27 18:07:42 +00:00
Kaelyn Takata 9ab7fb6b73 Add simple way for a CorrectionCandidateCallback to reject exact
matches of the typo.

Also be more proactive about checking a correction's visibility so that
a correction requiring a module import can be distinguished from the
original typo even if it looks identical. Otherwise the correction will
be excluded and the diagnostic about needing the module import won't be
emitted.

Note that no change was made to checkCorrectionVisibility other than
moving where it is at in SemaLookup.cpp.

llvm-svn: 220696
2014-10-27 18:07:40 +00:00
Kaelyn Takata 6c759519bb Start adding the infrastructure for handling TypoExprs.
Part of the infrastructure is a map from a TypoExpr to the Sema-specific
state needed to correct it, along with helpers to ease dealing with the
state.

The the typo count is propagated up the stack of
ExpressionEvaluationContextRecords when one is popped off of to
avoid accidentally dropping TypoExprs on the floor. For example,
the attempted correction of g() in test/CXX/class/class.mem/p5-0x.cpp
happens with an ExpressionEvaluationContextRecord that is popped off
the stack prior to ActOnFinishFullExpr being called and the tree
transform for TypoExprs being run.

llvm-svn: 220695
2014-10-27 18:07:37 +00:00
Kaelyn Takata 0d6a3edcce Have TypoCorrectionConsumer remember the TypoCorrections it returned.
Two additional methods are provided: one to return the current
correction (the last correction returned by getNextCorrection), and one
to "reset" the state so that getNextCorrection will return the previous
corrections before returning any new corrections.

Also ensure that all TypoCorrections have valid source ranges.

llvm-svn: 220694
2014-10-27 18:07:34 +00:00
Kaelyn Takata 89c881b548 Pass around CorrectionCandidateCallbacks as unique_ptrs so
TypoCorrectionConsumer can keep the callback around as long as needed.

llvm-svn: 220693
2014-10-27 18:07:29 +00:00
Kaelyn Takata e1f49d545d Add the initial TypoExpr AST node for delayed typo correction.
llvm-svn: 220692
2014-10-27 18:07:20 +00:00
Kaelyn Takata d2287c3942 Move TypoCorrectionConsumer into a header.
This makes it available outside of SemaLookup.cpp, as
needed for the forthcoming TypoExpr AST node which will
keep a TypoCorrectionConsumer that provides the possible
typo corrections for that TypoExpr.

llvm-svn: 220691
2014-10-27 18:07:13 +00:00
NAKAMURA Takumi 729be14435 Prune CRLF.
llvm-svn: 220678
2014-10-27 12:37:26 +00:00
Reid Kleckner d7857f05f4 Add frontend support for __vectorcall
Wire it through everywhere we have support for fastcall, essentially.

This allows us to parse the MSVC "14" CTP headers, but we will
miscompile them because LLVM doesn't support __vectorcall yet.

Reviewed By: Aaron Ballman

Differential Revision: http://reviews.llvm.org/D5808

llvm-svn: 220573
2014-10-24 17:42:17 +00:00
Aaron Ballman b2e2c1bd96 Report when a function-try-block does not return a value on all control paths. Fixed PR14620.
llvm-svn: 220557
2014-10-24 13:19:19 +00:00
Fariborz Jahanian 4c8cb14c1a patch to issue warning on comparing parameters with
nonnull attribute when comparison is always
true/false. Patch by Steven Wu with few fixes and minor
refactoring and adding tests by me. rdar://18712242

llvm-svn: 220496
2014-10-23 19:00:10 +00:00
Reid Kleckner 89bd8d62f3 Reland r219810 "Fix late template parsing leak with incremental processing"
Original message:
Add a second late template parser callback meant to cleanup any
resources allocated by late template parsing.  Call it from the
Sema::ActOnEndOfTranslationUnit method after all pending template
instantiations have been completed.  Teach Parser::ParseTopLevelDecl to
install the cleanup callback when incremental processing is enabled so
that Parser::TemplateIds can be freed.

Patch by Brad King!

llvm-svn: 220400
2014-10-22 17:50:19 +00:00
Richard Trieu 353a4b4283 Fix style issue from r220363. No functional change.
llvm-svn: 220370
2014-10-22 05:21:59 +00:00
Richard Trieu 277ace025d Disable the uninitialized field warning in uninstantiated classes.
If a templated class is not instantiated, then the AST for it could be missing
some things that would throw the field checker off.  Wait until specialization
before emitting these warnings.

llvm-svn: 220363
2014-10-22 02:52:00 +00:00
Alexey Bataev 03b340a3a5 [OPENMP] Codegen for 'private' clause in 'parallel' directive.
This patch generates some helper variables which used as a private copies of the corresponding original variables inside an OpenMP 'parallel' directive. These generated variables are initialized by default (with the default constructor, if any). In outlined function references to original variables are replaced by the references to these private helper variables. At the end of the initialization of the private variables and implicit barier is set by calling __kmpc_barrier(...) runtime function to be sure that all threads were initialized using original values of the variables.
Differential Revision: http://reviews.llvm.org/D4752

llvm-svn: 220262
2014-10-21 03:16:40 +00:00
Hal Finkel 23a0739161 Add RestrictQualifierLoc to DeclaratorChunk::FunctionTypeInfo
Clang supports __restrict__ as a function qualifier, but
DeclaratorChunk::FunctionTypeInfo lacked a field to track the qualifier's
source location (as we do with volatile, etc.). This was the subject of a FIXME
in GetFullTypeForDeclarator (in SemaType.cpp). This should also prove useful as
we add more warnings regarding questionable uses of the restrict qualifier.

There is no significant functional change (except for an improved source range
associated with the err_invalid_qualified_function_type diagnostic fixit
generated by GetFullTypeForDeclarator).

llvm-svn: 220215
2014-10-20 17:32:04 +00:00
NAKAMURA Takumi 1af7cd7d3f SemaDeclCXX.cpp: UninitializedFieldVisitor: Avoid member initializers to appease msc17.
llvm-svn: 220111
2014-10-17 23:46:34 +00:00
Nick Lewycky 314a4498ca Fix typo in comment.
llvm-svn: 220098
2014-10-17 22:45:44 +00:00
Richard Trieu fa1d0a7dbf Add support for initializer lists on field initializers for -Wuninitialized
llvm-svn: 220087
2014-10-17 20:56:10 +00:00
Richard Smith cc92866e0c Don't forget to substitute into the qualifier when instantiating the definition
of a member function of a class template that is defined outside the template.
This substitution can actually fail in some weird cases.

llvm-svn: 220085
2014-10-17 20:37:29 +00:00
Saleem Abdulrasool e8aab7480c Sema: address post-commit review comment
Hoist the IgnoreParens so that we ignore it around attributes as well in order
to future-proof the code.  Addresses Richard's comments for SVN r219974.

llvm-svn: 220053
2014-10-17 17:20:33 +00:00
NAKAMURA Takumi 23224155e1 Revert r219977, "Re-commit r217995 and follow-up patches (r217997, r218011, r218053). These were"
It broke some builders. I guess it'd be reproducible with --vg.

  Failing Tests (3):
      Clang :: CXX/except/except.spec/p1.cpp
      Clang :: SemaTemplate/instantiate-exception-spec-cxx11.cpp
      Clang :: SemaTemplate/instantiate-exception-spec.cpp

llvm-svn: 220038
2014-10-17 12:48:37 +00:00
Richard Smith 9c04bce1f1 Re-commit r217995 and follow-up patches (r217997, r218011, r218053). These were
reverted in r218058 because they triggered a rejects-valid bug in MSVC.

Original commit message from r217995:

Instantiate exception specifications when instantiating function types (other
than the type of a function declaration). We previously didn't instantiate
these at all! This also covers the pathological case where the only mention of
a parameter pack is within the exception specification; this gives us a second
way (other than alias templates) to reach the horrible state where a type
contains an unexpanded pack, but its canonical type does not.

llvm-svn: 219977
2014-10-16 23:00:46 +00:00
Saleem Abdulrasool 374b5aa170 Sema: handle additional case of qualified types
A second instance of attributed types escaped the previous change, identified
thanks to Richard Smith!  When deducing the void case, we would also assume that
the type would not be attributed.  Furthermore, properly handle multiple
attributes being applied to a single TypeLoc.

Properly handle this case and future-proof a bit by ignoring parenthesis
further.  The test cases do use the additional parenthesis to ensure that this
case remains properly handled.

Addresses post-commit review comments from Richard Smith to SVN r219851.

llvm-svn: 219974
2014-10-16 22:42:53 +00:00
Hans Wennborg 899ded9cdf MS Compat: mark globals emitted in read-only sections const
They cannot be written to, so marking them const makes sense and may improve
optimisation.

As a side-effect, SectionInfos has to be moved from Sema to ASTContext.

It also fixes this problem, that occurs when compiling ATL:

  warning LNK4254: section 'ATL' (C0000040) merged into '.rdata' (40000040) with different attributes

The ATL headers are putting variables in a special section that's marked
read-only. However, Clang currently can't model that read-onlyness in the IR.
But, by making the variables const, the section does become read-only, and
the linker warning is avoided.

Differential Revision: http://reviews.llvm.org/D5812

llvm-svn: 219960
2014-10-16 20:52:46 +00:00
Aaron Ballman 78ecb8737d No longer emit diagnostics about unused results (comparisons, etc) from unevaluated contexts. Fixes PR18571.
llvm-svn: 219954
2014-10-16 20:13:28 +00:00
Aaron Ballman ae2144ec3f Switching to range-based for loops; NFC.
llvm-svn: 219940
2014-10-16 17:53:07 +00:00
David Blaikie 0f62c8d8f8 PR21246: DebugInfo: Emit the appropriate type (cv qualifiers, reference-ness, etc) for non-type template parameters
Plumb through the full QualType of the TemplateArgument::Declaration, as
it's insufficient to only know whether the type is a reference or
pointer (that was necessary for mangling, but insufficient for debug
info). This shouldn't increase the size of TemplateArgument as
TemplateArgument::Integer is still longer by another 32 bits.

Several bits of code were testing that the reference-ness of the
parameters matched, but this seemed to be insufficient (various other
features of the type could've mismatched and wouldn't've been caught)
and unnecessary, at least insofar as removing those tests didn't cause
anything to fail.

(Richard - perchaps you can hypothesize why any of these checks might
need to test reference-ness of the parameters (& explain why
reference-ness is part of the mangling - I would've figured that for the
reference-ness to be different, a prior template argument would have to
be different). I'd be happy to add them in/beef them up and add test
cases if there's a reason for them)

llvm-svn: 219900
2014-10-16 04:21:25 +00:00
Alexey Bataev 2a06681133 Bugfix in template instantiation in CXXPseudoDestructorExpr.
Fix for clang crash when instantiating a template with qualified lookup for members in non-class types.
Differential Revision: http://reviews.llvm.org/D5769

llvm-svn: 219897
2014-10-16 03:04:35 +00:00
Saleem Abdulrasool bbdd6c13de Sema: handle AttributedTypeLocs in C++14 auto deduction
When performing a type deduction from the return type, the FunctionDecl may be
attributed with a calling convention.  In such a case, the retrieved type
location may be an AttributedTypeLoc.  Performing a castAs<FunctionProtoTypeLoc>
on such a type loc would result in an assertion as they are not derived types.

Ensure that we correctly handle the attributed type location by looking through
it to the modified type loc.

Fixes an assertion triggered in C++14 mode.

llvm-svn: 219851
2014-10-15 21:37:55 +00:00
Reid Kleckner 8178dd362f Revert "Fix late template parsing leak with incremental processing"
This reverts commit r219810.

The test suite appears broken.

llvm-svn: 219813
2014-10-15 17:22:56 +00:00