Commit Graph

19714 Commits

Author SHA1 Message Date
David Majnemer 68c880b5f9 AST: Handle multidimensional arrays inside of __uuidof()
We previously handled one-dimensional arrays but didn't consider the
general case.  The fix is simple: keep going through subsequent
dimensions until we get to the base element.

llvm-svn: 191493
2013-09-27 07:57:34 +00:00
David Majnemer 143c55ead2 AST: Handle qualified array types in typeid() expressions
The intent of getTypeOperand() was to yield an unqualified type.
However QualType::getUnqualifiedType() does not strip away qualifiers on
arrays.

N.B.  This worked fine when typeid() was applied to an expression
because we would inject as implicit cast to the unqualified array type
in the AST.

llvm-svn: 191487
2013-09-27 07:04:31 +00:00
Nick Lewycky acfcd0d51b Add -fno-unsigned-char and ignore it. We already support -fno-signed-char, add
both flags to the driver test.

llvm-svn: 191486
2013-09-27 05:06:31 +00:00
David Majnemer c185aa7d92 Sema: Respect -fdelayed-template-parsing when parsing constexpr functions
Functions declared as constexpr must have their parsing delayed in
-fdelayed-template-parsing mode so as not to upset later template
instantiation.

N.B. My reading of the standard makes it seem like delayed template
parsing is at odds with constexpr.  We may want to make refinements in
other places in clang to make constexpr play nicer with this feature.

This fixes PR17334.

llvm-svn: 191484
2013-09-27 04:14:12 +00:00
Fariborz Jahanian 7c1a445c9e ObjectiveC migrator: Donlt annotate NS_RETURNS_INNER_POINTER
on class methods, as it makes no sense. // rdar://15069200

llvm-svn: 191468
2013-09-26 22:43:41 +00:00
Fariborz Jahanian 73466cafc1 ObjectiveC migrator: function pointer is not an
inner pointer for annotation to
objc_returns_inner_pointer purposes.
// rdar://15044991

llvm-svn: 191465
2013-09-26 21:43:47 +00:00
Adrian Prantl 179af903d2 Debug info: Fix a crash when trying to construct a type with redundant
ownership qualifiers.
Fixes rdar://problem/14990656.

llvm-svn: 191463
2013-09-26 21:35:50 +00:00
Kaelyn Uhrain f73430183a Fix error recovery when a return type correction includes a new name specifier.
llvm-svn: 191459
2013-09-26 21:13:05 +00:00
Bob Wilson a1b4206a70 Fix up fallout from r187156.
The previous change caused the driver to translate -Wa,-L to the
-msave-temp-labels option for cc1as, but cc1as did not accept that option.
This patch follows the same approach used for similar options (-relax-all,
-noexecstack) in the previous patch.

llvm-svn: 191458
2013-09-26 21:00:51 +00:00
Faisal Vali 2b391ab708 Implement a rudimentary form of generic lambdas.
Specifically, the following features are not included in this commit:
  - any sort of capturing within generic lambdas 
  - generic lambdas within template functions and nested 
    within other generic lambdas
  - conversion operator for captureless lambdas
  - ensuring all visitors are generic lambda aware
  (Although I have gotten some useful feedback on my patches of the above and will be incorporating that as I submit those patches for commit)

As an example of what compiles through this commit:

template <class F1, class F2>
struct overload : F1, F2 {
    using F1::operator();
    using F2::operator();
    overload(F1 f1, F2 f2) : F1(f1), F2(f2) { }
  };

  auto Recursive = [](auto Self, auto h, auto ... rest) {
    return 1 + Self(Self, rest...);
  };
  auto Base = [](auto Self, auto h) {
      return 1;
  };
  overload<decltype(Base), decltype(Recursive)> O(Base, Recursive);
  int num_params =  O(O, 5, 3, "abc", 3.14, 'a');

Please see attached tests for more examples.

This patch has been reviewed by Doug and Richard.  Minor changes (non-functionality affecting) have been made since both of them formally looked at it, but the changes involve removal of supernumerary return type deduction changes (since they are now redundant, with richard having committed a recent patch to address return type deduction for C++11 lambdas using C++14 semantics). 



Some implementation notes:

  - Add a new Declarator context => LambdaExprParameterContext to 
    clang::Declarator to allow the use of 'auto' in declaring generic
    lambda parameters
      
  - Add various helpers to CXXRecordDecl to facilitate identifying
    and querying a closure class
  
  - LambdaScopeInfo (which maintains the current lambda's Sema state)
    was augmented to house the current depth of the template being
    parsed (id est the Parser calls Sema::RecordParsingTemplateParameterDepth)
    so that SemaType.cpp::ConvertDeclSpecToType may use it to immediately 
    generate a template-parameter-type when 'auto' is parsed in a generic
    lambda parameter context.  (i.e we do NOT use AutoType deduced to 
    a template parameter type - Richard seemed ok with this approach).  
    We encode that this template type was generated from an auto by simply
    adding $auto to the name which can be used for better diagnostics if needed.

  - SemaLambda.h was added to hold some common lambda utility
    functions (this file is likely to grow ...)
    
  - Teach Sema::ActOnStartOfFunctionDef to check whether it
    is being called to instantiate a generic lambda's call
    operator, and if so, push an appropriately prepared
    LambdaScopeInfo object on the stack.
    
  - various tests were added - but much more will be needed.

There is obviously more work to be done, and both Richard (weakly) and Doug (strongly) 
have requested that LambdaExpr be removed form the CXXRecordDecl LambdaDefinitionaData
in a future patch which is forthcoming.

A greatful thanks to all reviewers including Eli Friedman, James Dennett, 
and especially the two gracious wizards (Richard Smith and Doug Gregor) 
who spent hours providing feedback (in person in Chicago and on the mailing lists).  
And yet I am certain that I have allowed unidentified bugs to creep in; bugs, that I will do my best to slay, once identified!

Thanks!

llvm-svn: 191453
2013-09-26 19:54:12 +00:00
Kaelyn Uhrain deedc3a6bd Fix a bug in the typo correction replacement location.
I noticed the wrong text was being replaced with the correction while
working on expanding the "namespace-aware" typo correction to include
classes.

llvm-svn: 191450
2013-09-26 19:10:34 +00:00
Kaelyn Uhrain 95995be7a3 Teach typo correction to look inside of classes like it does namespaces.
Unlike with namespaces, searching inside of classes requires also
checking the access to correction candidates (i.e. don't suggest a
correction to a private class member for a correction occurring outside
that class and its methods or friends).

Included is a small (one line) fix for a bug, that was uncovered while
cleaning up the unit tests, where the decls from a TypoCorrection candidate
were preserved in new TypoCorrection candidates that are derived (copied)
from the old TypoCorrection--notably when creating a new candidate by
changing the NestedNameSpecifier associated with the base idenitifer.

llvm-svn: 191449
2013-09-26 19:10:29 +00:00
Richard Smith 52d0211ce3 Add macro test from N3781.
llvm-svn: 191444
2013-09-26 18:15:22 +00:00
Richard Smith 7f2707a7f4 Per updates to D3781, allow underscore under ' in a pp-number, and allow ' in a #line directive.
llvm-svn: 191443
2013-09-26 18:13:20 +00:00
Reid Kleckner af1acd9a5e clang-cl: Add /FI (forced include) as an alias for -include
Patch by Jeff Muizelaar, with added test case.

llvm-svn: 191442
2013-09-26 17:41:14 +00:00
Jordan Rose 3d08340b3c [driver] Ignore -fno-var-tracking; it's a GCC option we don't support.
-fvar-tracking (which IIUC is on by default in GCC) will still generate
an error.

llvm-svn: 191439
2013-09-26 17:03:34 +00:00
Rafael Espindola 64437be2c2 Remove fno_builtin_strcat and fno_builtin_strcpy.
They are already handled by the generic fno_bultin_, which also
avoids unused warnings.

llvm-svn: 191437
2013-09-26 16:45:27 +00:00
Rafael Espindola 07bed1386e Ignore unknown -fno-builtin-*.
This matches gcc's behavior.

llvm-svn: 191434
2013-09-26 16:15:40 +00:00
Rafael Espindola fa74eee737 Ignore some -f options that are supported by gcc.
It is possible that we should say some of these are unsupported, but this is
not any worse than the old behavior of ignoring all unknown -f options.

llvm-svn: 191429
2013-09-26 13:10:14 +00:00
Richard Smith 10b55fc85e If a partial specialization of a member template is declared within a class
template and defined outside it, don't instantiate it twice when instantiating
the surrounding class template specialization. That would cause us to reject
the code because we think two partial specializations instantiated to produce
the same signature.

llvm-svn: 191418
2013-09-26 03:49:48 +00:00
Richard Smith fde9485297 Implement C++1y digit separator proposal (' as a digit separator). This is not
yet approved by full committee, but was unanimously supported by EWG.

llvm-svn: 191417
2013-09-26 03:33:06 +00:00
Alexey Bataev 7d2960bd2a [OPENMP] Improved variable lookup procedure for threadprivate variables.
llvm-svn: 191416
2013-09-26 03:24:06 +00:00
Fariborz Jahanian b7c5f74264 ObjectiveC: Handle the case of qualifying protocols
declared in a typedef declaraton used as super
class of an ObjC class. Curretnly, these protocols
are dropped from the class hierarchy. Test shows that
it is now included. // rdar://15051465

llvm-svn: 191395
2013-09-25 19:36:32 +00:00
Rafael Espindola cf526ee99c Produce an error for unknown -f options.
llvm-svn: 191394
2013-09-25 19:07:08 +00:00
Reid Kleckner 95e036c669 PR17359: Fix off-by-one OOB on _Pragma("") and an unescaping bug
Previously the code would reduce a run of backslashes to a single
backslash, and now it will properly leave behind every other backslash.

llvm-svn: 191382
2013-09-25 16:42:48 +00:00
Jordan Rose 1ccc43d50e [analyzer] Handle destructors for the argument to C++ 'delete'.
Now that the CFG includes nodes for the destructors in a delete-expression,
process them in the analyzer using the same common destructor interface
currently used for local, member, and base destructors. Also, check for when
the value is known to be null, in which case no destructor is actually run.

This does not yet handle destructors for deleted /arrays/, which may need
more CFG work. It also causes a slight regression in the location of
double delete warnings; the double delete is detected at the destructor
call, which is implicit, and so is reported on the first access within the
destructor instead of at the 'delete' statement. This will be fixed soon.

Patch by Karthik Bhat!

llvm-svn: 191381
2013-09-25 16:06:17 +00:00
Rafael Espindola cc707bc989 Produce an error if a -cc1 only option is passed to the driver.
llvm-svn: 191380
2013-09-25 15:54:41 +00:00
Rafael Espindola cbbe1d4454 Use -Xclang to pass -internal-isystem and -internal-externc-isystem to -cc1.
They are cc1 options only, so the driver was ignoring them.

llvm-svn: 191379
2013-09-25 15:47:05 +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
Fariborz Jahanian 7391a7b5aa ObjectiveC migrator. Don't suggest @property for
methods which look like getters but belong to
known family of methods. // rdar://15044058

llvm-svn: 191347
2013-09-25 00:17:07 +00:00
Argyrios Kyrtzidis 16834f1cf9 [libclang] Provide location for attributes and expose 'packed' attribute.
Patch by Loïc Jaquemet!

llvm-svn: 191345
2013-09-25 00:14:38 +00:00
Eli Friedman 3ce27103d9 Allow dynamic_cast to void* even with -fno-rtti.
PR17346.

llvm-svn: 191340
2013-09-24 23:21:41 +00:00
Eli Friedman 1f5d8882f9 Fix -Wmissing-variable-declarations regression.
This issue was introduced in r181677.

PR17349.

llvm-svn: 191339
2013-09-24 23:10:08 +00:00
Fariborz Jahanian 7797c0d0f7 ObjectiveC migrator: provide space between the property
keyword and the rest on suggested property. // rdar://15069044

llvm-svn: 191335
2013-09-24 21:27:58 +00:00
Fariborz Jahanian aaabfcdffe ObjectiveC migrator: Another test for my last patch.
// rdar://15044991

llvm-svn: 191334
2013-09-24 20:31:24 +00:00
Fariborz Jahanian 10b7435ceb ObjectiveC migrator: iDOn't mangle names when
NS_RETURNS_INNER_POINTER annotation is suggested on
a property. // rdar://15044991

llvm-svn: 191332
2013-09-24 20:20:52 +00:00
Rafael Espindola 4f3f5ade54 Produce an error for unknown -m options.
llvm-svn: 191328
2013-09-24 19:35:01 +00:00
Yunzhong Gao 1f6aeebe76 Adding -mtbm and -mno-tbm command line options to the clang front end for the
x86 TBM instruction set. Also adding a __TBM__ macro if the TBM feature is
enabled. Otherwise there should be no functionality change to existing features.

Phabricator code review is located here: http://llvm-reviews.chandlerc.com/D1693

llvm-svn: 191326
2013-09-24 19:00:58 +00:00
Hans Wennborg b6331dcb51 clang-cl: fix passing optimization level to cl.exe in /fallback mode
We were previously mostly passing it through, but -O0 and -O3 are not valid
options to cl.exe.

We should translate -O0 to /Od and -O3 to /Ox. -O{1,2,s} get passed through.

llvm-svn: 191323
2013-09-24 18:17:21 +00:00
Hans Wennborg 263c213061 clang-cl: pass /nologo when falling back to cl.exe
llvm-svn: 191316
2013-09-24 17:36:21 +00:00
Fariborz Jahanian 0dded8ab04 Revert my patch in r191155 to allow forward
class/protocol decls in @implementation and
fixup modern rewriter to handle that.
// rdar://15066233

llvm-svn: 191311
2013-09-24 17:03:07 +00:00
Rafael Espindola 96a051367b Use a valid option (-msse) for testing QA_OVERRIDE_GCC3_OPTIONS.
llvm-svn: 191300
2013-09-24 13:37:21 +00:00
Daniel Jasper ca9f73812c Add -fmodule-map-file option.
With this option, arbitrarily named module map files can be specified
to be loaded as required for headers in the respective (sub)directories.

This, together with the extern module declaration allows for specifying
module maps in a modular fashion without the need for files called
"module.map".

Among other things, this allows a directory to contain two modules that
are completely independent of one another.

Review: http://llvm-reviews.chandlerc.com/D1697.
llvm-svn: 191284
2013-09-24 09:27:13 +00:00
Daniel Jasper ba7f2f7110 Module use declarations (II)
Review: http://llvm-reviews.chandlerc.com/D1546.

I have picked up this patch form Lawrence
(http://llvm-reviews.chandlerc.com/D1063) and did a few changes.

From the original change description (updated as appropriate):
This patch adds a check that ensures that modules only use modules they
have so declared. To this end, it adds a statement on intended module
use to the module.map grammar:

  use module-id

A module can then only use headers from other modules if it 'uses' them.
This enforcement is off by default, but may be turned on with the new
option -fmodules-decluse.

When enforcing the module semantics, we also need to consider a source
file part of a module. This is achieved with a compiler option

-fmodule-name=<module-id>.

The compiler at present only applies restrictions to the module directly
being built.

llvm-svn: 191283
2013-09-24 09:14:14 +00:00
Simon Atanasyan 22127cee34 [Mips] Support -mnan=2008 option. Define "__mips_nan2008" macros and pass
this option to the assembler.

llvm-svn: 191282
2013-09-24 09:09:16 +00:00
Richard Smith b12cf6ceb7 Hopefully unbreak bots which are seeing an assert in this test. Temporary, real
fix to come once I've tracked down the problem (which is pre-existing and not
related to the change which introduced this test).

llvm-svn: 191279
2013-09-24 05:07:58 +00:00
Richard Smith 300e0c36a3 Implement restriction that a partial specialization must actually specialize
something, for variable templates.

llvm-svn: 191278
2013-09-24 04:49:23 +00:00
Richard Smith 2a98862be2 Handle standard libraries that miss out the space when defining the standard
literal operators. Also, for now, allow the proposed C++1y "il", "i", and "if"
suffixes too. (Will revert the latter if LWG decides not to go ahead with that
change after all.)

llvm-svn: 191274
2013-09-24 04:06:10 +00:00
Jiangning Liu 036f16dc8c Initial support for Neon scalar instructions.
Patch by Ana Pazos.

1.Added support for v1ix and v1fx types.
2.Added Scalar Pairwise Reduce instructions.
3.Added initial implementation of Scalar Arithmetic instructions.

llvm-svn: 191264
2013-09-24 02:48:06 +00:00
Hans Wennborg f4aee18086 clang-cl: print diagnostics as "error(clang): foo" in /fallback mode
This solves two problems:

1) MSBuild will not flag the build as unsuccessful just because we print
   an error in the output, since "error(clang):" doesn't seem to match
   the regex it's using.

2) It becomes more clear that the diagnostic is coming from clang as
   supposed to cl.exe.

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

llvm-svn: 191250
2013-09-24 00:08:55 +00:00