Commit Graph

19442 Commits

Author SHA1 Message Date
Jordan Rose e600025528 [analyzer] Treat the rvalue of a forward-declared struct as Unknown.
This will never happen in the analyzed code code, but can happen for checkers
that over-eagerly dereference pointers without checking that it's safe.
UnknownVal is a harmless enough value to get back.

Fixes an issue added in r189590, caught by our internal buildbot.

llvm-svn: 189688
2013-08-30 19:17:26 +00:00
Fariborz Jahanian ff3476e499 ObjectiveC migrator: infer NS_ENUM even when user
specified NSUInteger as the followup typedef.
With this change, NS_OPTIONS is only inferred
based on looking up how enumerators are speficied
(if they her hexadecimal, power of 2, or have
 bitwise constant expressions).

llvm-svn: 189682
2013-08-30 17:46:01 +00:00
Benjamin Kramer ffecc84583 Add support for -march=slm, aka Intel Atom Silvermont.
llvm-svn: 189670
2013-08-30 14:05:34 +00:00
Hans Wennborg d024c1c803 clang-cl: Pass -incremental:no to linker when using ASan
llvm-svn: 189664
2013-08-30 10:50:52 +00:00
Yunzhong Gao 0ebf1bb150 Revert r189649 because it was breaking sanitizer bots.
llvm-svn: 189660
2013-08-30 08:53:09 +00:00
Pavel Labath 58934986f2 Sema: avoid reuse of Exprs when synthesizing operator=
Summary:
Previously, Sema was reusing parts of the AST when synthesizing an assignment
operator, turning it into a AS-dag. This caused problems for the static
analyzer, which assumed an expression appears in the tree only once.

Here I make sure to always create a fresh Expr, when inserting something into
the AST, fixing PR16745 in the process.

Reviewers: doug.gregor

CC: cfe-commits, jordan_rose

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

llvm-svn: 189659
2013-08-30 08:52:28 +00:00
Yunzhong Gao be8d7ba93a Fixing a bug where debug info for a local variable gets emitted at file scope.
The patch was discussed in Phabricator. See:
http://llvm-reviews.chandlerc.com/D1281

llvm-svn: 189649
2013-08-30 05:37:02 +00:00
Richard Smith 99bc1b99d3 Mention in AST dump whether a class declaration is a definition.
llvm-svn: 189647
2013-08-30 05:32:29 +00:00
Richard Smith a4ba74c5f5 Don't eagerly load all conversion operators when loading a class declaration
from a PCH/module.

llvm-svn: 189646
2013-08-30 04:46:40 +00:00
Charles Davis b5a214e4f3 Add ms_abi and sysv_abi attribute handling.
Based on a patch by Benno Rice!

llvm-svn: 189644
2013-08-30 04:39:01 +00:00
Eric Christopher 531cd4b278 Pass the special backend option to this test for now to get it passing
again.

This test should a) test IR or be moved, and b) get an actual option
for the dwarf pub sections.

llvm-svn: 189633
2013-08-30 00:52:06 +00:00
Richard Smith 9dd9f036c6 Map from local decl IDs to global decl IDs when lazily deserializing friend decl chains.
llvm-svn: 189629
2013-08-30 00:23:29 +00:00
Fariborz Jahanian a23f4fb5c9 ObjectiveC migrator: User of hexadecimal enumerator
should infer migration to NS_OPTIONS.

llvm-svn: 189628
2013-08-30 00:10:37 +00:00
Richard Smith 676c404dec Be lazier when loading KeyFunctions from PCH/modules. We don't need to load
these in eagerly if we're not actually processing a translation unit. The added
laziness here also avoids us loading in parts of a CXXRecordDecl earlier than an
upcoming class template specialization merging patch would like.

Ideally, we should mark the vtable as used when we see a definition for the key
function, rather than having a separate pass over dynamic classes at the end of
the TU. The existing approach is pretty bad for PCH/modules, since it forcibly
loads the declarations of all key functions in all imported modules, whether or
not those key functions are defined.

llvm-svn: 189627
2013-08-29 23:59:27 +00:00
Eli Friedman 0718591771 Adjust clang for change to APFloat::toString.
I changed the diagnostic printing code because it's probably better
to cut off a digit from DBL_MAX than to print something like
1.300000001 when the user wrote 1.3.

llvm-svn: 189625
2013-08-29 23:44:43 +00:00
Manman Ren e0064d8c24 Debug Info: generate a unique identifier for C++ struct, class, union, and enum.
We use CXX mangler to generate unique identifier for external C++ struct,
union, class and enum. Types with unique identifier are added to retained
types by DIBuilder.

Testing cases are updated to reflect the unique identifier generated for types.
The order of MDNodes is changed because of retained types and testing cases
are updated accordingly.

Testing case debug-info-uuid.cpp now emits error with Itanium mangler, since
uuid is not yet handled in Itanium mangler. And it will check for the error
message.

llvm-svn: 189622
2013-08-29 23:19:58 +00:00
DeLesley Hutchins b570c13574 Consumed analysis: track function parameters.
Patch by chris.wailes@gmail.com.

llvm-svn: 189616
2013-08-29 22:36:05 +00:00
DeLesley Hutchins 7fa60edb47 Consumed analysis: non-const methods no longer transfer an object into an
unknown state.  Patch by chris.wailes@gmail.com.

llvm-svn: 189612
2013-08-29 21:17:25 +00:00
Manman Ren f801f808ba Debug Info: this reverts commit r189600.
We had further discussions on how to retain types, whether to do it in front end
or in DIBuilder. And we agree to do it in DIBuilder so front ends
generating unique identifier do not need to worry about retaining them.

llvm-svn: 189609
2013-08-29 20:48:48 +00:00
Manman Ren 035c4b029f Debug Info: generate a unique identifier for C++ struct, class, union, and enum.
We use CXX mangler to generate unique identifier for external C++ struct,
union, class and enum. Types with unique identifier are added to RetainedTypes
to make sure they are treated as used even when all uses are replaced with
the identifiers.

A single type can be added to RetainedTypes multiple times. For example, both 
createForwardDecl and createLimitedType can add the same type to RetainedTypes.
A set is used to avoid duplication when updating AllRetainTypes in DIBuilder.

Testing cases are updated to reflect the unique identifier generated for types.
The order of MDNodes is changed because of retained types and testing cases
are updated accordingly.

Testing case debug-info-uuid.cpp now emits error with Itanium mangler, since
uuid is not yet handled in Itanium mangler.

We choose to update RetainedTypes in clang, then at finalize(), we update
AllRetainTypes in DIBuilder. The other choice is to update AllRetainTypes
in DIBuilder when creating a DICompositeType with unique identifier. This
option requires using ValueHandle for AllRetainTypes in DIBuilder since
the created DICompositeType can be modified later on by setContainingType etc.

llvm-svn: 189600
2013-08-29 18:51:51 +00:00
DeLesley Hutchins 5533ec5c55 Consumed analysis: improve handling of conditionals.
Patch by chris.wailes@gmail.com.

* The TestedVarsVisitor was folded into the ConsumedStmtVisitor.
* The VarTestResult class was updated to allow these changes.
* The PropagationInfo class was updated for the same reasons.
* Correctly handle short-circuiting of Boolean operations.
* Blocks are now marked as unreachable when we can statically prove we will
  never branch to them.
* Unreachable blocks are skipped by the analysis.

llvm-svn: 189594
2013-08-29 17:26:57 +00:00
NAKAMURA Takumi 5cbfb3b423 clang/test/Frontend/rewrite-includes.c: Tweak expressions for r'\\', not r'\', on win32.
llvm-svn: 189591
2013-08-29 16:11:17 +00:00
Pavel Labath 2c65dfaab5 [analyzer] Fix handling of "empty" structs with base classes
Summary:
RegionStoreManager had an optimization which replaces references to empty
structs with UnknownVal. Unfortunately, this check didn't take into account
possible field members in base classes.

To address this, I changed this test to "is empty and has no base classes". I
don't consider it worth the trouble to go through base classes and check if all
of them are empty.

Reviewers: jordan_rose

CC: cfe-commits

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

llvm-svn: 189590
2013-08-29 16:06:04 +00:00
Daniel Dunbar 14e88a1577 [tests] Use 'printf' instead of 'echo -e', which is not part of BSD echo.
llvm-svn: 189562
2013-08-29 03:02:39 +00:00
Eli Friedman 80e45b8cd4 Properly escape filenames in line directives.
Fixes PR17018.  Only partial test coverage because I don't want
to try to write a test which generates a file whose name contains a newline.

llvm-svn: 189557
2013-08-29 01:42:42 +00:00
Renato Golin 8d5f31432e use the last passed -munaligned-access / -mno-unaligned-access
Passing inconsistent munaligned-access / mno-unaligned-access
flags, intentionally resulted in a warning and the flag
no-unaligned-access being used.

Gcc does, at least in practice, use the last flag in such a
case. This patch updates clang behaviour accordingly; use the
last flag or base alignment behaviour on the target (which
llvm will do if no flag is explicitly passed)

Patch by Jeroen Hofstee.

llvm-svn: 189542
2013-08-28 23:56:07 +00:00
David Majnemer 8918920a32 Sema: Subst type default template args earlier
Summary:
We would not perform substitution at an appropriate point, allowing strange
results to appear. We would accepts things that we shouldn't or mangle things incorrectly.  Note that this hasn't fixed the other cases like
template-template parameters or non-type template parameters.

Reviewers: doug.gregor, rjmccall, rsmith

Reviewed By: rsmith

CC: cfe-commits

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

llvm-svn: 189540
2013-08-28 23:48:32 +00:00
Fariborz Jahanian 55d6e6c930 ObjectiveC migrator. This patch infers readonly properties for no-parameter
instance methods returning non-void. This will be quite noisy. So, it is 
placed under a new migrator flag -objcmt-migrate-readonly-property.

llvm-svn: 189537
2013-08-28 23:22:46 +00:00
Peter Collingbourne ec1cb850d1 Add missing definitions to unwind.h.
Original patch by Charles Davis.

llvm-svn: 189535
2013-08-28 23:16:49 +00:00
David Blaikie f2053af82c DebugInfo: Further fix/improvements to r189494 (and LLVM r189495).
Selfhosting was crashing with the same type of problem but involving
template specializations.

llvm-svn: 189530
2013-08-28 23:06:52 +00:00
Fariborz Jahanian 7dd7143a2b ObjectiveC migrator: In suggesting 'instancetype' use clang's
hasRelatedResultType() as it knows of methods which have
related result type by default. Such methods do not need
a redundant 'instancetype'.

llvm-svn: 189520
2013-08-28 21:23:00 +00:00
Manman Ren 27c22edde4 Debug Info testing case: update uuid testing case to check against Itanium.
Right now, the output for Itanium vs. Microsoft is the same. Once we start
calling mangler to get the unique identifier, this testing case will require
support for uuid mangling.

llvm-svn: 189518
2013-08-28 21:19:31 +00:00
Eli Friedman cefc7eafc6 Fix "//" comments with -traditional-cpp in C++.
Apparently, gcc's -traditional-cpp behaves slightly differently in C++ mode;
specifically, it discards "//" comments.  Match gcc's behavior.

<rdar://problem/14808126>

llvm-svn: 189515
2013-08-28 20:53:32 +00:00
Fariborz Jahanian 1a26c209f6 For methods where clang automatically infers instancetype from the selector
(e.g., all -init* methods), no need to suggest "instancetype" because it 
is redundant.

llvm-svn: 189514
2013-08-28 20:49:58 +00:00
Eli Friedman 2afb63c001 Handle -D arguments ending in a backslash.
We translate these into #define directives; to preserve gcc-compatible
semantics (where the expanded macro includes the backslash), we add
an extra "\\\n" to the end of the synthesized "#define".

<rdar://problem/14810220>

llvm-svn: 189511
2013-08-28 20:35:38 +00:00
Eli Friedman a31efa07ff Improve error for assignment to incomplete class.
PR7681.

llvm-svn: 189510
2013-08-28 20:35:35 +00:00
Manman Ren 404fbfedf8 Debug Info testing case: move uuid-related testing to a separate file.
Seperate the parts related to uuid from debug-info-template.cpp to
debug-info-uuid.cpp since Itanium mangler does not have support for mangling
uuid yet.

Remove -fms-extensions from RUN line of debug-info-template.cpp.
RUN line of debug-info-uuid.cpp has -fms-extensions and -cxx-abi microsoft.

llvm-svn: 189498
2013-08-28 18:31:02 +00:00
Hans Wennborg 0517e75164 clang-cl: Pass -debug to the linker when using -fsanitize=address
llvm-svn: 189496
2013-08-28 17:36:07 +00:00
Jordan Rose acd080b956 [analyzer] Add support for testing the presence of weak functions.
When casting the address of a FunctionTextRegion to bool, or when adding
constraints to such an address, use a stand-in symbol to represent the
presence or absence of the function if the function is weakly linked.
This is groundwork for possible simple availability testing checks, and
can already catch mistakes involving inverted null checks for
weakly-linked functions.

Currently, the implementation reuses the "extent" symbols, originally created
for tracking the size of a malloc region. Since FunctionTextRegions cannot
be dereferenced, the extent symbol will never be used for anything else.
Still, this probably deserves a refactoring in the future.

This patch does not attempt to support testing the presence of weak
/variables/ (global variables), which would likely require much more of
a change and a generalization of "region structure metadata", like the
current "extents", vs. "region contents metadata", like CStringChecker's
"string length".

Patch by Richard <tarka.t.otter@googlemail.com>!

llvm-svn: 189492
2013-08-28 17:07:04 +00:00
Pavel Labath fce1b03ee7 [analyzer] Assume new returns non-null even under -fno-exceptions
Summary:
-fno-exceptions does not implicitly attach a nothrow specifier to every operator
new. Even in this mode, non-nothrow new must not return a null pointer. Failure
to allocate memory can be signalled by other means, or just by killing the
program. This behaviour is consistent with the compiler - even with
-fno-exceptions, the generated code never tests for null (and would segfault if
the opeator actually happened to return null).

Reviewers: jordan_rose

CC: cfe-commits

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

llvm-svn: 189452
2013-08-28 08:04:08 +00:00
David Majnemer 8a0caa8525 Richard makes a good point, clean up this test.
llvm-svn: 189444
2013-08-28 05:45:53 +00:00
Hal Finkel 108c46a7bf Revert r189440 - Disable loop vectorizer unrolling when no unrolling requested
As Chandler pointed out, we should not be using -backend-option because this
will cause crashes for users of the tooling interface, etc. A better way to fix
this will be to provide the unrolling pass-manager flag to the loop vectorizer
directly.

Original commit message:

Disable loop vectorizer unrolling when no unrolling requested

In addition to the regular loop unrolling transformation, the loop vectorizer
can also unroll loops. If no unrolling has specifically been requested (by
-fno-unroll-loops), and the loop vectorizer will be used, then add the backend
option to (also) prevent the loop vectorizer from unrolling loops.

I confirmed with Nadav (off list) that disabling vectorizer loop unrolling when
-fno-unroll-loops is provided is the desired behavior.

llvm-svn: 189441
2013-08-28 05:21:45 +00:00
Hal Finkel 7d0867f48c Disable loop vectorizer unrolling when no unrolling requested
In addition to the regular loop unrolling transformation, the loop vectorizer
can also unroll loops. If no unrolling has specifically been requested (by
-fno-unroll-loops), and the loop vectorizer will be used, then add the backend
option to (also) prevent the loop vectorizer from unrolling loops.

I confirmed with Nadav (off list) that disabling vectorizer loop unrolling when
-fno-unroll-loops is provided is the desired behavior.

llvm-svn: 189440
2013-08-28 04:40:22 +00:00
David Majnemer 3425710cca Some of this test doesn't want -std=c++11
Sorry for the churn.

llvm-svn: 189429
2013-08-28 00:13:42 +00:00
David Majnemer af8795d46d This test now needs C++11
llvm-svn: 189425
2013-08-28 00:03:12 +00:00
David Majnemer 03f4ab7531 AST: Don't treat a TemplateExpansion as a Template
Summary:
Instead of calling getAsTemplate(), call
getAsTemplateOrTemplatePattern() because it handles the
TemplateExpansion case too.

This fixes PR16997.

Reviewers: doug.gregor, rsmith

Reviewed By: rsmith

CC: cfe-commits

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

llvm-svn: 189422
2013-08-28 00:00:27 +00:00
David Blaikie ebe87e1cfa Revert "PR14569: Omit debug info for thunks"
This reverts commit r189320.

Alexey Samsonov and Dmitry Vyukov presented some arguments for keeping
these around - though it still seems like those tasks could be solved by
a tool just using the symbol table. In a very small number of cases,
thunks may be inlined & debug info might be able to save profilers &
similar tools from misclassifying those cases as part of the caller.

The extra changes here plumb through the VarDecl for various cases to
CodeGenFunction - this provides better fidelity through a few APIs but
generally just causes the CGF::StartFunction to fallback to using the
name of the IR function as the name in the debug info.

The changes to debug-info-global-ctor-dtor.cpp seem like goodness. The
two names that go missing (in favor of only emitting those names as
linkage names) are names that can be demangled - emitting them only as
the linkage name should encourage tools to do just that.

Again, thanks to Dinesh Dwivedi for investigation/work on this issue.

llvm-svn: 189421
2013-08-27 23:57:18 +00:00
Reid Kleckner 78af0708b7 Delete CC_Default and use the target default CC everywhere
Summary:
Makes functions with implicit calling convention compatible with
function types with a matching explicit calling convention.  This fixes
things like calls to qsort(), which has an explicit __cdecl attribute on
the comparator in Windows headers.

Clang will now infer the calling convention from the declarator.  There
are two cases when the CC must be adjusted during redeclaration:
1. When defining a non-inline static method.
2. When redeclaring a function with an implicit or mismatched
convention.

Fixes PR13457, and allows clang to compile CommandLine.cpp for the
Microsoft C++ ABI.

Excellent test cases provided by Alexander Zinenko!

Reviewers: rsmith

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

llvm-svn: 189412
2013-08-27 23:08:25 +00:00
Fariborz Jahanian 63ffce2001 ObjectiveC migrator: Do not add explicit cf annotation for
cf functions which are CF_IMPLICIT_BRIDGING_ENABLED.
Add cf annotation to those not CF_IMPLICIT_BRIDGING_ENABLED
to reduce bridge casts.

llvm-svn: 189409
2013-08-27 22:42:30 +00:00
Roman Divacky 718fb1cdf9 Make the information about disabled ARCMT/Rewriter/StaticAnalyzer available
to lit and use this info to disable Analysis/FixIt/Rewriter/Analysis tests
when those are not compiled into clang.

llvm-svn: 189395
2013-08-27 19:27:35 +00:00