Commit Graph

17442 Commits

Author SHA1 Message Date
Nico Weber 8bf410fafa Call ResolveExceptionSpec for non-OdrUsed functions.
In C++11, instantiation of exception specs is deferred. The instantiation is
done in MarkFunctionReferenced(), which wasn't called for non-OdrUsed functions,
which then caused an assert in codegen. Fixes PR19190, see the bug for details.

llvm-svn: 216562
2014-08-27 17:04:39 +00:00
Oliver Stannard ed8ecc8429 Allow __fp16 as a function arg or return type for AArch64
ACLE 2.0 allows __fp16 to be used as a function argument or return
type. This enables this for AArch64.

This also fixes an existing bug that causes clang to not allow
homogeneous floating-point aggregates with a base type of __fp16. This
is valid for AAPCS64, but not for AAPCS-VFP.

llvm-svn: 216558
2014-08-27 16:31:57 +00:00
Ted Kremenek 49d8ce03ce Use unique_ptr instead of OwningPtr. I'm not certain how this compiled.
llvm-svn: 216552
2014-08-27 15:30:35 +00:00
Ted Kremenek eeccb30b94 Add support for the static analyzer to synthesize function implementations from external model files.
Currently the analyzer lazily models some functions using 'BodyFarm',
which constructs a fake function implementation that the analyzer
can simulate that approximates the semantics of the function when
it is called.  BodyFarm does this by constructing the AST for
such definitions on-the-fly.  One strength of BodyFarm
is that all symbols and types referenced by synthesized function
bodies are contextual adapted to the containing translation unit.
The downside is that these ASTs are hardcoded in Clang's own
source code.

A more scalable model is to allow these models to be defined as source
code in separate "model" files and have the analyzer use those
definitions lazily when a function body is needed.  Among other things,
it will allow more customization of the analyzer for specific APIs
and platforms.

This patch provides the initial infrastructure for this feature.
It extends BodyFarm to use an abstract API 'CodeInjector' that can be
used to synthesize function bodies.  That 'CodeInjector' is
implemented using a new 'ModelInjector' in libFrontend, which lazily
parses a model file and injects the ASTs into the current translation
unit.  

Models are currently found by specifying a 'model-path' as an
analyzer option; if no path is specified the CodeInjector is not
used, thus defaulting to the current behavior in the analyzer.

Models currently contain a single function definition, and can
be found by finding the file <function name>.model.  This is an
initial starting point for something more rich, but it bootstraps
this feature for future evolution.

This patch was contributed by Gábor Horváth as part of his
Google Summer of Code project.

Some notes:

- This introduces the notion of a "model file" into
  FrontendAction and the Preprocessor.  This nomenclature
  is specific to the static analyzer, but possibly could be
  generalized.  Essentially these are sources pulled in
  exogenously from the principal translation.

  Preprocessor gets a 'InitializeForModelFile' and
  'FinalizeForModelFile' which could possibly be hoisted out
  of Preprocessor if Preprocessor exposed a new API to
  change the PragmaHandlers and some other internal pieces.  This
  can be revisited.

  FrontendAction gets a 'isModelParsingAction()' predicate function
  used to allow a new FrontendAction to recycle the Preprocessor
  and ASTContext.  This name could probably be made something
  more general (i.e., not tied to 'model files') at the expense
  of losing the intent of why it exists.  This can be revisited.

- This is a moderate sized patch; it has gone through some amount of
  offline code review.  Most of the changes to the non-analyzer
  parts are fairly small, and would make little sense without
  the analyzer changes.

- Most of the analyzer changes are plumbing, with the interesting
  behavior being introduced by ModelInjector.cpp and
  ModelConsumer.cpp.

- The new functionality introduced by this change is off-by-default.
  It requires an analyzer config option to enable.

llvm-svn: 216550
2014-08-27 15:14:15 +00:00
Oliver Stannard 2bfdc5b517 Move some ARM-specific code from CGCall.cpp to TargetInfo.cpp
This tidies up some ARM-specific code added by r208417 to move it out
of the target-independent parts of clang into TargetInfo.cpp. This
also has the advantage that we can now flatten struct arguments to
variadic AAPCS functions.

llvm-svn: 216535
2014-08-27 10:43:15 +00:00
Craig Topper 5fc8fc2d31 Simplify creation of a bunch of ArrayRefs by using None, makeArrayRef or just letting them be implicitly created.
llvm-svn: 216528
2014-08-27 06:28:36 +00:00
Craig Topper 3cb91b2ad1 Fix some cases were ArrayRefs were being passed by reference.
llvm-svn: 216527
2014-08-27 06:28:16 +00:00
Justin Bogner ce46adb4f8 Driver: Restore -fkeep-inline-functions as an ignored flag
Several options were moved to the clang_ignored_gcc_optimization group
in r213365, but -fkeep-inline-functions was accidentally dropped. This
restores the flag.

Patch by Steven Wu. Thanks!

llvm-svn: 216522
2014-08-27 05:12:35 +00:00
Richard Smith 588bd9b7f8 Fix representation of __attribute__((nonnull)) to support correctly modeling
the no-arguments case. Don't expand this to an __attribute__((nonnull(A, B,
C))) attribute, since that does the wrong thing for function templates and
varargs functions.

In passing, fix a grammar error in the diagnostic, a crash if
__attribute__((nonnull(N))) is applied to a varargs function,
a bug where the same null argument could be diagnosed multiple
times if there were multiple nonnull attributes referring to it,
and a bug where nonnull attributes would not be accumulated correctly
across redeclarations.

llvm-svn: 216520
2014-08-27 04:59:42 +00:00
Rafael Espindola 16e1ba1e0b Return a std::unique_ptr from getBufferForFile. NFC.
llvm-svn: 216478
2014-08-26 20:17:44 +00:00
Reid Kleckner 64ecbe22aa Ignore -fdevirtualize and -fdevirtualize-speculatively for gcc compat
llvm-svn: 216477
2014-08-26 19:57:01 +00:00
Rafael Espindola 6406f7b8e0 Return a std::unique_ptr from getBufferForFile. NFC.
llvm-svn: 216476
2014-08-26 19:54:40 +00:00
Joerg Sonnenberger a43604ad50 Convert MC command line flag for fatal assembler warnings into a proper
flag.

llvm-svn: 216472
2014-08-26 18:40:25 +00:00
Yi Kong 1d268af094 ARM: Add dbg builtin intrinsic
llvm-svn: 216452
2014-08-26 12:48:06 +00:00
Daniel Jasper ad981f888a clang-format: New option SpacesInSquareBrackets.
Before:
  int a[5];
  a[3] += 42;

After:
  int a[ 5 ];
  a[ 3 ] += 42;

Fixes LLVM bug #17887 (http://llvm.org/bugs/show_bug.cgi?id=17887).

Patch by Marek Kurdej, thank you!

llvm-svn: 216449
2014-08-26 11:41:14 +00:00
Richard Smith 43ccec8e53 [modules] Track the described template in an alias declaration that is the
pattern of an alias template declaration. Use this to merge alias templates
properly when they're members of class template specializations.

llvm-svn: 216437
2014-08-26 03:52:16 +00:00
Fariborz Jahanian 4229228389 Objective-C. Allow [super initialize] in an +initialize
implementation but not anywhere else.
rdar://16628028

llvm-svn: 216408
2014-08-25 21:27:38 +00:00
Fariborz Jahanian be7bf7285b Objective-C modernization. Convert -initWithUTF8String messaging
with auto-boxing syntax for literals. rdar://18080352

llvm-svn: 216405
2014-08-25 20:22:25 +00:00
Rafael Espindola dae941a6c8 Update for llvm api change.
llvm-svn: 216397
2014-08-25 18:17:04 +00:00
Will Dietz dff50cbe26 ASTVector: Fix return value of various insert() methods.
Error caught using -fsanitize=pointer-overflow.

Expand ASTVectorTest to verify basic behavior,
test fails without functionality in this patch.

llvm-svn: 216385
2014-08-25 16:09:51 +00:00
Manuel Klimek 3fe8a38110 Add hasAttr matcher for declarations.
Delete special-case CUDA attribute matchers.

Patch by Jacques Pienaar.

llvm-svn: 216379
2014-08-25 11:23:50 +00:00
Nikola Smiljanic 92516a8e7a PR20716 - Crash when recovering from type in known dependent base.
llvm-svn: 216352
2014-08-24 23:28:47 +00:00
Richard Smith 88ebade8d9 [modules] When merging a tag declaration that has a typedef name for linkage
purposes, look for other typedefs with that same name and merge into their
named tag declaration if there is one.

llvm-svn: 216312
2014-08-23 01:45:27 +00:00
Fariborz Jahanian 4bf437ecd8 Objective-C. Warn when @encode'ing provides an incomplete
type encoding because in certain cases, such as for vector
types, because we still haven't designed encoding for them.
rdar://9255564

llvm-svn: 216301
2014-08-22 23:17:52 +00:00
Hans Wennborg 0dac192d77 Ignore -Wunsupported-dll-base-class-template by default
The situation it is warning about (see PR20725) is not very likely
to be a real problem, and it is unclear what action the user should take
if the warning does fire.

llvm-svn: 216283
2014-08-22 20:33:18 +00:00
Fariborz Jahanian 78e9debf68 Objective-C. Warn if user has made explicit call
to +initilize as this results in an extra call
to this method. rdar://16628028

llvm-svn: 216271
2014-08-22 16:57:26 +00:00
Reid Kleckner efd1375f2a -fms-extensions: Alias _intNN to __intNN
Fixes build for SPEC 2000 CPU. MSVC disables these aliases under /Za,
which enables stricter standards compliance. We don't currently have any
way to disable them.

Patch by Kevin Smith!

llvm-svn: 216270
2014-08-22 16:52:57 +00:00
Akira Hatanaka 987f1864ca [AArch64, inline-asm] Improve diagnostic that is printed when the size of a
variable that has regiser constraint "r" is not 64-bit.

General register operands are output using 64-bit "x" register names, regardless
of the size of the variable, unless the asm operand is prefixed with the "%w"
modifier. This surprises and confuses many users who aren't familiar with
aarch64 inline assembly rules.

With this commit, a note and fixit hint are printed which tell the users that
they need modifier "%w" in order to output a "w" register instead of an "x"
register.

<rdar://problem/12764785>

llvm-svn: 216260
2014-08-22 06:05:21 +00:00
David Majnemer 118da50a2a MS ABI: Don't use the Itanium scheme for numbering lambdas
The Itanium ABI will give out the same mangling number for two different
lambdas if their call operators have different types.  The MS ABI cannot
do the same because it does not mangle the return type into it's
lambdas.

This fixes PR20719.

llvm-svn: 216259
2014-08-22 04:22:50 +00:00
Richard Smith 1f15fd489e Fix grammatical error in diagnostic.
llvm-svn: 216221
2014-08-21 20:43:52 +00:00
Tom Stellard f414fb75b0 Driver: Implement -cl-denorms-are-zero
This is currently a no-op, which is allowed by the OpenCL specification.

llvm-svn: 216179
2014-08-21 13:58:36 +00:00
Fariborz Jahanian 19c2e2fab2 Objective-C [qoi]. Provide fix-it hint when sending
class method to an object receiver. rdar://16263395

llvm-svn: 216038
2014-08-19 23:39:17 +00:00
Aaron Ballman dd69ef38db C++1y is now C++14!
Changes diagnostic options, language standard options, diagnostic identifiers, diagnostic wording to use c++14 instead of c++1y. It also modifies related test cases to use the updated diagnostic wording.

llvm-svn: 215982
2014-08-19 15:55:55 +00:00
Rafael Espindola e8337304f3 Move the body out of line to try to fix a buildbot.
llvm-svn: 215980
2014-08-19 14:36:35 +00:00
Rafael Espindola aca3be852a Go back to having a takeModule instead of a getModule.
Returning a std::unique_ptr is more constrained. Thanks to David Blaikie for the
suggestion.

llvm-svn: 215979
2014-08-19 14:32:16 +00:00
Alexander Musman 3aaab669c8 [OPENMP] Extract common superclass from all the loop directives. No functional changes (having common superclass is convenient for future loop directives CodeGen implementation)
llvm-svn: 215975
2014-08-19 11:27:13 +00:00
Rafael Espindola a296664479 Update for llvm api change.
llvm-svn: 215968
2014-08-19 04:04:30 +00:00
Nico Weber f69cba649e Add a warning flag for an existing diagnostic.
One more, and the number of flags without a dedicated flag fits in two decimal
digits :-)

llvm-svn: 215946
2014-08-18 23:02:03 +00:00
Rafael Espindola 5cd06f26ae Store std::unique_ptr in InMemoryBuffers. NFC.
llvm-svn: 215928
2014-08-18 19:16:31 +00:00
Rafael Espindola 2346a37599 return a std::unique_ptr from getMainBufferWithPrecompiledPreamble. NFC.
llvm-svn: 215927
2014-08-18 18:47:08 +00:00
Rafael Espindola e0f6d88678 Use std::unique_ptr to simplify this code a bit.
llvm-svn: 215926
2014-08-18 18:33:41 +00:00
Rafael Espindola b694a0d5c5 Inline function into only use.
llvm-svn: 215925
2014-08-18 18:17:32 +00:00
Rafael Espindola 32482080fe Simplify ASTUnit::Parse a bit by passing a std::unique_ptr to it.
llvm-svn: 215900
2014-08-18 16:23:45 +00:00
Craig Topper 4dd9b43c8d Repace SmallPtrSet with SmallPtrSetImpl in function arguments to avoid needing to mention the size.
llvm-svn: 215869
2014-08-17 23:49:53 +00:00
Rafael Espindola 1a1b1562e6 Use std::unique_ptr in a few methods that take ownership.
llvm-svn: 215864
2014-08-17 23:12:27 +00:00
Rafael Espindola 04ab21d75d Convert a few ownership comments with std::unique_ptr.
llvm-svn: 215853
2014-08-17 22:12:58 +00:00
Ben Langmuir fe971d9894 When loading a module with no local entities, still bump the size of the
tables that correspond to ContinuousRangeMaps, since the keys to those
maps need to be unique, or we may map to the wrong offset.

This fixes a crash + malformed AST file seen when loading some modules
that import Cocoa on Darwin, which is a module with no contents except
imports of other modules. Unfortunately I have not been able to find a
reduced test case that reproduces this problem.

Also add an assert that we aren't mapping one key to multiple values
in CRM.  We ought to be able to say there are no duplicate keys at all,
but there are a bunch of 0 -> 0 mappings that are showing up, probably
coming from the source location table.

llvm-svn: 215810
2014-08-16 04:54:18 +00:00
Argyrios Kyrtzidis ac3997eb52 [libclang] Introduce clang_File_isEqual for comparing CXFile handles.
llvm-svn: 215796
2014-08-16 00:26:19 +00:00
Nico Weber ccec9d8cee Add a RAII class for saving and restoring instantiations and uses. No behavior change.
llvm-svn: 215780
2014-08-15 22:29:14 +00:00
James Dennett 64fa12372c Typo fix in comments: definintion -> definition
llvm-svn: 215764
2014-08-15 20:04:40 +00:00