Commit Graph

15623 Commits

Author SHA1 Message Date
Bernard Ogden 18b5701a68 ARM: Add -m[no-]crc to dis/enable CRC subtargetfeature from clang
Allow users to disable or enable CRC subtarget feature.

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

llvm-svn: 193600
2013-10-29 09:47:51 +00:00
Alp Toker a23d26607e Use Rewriter::overwriteChangedFiles() directly
This replaces the custom code in RefactoringTool::saveRewrittenFiles() which
lacked atomic file saving and error diagnostics, resolving an old FIXME from
r157331.

Landing this time with the proper return code, plus a very unhelpful comment
cleared up.

Rubber-stamped by Manuel Klimek.

llvm-svn: 193594
2013-10-29 08:32:41 +00:00
Alp Toker 54d5b55b0a Remove obsolete RewriteBuffer comment
The string buffer in question was replaced with RewriteRope in r43884
back in 2007.

llvm-svn: 193591
2013-10-29 07:47:57 +00:00
Nick Lewycky 2c531165ff Add missing attributes [[gnu::no_sanitize_address]] and
[[gnu::no_address_safety_analysis]].

llvm-svn: 193583
2013-10-29 03:54:41 +00:00
Nick Lewycky d0604672d9 Treat [[gnu::__const]] the same as [[gnu::const]]. GCC's tokenizer can't tell
the difference.

llvm-svn: 193582
2013-10-29 03:33:57 +00:00
Richard Smith a3feee2ad6 Allow a new syntax in a module requires-declaration:
requires ! feature

The purpose of this is to allow (for instance) the module map for /usr/include
to exclude <tgmath.h> and <complex.h> when building in C++ (these headers are
instead provided by the C++ standard library in this case, and the glibc C
<tgmath.h> header would otherwise try to include <complex.h>, resulting in a
module cycle).

llvm-svn: 193549
2013-10-28 22:18:19 +00:00
Richard Smith 426a47bddb Fix a parser crash when there are #pragmas in a context which requires a single
statement (after a case label, if, etc). Patch by Olivier Goffart!

llvm-svn: 193545
2013-10-28 22:04:30 +00:00
Benjamin Kramer 6b7500e1c3 Remove unused diagnostic.
llvm-svn: 193469
2013-10-26 10:12:33 +00:00
Fariborz Jahanian 7196487de9 ObjectiveC arc. Warn when an implicitly 'strong' property
is redeclared as 'weak' in class extension.
// rdar://15304886

llvm-svn: 193453
2013-10-26 00:35:39 +00:00
Fariborz Jahanian 5e3429c395 ObjectiveC: under -Wunused-property-ivar warn if property's
backing warning is not used in one of its accessor methods.
// rdar://14989999

llvm-svn: 193439
2013-10-25 21:44:50 +00:00
Jordan Rose 5565941eff Add -Wstring-plus-char, which warns when adding char literals to C strings.
Specifically, this warns when a character literal is added (using '+') to a
variable with type 'char *' (or any other pointer to character type). Like
-Wstring-plus-int, there is a fix-it to change "foo + 'a'" to "&foo['a']"
iff the character literal is on the right side of the string.

Patch by Anders Rönnholm!

llvm-svn: 193418
2013-10-25 16:52:00 +00:00
Daniel Jasper 33b909c5f3 clang-format: Adapt line break penalties for LLVM style.
Specifically make clang-format less eager to break after the opening
parenthesis of a function call.

Before:
  aaaaaaaaaaaaaaaaa(
      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

After:
  aaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
                        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
                    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

Apparently that is preferable. This penalties are adapted
conservatively, we might have to increase them a little bit further.

llvm-svn: 193410
2013-10-25 14:29:37 +00:00
David Majnemer 9adc361008 Sema: Do not allow lambda expressions to appear inside of constant expressions
We would previously not diagnose this which would lead to crashes (on
very strange code).

This fixes PR17675.

llvm-svn: 193397
2013-10-25 09:12:52 +00:00
Richard Trieu ef64e94d5c Simplify and refactor the uninitialized field warning.
Change the uninitialized field warnings so that field initializers are checked
inside the constructor.  Previously, in class initializers were checked
separately.  Running one set of checks also simplifies the logic for preventing
duplicate warnings.  Added new checks to warn when an uninitialized field is
used in base class initialization.  Also fixed misspelling of uninitialized
and moved all code for this warning together.

llvm-svn: 193386
2013-10-25 00:56:00 +00:00
Argyrios Kyrtzidis 0ac5837cab Revert "Tooling/ReplacementsYaml.h: Prune Tooling's llvm::yaml::ScalarTraits<std::string> corresponding to LLVM r193344."
This reverts commit r193350, because it addressed an llvm API change that has been reverted.

llvm-svn: 193353
2013-10-24 15:49:10 +00:00
NAKAMURA Takumi 0b59a430e5 Tooling/ReplacementsYaml.h: Prune Tooling's llvm::yaml::ScalarTraits<std::string> corresponding to LLVM r193344.
llvm-svn: 193346
2013-10-24 14:24:30 +00:00
Chandler Carruth 5998ee6b3d Teach Clang to accept and ignore -f[no-]implicit-templates.
This GCC flag is useful when you want to control whether implicit
template instantiation occurs at the commandline level. Clang doesn't
currently support such controls, but technically *always* implicitly
instantiating (what Clang does, and what every other compiler still in
use does by default) is valid behavior even under
-fno-implicit-templates, it just may be slow and very wasteful. If
people really want this, we can try to implement it, but I don't have an
actual use.

This should help fix the build of libstdc++ with Clang, its build system
uses this flag.

llvm-svn: 193319
2013-10-24 09:21:37 +00:00
Chandler Carruth 685dca5b0a Teach Clang to recognize and ignore GCC's -fdiagnostics-show-location
flag. We should probably wire at least some variants of this up to our
actual diagnostics engine, but I'm leaving that for someone else. This
fixes the builds of packages which hard code something here, at least
including libstdc++ itself.

llvm-svn: 193318
2013-10-24 09:17:35 +00:00
Manuel Klimek 1f76c4e810 Use the same SourceManager for ModuleMaps and compilations.
This allows using virtual file mappings on the original SourceManager to
map in virtual module.map files. Without this patch, the ModuleMap
search will find a module.map file (as the FileEntry exists in the
FileManager), but will be unable to get the content from the
SourceManager (as ModuleMap previously created its own SourceManager).

Two problems needed to be fixed which this patch exposed:

1. Storing the inferred module map
When writing out a module, the ASTWriter stores the names of the files
in the main source manager; when loading the AST again, the ASTReader
errs out if such a file is found missing, unless it is overridden.
Previously CompilerInstance's compileModule method would store the
inferred module map to a temporary file; the problem with this approach
is that now that the module map is handled by the main source manager,
the ASTWriter stores the name of the temporary module map as source to
the compilation; later, when the module is loaded, the temporary file
has already been deleted, which leads to a compilation error. This patch
changes the inferred module map to instead inject a virtual file into
the source manager. This both saves some disk IO, and works with how the
ASTWriter/ASTReader handle overridden source files.

2. Changing test input in test/Modules/Inputs/*
Now that the module map file is handled by the main source manager, the
VerifyDiagnosticConsumer will not ignore diagnostics created while
parsing the module map file. The module test test/Modules/renamed.m uses
-I test/Modules/Inputs and triggers recursive loading of all module maps
in test/Modules/Inputs, some of which had conflicting names, thus
leading errors while parsing the module maps. Those diagnostics already
occur on trunk, but before this patch they would not break the test, as
they were ignored by the VerifyDiagnosticConsumer. This patch thus
changes the module maps that have been recently introduced which broke
the invariant of compatible modules maps in test/Modules/Inputs.

llvm-svn: 193314
2013-10-24 07:51:24 +00:00
Richard Smith 66e7168f8d PR17666: Instead of allowing an initial identifier argument in any attribute
which we don't think can't have one, only allow it in the tiny number of
attributes which opts into this weird parse rule.

I've manually checked that the handlers for all these attributes can in fact
cope with an identifier as the argument. This is still somewhat terrible; we
should move more fully towards picking the parsing rules based on the
attribute, and make the Parse -> Sema interface more type-safe.

llvm-svn: 193295
2013-10-24 01:07:54 +00:00
Rafael Espindola e4865d2836 A decl never becomes unused. Make that explicit in the API.
llvm-svn: 193248
2013-10-23 16:46:34 +00:00
Faisal Vali c1a6dc4907 Refactor out the circular reference to LambdaExpr in CXXRecordDecl.
A prior commit of this patch was reverted because it was within the blamelist's purview of a failing test.  The failure of that test has been addressed here: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20131021/091546.html.  Therefore I am recommitting this patch (all tests pass on windows, except for the usual modules & index suspects that never pass on my box).

Some background: Both Doug and Richard had asked me in Chicago to remove the circular reference in CXXRecordDecl to LambdaExpr by factoring out and storing the needed information from LambdaExpr directly into CXXRecordDecl.
 
In addition, I have added an IsGenericLambda flag - this makes life a little easier when we implement capturing, and are Sema-analyzing the body of a lambda (and the calloperator hasn't been wired to the closure class yet). Any inner lambdas can have potential captures that could require walking up the scope chain and checking if any generic lambdas are capture-ready. This 'bit' makes some of that checking easier. 

No change in functionality.

This patch was approved by Doug with minor modifications (comments were cleaned up, and all data members were converted from bool/enum to unsigned, as requested): 
http://llvm-reviews.chandlerc.com/D1856

Thanks!

llvm-svn: 193246
2013-10-23 16:10:50 +00:00
Daniel Sanders ffd8df29b6 [mips][msa] Add intrinsics that map to pseudo-instructions.
Unlike the previously added intrinsics, these do not map to a single instruction
on MIPS32. They are provided for regularity (to round out the .[bhw] variants
of the same operation) and compatibility with GCC.

Includes:
  copy_[us].d, fill.d, insert.d, insve.d

llvm-svn: 193237
2013-10-23 10:12:44 +00:00
Rafael Espindola 09b00e34fa Revert r193223 and r193216.
They were causing CodeGenCXX/mangle-exprs.cpp to fail.

Revert "Remove the circular reference to LambdaExpr in CXXRecordDecl."

Revert "Again: Teach TreeTransform and family how to transform generic lambdas nested within templates and themselves."

llvm-svn: 193226
2013-10-23 04:12:23 +00:00
Faisal Vali 632fba3cb2 Remove the circular reference to LambdaExpr in CXXRecordDecl.
Both Doug and Richard had asked me to remove the circular reference in CXXRecordDecl to LambdaExpr by factoring out and storing the needed information from LambdaExpr directly into CXXRecordDecl.

No change in functionality. 

In addition, I have added an IsGenericLambda flag - this makes life a little easier when we implement capturing, and are Sema-analyzing the body of a lambda (and the calloperator hasn't been wired to the closure class yet). Any inner lambdas can have potential captures that could require walking up the scope chain and checking if any generic lambdas are capture-ready. This 'bit' makes some of that checking easier. 

This patch was approved by Doug with minor modifications (comments were cleaned up, and all data members were converted from bool/enum to unsigned, as requested): 
http://llvm-reviews.chandlerc.com/D1856

Thanks!

llvm-svn: 193223
2013-10-23 02:59:27 +00:00
Richard Smith fd8634a09d Make UsingShadowDecls redeclarable. This fixes some visibility problems with
modules.

With this fixed, I no longer see any test regressions in the libc++ test suite
when enabling a single-module module.map for libc++ (other than issues with my
system headers).

llvm-svn: 193219
2013-10-23 02:17:46 +00:00
Alp Toker dd551fc3ae Retain previous language linkage of friend function declarations
With this extension, friend function declarations will retain the language
linkage specified for previous declarations instead of emitting an error
diagnostic.

The feature is known to be compatible with GCC and MSVC and permits a
language to be specified indirectly where it cannot otherwise be written
directly in class scope.

Work is ongoing to improve linkage spec diagnostics.

Fixes PR17337.

Reviewed by Richard Smith.

llvm-svn: 193206
2013-10-22 22:53:01 +00:00
Richard Smith 6b53e224eb Split -fsanitize=bounds to -fsanitize=array-bounds (for the frontend-inserted
check using the ubsan runtime) and -fsanitize=local-bounds (for the middle-end
check which inserts traps).

Remove -fsanitize=local-bounds from -fsanitize=undefined. It does not produce
useful diagnostics and has false positives (PR17635), and is not a good
compromise position between UBSan's checks and ASan's checks.

Map -fbounds-checking to -fsanitize=local-bounds to restore Clang's historical
behavior for that flag.

llvm-svn: 193205
2013-10-22 22:51:04 +00:00
Rafael Espindola d53ffa0a70 Treat aliases as definitions.
This fixes pr17639.

Before this patch clang would consider

void foo(void) __attribute((alias("__foo")));

a declaration. It now correctly handles it as a definition.

Initial patch by Alp Toker. I added support for variables.

llvm-svn: 193200
2013-10-22 21:39:03 +00:00
Rafael Espindola 208b5c0fa5 New fix for pr17535.
This is a fixed version of r193161. In order to handle

    void foo() __attribute__((alias("bar")));
    void bar() {}
    void zed() __attribute__((alias("foo")));

it is not enough to delay aliases to the end of the TU, we have to do two
passes over them to find if they are defined or not.

This can be implemented by producing alias as we go and just doing the second
pass at the end. This has the advantage that other parts of clang that were
expecting alias to be processed in order don't have to be changed.

This patch also handles cyclic aliases.

llvm-svn: 193188
2013-10-22 19:26:13 +00:00
Chandler Carruth b3b8ea8007 Revert r193073 and the attempt to fix it in r193170.
This patch wasn't reviewed, and isn't correctly preserving the behaviors
relied upon by QT. I don't have a direct example of fallout, but it
should go through the standard code review process. For example, it
should never have removed the QT test case that was added when fixing
those users.

llvm-svn: 193174
2013-10-22 18:07:04 +00:00
Rafael Espindola 6956d58722 Revert "This patch causes clang to reject alias attributes that point to undefined names. For example, with this patch we now reject"
This reverts commit r193161.

It broke

void foo() __attribute__((alias("bar")));
void bar() {}
void zed() __attribute__((alias("foo")));

Looks like we have to fix pr17639 first :-(

llvm-svn: 193162
2013-10-22 14:23:09 +00:00
Rafael Espindola 0fad0d7724 This patch causes clang to reject alias attributes that point to undefined
names. For example, with this patch we now reject

void f1(void) __attribute__((alias("g1")));

This patch is implemented in CodeGen. It is quiet a bit simpler and more
compatible with gcc than implementing it in Sema. The downside is that the
errors only fire during -emit-llvm.

llvm-svn: 193161
2013-10-22 13:51:06 +00:00
Daniel Jasper 97da9178ce Allow a header to be part of multiple modules.
This patch changes two things:

a) Allow a header to be part of multiple modules. The reasoning is that
in existing codebases that have a module-like build system, the same
headers might be used in several build targets. Simple reasons might be
that they defined different classes that are declared in the same
header. Supporting a header as a part of multiple modules will make the
transistion easier for those cases. A later step in clang can then
determine whether the two modules are actually compatible and can be
merged and error out appropriately. The later check is similar to what
needs to be done for template specializations anyway.

b) Allow modules to be stored in a directory tree separate from the
headers they describe.

Review: http://llvm-reviews.chandlerc.com/D1951
llvm-svn: 193151
2013-10-22 08:09:47 +00:00
David Majnemer 766e259e38 Sema: Do not allow template declarations inside local classes
Summary:
Enforce the rule in C++11 [temp.mem]p2 that local classes cannot have
member templates.

This fixes PR16947.

N.B.  C++14 has slightly different wording to afford generic lambdas
declared inside of functions.

Fun fact:  Some formulations of local classes with member templates
would cause clang to crash during Itanium mangling, such as the
following:

void outer_mem() {
  struct Inner {
    template <typename = void>
    struct InnerTemplateClass {
      static void itc_mem() {}
    };
  };
  Inner::InnerTemplateClass<>::itc_mem();
}

Reviewers: eli.friedman, rsmith, doug.gregor, faisalv

Reviewed By: doug.gregor

CC: cfe-commits, ygao

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

llvm-svn: 193144
2013-10-22 04:14:18 +00:00
Reid Kleckner 9171f02528 Revert "Refactor DynTypedMatcher into a value type class, just like Matcher<T>."
This reverts commit r193100.

It was failing to compile with MSVC 2012 while instantiating
llvm::Optional<DynTypedMatcher>.

llvm-svn: 193123
2013-10-21 22:26:36 +00:00
Chad Rosier c2a0b13c25 [AArch64] Add the constraint to NEON scalar mla/mls instructions.
llvm-svn: 193118
2013-10-21 20:12:01 +00:00
Rafael Espindola 2a1c07a5fb Ignore -fstrength-reduce and -fno-strength-reduce.
GCC does the same.

llvm-svn: 193103
2013-10-21 18:49:56 +00:00
Samuel Benzaquen f46e5f1c9a Refactor DynTypedMatcher into a value type class, just like Matcher<T>.
Summary:
Refactor DynTypedMatcher into a value type class, just like Matcher<T>.
This simplifies its usage and removes the virtual hierarchy from Matcher<T>.
It also enables planned changes to replace MatcherInteface<T>.
Too many instantiaions of this class hierarchy has been causing Registry.cpp.o to bloat in size and number of symbols.

Reviewers: klimek

CC: cfe-commits, revane

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

llvm-svn: 193100
2013-10-21 18:40:51 +00:00
Rafael Espindola 0840214c84 Cleanup redundant include.
Patch by Daniel Marjamäki.

llvm-svn: 193093
2013-10-21 17:34:39 +00:00
Matheus Almeida 70fbf77546 [mips][msa] Fix definition of SLD instruction.
The second parameter of the SLD intrinsic is the number of columns (GPR) to 
slide left the source array.

llvm-svn: 193076
2013-10-21 11:47:56 +00:00
Silviu Baranga f9671dd09d Add the __ARM_ARCH_EXT_IDIV__ predefine. It is set to 1 if we have hardware divide in the mode that we are compiling in (depending on the target features), not defined if we don't. Should be compatible with the GCC conterpart. Also adding a -hwdiv option to overide the default behavior.
llvm-svn: 193074
2013-10-21 10:54:53 +00:00
Serge Pavlov 6652921d5a Fix to PR8880 (clang dies processing a for loop).
Due to statement expressions supported as GCC extension, it is possible
to put 'break' or 'continue' into a loop/switch statement but outside its
body, for example:

    for ( ; ({ if (first) { first = 0; continue; } 0; }); )

Such usage must be diagnosed as an error, GCC rejects it. To recognize
this and similar patterns the flags BreakScope and ContinueScope are
temporarily turned off while parsing condition expression.

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

llvm-svn: 193073
2013-10-21 09:34:44 +00:00
Daniel Jasper ac42b75195 Expose -fmodule-name and -fmodule-map-file as driver options.
Review: http://llvm-reviews.chandlerc.com/D1974
llvm-svn: 193069
2013-10-21 06:34:34 +00:00
David Majnemer 67900f0c63 [-fms-extensions] __is_interface_class was miscategorized
We claimed that the __is_interface_class keyword was KEYCXX even though
the __interface keyword was KEYMS.

llvm-svn: 193065
2013-10-21 04:55:56 +00:00
David Majnemer e29296e48c Be more precise when diagnosing 'inline' on global replacement functions
llvm-svn: 193061
2013-10-21 00:22:03 +00:00
Peter Collingbourne b453cd64a7 Implement function type checker for the undefined behavior sanitizer.
This uses function prefix data to store function type information at the
function pointer.

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

llvm-svn: 193058
2013-10-20 21:29:19 +00:00
Alp Toker 67b47ac0a7 Fix crash in cleanup attr handling
ResolveSingleFunctionTemplateSpecialization() returns 0 and doesn't emit diags
unless the expression has template-ids, so we must null check the result.

Also add a better diag noting which overloads are causing the problem.

Reviewed by Aaron Ballman.

llvm-svn: 193055
2013-10-20 18:48:56 +00:00
Benjamin Kramer 2501f14197 Miscellaneous speling fixes.
llvm-svn: 193046
2013-10-20 11:47:15 +00:00
David Majnemer ad51f1bc70 Sema: Diagnose global replacement functions declared as inline
This fixes PR17591.

N.B. This actually goes beyond what the standard mandates by requiring
the restriction to hold for declarations instead of definitions.  This
is believed to be a defect in the standard and an LWG issue has been
submitted.

llvm-svn: 193044
2013-10-20 05:40:29 +00:00