Commit Graph

86 Commits

Author SHA1 Message Date
Nico Weber 8d26b72aca Don't crash on an invalid trailing return type on a function before a '...'
clang tries to produce a helpful diagnostic for the traiilng '...', but the
code that r216778 added for this doesn't expect an invalid trailing return type.
Add code to explicitly handle this.

Having explicit code for this but not for other things looks a bit strange, but
trailing return types are special in that they have a separate existence bit in
addition to the type (see r158348).

llvm-svn: 224974
2014-12-30 02:06:40 +00:00
David Blaikie 82e95a3c79 Update for LLVM API change to make Small(Ptr)Set::insert return pair<iterator, bool> as per the C++ standard's associative container concept.
llvm-svn: 222335
2014-11-19 07:49:47 +00:00
Richard Smith 0f0af19b05 [c++1z] N4295: fold-expressions.
This is a new form of expression of the form:

  (expr op ... op expr)

where one of the exprs is a parameter pack. It expands into

  (expr1 op (expr2onwards op ... op expr))

(and likewise if the pack is on the right). The non-pack operand can be
omitted; in that case, an empty pack gives a fallback value or an error,
depending on the operator.

llvm-svn: 221573
2014-11-08 05:07:16 +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
Larisse Voufo 2e84650768 Fix for PR20660, where unexpanded parameter pack in function parameter clause causes clang to crash.
llvm-svn: 216778
2014-08-29 21:08:16 +00:00
Richard Smith 36ee9fb219 Reject varargs '...' in function prototype if there are more parameters after
it. Diagnose with recovery if it appears after a function parameter that was
obviously supposed to be a parameter pack. Otherwise, warn if it immediately
follows a function parameter pack, because the user most likely didn't intend
to write a parameter pack followed by a C-style varargs ellipsis.

This warning can be syntactically disabled by using ", ..." instead of "...".

llvm-svn: 215408
2014-08-11 23:30:23 +00:00
Nikola Smiljanic 03ff2596cb Refactoring. Remove Owned method from Sema.
llvm-svn: 209812
2014-05-29 14:05:12 +00:00
Craig Topper c3ec149bb2 [C++11] Use 'nullptr'. Sema edition.
llvm-svn: 209613
2014-05-26 06:22:03 +00:00
John Thompson 2255f2ce90 Initial implementation of -modules-earch-all option, for searching for symbols in non-imported modules.
llvm-svn: 206977
2014-04-23 12:57:01 +00:00
Craig Topper e14c0f8e73 [C++11] Add 'override' keyword to virtual methods that override their base class.
llvm-svn: 203640
2014-03-12 04:55:44 +00:00
Benjamin Kramer 867ea1d426 [C++11] Replace llvm::tie with std::tie.
llvm-svn: 202639
2014-03-02 13:01:17 +00:00
Chandler Carruth 5553d0d4ca Sort all the #include lines with LLVM's utils/sort_includes.py which
encodes the canonical rules for LLVM's style. I noticed this had drifted
quite a bit when cleaning up LLVM, so wanted to clean up Clang as well.

llvm-svn: 198686
2014-01-07 11:51:46 +00:00
Alp Toker f22856a415 Remove OpenCL-specific type keywords and specifiers
This commit kills off custom type specifier and keyword handling of OpenCL C
data types.

Although the OpenCL spec describes them as keywords, we can handle them more
elegantly as predefined types. This should provide better error correction and
code completion as well as simplifying the implementation.

The primary intention is however to simplify the C/C++ parser and save some
packed bits on AST structures that had been extended in r170432 just for
OpenCL.

llvm-svn: 197578
2013-12-18 15:29:05 +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
Eli Friedman 94e9eaa4d7 Fix one place I missed that was memcpy'ing TypeLocs in a way that messes
up alignment.

Fixes utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp from the
libc++ testsuite.

llvm-svn: 184397
2013-06-20 04:11:21 +00:00
Eli Friedman 7152fbe57e Re-commit r183466 with a fix to make the TypeLoc casting machinery work
correctly in the presence of qualified types.

(I had to change the unittest because it was trying to cast a
QualifiedTypeLoc to TemplateSpecializationTypeLoc.)

llvm-svn: 183563
2013-06-07 20:31:48 +00:00
Manuel Klimek e29ec9680a Reverts r183466: "Perform dynamic alignment computations..."
This introduces bugs in TemplateSpecializationTypeLoc's angle bracket
locations.

Regression test follows in a subsequent commit.

llvm-svn: 183513
2013-06-07 11:27:53 +00:00
Eli Friedman 0b3175a6fc Perform dynamic alignment computations so that the data in TypeLocs is
correctly aligned.  Not performing such computations led to misaligned loads,
which crash on some platforms and are generally bad on other platforms.

The implementation of TypeLocBuilder::pushImpl is rather messy; code using
TypeLocBuilder accidentally assumes that partial TypeLocs are
laid out like a complete TypeLoc.  As a followup, I intend to work on
fixing the TypeLocBuilder API to avoid exposing partial TypeLocs; this should
substantially simplify the implemementation.

Fixes PR16144.

llvm-svn: 183466
2013-06-07 00:04:31 +00:00
Richard Smith ba71c08523 First pass of semantic analysis for init-captures: check the initializer, build
a FieldDecl from it, and propagate both into the closure type and the
LambdaExpr.

You can't do much useful with them yet -- you can't use them within the body
of the lambda, because we don't have a representation for "the this of the
lambda, not the this of the enclosing context". We also don't have support or a
representation for a nested capture of an init-capture yet, which was intended
to work despite not being allowed by the current standard wording.

llvm-svn: 181985
2013-05-16 06:20:58 +00:00
Richard Smith 74aeef50a0 Implement C++1y decltype(auto).
llvm-svn: 180610
2013-04-26 16:15:35 +00:00
David Blaikie 7a30dc53c5 Use None rather than Optional<T>() where possible.
llvm-svn: 175705
2013-02-21 01:47:18 +00:00
David Blaikie 05785d1622 Include llvm::Optional in clang/Basic/LLVM.h
Post-commit CR feedback from Jordan Rose regarding r175594.

llvm-svn: 175679
2013-02-20 22:23:23 +00:00
David Blaikie 6adc78e0df Replace TypeLoc llvm::cast support to be well-defined.
The TypeLoc hierarchy used the llvm::cast machinery to perform undefined
behavior by casting pointers/references to TypeLoc objects to derived types
and then using the derived copy constructors (or even returning pointers to
derived types that actually point to the original TypeLoc object).

Some context is in this thread:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-December/056804.html
Though it's spread over a few months which can be hard to read in the mail
archive.

llvm-svn: 175462
2013-02-18 22:06:02 +00:00
Guy Benyei 610541989a Add OpenCL samplers as Clang builtin types and check sampler related restrictions.
llvm-svn: 174601
2013-02-07 10:55:47 +00:00
Nick Lewycky 45b5052834 This patch makes "&Cls::purevfn" not an odr use. This isn't what the standard
says, but that's a defect (to be filed). "Cls::purevfn()" is still an odr use.

Also fixes a bug that caused us to not mark the function referenced just
because we didn't want to mark it odr used.

llvm-svn: 174242
2013-02-02 00:25:55 +00:00
Guy Benyei 1b4fb3e08b Implement OpenCL event_t as Clang builtin type, including event_t related OpenCL restrictions (OpenCL 1.2 spec 6.9)
llvm-svn: 172973
2013-01-20 12:31:11 +00:00
Guy Benyei d8a08ea98d Re-commit r170428 changes with Linux style file endings.
Add OpenCL images as clang builtin types.

llvm-svn: 170432
2012-12-18 14:38:23 +00:00
Guy Benyei 11169dded0 Revert changes from r170428, as I accidentally changed the line endings of these files to Windows style.
llvm-svn: 170431
2012-12-18 14:30:41 +00:00
Guy Benyei b13abb952a Add OpenCL images as clang builtin types.
llvm-svn: 170428
2012-12-18 12:30:03 +00:00
Chandler Carruth 3a02247dc9 Sort all of Clang's files under 'lib', and fix up the broken headers
uncovered.

This required manually correcting all of the incorrect main-module
headers I could find, and running the new llvm/utils/sort_includes.py
script over the files.

I also manually added quite a few missing headers that were uncovered by
shuffling the order or moving headers up to be main-module-headers.

llvm-svn: 169237
2012-12-04 09:13:33 +00:00
Joao Matos dc86f94f62 Improved MSVC __interface support by adding first class support for it, instead of aliasing to "struct" which had some incorrect behaviour. Patch by David Robins.
llvm-svn: 163013
2012-08-31 18:45:21 +00:00
Richard Smith 2589b9808e PR12057: Allow variadic template pack expansions to cross lambda boundaries.
Rather than adding a ContainsUnexpandedParameterPack bit to essentially every
AST node, we tunnel the bit directly up to the surrounding lambda expression
when we reach a context where an unexpanded pack can not normally appear.
Thus any statement or declaration within a lambda can now potentially contain
an unexpanded parameter pack.

llvm-svn: 160705
2012-07-25 03:56:55 +00:00
Richard Smith 198223b7e6 PR13386: When matching up parameters between a function template declaration
and a function template instantiation, if there's a parameter pack in the
declaration and one at the same place in the instantiation, don't assume that
the pack wasn't expanded -- it may have expanded to nothing. Instead, go ahead
and check whether the parameter pack was expandable. We can do this as a
side-effect of the work we'd need to do anyway, to find how many parameters
were produced.

llvm-svn: 160416
2012-07-18 01:29:05 +00:00
Richard Smith f016bbcc61 For PR11916: Add support for g++'s __int128 keyword. Unlike __int128_t, this is
a type specifier and can be combined with unsigned. This allows libstdc++4.7 to
be used with clang in c++98 mode.

Several other changes are still required for libstdc++4.7 to work with clang in
c++11 mode.

llvm-svn: 153999
2012-04-04 06:24:32 +00:00
David Blaikie bbafb8a745 Unify naming of LangOptions variable/get function across the Clang stack (Lex to AST).
The member variable is always "LangOpts" and the member function is always "getLangOpts".

Reviewed by Chris Lattner

llvm-svn: 152536
2012-03-11 07:00:24 +00:00
John McCall 113bee0536 Remove BlockDeclRefExpr and introduce a bit on DeclRefExpr to
track whether the referenced declaration comes from an enclosing
local context.  I'm amenable to suggestions about the exact meaning
of this bit.

llvm-svn: 152491
2012-03-10 09:33:50 +00:00
Ted Kremenek e65b086e07 Add clang support for new Objective-C literal syntax for NSDictionary, NSArray,
NSNumber, and boolean literals.  This includes both Sema and Codegen support.
Included is also support for new Objective-C container subscripting.

My apologies for the large patch.  It was very difficult to break apart.
The patch introduces changes to the driver as well to cause clang to link
in additional runtime support when needed to support the new language features.

Docs are forthcoming to document the implementation and behavior of these features.

llvm-svn: 152137
2012-03-06 20:05:56 +00:00
Eli Friedman 23b1be991e Fix the isReferenced bit on parameters in a couple of edge cases. PR12153.
llvm-svn: 151837
2012-03-01 21:32:56 +00:00
Bill Wendling 8ac06afa9b ArrayRef-icize the function arguments.
llvm-svn: 151151
2012-02-22 09:38:11 +00:00
Kaelyn Uhrain 4e8942c139 Make the callback object to Sema::CorrectTypo mandatory.
llvm-svn: 149451
2012-01-31 23:49:25 +00:00
David Blaikie e4d798f078 More dead code removal (using -Wunreachable-code)
llvm-svn: 148577
2012-01-20 21:50:17 +00:00
Kaelyn Uhrain 637b5b3235 Convert SemaTemplate*.cpp to pass a callback object to CorrectTypo.
The change to SemaTemplateVariadic.cpp improves the typo correction
results in certain situations, while the change to SemaTemplate.cpp
does not change existing behavior.

llvm-svn: 148155
2012-01-13 23:10:36 +00:00
Douglas Gregor 4a2a8f7fb8 Check for unexpanded parameter packs in the name that guards a
Microsoft __if_exists/__if_not_exists statement. Also note that we
weren't traversing DeclarationNameInfo *at all* within the
RecursiveASTVisitor, which would be rather fatal for variadic
templates.

llvm-svn: 142906
2011-10-25 03:44:56 +00:00
Anton Korobeynikov f0c267e6e0 Provide half floating point support as a storage only type.
Lack of half FP was a regression compared to llvm-gcc.

llvm-svn: 142016
2011-10-14 23:23:15 +00:00
Eli Friedman 0dfb889575 Support for C1x _Atomic specifier (see testcase). This is primarily being committed at the moment to help support C++0x <atomic>, but it should be a solid base for implementing the full specification of C1x _Atomic.
Thanks to Jeffrey Yasskin for the thorough review!

llvm-svn: 141330
2011-10-06 23:00:33 +00:00
David Blaikie b9c168a265 ArrayRef-ifying the UnexpandedParameterPacks passed to Sema::CheckParameterPacksForExpansion
llvm-svn: 140290
2011-09-22 02:34:54 +00:00
Chris Lattner 0e62c1cc0b remove unneeded llvm:: namespace qualifiers on some core types now that LLVM.h imports
them into the clang namespace.

llvm-svn: 135852
2011-07-23 10:55:15 +00:00
Douglas Gregor c2fa169d6c Add support for C++ namespace-aware typo correction, e.g., correcting
vector<int>

to

  std::vector<int>

Patch by Kaelyn Uhrain, with minor tweaks + PCH support from me. Fixes
PR5776/<rdar://problem/8652971>.

Thanks Kaelyn!

llvm-svn: 134007
2011-06-28 16:20:02 +00:00
Alexis Hunt e852b100e2 Implement a new type node, UnaryTransformType, designed to represent a
type that turns one type into another. This is used as the basis to
implement __underlying_type properly - with TypeSourceInfo and proper
behavior in the face of templates.

llvm-svn: 132017
2011-05-24 22:41:36 +00:00
Alexis Hunt 4a2570792c Implement __underlying_type for libc++.
llvm-svn: 131633
2011-05-19 05:37:45 +00:00