Commit Graph

74180 Commits

Author SHA1 Message Date
microsoft-github-policy-service[bot] e9a52cc0bf
Auto merge mandatory file pr
This pr is auto merged as it contains a mandatory file and is opened for more than 10 days.
2023-06-13 17:54:33 +00:00
microsoft-github-policy-service[bot] 1810ed9e1e
Microsoft mandatory file 2023-06-02 21:56:02 +00:00
Aaron Puchert 86d4513d3e Thread safety analysis: Handle ObjCIvarRefExpr in SExprBuilder::translate
Summary:
This imitates the code for MemberExpr.

Fixes PR38896.

Reviewers: aaron.ballman, delesley, lukasza, rjmccall

Reviewed By: delesley

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342600 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-19 23:57:38 +00:00
Shuai Wang bd0e6da3a7 [NFC] Declare instead of define non-void functions in unit tests.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342586 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-19 20:27:25 +00:00
Saleem Abdulrasool 47f7c9f1a7 test: actually fix the condition properly
I had locally changed the test to add an explicit triple to figure out the issue
with the SCEI buildbots, and that hid the error.  This now works with and
without the explicit triple.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342581 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-19 19:20:30 +00:00
Saleem Abdulrasool 27a174792c test: improve condition for the check
When the type of `wint_t` is `int`, the promotion will allow this to pass.
Check this explicitly rather than using the size.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342569 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-19 18:41:07 +00:00
Sylvestre Ledru 9e45e2ae46 redirecting to llvm.org/devmtg
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342568 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-19 18:39:15 +00:00
Saleem Abdulrasool 6f0e52207c Sema: handle `wint_t` more carefully for printf checking
In the case that `win_t` is an `unsigned short` (e.g. on Windows), we would
previously incorrectly diagnose the conversion because we would immediately
promote the argument type from `wint_t` (aka `unsigned short`) to `int` before
checking if the type matched.  This should repair the Windows hosted bots.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342565 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-19 18:13:34 +00:00
Shuai Wang 600775228a [analyzer] Fix nullptr access when processing instantiated function in ExprMutationAnalyzer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342562 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-19 18:00:55 +00:00
Saleem Abdulrasool 9e910c672d Basic: correct `__WINT_TYPE__` on Windows
Windows uses `unsigned short` for `wint_t`.  Correct the type definition as
vended by the compiler.  This type is defined in corecrt.h and is
unconditionally typedef'ed.  cl does not have an equivalent to `__WINT_TYPE__`
which is why this was never detected.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342557 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-19 16:18:55 +00:00
Eric Liu 51d76e9ec3 [Sema] Do not load macros from preamble when LoadExternal is false.
Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342528 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-19 09:34:55 +00:00
Shuai Wang 2282e12e22 [NFC] Fix uncompilable test cases of ExprMutationAnalyzer.
And ensure future test cases doesn't have compile errors.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342525 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-19 03:50:03 +00:00
Aaron Puchert 4a9b0e9a58 Thread safety analysis: Fix crash for function pointers
For function pointers, the FunctionDecl of the callee is unknown, so
getDirectCallee will return nullptr. We have to catch that case to avoid
crashing. We assume there is no attribute then.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342519 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-19 00:19:38 +00:00
Volodymyr Sapsai 30d3f201ef Add a callback for `__has_include` and use it for dependency scanning.
This adds a preprocessor callback for the `__has_include` and
`__has_include_next` directives.

Successful checking for the presence of a header should add it to the list of
header dependencies so this overrides the callback in the dependency scanner.

Patch by Pete Cooper with some additions by me.

rdar://problem/39545636

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342517 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-18 23:27:02 +00:00
Reid Kleckner c8df8c22bd [MS] Defer dllexport inline friend functions like other inline methods
This special case was added in r264841, but the code breaks our
invariants by calling EmitTopLevelDecl without first creating a
HandlingTopLevelDeclRAII scope.

This fixes the PCH crash in https://crbug.com/884427. I was never able
to make a satisfactory reduction, unfortunately. I'm not very worried
about this regressing since this change makes the code simpler while
passing the existing test that shows we do emit dllexported friend
function definitions. Now we just defer their emission until the tag is
fully complete, which is generally good.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342516 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-18 23:16:30 +00:00
Saleem Abdulrasool 6f42893d10 Driver: extract a local variable for the Toolchain (NFC)
Create and store a reference to the current toolchain rather than calling
`getToolChain` throughout the function.  NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342515 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-18 22:14:50 +00:00
Saleem Abdulrasool 51fd40c31f Driver: hoist `-mlimit-float-precision` (NFC)
Move the floating point argument handling into the RenderFloatingPointOptions
helper.  This relocation just puts the floating point related options into a
single location.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342512 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-18 21:12:39 +00:00
David Blaikie d361d13e84 Fix fomit-frame-pointe+pg error
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342510 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-18 20:11:45 +00:00
Stephen Hines 81fb2fbc3c Fix logic around determining use of frame pointer with -pg.
Summary:
As part of r342165, I rewrote the logic to check whether
-fno-omit-frame-pointer was passed after a -fomit-frame-pointer
argument. This CL switches that logic to use the consolidated
shouldUseFramePointer() function. This fixes a potential issue where -pg
gets used with -fomit-frame-pointer on a platform that must always retain
frame pointers.

Reviewers: dblaikie

Reviewed By: dblaikie

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342501 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-18 18:34:33 +00:00
Bruno Cardoso Lopes bd5ee58406 [Modules] Add platform and environment features to requires clause
Allows module map writers to add build requirements based on
platform/os. This helps when target features and language dialects
aren't enough to conditionalize building a module, among other things,
it allow module maps for different platforms to live in the same file.

rdar://problem/43909745

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342499 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-18 17:11:13 +00:00
Argyrios Kyrtzidis 16f27fb3e9 [index] Enhance indexing for module references
* Create a USR for the occurrences of the 'module' symbol kind
* Record module references for each identifier in an import declaration

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342484 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-18 15:02:56 +00:00
Hans Wennborg f02ab3c78b cl-options.c: Fix negative -cfguard check
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342470 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-18 13:07:55 +00:00
Eric Liu 0c965af23b [Index] Add an option to collect macros from preprocesor.
Summary: Also added unit tests for the index library; lit+c-index-test is painful...

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: mgorny, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342451 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-18 08:51:08 +00:00
Sam McCall ae8dcccdd1 [CodeComplete] Add completions for filenames in #include directives.
Summary:
The dir component ("somedir" in #include <somedir/fo...>) is considered fixed.
We append "foo" to each directory on the include path, and then list its files.

Completions are of the forms:
 #include <somedir/fo^
                   foo.h>
                   fox/

The filter is set to the filename part ("fo"), so fuzzy matching can be
applied to the filename only.

No fancy scoring/priorities are set, and no information is added to
CodeCompleteResult to make smart scoring possible. Could be in future.

Reviewers: ilya-biryukov

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342449 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-18 08:40:41 +00:00
Aaron Puchert 0fb55e03c7 Thread safety analysis: Run more tests with capability attributes [NFC]
Summary:
We run the tests for -Wthread-safety-{negative,verbose} with the new
attributes as well as the old ones. Also put the macros in a header so
that we don't have to copy them all around.

The warn-thread-safety-parsing.cpp test checks for warnings depending on
the actual attribute name, so it can't undergo the same treatment.

Together with D49275 this should fix PR33754.

Reviewers: aaron.ballman, delesley, grooverdan

Reviewed By: aaron.ballman

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342418 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-17 21:37:22 +00:00
George Karpenkov b9dbcf4f94 [analyzer] ExplodedGraph printing fixes
Fixes a number of issues:

 - Global variables are not used for communication
 - Trait should be defined on a graph, not on a node
 - Defining the trait on a graph allows us to use a correct allocator,
   no longer crashing while printing trimmed graphs

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342413 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-17 20:46:53 +00:00
Shuai Wang ccf123b17d [analyzer] Treat std::{move,forward} as casts in ExprMutationAnalyzer.
Summary:
This is a follow up of D52008 and should make the analyzer being able to handle perfect forwardings in real world cases where forwardings are done through multiple layers of function calls with `std::forward`.

Fixes PR38891.

Reviewers: lebedev.ri, JonasToth, george.karpenkov

Subscribers: xazax.hun, szepet, a.sidorin, mikhail.ramalho, Szelethus, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342409 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-17 20:10:56 +00:00
Shuai Wang 926e91b0e6 [ASTMatchers] Let isArrow also support UnresolvedMemberExpr, CXXDependentScopeMemberExpr
Reviewers: aaron.ballman

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342407 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-17 18:48:43 +00:00
Gabor Marton f98dc5ceb3 [ASTImporter] Fix import of VarDecl init
Summary:
The init expression of a VarDecl is overwritten in the "To" context if we
import a VarDecl without an init expression (and with a definition).  Please
refer to the added tests, especially InitAndDefinitionAreInDifferentTUs.  This
patch fixes the malfunction by importing the whole Decl chain similarly as we
did that in case of FunctionDecls.  We handle the init expression similarly to
a  definition, alas only one init expression will be in the merged ast.

Reviewers: a_sidorin, xazax.hun, r.stahl, a.sidorin

Subscribers: rnkovacs, dkrupp, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342384 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-17 12:04:52 +00:00
Andrew Savonichev 4a2af3e42a [OpenCL] Allow blocks to capture arrays in OpenCL
Summary: Patch by Egor Churaev

Reviewers: Anastasia, yaxunl

Reviewed By: Anastasia

Subscribers: asavonic, bader, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342370 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-17 11:19:42 +00:00
Andrew Savonichev d0960ed3a0 Merge two attribute diagnostics into one
Summary:
Merged the recently added `err_attribute_argument_negative` diagnostic
with existing `err_attribute_requires_positive_integer` diagnostic:
the former allows only strictly positive integer, while the latter
also allows zero.

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342367 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-17 10:39:46 +00:00
Mikhail Maltsev aa660b7dd3 [Analyzer] Define and use diff_plist in tests, NFC
This patch defines a new substitution and uses it to reduce
duplication in the Clang Analyzer test cases.

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342365 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-17 10:19:46 +00:00
Ilya Biryukov d046e91f17 [clang-Format] Fix indentation of member call after block
Summary:
before patch:
> echo "test() {([]() -> {int b = 32;return 3;}).as("");});" | clang-format -style=Google

```
test() {
  ([]() -> {
    int b = 32;
    return 3;
  })
      .as();
});
```

after patch:
> echo "test() {([]() -> {int b = 32;return 3;}).as("");});" | clang-format -style=Google

```
test() {
  ([]() -> {
    int b = 32;
    return 3;
  }).as();
});
```

Patch by Anders Karlsson (ank)!

Reviewers: klimek

Reviewed By: klimek

Subscribers: danilaml, acoomans, klimek, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342363 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-17 07:46:20 +00:00
Sylvestre Ledru ce5ca6bcf2 scan-build: Add support of the option --exclude like in scan-build-py
Summary:
To exclude thirdparty code.

To test:
With /tmp/foo.c
  
```
void test() {
    int x;
    x = 1; // warn
}  
```

```
$ scan-build --exclude non-existing/  --exclude /tmp/ -v gcc -c foo.c                                                                                                                                                                                   

scan-build: Using '/usr/lib/llvm-7/bin/clang' for static analysis
scan-build: Emitting reports for this run to '/tmp/scan-build-2018-09-16-214531-8410-1'.
foo.c:3:3: warning: Value stored to 'x' is never read
  x = 1; // warn
  ^   ~
1 warning generated.
scan-build: File '/tmp/foo.c' deleted: part of an ignored directory.
scan-build: 0 bugs found.
```

Reviewers: jroelofs

Reviewed By: jroelofs

Subscribers: whisperity, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342359 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-17 06:31:46 +00:00
Petr Hosek 6df2955606 [Lexer] Add xray_instrument feature
This can be used to detect whether the code is being built with XRay
instrumentation using the __has_feature(xray_instrument) predicate.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342358 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-17 05:25:47 +00:00
Shuai Wang 8f36d6cc15 [NFC] Minor refactoring to setup the stage for supporting pointers in ExprMutationAnalyzer
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342353 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-16 21:09:50 +00:00
Sylvestre Ledru c4dcc7785e scan-build: remove trailing whitespaces
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342351 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-16 19:51:16 +00:00
Sylvestre Ledru e434600b3e Also manages clang-X as tool for scan-build
Summary:
This will make
scan-build-7 clang-7 -c foo.c &> /dev/null

Reviewers: jroelofs

Subscribers: kristina, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342350 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-16 19:36:59 +00:00
Shuai Wang 71235610d1 [NFC] cosmetic tweaks to ExprMutationAnalyzer to be more consistent
especially considering future changes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342340 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-15 21:38:18 +00:00
Kelvin Li 3a0edf1ccb [OPENMP] Move OMPClauseReader/Writer classes to ASTReader/Writer (NFC)
Move declarations for OMPClauseReader, OMPClauseWriter to ASTReader.h 
and ASTWriter.h and move implementation to ASTReader.cpp and 
ASTWriter.cpp. This change helps generalize the serialization of
OpenMP clauses and will be used in the future implementation of new 
OpenMP directives (e.g. requires).

Patch by Patrick Lyster

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342322 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-15 13:54:15 +00:00
George Karpenkov 9bc2172b74 [analyzer] Temporary disabling svalbuilder-rearrange-comparisons test
As debug printing has changed, and format was not guaranteed to be
stable.
Artem is currently working on a better solution.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342317 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-15 02:35:06 +00:00
George Karpenkov 58cfe5b8b7 [analyzer] Further printing improvements: use declarations,
skip pointers whenever redundant, use unique prefixes.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342316 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-15 02:34:45 +00:00
George Karpenkov a495c43386 Generate unique identifiers for Decl objects
The generated identifier is stable across multiple runs,
and can be a great visualization or debugging aide.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342315 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-15 02:03:58 +00:00
George Karpenkov ab961c560a [analyzer] Generate and use stable identifiers for LocationContext
Those are not created in the allocator.
Since they are created fairly rarely, a counter overhead should not
affect the memory consumption.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342314 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-15 02:03:36 +00:00
George Karpenkov 7d1cca4458 [analyzer] Dump reproducible identifiers for statements in exploded graph in store
Differential Revision: https://reviews.llvm.org/D51826

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342313 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-15 02:03:17 +00:00
George Karpenkov 843c06ec25 [analyzer] Use correct end-of-line character when printing statements for exploded graph
Prevents bad centering.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342312 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-15 02:02:56 +00:00
George Karpenkov d046c9fafa StmtPrinter: allow customizing the end-of-line character
Differential Revision: https://reviews.llvm.org/D51824

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342311 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-15 02:02:31 +00:00
George Karpenkov f702afcb3e [analyzer] Dump unique identifiers for statements in exploded graph
Differential Revision: https://reviews.llvm.org/D51823

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342310 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-15 02:02:09 +00:00
George Karpenkov 03164d3e0e Support generating unique identifiers for Stmt objects
The generated identifiers are stable across multiple runs, and can be a
great debug or visualization aid.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342309 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-15 02:01:47 +00:00
George Karpenkov e4d256f38d [analyzer] Skip printing duplicate nodes, even if nodes have multiple predecessors/successors
Still generate a node, but leave the redundant field empty.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342308 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-15 02:01:26 +00:00