Commit Graph

75374 Commits

Author SHA1 Message Date
Artem Dergachev 69ece336b8 [analyzer] Fix a crash on casting symbolic pointers to derived classes.
Commit r340984 causes a crash when a pointer to a completely unrelated type
UnrelatedT (eg., opaque struct pattern) is being casted from base class BaseT to
derived class DerivedT, which results in an ill-formed region
Derived{SymRegion{$<UnrelatedT x>}, DerivedT}.

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

llvm-svn: 343051
2018-09-26 00:17:14 +00:00
Erik Pilkington 707c0ab755 Fix a bot failure from r343042.
llvm-svn: 343050
2018-09-25 23:52:29 +00:00
Artem Dergachev e527df03c4 [analyzer] Add a testing facility for testing relationships between symbols.
Tests introduced in r329780 was disabled in r342317 because these tests
were accidentally testing dump infrastructure, when all they cared about was
how symbols relate to each other. So when dump infrastructure changed,
tests became annoying to maintain.

Add a new feature to ExprInspection: clang_analyzer_denote() and
clang_analyzer_explain(). The former adds a notation to a symbol, the latter
expresses another symbol in terms of previously denoted symbols.

It's currently a bit wonky - doesn't print parentheses and only supports
denoting atomic symbols. But it's even more readable that way.

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

llvm-svn: 343048
2018-09-25 23:50:53 +00:00
Kristina Brooks 3ff0777064 [clang-check-codegen][cfstring] Accept either @ or % for progbits to make ppc64be bots happy.
PPC64BE bots use % instead of @ for directives like progbits. Since CFString tests also
check asm output, they fail on the following:

  cfstring3.c:44:19: error: CHECK-ASM-ELF: expected string not found in input
  // CHECK-ASM-ELF: .section cfstring,"aw",@progbits
  <stdin>:30:2: note: possible intended match here
  .section cfstring,"aw",%progbits

Updating that check with a {{[@%]}}progbits regex to make those bots happy.
 

llvm-svn: 343044
2018-09-25 23:17:09 +00:00
Erik Pilkington b794aec290 [Sema] Use a more civilized hash map to implement -Wduplicate-enum.
DenseMap<long, SOMETHING> used LONG_MAX as a tombstone, so it asserts
when you try to insert it!

rdar://44774672

llvm-svn: 343042
2018-09-25 22:53:06 +00:00
Richard Smith 4e966e8135 Don't emit "will be treated as an identifier character" warning for
UTF-8 characters that aren't identifier characters in the current
language mode.

llvm-svn: 343040
2018-09-25 22:34:45 +00:00
Kristina Brooks 34e24d5b6a Reland "[Clang][CodeGen][ObjC]: Fix CoreFoundation on ELF with `-fconstant-cfstrings`"
Relanding rL342883 with more fragmented tests to test ELF-specific
section emission separately from broad-scope CFString tests. Now this
tests the following separately

1). CoreFoundation builds and linkage for ELF while building it.
2). CFString ELF section emission outside CF in assembly output.
3). Broad scope `cfstring3.c` tests which cover all object formats at
    bitcode level and assembly level (including ELF). 

This fixes non-bridged CoreFoundation builds on ELF targets
that use -fconstant-cfstrings. The original changes from differential 
for a similar patch to PE/COFF (https://reviews.llvm.org/D44491) did not
check for an edge case where the global could be a constant which surfaced
as an issue when building for ELF because of different linkage semantics.

This patch addresses several issues with crashes related to CF builds on ELF
as well as improves data layout by ensuring string literals that back
the actual CFConstStrings end up in .rodata in line with Mach-O.

Change itself tested with CoreFoundation on Linux x86_64 but should be valid
for BSD-like systems as well that use ELF as the native object format.

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

llvm-svn: 343038
2018-09-25 22:27:40 +00:00
Artem Dergachev 0b7fdca640 [analyzer] NFC: CallDescription: Improve array management.
Combine the two constructor overrides into a single ArrayRef constructor
to allow easier brace initializations and simplify how the respective field
is used internally.

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

llvm-svn: 343037
2018-09-25 22:13:31 +00:00
Richard Smith 5c9b3b7576 P0969R0: allow structured binding of accessible members, not only public members.
llvm-svn: 343036
2018-09-25 22:12:44 +00:00
Artem Dergachev 579cf90367 [analyzer] NFC: Legalize state manager factory injection.
When a checker maintains a program state trait that isn't a simple list/set/map, but is a combination of multiple lists/sets/maps (eg., a multimap - which may be implemented as a map from something to set of something), ProgramStateManager only contains the factory for the trait itself. All auxiliary lists/sets/maps need a factory to be provided by the checker, which is annoying.

So far two checkers wanted a multimap, and both decided to trick the
ProgramStateManager into keeping the auxiliary factory within itself
by pretending that it's some sort of trait they're interested in,
but then never using this trait but only using the factory.

Make this trick legal. Define a convenient macro.

One thing that becomes apparent once all pieces are put together is that
these two checkers are in fact using the same factory, because the type that
identifies it, ImmutableMap<const MemRegion *, ImmutableSet<SymbolRef>>,
is the same. This situation is different from two checkers registering similar
primitive traits.

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

llvm-svn: 343035
2018-09-25 22:10:12 +00:00
Alexey Bataev 3dfc993437 Revert "[DRIVER][OFFLOAD] Do not invoke unbundler on unsupported file
types."

It reverts commit r342991 + several other commits intended to fix the
tests. Still have some failed tests, need to investigate it.

llvm-svn: 343002
2018-09-25 18:31:56 +00:00
Alexey Bataev a55471138d [OPENMP] Fix the test, NFC.
Fixed test to pacify buildbot.

llvm-svn: 342996
2018-09-25 17:58:08 +00:00
Alexey Bataev 99de44bc54 [OPENMP] Fix failed test, NFC.
llvm-svn: 342995
2018-09-25 17:47:53 +00:00
Alexey Bataev 464ab241e7 [DRIVER][OFFLOAD] Do not invoke unbundler on unsupported file types.
clang-offload-bundler should not be invoked with the unbundling action
when the input file type does not match the action type. For example,
.so files should be unbundled during linking phase and should be linked
only with the host code.

llvm-svn: 342991
2018-09-25 17:09:17 +00:00
Tri Vo 28e7e60ea4 [AArch64] Support adding X[8-15,18] registers as CSRs.
Summary:
Making X[8-15,18] registers call-saved is used to support
CONFIG_ARM64_LSE_ATOMICS in Linux kernel.

Signed-off-by: Tri Vo <trong@android.com>

Reviewers: srhines, nickdesaulniers, javed.absar

Reviewed By: nickdesaulniers

Subscribers: kristof.beyls, jfb, cfe-commits

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

llvm-svn: 342990
2018-09-25 16:48:40 +00:00
Hans Wennborg 934230c061 [clang-cl] Provide separate flags for all the /O variants
This provides better help text in "clang-cl /?".

Also it cleans things up a bit: previously "/Od" could be handled either
as a separate flag aliased to "-O0", or by the main optimization flag
processing in TranslateOptArg. With this patch, all the flags get
aliased back to /O so they're handled by TranslateOptArg.

Thanks to Nico for the idea!

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

llvm-svn: 342977
2018-09-25 14:10:26 +00:00
Eric Liu 0da443556d [VFS] Add a proxy FS that delegates calls to underlying FS by default.
Summary:
This is useful when derived file systems want to override some calls
and still proxy other calls.

Reviewers: ilya-biryukov, sammccall

Subscribers: cfe-commits

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

llvm-svn: 342976
2018-09-25 14:02:01 +00:00
Bruno Ricci cf86ce0a7a [AST] Squeeze some bits in LinkageComputer::QueryType
Replace the pair std::pair<const NamedDecl *, unsigned> where the
unsigned represents an LVComputationKind by a PointerIntPair.
This saves a pointer per entry in the map LinkageComputer::CachedLinkageInfo.

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

Reviewed by: rjmccall, george.burgess.iv, erichkeane

llvm-svn: 342973
2018-09-25 13:43:25 +00:00
Sven van Haastregt 0ea28c0e47 [OpenCL] Allow zero assignment and comparisons between queue_t type variables
This change allows for zero assignment and comparison of queue_t
type variables, and extends null_queue.cl to test this.

Patch by Alistair Davies.

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

llvm-svn: 342968
2018-09-25 12:59:34 +00:00
Fangrui Song b5305be699 Annotate LookupResult::clear() as LLVM_ATTRIBUTE_REINITIALIZES to silence bugprone-use-after-move after rC342925
Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits

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

llvm-svn: 342950
2018-09-25 08:07:42 +00:00
Saleem Abdulrasool 51313bc6d9 Driver: render arguments for the embedded bitcode correctly
When embedding bitcode, only a subset of the arguments should be recorded into
the bitcode compilation commandline.  The frontend job is split into two jobs,
one which will generate the bitcode.  Ensure that the arguments for the
compilation to bitcode is properly stripped so that the embedded arguments are
the permitted subset.

llvm-svn: 342929
2018-09-24 23:50:02 +00:00
Richard Smith e57418bb52 [www] Change 'Clang 7' items from yellow to green now Clang 7 is
released.

llvm-svn: 342927
2018-09-24 23:21:09 +00:00
Richard Smith d882704d36 [www] Update cxx_status to mark P0962R1 as done.
llvm-svn: 342926
2018-09-24 23:19:11 +00:00
Richard Smith 236ffdeeb2 P0962R1: only use the member form of 'begin' and 'end' in a range-based
for loop if both members exist.

This resolves a DR whereby an errant 'begin' or 'end' member in a base
class could result in a derived class not being usable as a range with
non-member 'begin' and 'end'.

llvm-svn: 342925
2018-09-24 23:17:44 +00:00
Artem Belevich 44ecb0e3c2 [CUDA] Added basic support for compiling with CUDA-10.0
llvm-svn: 342924
2018-09-24 23:10:44 +00:00
George Karpenkov 2a6deeb928 [analyzer] Prevent crashes in FindLastStoreBRVisitor
This patch is a band-aid. A proper solution would be too change
trackNullOrUndefValue to only try to dereference the pointer when it is
relevant to the problem.

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

llvm-svn: 342920
2018-09-24 21:20:30 +00:00
Calixte Denizet fcd661d278 [CodeGen] Revert commit https://reviews.llvm.org/rL342717
llvm-svn: 342912
2018-09-24 18:24:18 +00:00
Stefan Pintilie 9177cf411e [Power9] [CLANG] Add __float128 exponent GET and SET builtins
Added

__builtin_vsx_scalar_extract_expq
__builtin_vsx_scalar_insert_exp_qp

Builtins should behave the same way as in GCC.

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

llvm-svn: 342911
2018-09-24 18:14:50 +00:00
Benjamin Kramer 0181e7a6bd Fix the type of 1<<31 integer constants.
Shifting into the sign bit is technically undefined behavior. No known
compiler exploits it though.

llvm-svn: 342909
2018-09-24 17:51:15 +00:00
Michal Gorny 248319db40 [python] [tests] Update test_code_completion
Update expected completions to match output generated by clang-7.0.

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

llvm-svn: 342897
2018-09-24 16:10:25 +00:00
Kristina Brooks a6398cdcfc Revert "rL342883: [Clang][CodeGen][ObjC]: Fix CoreFoundation on ELF with `-fconstant-cfstrings`."
Seems to be causing buildbot failures, need to look into it.

llvm-svn: 342893
2018-09-24 15:26:08 +00:00
Kristina Brooks 1d0843c175 [CFString][ELF] Fix a missed test causing buildbot failures from 342883.
Accidetanlly forgot to update it, big sorry.

llvm-svn: 342890
2018-09-24 14:52:48 +00:00
Eric Liu 495847ad77 [VFS] Use llvm::StringMap instead of std::map. NFC
llvm-svn: 342889
2018-09-24 14:52:11 +00:00
Anastasia Stulova ae2e86fb2f Revert "We allow implicit function declarations as an extension in all C dialects. Remove OpenCL special case."
Discussed on cfe-commits (Week-of-Mon-20180820), this change leads to
the generation of invalid IR for OpenCL without giving an error.
Therefore, the conclusion was to revert.

llvm-svn: 342885
2018-09-24 14:21:56 +00:00
Kristina Brooks 7c142a52e2 [Clang][CodeGen][ObjC]: Fix CoreFoundation on ELF with `-fconstant-cfstrings`.
[Clang][CodeGen][ObjC]: Fix non-bridged CoreFoundation builds on ELF targets
that use `-fconstant-cfstrings`. The original changes from differential 
for a similar patch to PE/COFF (https://reviews.llvm.org/D44491) did not
check for an edge case where the global could be a constant which surfaced
as an issue when building for ELF because of different linkage semantics.

This patch addresses several issues with crashes related to CF builds on ELF
as well as improves data layout by ensuring string literals that back
the actual CFConstStrings end up in .rodata in line with Mach-O.

Change itself tested with CoreFoundation on Linux x86_64 but should be valid
for BSD-like systems as well that use ELF as the native object format.

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

llvm-svn: 342883
2018-09-24 14:06:47 +00:00
Sven van Haastregt 7b39a085d9 Fix Wundef NDEBUG warning; NFC
Check for definedness of the NDEBUG macro rather than its value,
to be consistent with other uses.

llvm-svn: 342876
2018-09-24 12:12:03 +00:00
Sjoerd Meijer c017656202 [ARM][AArch64] Add feature +fp16fml
Armv8.4-A adds a few FP16 instructions that can optionally be implemented
in CPUs of Armv8.2-A and above.

This patch adds a feature to clang to permit selection of these
instructions. This interacts with the +fp16 option as follows:

Prior to Armv8.4-A:
*) +fp16fml implies +fp16
*) +nofp16 implies +nofp16fml

From Armv8.4-A:
*) The above conditions apply, additionally: +fp16 implies +fp16fml

Patch by Bernard Ogden.

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

llvm-svn: 342862
2018-09-24 07:55:20 +00:00
Michael Kruse 4c99f5fe2b Add inherited attributes before parsed attributes.
Currently, attributes from previous declarations ('inherited attributes')
are added to the end of a declaration's list of attributes. Before
r338800, the attribute list was in reverse. r338800 changed the order
of non-inherited (parsed from the current declaration) attributes, but
inherited attributes are still appended to the end of the list.

This patch appends inherited attributes after other inherited
attributes, but before any non-inherited attribute. This is to make the
order of attributes in the AST correspond to the order in the source
code.

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

llvm-svn: 342861
2018-09-24 06:31:37 +00:00
Kristof Umann 82eeca363a [analyzer][UninitializedObjectChecker] Using the new const methods of ImmutableList
Differential Revision: https://reviews.llvm.org/D51886

llvm-svn: 342834
2018-09-23 09:16:27 +00:00
Petr Hosek b2de4b39be [CMake] Use internal_linkage rather than always_inline for libc++
This is a workaround for PR39053 which was uncovered by D50652 when
the default attribute has been changed from internal_linkage to
always_inline.

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

llvm-svn: 342833
2018-09-23 08:46:31 +00:00
David Carlier 75cb0dd5ed [CStringSyntaxChecker] Check strlcat sizeof check
Assuming strlcat is used with strlcpy we check as we can if the last argument does not equal os not larger than the buffer.
Advising the proper usual pattern.

Reviewers: george.karpenkov, NoQ, MaskRay

Reviewed By: MaskRay

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

llvm-svn: 342832
2018-09-23 08:30:17 +00:00
Fangrui Song f750f7f3fb [Index] Report specialization bases as references when IndexImplicitInstantiation is true
Summary:
    template <typename T> struct B {};
    template <typename T> struct D : B<T> {}; // `B` was not reported as a reference

This patch fixes this.

Reviewers: akyrtzi, arphaman, devnexen

Reviewed By: devnexen

Subscribers: cfe-commits

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

llvm-svn: 342831
2018-09-23 08:23:48 +00:00
Eric Fiselier 91cef98d2c Fix modules build with shared library.
r341994 caused clangAnalysis to pull all of the AST matchers
library into clang. Due to inline key functions in the headers,
importing the AST matchers library gives a link dependency on the
AST matchers (and thus the AST), which clang should not
have.

This patch works around the issues by excluding the offending
libclangAnalysis header in the modulemap.

llvm-svn: 342827
2018-09-23 00:48:05 +00:00
Fangrui Song dfc3b7bbf7 [Index] Fix header guard naming
llvm-svn: 342825
2018-09-22 22:49:38 +00:00
Aaron Puchert 88d8536566 Eliminate some unneeded signed/unsigned conversions
No functional change is intended, but generally this should be a bit
more safe.

llvm-svn: 342823
2018-09-22 21:56:16 +00:00
Caroline Tice 29f0282b3e Fix codemodels.c test case (only test mcmodel=medium on X86).
aarch64 testing is broken because "medium" is not a valid
code-model on aarch64, and codemodels.c tests that.  This fixes
that problem by adding "-triple x86_64-unknown-linux-gnu" to the
test with "-mcode-model moedium".

llvm-svn: 342812
2018-09-22 18:25:58 +00:00
Sylvestre Ledru 9ea1f3554d use the current url for bugzilla
llvm-svn: 342802
2018-09-22 07:41:09 +00:00
Sylvestre Ledru b06fe489aa update the links to use https
llvm-svn: 342801
2018-09-22 07:39:44 +00:00
Richard Trieu 8d3fa39a0d Update smart pointer detection for thread safety analysis.
Objects are determined to be smart pointers if they have both a star and arrow
operator.  Some implementations of smart pointers have these overloaded
operators in a base class, while the check only searched the derived class.
This fix will also look for the operators in the base class.

llvm-svn: 342794
2018-09-22 01:50:52 +00:00
Leonard Chan b32d40417e [Lexer] Add udefined_behavior_sanitizer feature
This can be used to detect whether the code is being built with UBSan using
the __has_feature(undefined_behavior_sanitizer) predicate.

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

llvm-svn: 342793
2018-09-22 01:03:16 +00:00