Commit Graph

17510 Commits

Author SHA1 Message Date
Ehsan Akhgari 81f36b712f clang-cl: Add support for the /o option for object files, executables, and preprocessor output
Summary:
cl.exe recognizes /o as a deprecated and undocumented option similar to
/Fe.  This patch adds support for this option to clang-cl for /Fe, /Fo
and /Fi.  It also ensures that the last option among /o and /F* wins,
if both specified.

This is required at least for building autoconf based software, since
autoconf uses -o to specify the executable output.

This fixes http://llvm.org/PR20894.

Test Plan: The patch includes automated tests.

Reviewers: rnk

Subscribers: cfe-commits

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

llvm-svn: 217615
2014-09-11 18:16:21 +00:00
Benjamin Kramer 22c68ef845 Avoid some unnecessary SmallVector copies.
No functionality change.

llvm-svn: 217586
2014-09-11 14:13:49 +00:00
DeLesley Hutchins 4e38f100b5 Thread Safety Analysis: major update to thread safety TIL.
Numerous changes, including:
  * Changed the way variables and instructions are handled in basic blocks to
    be more efficient.
  * Eliminated SExprRef.
  * Simplified futures.
  * Fixed documentation.
  * Compute dominator and post dominator trees.

llvm-svn: 217556
2014-09-10 22:12:52 +00:00
Ben Langmuir 5418f40127 Avoid a couple of assertions when preprocessing with modules
1. We were hitting the NextIsPrevious assertion because we were trying
to merge decl chains that were independent of each other because we had
no Sema object to allow them to find existing decls. This is fixed by
delaying loading the "preloaded" decls until Sema is available.

2. We were trying to get identifier info from an annotation token, which
asserts.  The fix is to special-case the module annotations in the
preprocessed output printer.

Fixed in a single commit because when you hit 1 you almost invariably
hit 2 as well.

llvm-svn: 217550
2014-09-10 21:29:41 +00:00
Daniel Jasper b87899b567 clang-format: Add option to allow short case labels on a single line.
On a single line:
  switch (a) {
  case 1: x = 1; return;
  case 2: x = 2; return;
  default: break;
  }

Not on a single line:
  switch (a) {
  case 1:
    x = 1;
    return;
  case 2:
    x = 2;
    return;
  default:
    break;
  }

This partly addresses llvm.org/PR16535. In the long run, we probably want to
lay these out in columns.

llvm-svn: 217501
2014-09-10 13:11:45 +00:00
Craig Topper b8a7053055 Unique_ptrify PPCallbacks ownership.
Unique_ptr creation stil needs to be moved earlier at some of the call sites.

llvm-svn: 217474
2014-09-10 04:53:53 +00:00
Fariborz Jahanian 6485fe4b07 Objective-C. Under a special flag, -Wcstring-format-directive,
off by default, issue a warning if %s directive is used in
certain CF/NS formatting APIs, to assist user in deprecating
use of such %s in these APIs. rdar://18182443

llvm-svn: 217467
2014-09-09 23:10:54 +00:00
Daniel Jasper 23376259c0 clang-format: [JS] Support regex literals with trailing escaped slash.
Before:
  var regex = / a\//; int i;

After:
  var regex = /a\//;
  int i;

This required pushing the Lexer into its wrapper class and generating a
new one in this specific case. Otherwise, the sequence get lexed as a
//-comment. This is hacky, but I don't know a better way (short of
supporting regex literals in the Lexer).

Pushing the Lexer down seems to make all the call sites simpler.

llvm-svn: 217444
2014-09-09 14:37:39 +00:00
Benjamin Kramer efffbee024 Tooling: Ignore file names in tooling::deduplicate.
This was horribly broken due to how the sort predicate works. We would
report a conflict for files with a replacement in the same position but
different names if the length differed. Just ignore paths as this is often
what the user wants. Files can occur with different names (due to symlinks
or relative paths) and we don't ever want to do the same edit in one file
twice.

llvm-svn: 217439
2014-09-09 13:53:29 +00:00
Alexey Samsonov 8e1162c71d Implement nonnull-attribute sanitizer
Summary:
This patch implements a new UBSan check, which verifies
that function arguments declared to be nonnull with __attribute__((nonnull))
are actually nonnull in runtime.

To implement this check, we pass FunctionDecl to CodeGenFunction::EmitCallArgs
(where applicable) and if function declaration has nonnull attribute specified
for a certain formal parameter, we compare the corresponding RValue to null as
soon as it's calculated.

Test Plan: regression test suite

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits, rnk

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

llvm-svn: 217389
2014-09-08 17:22:45 +00:00
Ben Langmuir ab86fbe425 Make FileEntry::getName() valid across calls to FileManager::getFile()
Because we may change the name of a FileEntry inside getFile, the name
returned by FileEntry::getName() could be destroyed.  This was causing a
use-after-free when searching the HeaderFileInfo on-disk hashtable for a
module or pch.

llvm-svn: 217385
2014-09-08 16:15:54 +00:00
Hal Finkel bcc06085a8 Add __builtin_assume and __builtin_assume_aligned using @llvm.assume.
This makes use of the recently-added @llvm.assume intrinsic to implement a
__builtin_assume(bool) intrinsic (to provide additional information to the
optimizer). This hooks up __assume in MS-compatibility mode to mirror
__builtin_assume (the semantics have been intentionally kept compatible), and
implements GCC's __builtin_assume_aligned as assume((p - o) & mask == 0). LLVM
now contains special logic to deal with assumptions of this form.

llvm-svn: 217349
2014-09-07 22:58:14 +00:00
Hans Wennborg c597b4c529 MS format strings: parse the 'Z' printf conversion specifier (PR20808)
llvm-svn: 217326
2014-09-07 03:03:51 +00:00
Chandler Carruth 2949e548f4 [x86] Clean up the x86 builtin specs to reflect r217310 in LLVM which
made the 8-bit masks actually 8-bit arguments to these intrinsics.

These builtins are a mess. Many were missing the I qualifier which
I added where obviously correct. Most aren't tested, but I've updated
the relevant tests. I've tried to catch all the things that should
become 'c' in this round.

It's also frustrating because the set of these is really ad-hoc and
doesn't really map that cleanly to the set supported by either GCC or
LLVM. Oh well...

llvm-svn: 217311
2014-09-06 10:30:51 +00:00
Richard Smith efa6f736e6 Add error, recovery and fixit for "~A::A() {...}".
llvm-svn: 217302
2014-09-06 02:06:12 +00:00
Nico Weber 728894340f Add -Wunused-local-typedef, a warning that finds unused local typedefs.
The warning warns on TypedefNameDecls -- typedefs and C++11 using aliases --
that are !isReferenced(). Since the isReferenced() bit on TypedefNameDecls
wasn't used for anything before this warning it wasn't always set correctly,
so this patch also adds a few missing MarkAnyDeclReferenced() calls in
various places for TypedefNameDecls.

This is made a bit complicated due to local typedefs possibly being used only
after their local scope has closed. Consider:

    template <class T>
    void template_fun(T t) {
      typename T::Foo s3foo;  // YYY
      (void)s3foo;
    }
    void template_fun_user() {
      struct Local {
        typedef int Foo;  // XXX
      } p;
      template_fun(p);
    }

Here the typedef in XXX is only used at end-of-translation unit, when YYY in
template_fun() gets instantiated. To handle this, typedefs that are unused when
their scope exits are added to a set of potentially unused typedefs, and that
set gets checked at end-of-TU. Typedefs that are still unused at that point then
get warned on. There's also serialization code for this set, so that the
warning works with precompiled headers and modules. For modules, the warning
is emitted when the module is built, for precompiled headers each time the
header gets used.

Finally, consider a function using C++14 auto return types to return a local
type defined in a header:

    auto f() {
      struct S { typedef int a; };
      return S();
    }

Here, the typedef escapes its local scope and could be used by only some
translation units including the header. To not warn on this, add a
RecursiveASTVisitor that marks all delcs on local types returned from auto
functions as referenced. (Except if it's a function with internal linkage, or
the decls are private and the local type has no friends -- in these cases, it
_is_ safe to warn.)

Several of the included testcases (most of the interesting ones) were provided
by Richard Smith.

(gcc's spelling -Wunused-local-typedefs is supported as an alias for this
warning.)

llvm-svn: 217298
2014-09-06 01:25:55 +00:00
Richard Smith 091405d7e3 Reword switch/goto diagnostics "protected scope" diagnostics. Making up a term
"protected scope" is very unhelpful here and actively confuses users. Instead,
simply state the nature of the problem in the diagnostic: we cannot jump from
here to there. The notes explain nicely why not.

llvm-svn: 217293
2014-09-06 00:24:58 +00:00
Samuel Benzaquen 7ec2cb2fda Separate the matchers by type and statically dispatch to the right list.
Summary:
Separate the matchers by type and statically dispatch to the right list.
For any node type that we support, it reduces the number of matchers we
run it through.
For node types we do not support, it makes match() a noop.
This change improves our clang-tidy related benchmark by ~30%.

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 217274
2014-09-05 20:15:31 +00:00
James Molloy 163b1ba471 [ARMv8] Add support for 32-bit MIN/MAXNM and directed rounding.
This patch adds support for the 32bit numeric max/min and directed round-to-integral NEON intrinsics that were added as part of v8, along with unit tests.

Patch by Graham Hunter!

llvm-svn: 217242
2014-09-05 13:50:34 +00:00
David Blaikie bc48abf43d Fix comment indentation.
llvm-svn: 217209
2014-09-05 00:07:20 +00:00
David Blaikie b564d1fb43 unique_ptrify ExplodedGraph::trim
llvm-svn: 217208
2014-09-05 00:04:19 +00:00
David Blaikie 7c35f6194f unique_ptrify the result of ConstraintManagerCreator and StoreManagerCreator
llvm-svn: 217206
2014-09-04 23:54:37 +00:00
David Blaikie 91e7902622 unique_ptrify BugReporter::visitors
llvm-svn: 217205
2014-09-04 23:54:33 +00:00
Hans Wennborg 93dbeae0f7 Don't allow inline asm statements to reference parameters in naked functions
Differential Revision: http://reviews.llvm.org/D5183

llvm-svn: 217200
2014-09-04 22:16:48 +00:00
Hans Wennborg d62cdd2c14 Don't allow non-ASM statements in naked functions
Naked functions don't have prologues or epilogues, so doing
codegen for anything other than inline assembly would be completely
hit or miss.

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

llvm-svn: 217199
2014-09-04 22:16:40 +00:00
Richard Smith 8d082d187e PR20844: If we fail to list-initialize a reference, map to the referenced type
before retrying the initialization to produce diagnostics. Otherwise, we may
fail to produce any diagnostics, and silently produce invalid AST in a -Asserts
build. Also add a note to this codepath to make it more clear why we were
trying to create a temporary.

llvm-svn: 217197
2014-09-04 22:13:39 +00:00
Hans Wennborg 68f42b9515 MS format strings: support the 'w' length modifier (PR20808)
llvm-svn: 217195
2014-09-04 21:39:46 +00:00
Daniel Jasper 4db69bd542 clang-format: [JS] Support alternative operator names as identifiers.
Before:
  not. and . or . not_eq = 1;

After:
  not.and.or.not_eq = 1;

llvm-svn: 217179
2014-09-04 18:23:42 +00:00
David Blaikie c11bf80265 unique_ptrify JobList::Jobs
llvm-svn: 217168
2014-09-04 16:04:28 +00:00
David Blaikie ba97c37ccd Fix the clang -Werror build after r217152 by flagging a polymorphically used but statically owned hierarchy with a protected base dtor and final classes to satisfy -Wnon-virtual-dtor
llvm-svn: 217167
2014-09-04 16:01:24 +00:00
Samuel Benzaquen ab005ed0c0 Refactor VariantMatcher::MatcherOps to reduce the amount of generated code.
Summary:
Refactor VariantMatcher::MatcherOps to reduce the amount of generated code.
 - Make some code type agnostic and move it to the cpp file.
 - Return a DynTypedMatcher instead of storing the object in MatcherOps.

This change reduces the number of symbols generated in Registry.cpp by
~19%, the object byte size by ~17% and the compilation time (in non-release mode) by ~20%.

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

llvm-svn: 217152
2014-09-04 14:13:58 +00:00
Manuel Klimek 94ad0bf10d Add matcher for linkage specification
Patch by Jacques Pienaar.

llvm-svn: 217135
2014-09-04 08:51:06 +00:00
Richard Smith f463436d9c [modules] Make NamespaceAliasDecl redeclarable, as it should be. This fixes
merging of namespace aliases across modules and improves source fidelity.
Incidentally also fixes PR20816.

llvm-svn: 217103
2014-09-03 23:11:22 +00:00
Nico Weber 2a9b6aae9a Fix indentation. No behavior change.
llvm-svn: 217044
2014-09-03 15:28:00 +00:00
Benjamin Kramer 7ab8476c15 ASTMatchers: Add a matcher to detect whether a decl or stmt is inside a template instantiation.
This is hoisted from clang-tidy where it's used everywhere. The implementation
is not particularly efficient right now, but there is no easy fix for that.

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

llvm-svn: 217029
2014-09-03 12:08:14 +00:00
Benjamin Kramer a39beb9dd6 Parse: Replace polymorphic functor objects with lambdas and llvm::function_ref.
No change in functionality.

llvm-svn: 217025
2014-09-03 11:06:10 +00:00
Daniel Jasper db986eb6bb clang-format: Add an option 'SpaceAfterCStyleCast'.
This permits to add a space after closing parenthesis of a C-style cast.
Defaults to false to preserve old behavior.

Fixes llvm.org/PR19982.

Before:
  (int)i;

After:
  (int) i;

Patch by Marek Kurdej.

llvm-svn: 217022
2014-09-03 07:37:29 +00:00
Richard Smith 73b21d8fa1 [modules] Use DeclContext::equals rather than == on DeclContext* when
determining whether a declaration is out of line, instead of assuming
that the semantic and lexical DeclContext will be the same declaration
whenever they're the same entity.

This fixes behavior of declarations within merged classes and enums.

llvm-svn: 217008
2014-09-03 02:33:22 +00:00
Reid Kleckner be80f6d901 Add --analyze to clang-cl
llvm-svn: 216964
2014-09-02 21:35:28 +00:00
Craig Topper bf3e32705a Fix some cases where StringRef was being passed by const reference. Remove const from some other StringRefs since its implicitly const already.
llvm-svn: 216825
2014-08-30 16:55:52 +00:00
Craig Topper 8c2a2a0f82 Use llvm::makeArrayRef instead of explicitly calling ArrayRef constructor and mentioning the type. This works now that we have a conversion from ArrayRef<T*> to ArrayRef<const T*>.
llvm-svn: 216824
2014-08-30 16:55:39 +00:00
David Blaikie 02118cedd5 unique_ptrify PTHManager's PerIDCache using the newly added llvm::FreeDeleter
llvm-svn: 216786
2014-08-29 22:04:45 +00:00
David Blaikie 60e836ba99 unique_ptrify some parameters to PTHManager::PTHManager
A couple of these arguments were passed by void* as a rather extreme
example of pimpling. Adjusting this to a more classic form of the idiom
(involving forward declarations) makes this more legible and allows
explicit passing of ownership via std::unique_ptr.

llvm-svn: 216785
2014-08-29 22:04:40 +00:00
David Blaikie eb62b822e3 unique_ptrify the raw_ostream argument to clang::serialized_diags::create
llvm-svn: 216767
2014-08-29 20:17:13 +00:00
David Blaikie 53dd8fea69 unique_ptrify clang::ento::createCheckerManager
llvm-svn: 216765
2014-08-29 20:11:03 +00:00
David Blaikie c9950cb1dd unique_ptrify PathDiagnosticConsumer::HandlePathDiagnostic
FoldingSet, another intrusive data structure that could use some
unique_ptr love on its interfaces. Eventually.

llvm-svn: 216764
2014-08-29 20:06:10 +00:00
Anna Zaks d5478fdd8f Add an option to silence all analyzer warnings.
People have been incorrectly using "-analyzer-disable-checker" to
silence analyzer warnings on a file, when analyzing a project. Add
the "-analyzer-disable-all-checks" option, which would allow the
suppression and suggest it as part of the error message for
"-analyzer-disable-checker". The idea here is to compose this with
"--analyze" so that users can selectively opt out specific files from
static analysis.

llvm-svn: 216763
2014-08-29 20:01:38 +00:00
David Blaikie 43e3717bdb unique_ptrify thep passing of BugReports to BugReportEquivClass
I suspect llvm::ilist should take elements by unique_ptr, since it does
take ownership of the element (by stitching it into the linked list) -
one day.

llvm-svn: 216761
2014-08-29 19:57:52 +00:00
David Blaikie 09844adc41 unique_ptrify HeaderMap::FileBuffer
llvm-svn: 216758
2014-08-29 19:51:32 +00:00
David Blaikie 6d5038c19c unique_ptrify Preprocessor's TokenLexerCache
llvm-svn: 216756
2014-08-29 19:36:52 +00:00