Commit Graph

31274 Commits

Author SHA1 Message Date
Simon Atanasyan 9812d231ed [mips] Add one more check to the micromips attribute test case. NFC
llvm-svn: 303565
2017-05-22 15:53:34 +00:00
Alex Lorenz 832d8fcc63 [index] Index the deleted functions
rdar://32323386

llvm-svn: 303563
2017-05-22 15:42:45 +00:00
Erik Pilkington 6ac77a6c37 [Sema][ObjC] Fix a bug where -Wunguarded-availability was emitted at the wrong location
Differential revision: https://reviews.llvm.org/D33250

llvm-svn: 303562
2017-05-22 15:41:12 +00:00
Alex Lorenz 365cb47818 [index] Visit the default argument values in function definitions
rdar://32323315

llvm-svn: 303559
2017-05-22 15:17:44 +00:00
Alex Lorenz d65b3e4212 [index] 'using namespace' declarations in functions should record
the reference to the namespace

rdar://32323190

llvm-svn: 303555
2017-05-22 14:39:39 +00:00
Simon Atanasyan 2c87f5341d [mips] Support `micromips` attribute
This patch adds support for the `micromips` and `nomicromips` attributes
for MIPS targets.

Differential revision: https://reviews.llvm.org/D33363

llvm-svn: 303546
2017-05-22 12:47:43 +00:00
Faisal Vali 56f1de4dcb Fix PR25627: constant expressions being odr-used in template arguments.
This patch ensures that clang processes the expression-nodes that are generated when disambiguating between types and expressions within template arguments as constant-expressions by installing the ConstantEvaluated ExpressionEvaluationContext just before attempting the disambiguation - and then making sure that Context carries through into ParseConstantExpression (by refactoring it out into a function that does not create its own EvaluationContext: ParseConstantExpressionInExprEvalContext) 

Note, prior to this patch, trunk would correctly disambiguate and identify the expression as an expression - and while it would annotate the token with the expression - it would fail to complete the odr-use processing (specifically, failing to trigger Sema::UpdateMarkingForLValueToRValue as is done for all Constant Expressions, which would remove it from being considered odr-used).  By installing the ConstantExpression Evaluation Context prior to disambiguation, and making sure it carries though, we ensure correct processing of the expression-node.

For e.g:
  template<int> struct X { };
  void f() {
    const int N = 10;
    X<N> x; // should be OK.
    [] { return X<N>{}; }; // Should be OK - no capture - but clang errors!
  }

See a related bug: https://bugs.llvm.org//show_bug.cgi?id=25627

In summary (and reiteration), the fix is as follows:

    - Remove the EnteredConstantEvaluatedContext action from ParseTemplateArgumentList (relying on ParseTemplateArgument getting it right)
    - Add the EnteredConstantEvaluatedContext action just prior to undergoing the disambiguating parse, and if the parse succeeds for an expression, carry the context though into a refactored version of ParseConstantExpression that does not create its own ExpressionEvaluationContext.

See https://reviews.llvm.org/D31588 for additional context regarding some of the more fragile and complicated approaches attempted, and Richard's feedback that eventually shaped the simpler and more robust rendition that is being committed.

Thanks Richard!

llvm-svn: 303492
2017-05-20 19:58:04 +00:00
Argyrios Kyrtzidis 11d704839f [index] Fix forward declarations interfering with USR generation of external source symbols
Patch by Nathan Hawes.
https://reviews.llvm.org/D33346

llvm-svn: 303484
2017-05-20 04:11:33 +00:00
Matthias Braun a451953224 CodeGenModule: Always output wchar_size, check LLVM assumptions.
Re-commit r303463 now that LLVM is fixed and adjust some lit tests.

llvm::TargetLibraryInfo needs to know the size of wchar_t to work on
functions like `wcslen`. This patch changes clang to always emit the
wchar_size module flag (it would only do so for ARM previously).
This also adds an `assert()` to ensure the LLVM defaults based on the
target triple are in sync with clang.

Differential Revision: https://reviews.llvm.org/D32982

llvm-svn: 303478
2017-05-20 01:29:55 +00:00
Matthias Braun 421b63dd70 Revert "CodeGenModule: Always output wchar_size, check LLVM assumptions."
Let's revert this for now (and with it the assert()) to get the bots
back to green until I have LLVM synced up properly.

This reverts commit r303463.

llvm-svn: 303474
2017-05-20 00:38:27 +00:00
Hubert Tong 605eacafa7 Fix valid-for-expr ellipses eaten as invalid decl
Summary:
The trial parse for declarative syntax accepts an invalid pack
declaration syntax, which is ambiguous with valid pack expansions of
expressions. This commit removes the invalid pack declaration syntax to
avoid mistaking valid pack expansions as invalid declarator components.

Additionally, the trial parse of a //template-argument-list// then needs
to handle the optional ellipsis that is part of that grammar, as opposed
to relying on the trial parse for declarators accepting stray ellipses.

Reviewers: rsmith, rcraik, aaron.ballman

Reviewed By: rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D33339

llvm-svn: 303472
2017-05-20 00:21:55 +00:00
Richard Smith 4971ed0fea [modules] Simplify module macro handling in non-local-submodule-visibility mode.
When reaching the end of a module, we used to convert its macros to
ModuleMacros but also leave them in the MacroDirective chain for the
identifier. This meant that every lookup of such a macro would find two
(identical) definitions. It also made it difficult to determine the correct
owner for a macro when reaching the end of a module: the most recent
MacroDirective in the chain could be from an #included submodule rather than
the current module.

Simplify this: whenever we convert a MacroDirective to a ModuleMacro when
leaving a module, clear out the MacroDirective chain for that identifier, and
just rely on the ModuleMacro to provide the macro definition information.

(We don't want to do this for local submodule visibility mode, because in that
mode we maintain a distinct MacroDirective chain for each submodule, and we
need to keep around the prior MacroDirective in case we re-enter the submodule
-- for instance, if its header is #included more than once in a module build,
we need the include guard directive to stick around. But the problem doesn't
arise in this case for the same reason: each submodule has its own
MacroDirective chain, so the macros don't leak out of submodules in the first
place.)


This reinstates r302932, reverted in r302947, with a fix for a bug that
resulted in us sometimes losing macro definitions due to failing to clear out
the overridden module macro list when promoting a directive to a module macro.

llvm-svn: 303468
2017-05-19 23:32:38 +00:00
Matthias Braun bf4a869dfb CodeGenModule: Always output wchar_size, check LLVM assumptions.
llvm::TargetLibraryInfo needs to know the size of wchar_t to work on
functions like `wcslen`. This patch changes clang to always emit the
wchar_size module flag (it would only do so for ARM previously).
This also adds an `assert()` to ensure the LLVM defaults based on the
target triple are in sync with clang.

Differential Revision: https://reviews.llvm.org/D32982

llvm-svn: 303463
2017-05-19 22:37:15 +00:00
Richard Trieu cc6893736b [ODRHash] Revert r303450 to fix buildbot
r303450
[ODRHash] Support TemplateName and TemplateArgument

llvm-svn: 303459
2017-05-19 22:35:41 +00:00
Richard Smith 0a12b90c98 Do not issue -Wnullability-completeness for dependent types that are not written as pointer types.
llvm-svn: 303451
2017-05-19 20:20:13 +00:00
Richard Trieu d05a006a53 [ODRHash] Support TemplateName and TemplateArgument
llvm-svn: 303450
2017-05-19 20:05:16 +00:00
Richard Smith 74639b1900 When a type-id is unexpectedly given a name, assume that the name is unrelated
syntax unless we have a reason to think otherwise.

This improves error recovery in a couple of cases.

llvm-svn: 303398
2017-05-19 01:54:59 +00:00
Richard Smith f4f62003f4 When we enter a module within a linkage specification, switch the linkage
specification and the TU to the new module.

This is necessary to get the module ownership correct for entities that we
temporarily hang off the TranslationUnitDecl, such as template parameters and
function parameters.

llvm-svn: 303373
2017-05-18 19:34:55 +00:00
Richard Smith af3b325627 Fix the location of "missing ';'" suggestions after annotation tokens.
We were incorrectly setting PrevTokLocation to the first token in the
annotation token instead of the last when consuming it. To fix this without
adding a complex switch to the hot path through ConsumeToken, we now have a
ConsumeAnnotationToken function for consuming annotation tokens in addition
to the other Consume*Token special case functions.

llvm-svn: 303372
2017-05-18 19:21:48 +00:00
Yaxun Liu 6d96f16347 CodeGen: Cast alloca to expected address space
Alloca always returns a pointer in alloca address space, which may
be different from the type defined by the language. For example,
in C++ the auto variables are in the default address space. Therefore
cast alloca to the expected address space when necessary.

Differential Revision: https://reviews.llvm.org/D32248

llvm-svn: 303370
2017-05-18 18:51:09 +00:00
Alex Lorenz 6796c0b97f [index] Avoid one more crash caused by infinite recursion that happens when
looking up a dependent name in a record that derives from itself

rdar://32273000

Differential Revision: https://reviews.llvm.org/D33324

llvm-svn: 303366
2017-05-18 18:06:07 +00:00
Alex Lorenz e1e566d4df [index] Record references to class receivers used in property references
rdar://32250025

llvm-svn: 303343
2017-05-18 10:43:11 +00:00
Alexander Kornienko fd3e39846d Fix an assertion failure in FormatASTNodeDiagnosticArgument.
Summary:
The test being added in this patch used to cause an assertion failure:

/build/./bin/clang -cc1 -internal-isystem /build/lib/clang/5.0.0/include -nostdsysteminc -verify -fsyntax-only -std=c++11 -Wshadow-all /src/tools/clang/test/SemaCXX/warn-shadow.cpp
--
Exit Code: 134

Command Output (stderr):
--
clang: /src/tools/clang/lib/AST/ASTDiagnostic.cpp:424: void clang::FormatASTNodeDiagnosticArgument(DiagnosticsEngine::ArgumentKind, intptr_t, llvm::StringRef, llvm::StringRef, ArrayRef<DiagnosticsEngine::ArgumentValue>, SmallVectorImpl<char> &, void *, ArrayRef<intptr_t>): Assertion `isa<NamedDecl>(DC) && "Expected a NamedDecl"' failed.
#0 0x0000000001c7a1b4 PrintStackTraceSignalHandler(void*) (/build/./bin/clang+0x1c7a1b4)
#1 0x0000000001c7a4e6 SignalHandler(int) (/build/./bin/clang+0x1c7a4e6)
#2 0x00007f30880078d0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0xf8d0)
#3 0x00007f3087054067 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35067)
#4 0x00007f3087055448 abort (/lib/x86_64-linux-gnu/libc.so.6+0x36448)
#5 0x00007f308704d266 (/lib/x86_64-linux-gnu/libc.so.6+0x2e266)
#6 0x00007f308704d312 (/lib/x86_64-linux-gnu/libc.so.6+0x2e312)
#7 0x00000000035b7f22 clang::FormatASTNodeDiagnosticArgument(clang::DiagnosticsEngine::ArgumentKind, long, llvm::StringRef, llvm::StringRef, llvm::ArrayRef<std::pair<clang::DiagnosticsEngine::ArgumentKind, long> >, llvm::SmallVectorImpl<char>&, void*, llvm::ArrayRef<long>) (/build/
./bin/clang+0x35b7f22)
#8 0x0000000001ddbae4 clang::Diagnostic::FormatDiagnostic(char const*, char const*, llvm::SmallVectorImpl<char>&) const (/build/./bin/clang+0x1ddbae4)
#9 0x0000000001ddb323 clang::Diagnostic::FormatDiagnostic(char const*, char const*, llvm::SmallVectorImpl<char>&) const (/build/./bin/clang+0x1ddb323)
#10 0x00000000022878a4 clang::TextDiagnosticBuffer::HandleDiagnostic(clang::DiagnosticsEngine::Level, clang::Diagnostic const&) (/build/./bin/clang+0x22878a4)
#11 0x0000000001ddf387 clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&) const (/build/./bin/clang+0x1ddf387)
#12 0x0000000001dd9dea clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool) (/build/./bin/clang+0x1dd9dea)
#13 0x0000000002cad00c clang::Sema::EmitCurrentDiagnostic(unsigned int) (/build/./bin/clang+0x2cad00c)
#14 0x0000000002d91cd2 clang::Sema::CheckShadow(clang::NamedDecl*, clang::NamedDecl*, clang::LookupResult const&) (/build/./bin/clang+0x2d91cd2)

Stack dump:
0.      Program arguments: /build/./bin/clang -cc1 -internal-isystem /build/lib/clang/5.0.0/include -nostdsysteminc -verify -fsyntax-only -std=c++11 -Wshadow-all /src/tools/clang/test/SemaCXX/warn-shadow.cpp
1.      /src/tools/clang/test/SemaCXX/warn-shadow.cpp:214:23: current parser token ';'
2.      /src/tools/clang/test/SemaCXX/warn-shadow.cpp:213:26: parsing function body 'handleLinkageSpec'
3.      /src/tools/clang/test/SemaCXX/warn-shadow.cpp:213:26: in compound statement ('{}')
/build/tools/clang/test/SemaCXX/Output/warn-shadow.cpp.script: line 1: 15595 Aborted                 (core dumped) /build/./bin/clang -cc1 -internal-isystem /build/lib/clang/5.0.0/include -nostdsysteminc -verify -fsyntax-only -std=c++11 -Wshadow-all /src/tools/clang/test/SemaCXX/warn-shadow.cpp

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: krytarowski, cfe-commits

Differential Revision: https://reviews.llvm.org/D33207

llvm-svn: 303325
2017-05-18 03:02:15 +00:00
Richard Smith 54f0440c1f [modules] Switch from inferring owning modules based on source location to
inferring based on the current module at the point of creation.

This should result in no functional change except when building a preprocessed
module (or more generally when using #pragma clang module begin/end to switch
module in the middle of a file), in which case it allows us to correctly track
the owning module for declarations. We can't map from FileID to module in the
preprocessed module case, since all modules would have the same FileID.

There are still a couple of remaining places that try to infer a module from a
source location; I'll clean those up in follow-up changes.

llvm-svn: 303322
2017-05-18 02:29:20 +00:00
Nick Lewycky 9add1594d2 The constant expression evaluator should examine function arguments for non-constexpr function calls unless the EvalInfo says to stop.
llvm-svn: 303317
2017-05-17 23:56:54 +00:00
Alex Lorenz d47546612d [Lexer] Ensure that the token is not an annotation token when
retrieving the identifer info for an Objective-C keyword

This commit fixes an assertion that's triggered in getIdentifier when the token
is an annotation token.

rdar://32225463

llvm-svn: 303246
2017-05-17 11:08:36 +00:00
Richard Trieu ce81b194a0 [ODRHash] Support NestedNameSpecifier
llvm-svn: 303233
2017-05-17 03:23:35 +00:00
Richard Trieu 58bb7bd18a [ODRHash] Support more types in the ODR checker.
Added support for TagType, TypeWithKeyword, and all children types.

llvm-svn: 303231
2017-05-17 02:29:02 +00:00
Richard Smith 26342f915b [modules] When creating a declaration, cache its owning module immediately
rather than waiting until it's queried.

Currently this is only applied to local submodule visibility mode, as we don't
yet allocate storage for the owning module in non-local-visibility modules
compilations.


This reinstates r302965, reverted in r303037, with a fix for the reported
crash, which occurred when reparenting a local declaration to be a child of
a hidden imported declaration (specifically during template instantiation).

llvm-svn: 303224
2017-05-17 00:24:14 +00:00
Adrian Prantl 6fc8875739 Fix scope of namespaced DISubprograms when the function definition is out-of-line.
This fixes a regression introduced in r302915.

Using the lexical decl context is not necessary here for what r302915
wast trying to achieve. Not canonicalizing the NamespaceDecl in
getOrCreateNamespace is suficient.

rdar://problem/29339538

llvm-svn: 303222
2017-05-16 23:46:10 +00:00
Alex Lorenz d2b8aaa05a [index] Avoid another crash that happens when looking up a dependent name
in a record that has a base without a definition

rdar://32224197

llvm-svn: 303192
2017-05-16 17:33:17 +00:00
Alex Lorenz 6f91112051 [Sema] Avoid duplicate -Wunguarded-availability warnings in nested functions
rdar://31862310

llvm-svn: 303170
2017-05-16 13:58:53 +00:00
Alex Lorenz de69ff9b7c Fix PR 10758: Infinite recursion when dealing with copy-initialization
This commit fixes a bug that's tracked by PR 10758 and duplicates like PR 30343.
The bug causes clang to crash with a stack overflow while recursing infinitely
trying to perform copy-initialization on a type without a copy constructor but
with a constructor that accepts another type that can be constructed using the
original type.

The commit fixes this bug by detecting the recursive behavior and failing
correctly with an appropriate error message. It also tries to provide a
meaningful diagnostic note about the constructor which leads to this behavior.

rdar://28483944

Differential Revision: https://reviews.llvm.org/D25051

llvm-svn: 303156
2017-05-16 10:23:58 +00:00
Evgeniy Stepanov 5c3e07f78d [asan] One more test for -fsanitize-address-globals-dead-stripping.
llvm-svn: 303114
2017-05-15 20:43:48 +00:00
Alexey Bataev 2c84541a21 [OPENMP] Check DSA for variables captured by value.
Currently clang checks for default data sharing attributes only for
variables captured in OpenMP regions by reference. Patch adds checks for
variables captured by value.

llvm-svn: 303077
2017-05-15 16:26:15 +00:00
Yaxun Liu 4f33b3d396 [OpenCL] Emit function-scope variable in constant address space as static variable
Differential Revision: https://reviews.llvm.org/D32977

llvm-svn: 303072
2017-05-15 14:47:47 +00:00
Alex Lorenz 048c8a9e7f [index] References to fields from template instantiations should refer to
fields in base templates

rdar://32197158

llvm-svn: 303068
2017-05-15 14:26:22 +00:00
Alex Lorenz 4ab5193735 [index] Visit and store information about namespace alias declarations
rdar://32195226

llvm-svn: 303048
2017-05-15 10:56:31 +00:00
Alex Lorenz 57c4f648d1 [index] Store correct location for namespace nested name qualifiers
rdar://32195200

llvm-svn: 303046
2017-05-15 10:41:04 +00:00
Alex Lorenz 09653330bc [index] Avoid a crash that happens when looking up a dependent name
in a record that has no definition

rdar://32194921

llvm-svn: 303045
2017-05-15 10:20:39 +00:00
Faisal Vali 718b7457e8 Silence buildbots by tweaking an IR codegen test to be less specific w register names.
llvm-svn: 303030
2017-05-15 02:56:02 +00:00
Faisal Vali c3dbd7f270 [NFC] Remove some comments (IR aid) from a test file erroneous committed in r303026
llvm-svn: 303027
2017-05-15 01:54:02 +00:00
Faisal Vali 1ca2d9679b Fix PR32933: crash on lambda capture of VLA
https://bugs.llvm.org/show_bug.cgi?id=32933

Turns out clang wasn't really handling vla's (*) in C++11's for-range entirely correctly. 

For e.g. This would lead to generation of buggy IR:

  void foo(int b) {
    int vla[b];
    b = -1;  // This store would affect the '__end = vla + b'
    for (int &c : vla) 
      c = 0;
  }

Additionally, code-gen would get confused when VLA's were reference-captured by lambdas, and then used in a for-range, which would result in an attempt to generate IR for '__end = vla + b' within the lambda's body - without any capture of 'b' - hence the assertion.

This patch modifies clang, so that for VLA's it translates the end pointer approximately into:
  __end = __begin + sizeof(vla)/sizeof(vla->getElementType())

As opposed to the __end = __begin + b;

I considered passing a magic value into codegen - or having codegen special case the '__end' variable when it referred to a variably-modified type, but I decided against that approach, because it smelled like I would be increasing a complicated form of coupling, that I think would be even harder to maintain than the above approach (which can easily be optimized (-O1) to refer to the run-time bound that was calculated upon array's creation or copied into the lambda's closure object).


(*) why oh why gcc would you enable this by default?! ;)

llvm-svn: 303026
2017-05-15 01:49:19 +00:00
Sean Callanan 9092d4795d [ASTImporter] Improve handling of incomplete types
ASTImporter has some bugs when it's importing types 
that themselves come from an ExternalASTSource. This 
is exposed particularly in the behavior when 
comparing complete TagDecls with forward 
declarations. This patch does several things:

- Adds a test case making sure that conflicting 
  forward-declarations are resolved correctly;
- Extends the clang-import-test harness to test 
  two-level importing, so that we make sure we 
  complete types when necessary; and
- Fixes a few bugs I found this way. Failure to 
  complete types was one; however, I also discovered 
  that complete RecordDecls aren't properly added to 
  the redecls chain for existing forward 
  declarations.

llvm-svn: 302975
2017-05-13 00:46:33 +00:00
Simon Dardis e94124804e [Sema] Silence buildbot failures introduced by r302935
Attempt to silence buildbot failures by pinning the test to a given
triple rather than the host's triple.

llvm-svn: 302941
2017-05-12 19:55:32 +00:00
Teresa Johnson 517729fb20 Remove ignore-empty-index-file option
Summary:
Clang changes to remove this option and replace with a parameter
always set in the context of a ThinLTO distributed backend.

Depends on D33133.

Reviewers: pcc

Subscribers: mehdi_amini, eraman, cfe-commits

Differential Revision: https://reviews.llvm.org/D33134

llvm-svn: 302940
2017-05-12 19:32:17 +00:00
Simon Dardis 7cd5876e60 [Sema] Support implicit scalar to vector conversions
This patch teaches clang to perform implicit scalar to vector conversions
when one of the operands of a binary vector expression is a scalar which
can be converted to the element type of the vector without truncation
following GCC's implementation.

If the (constant) scalar is can be casted safely, it is implicitly casted to the
vector elements type and splatted to produce a vector of the same type.

Contributions from: Petar Jovanovic

Reviewers: bruno, vkalintiris

Differential Revision: https://reviews.llvm.org/D25866

llvm-svn: 302935
2017-05-12 19:11:06 +00:00
Alex Lorenz d43f75b54a [index] Index template specialization arguments for function templats
Also ensure that class template specialization arguments are covered

rdar://31812032

llvm-svn: 302918
2017-05-12 16:32:26 +00:00
James Y Knight eb96e44aea [SPARC] Support 'f' and 'e' inline asm constraints.
Patch by Patrick Boettcher.

Differential Revision: https://reviews.llvm.org/D29117

llvm-svn: 302913
2017-05-12 16:01:23 +00:00
Krzysztof Parzyszek 408b272a00 [Hexagon] Make sure to pass empty struct arguments with nontrivial ctors
Thanks to Richard Smith for the suggested fix.

This fixes llvm.org/PR33009

llvm-svn: 302895
2017-05-12 13:18:07 +00:00