Commit Graph

70101 Commits

Author SHA1 Message Date
Yuka Takahashi 45244edfa2 [Bash-autocompletion] Add support for -std=
Summary:
Add support for autocompleting values of -std= by including
LangStandards.def. This patch relies on D36782, and is using two-stage
code generation.

Reviewers: v.g.vassilev, teemperor, ruiu

Subscribers: cfe-commits

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

llvm-svn: 311971
2017-08-29 02:01:56 +00:00
Richard Smith 2cd5604823 Improve constant expression evaluation of arrays of unknown bound.
The standard is not clear on how these are supposed to be handled, so we
conservatively treat as non-constant any cases whose value is unknown or whose
evaluation might result in undefined behavior.

llvm-svn: 311970
2017-08-29 01:52:13 +00:00
Yuka Takahashi 24bc6a4c4f Revert "Revert r311552: [Bash-autocompletion] Add support for static analyzer flags"
This reverts commit 7c46b80c022e18d43c1fdafb117b0c409c5a6d1e.

r311552 broke lld buildbot because I've changed OptionInfos type from
ArrayRef to vector. However the bug is fixed, so I'll commit this again.

llvm-svn: 311958
2017-08-29 00:09:31 +00:00
Alexander Shaposhnikov f1cfa039ae [analyzer] Adjust ptr arithmetic test
Replace "long" with __UINTPTR_TYPE__
to make the test added in rL311935 Windows-friendly.
Caught by the buildbot llvm-clang-x86_64-expensive-checks-win.

llvm-svn: 311947
2017-08-28 22:58:54 +00:00
Rui Ueyama 5ad6bdf2fd Remove trailing space.
llvm-svn: 311936
2017-08-28 21:38:14 +00:00
Alexander Shaposhnikov 18d77984fb [analyzer] Fix crash in modeling arithmetic
This diff fixes modeling of arithmetic 
expressions where pointers are treated as integers 
(i.e. via C-style / reinterpret casts).
For now we return UnknownVal unless the operation is a comparison.

Test plan: make check-all

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

llvm-svn: 311935
2017-08-28 21:15:21 +00:00
Michal Gorny 62dc83b9b7 Reland r311836 - [Driver] Use arch type to find compiler-rt libraries (on Linux)
Use llvm::Triple::getArchTypeName() when looking for compiler-rt
libraries, rather than the exact arch string from the triple. This is
more correct as it matches the values used when building compiler-rt
(builtin-config-ix.cmake) which are the subset of the values allowed
in triples.

For example, this fixes an issue when the compiler set for
i686-pc-linux-gnu triple would not find an i386 compiler-rt library,
while this is the exact arch that is detected by compiler-rt. The same
applies to any other i?86 variant allowed by LLVM.

This also makes the special case for MSVC unnecessary, since now i386
will be used reliably for all 32-bit x86 variants.

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

llvm-svn: 311923
2017-08-28 20:29:52 +00:00
Alexey Bataev f32ec1ab31 [OPENMP] Remove unused header files, NFC.
llvm-svn: 311908
2017-08-28 19:26:54 +00:00
Erich Keane 0a539b5859 Change Diagnostic Category size error from runtime to compiletime
Diagnostic Categories are fairly annoying, and are only enforced
by a runtime-debug-only assert. This puts in a touch more work
to get this all done at compile-time with static asserts

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

llvm-svn: 311905
2017-08-28 18:53:17 +00:00
Reid Kleckner ea2683ecb8 Fix inaccurate comment about -fdelayed-template-parsing and MSVC
llvm-svn: 311899
2017-08-28 17:59:24 +00:00
Hans Wennborg edd66ab9dc Revert r311857 "Emit static constexpr member as available_externally definition"
It caused PR759744.

> Emit static constexpr member as available_externally definition
>
> By exposing the constant initializer, the optimizer can fold many
> of these constructs.
>
> Differential Revision: https://reviews.llvm.org/D34992

llvm-svn: 311898
2017-08-28 17:53:00 +00:00
Alex Lorenz 595c644f84 Avoid missing std error code in RefactoringActionRulesTest.cpp
This should fix this bot:
http://bb.pgr.jp/builders/i686-mingw32-RA-on-linux

llvm-svn: 311886
2017-08-28 12:03:08 +00:00
Alex Lorenz 1586fa70a6 [refactor] initial support for refactoring action rules
This patch implements the initial support for refactoring action rules. The
first rule that's supported is a "source change" rule that returns a set of
atomic changes. This patch is based on the ideas presented in my RFC:

http://lists.llvm.org/pipermail/cfe-dev/2017-July/054831.html

The following pieces from the RFC are added by this patch:

- `createRefactoringRule` (known as `apply` in the RFC)
- `requiredSelection` refactoring action rule requirement.
- `selection::SourceSelectionRange` selection constraint.

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

llvm-svn: 311884
2017-08-28 11:12:05 +00:00
Peter Szecsi 0db84863d0 [StaticAnalyzer] LoopUnrolling: Keep track the maximum number of steps for each loop
This way the unrolling can be restricted for loops which will take at most a
given number of steps. It is defined as 128 in this patch and it seems to have
a good number for that purpose.

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

llvm-svn: 311883
2017-08-28 10:50:28 +00:00
Peter Szecsi d0604acd8e [StaticAnalyzer] LoopUnrolling: Excluding loops which splits the state
Added check if the execution of the last step of the given unrolled loop has
generated more branches. If yes, than treat it as a normal (non-unrolled) loop
in the remaining part of the analysis.

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

llvm-svn: 311881
2017-08-28 10:34:50 +00:00
Peter Szecsi d91554bc91 [StaticAnalyzer] LoopUnrolling fixes
1. The LoopUnrolling feature needs the LoopExit included in the CFG so added this
dependency via the config options
2. The LoopExit element can be encountered even if we haven't encountered the 
block of the corresponding LoopStmt. So the asserts were not right.
3. If we are caching out the Node then we get a nullptr from generateNode which
case was not handled.


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

llvm-svn: 311880
2017-08-28 10:21:24 +00:00
Gabor Horvath 857ccd2919 [analyzer][GSoC] Re-implemente current virtual calls checker in a path-sensitive way
Patch by: Xin Wang

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

llvm-svn: 311877
2017-08-28 08:44:43 +00:00
Craig Topper 2c03e53f4e [X86] Add support for __builtin_cpu_init
This adds builtin_cpu_init which will emit a call to cpu_indicator_init in libgcc or compiler-rt.

This is needed to support builtin_cpu_supports/builtin_cpu_is in an ifunc resolver.

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

llvm-svn: 311874
2017-08-28 05:43:23 +00:00
Richard Smith 8b633447da Add test for -Wc++17-compat warning for P0683R1.
llvm-svn: 311868
2017-08-28 00:31:35 +00:00
Richard Smith 6b8e3c02ca [c++2a] P0683R1: Permit default member initializers for bit-fields.
This would be trivial, except that our in-memory and serialized representations
for FieldDecls assumed that this can't happen.

llvm-svn: 311867
2017-08-28 00:28:14 +00:00
Johannes Altmanninger 41395022a3 [clang-diff] Treat CXXCtorInitializer as a node
Reviewers: arphaman

Subscribers: cfe-commits, klimek

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

llvm-svn: 311865
2017-08-27 22:52:20 +00:00
Michal Gorny 617e898dca Revert r311836 - [Driver] Use arch type to find compiler-rt libraries (on Linux)
This causes a breakage on the Android build bot. Let's revert it until
we figure out the correct solution there.

llvm-svn: 311861
2017-08-27 20:38:43 +00:00
Mehdi Amini 8e8f25b1a5 CMake: only try to find the Z3 package when `CLANG_ANALYZER_BUILD_Z3` is ON
This avoids the spurious message:

 Could NOT find Z3 (missing:  Z3_LIBRARIES Z3_INCLUDE_DIR) (Required is at least version "4.5")

llvm-svn: 311858
2017-08-27 20:24:23 +00:00
Mehdi Amini f23847604b Emit static constexpr member as available_externally definition
By exposing the constant initializer, the optimizer can fold many
of these constructs.

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

llvm-svn: 311857
2017-08-27 20:24:09 +00:00
Faisal Vali 55bc389aeb revert changes from r311851.
The right answers here (and how clang needs to be tweaked) require further analysis (ongoing cwg thread).

sorry.

llvm-svn: 311855
2017-08-27 19:00:08 +00:00
Sylvestre Ledru 6fd8839ab9 Fix two typos in the doc. Patch by kamleshbhalui on github
llvm-svn: 311854
2017-08-27 17:34:06 +00:00
Faisal Vali 5f5b29dd22 Don't see through 'using member-declarations' when determining the relation of any potential implicit object expression to the parent class of the member function containing the function call.
Prior to this patch clang would not error here:

  template <class T> struct B;
  
  template <class T> struct A {
    void foo();
    void foo2();
    
    void test1() {
      B<T>::foo();  // OK, foo is declared in A<int> - matches type of 'this'.
      B<T>::foo2(); // This should be an error!  
                    // foo2 is found in B<int>, 'base unrelated' to 'this'.
    }
  };

  template <class T> struct B : A<T> {
    using A<T>::foo2;
  };

llvm-svn: 311851
2017-08-27 16:49:47 +00:00
NAKAMURA Takumi 7103730a4d ClangCodeGenTests: Update libdeps.
llvm-svn: 311846
2017-08-27 11:46:05 +00:00
Vassil Vassilev bf411731bc Add forgotten file in r311844.
llvm-svn: 311845
2017-08-27 11:31:01 +00:00
Vassil Vassilev 3d05c56ef2 D34059: Get the file name for the symbol from the Module, not the SourceManager.
This allows multi-module / incremental compilation environments to have unique
initializer symbols.

Patch by Axel Naumann with minor modifications by me!

llvm-svn: 311844
2017-08-27 11:27:30 +00:00
Vassil Vassilev 4d54e543ab D34444: Teach codegen to work in incremental processing mode.
When isIncrementalProcessingEnabled is on we might want to produce multiple
llvm::Modules. This patch allows the clients to start a new llvm::Module,
allowing CodeGen to continue working after a HandleEndOfTranslationUnit call.

This should give the necessary facilities to write a unittest for D34059.

As discussed in the review this is meant to give us a way to proceed forward
in our efforts to upstream our interpreter-related patches. The design of this
will likely change soon.

llvm-svn: 311843
2017-08-27 10:58:03 +00:00
Faisal Vali 13624cf980 Pass the correct object argument when a member call to an 'unrelated' class is made.
Prior to this patch, clang would do the wrong thing here (see inline comments for pre-patch behavior):

  struct A {
    void bar(int) { }
    static void bar(double) { }
    
    void g(int*);
    static void g(char *);
  };


  struct B {
    void f() {
      A::bar(3);  // selects (double) ??!!
      A::g((int*)0); // Instead of no object argument, states conversion error?!!
    }
  };


The fix is as follows:  When we detect that what appears to be an implicit member function call (A::bar) is actually a call to a member of a class (A) unrelated to the type (B) that contains the member function (B::f) from which the call is being made, don't treat it (A::bar) as an Implicit Member Call Expression.

P.S. I wonder if there is an existing bug report related to this? (Surprisingly, a cursory search did not find one).

llvm-svn: 311839
2017-08-27 02:21:21 +00:00
Michal Gorny 1726459252 [Driver] Use arch type to find compiler-rt libraries (on Linux)
Use llvm::Triple::getArchTypeName() when looking for compiler-rt
libraries, rather than the exact arch string from the triple. This is
more correct as it matches the values used when building compiler-rt
(builtin-config-ix.cmake) which are the subset of the values allowed
in triples.

For example, this fixes an issue when the compiler set for
i686-pc-linux-gnu triple would not find an i386 compiler-rt library,
while this is the exact arch that is detected by compiler-rt. The same
applies to any other i?86 variant allowed by LLVM.

This also makes the special case for MSVC unnecessary, since now i386
will be used reliably for all 32-bit x86 variants.

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

llvm-svn: 311836
2017-08-26 21:35:11 +00:00
Richard Smith f667ad5f98 Add flag to request Clang is ABI-compatible with older versions of itself
This patch adds a flag -fclang-abi-compat that can be used to request that
Clang attempts to be ABI-compatible with some older version of itself.

This is provided on a best-effort basis; right now, this can be used to undo
the ABI change in r310401, reverting Clang to its prior C++ ABI for pass/return
by value of class types affected by that change, and to undo the ABI change in
r262688, reverting Clang to using integer registers rather than SSE registers
for passing <1 x long long> vectors. The intent is that we will maintain this
backwards compatibility path as we make ABI-breaking fixes in future.

The reversion to the old behavior for r310401 is also applied to the PS4 target
since that change is not part of its platform ABI (which is essentially to do
whatever Clang 3.2 did).

llvm-svn: 311823
2017-08-26 01:04:35 +00:00
Matt Morehouse 6ec7595b1e Revert "[SanitizeCoverage] Enable stack-depth coverage for -fsanitize=fuzzer"
This reverts r311801 due to a bot failure.

llvm-svn: 311803
2017-08-25 22:01:21 +00:00
Matt Morehouse f42bd31323 [SanitizeCoverage] Enable stack-depth coverage for -fsanitize=fuzzer
Summary:
- Don't sanitize __sancov_lowest_stack.
- Don't instrument leaf functions.
- Add CoverageStackDepth to Fuzzer and FuzzerNoLink.

Reviewers: vitalybuka, kcc

Reviewed By: kcc

Subscribers: cfe-commits, llvm-commits, hiraditya

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

llvm-svn: 311801
2017-08-25 21:18:29 +00:00
Kostya Serebryany d3e4b7e24a [sanitizer-coverage] extend fsanitize-coverage=pc-table with flags for every PC
llvm-svn: 311794
2017-08-25 19:29:47 +00:00
Daniel Jasper 4917af67b6 [Format] Invert nestingAndIndentLevel pair in WhitespaceManager used for
alignments

Indent should be compared before nesting level to determine if a token
is on the same scope as the one we align with. Because it was inverted,
clang-format sometimes tried to align tokens with tokens from outer
scopes, causing the assert(Shift >= 0) to fire.

This fixes bug #33507. Patch by Beren Minor, thank you!

llvm-svn: 311792
2017-08-25 19:14:53 +00:00
Nico Weber 524ae44dfa Fix typo in comment, no behavior change.
llvm-svn: 311790
2017-08-25 18:41:41 +00:00
Faisal Vali f241b0dcd6 [NFC] Remove a cstyle cast and replace some uses of Decl with NamedDecl during the processing of TemplateParameterLists.
llvm-svn: 311788
2017-08-25 18:24:20 +00:00
Vedant Kumar fd9fad9e02 [Frontend] Fix printing policy for AST context loaded from file
In ASTUnit::LoadFromASTFile, the context object is set up using
default-constructed LangOptions (which only later get populated). As the
language options are used in the constructor of PrintingPolicy, this
needs to be updated explicitly after the language options are available.

Patch by Johann Klähn!

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

llvm-svn: 311787
2017-08-25 18:07:03 +00:00
Alex Lorenz d9f1284009 [ObjC] Add a -Wobjc-messaging-id warning
-Wobjc-messaging-id is a new, non-default warning that warns about
message sends to unqualified id in Objective-C. This warning is useful
for projects that would like to avoid any potential future compiler
errors/warnings, as the system frameworks might add a method with the same
selector which could make the message send to id ambiguous.

rdar://33303354

llvm-svn: 311779
2017-08-25 16:12:17 +00:00
Alex Lorenz d0e27266d8 [Basic] Add a DiagnosticError llvm::ErrorInfo subclass
Clang's DiagnosticError is an llvm::Error payload that stores a partial
diagnostic and its location. I'll be using it in the refactoring engine.

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

llvm-svn: 311778
2017-08-25 15:48:00 +00:00
Alexey Bataev fdc2035373 [OPENMP] Fix for PR34321: ustom OpenMP reduction in C++ template causes
SEGFAULT at compile time

Compiler crashed when tried to rebuild non-template expression in
dependent context.

llvm-svn: 311777
2017-08-25 15:43:55 +00:00
Alex Lorenz 6cc8317c38 [IRGen] Evaluate constant static variables referenced through member
expressions

C++ allows us to reference static variables through member expressions. Prior to
this commit, non-integer static variables that were referenced using a member
expression were always emitted using lvalue loads. The old behaviour introduced
an inconsistency between regular uses of static variables and member expressions
uses. For example, the following program compiled and linked successfully:

struct Foo {
   constexpr static const char *name = "foo";
};
int main() {
  return Foo::name[0] == 'f';
}

but this program failed to link because "Foo::name" wasn't found:

struct Foo {
   constexpr static const char *name = "foo";
};
int main() {
  Foo f;
  return f.name[0] == 'f';
}

This commit ensures that constant static variables referenced through member
expressions are emitted in the same way as ordinary static variable references.

rdar://33942261

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

llvm-svn: 311772
2017-08-25 10:07:00 +00:00
Johannes Altmanninger bc3e993c1f [clang-diff] Remove NodeCountVisitor, NFC
Subscribers: klimek, cfe-commits

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

llvm-svn: 311770
2017-08-25 09:49:49 +00:00
Sylvestre Ledru cb0d604244 Remove the old meeting links. Also available from the link: http://llvm.org/devmtg/
llvm-svn: 311767
2017-08-25 08:47:57 +00:00
Sylvestre Ledru 29e2a589f1 clang also supports C++14 & 17 + remove trailing whitespaces
llvm-svn: 311766
2017-08-25 08:44:56 +00:00
Gor Nishanov 0f33300609 [coroutines] Support coroutine-handle returning await-suspend (i.e symmetric control transfer)
Summary:
If await_suspend returns a coroutine_handle, as in the example below:
```
  coroutine_handle<> await_suspend(coroutine_handle<> h) {
    coro.promise().waiter = h;
    return coro;
  }
```
suspensionExpression processing will resume the coroutine pointed at by that handle.
Related LLVM change rL311751 makes resume calls of this kind `musttail` at any optimization level.

This enables unlimited symmetric control transfer from coroutine to coroutine without blowing up the stack.

Reviewers: GorNishanov

Reviewed By: GorNishanov

Subscribers: rsmith, EricWF, cfe-commits

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

llvm-svn: 311762
2017-08-25 04:46:54 +00:00
Richard Smith 43670975dd Rename diagnostic groups from CXX1z to CXX17. No functionality change.
llvm-svn: 311758
2017-08-25 02:39:05 +00:00