Skip to content

Repo sync for protected CLA branch #2551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Oct 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 31 additions & 19 deletions docs/build/pgosweep.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,64 @@
---
title: "pgosweep"
ms.date: "03/14/2018"
description: "Use the pgosweep command to write profile data to a PGC file for use in profile-guided optimization."
ms.date: 10/23/2020
helpviewer_keywords: ["pgosweep program", "profile-guided optimizations, pgosweep"]
ms.assetid: f39dd3b7-1cd9-4c3b-8e8b-fb794744b757
---
# pgosweep

Used in profile-guided optimization to write all profile data from a running program to the .pgc file.
Used in profile-guided optimization to write all profile data from a running program to the PGC file.

## Syntax

> **pgosweep** [*options*] *image* *pgcfile*
> **`pgosweep`** [*options*] *image* *pgcfile*

### Parameters

*options*<br/>
*options*\
(Optional) The valid values for *options* are:

- **/?** or **/help** displays the help message.
- **`/?`** or **`/help`** displays the help message.

- **/noreset** preserves the count in the runtime data structures.
- **`/reset`** resets counts to zero after sweep. This behavior is the default.

*image*<br/>
The full path of an .exe or .dll file that was created by using the [/GENPROFILE](reference/genprofile-fastgenprofile-generate-profiling-instrumented-build.md), [/FASTGENPROFILE](reference/genprofile-fastgenprofile-generate-profiling-instrumented-build.md), or [/LTCG:PGINSTRUMENT](reference/ltcg-link-time-code-generation.md) option.
- **`/pid:n`** only sweeps the specified PID, where *n* is the PID number.

*pgcfile*<br/>
The .pgc file where this command writes out the data counts.
- **`/wait`** waits for the specified PID to terminate before collecting counts.

- **`/onlyzero`** doesn't save a PGC file, only zero counts.

- **`/pause`** pauses count collection on the system.

- **`/resume`** resumes count collection on the system.

- **`/noreset`** preserves the count in the runtime data structures.

*image*\
The full path of an EXE or DLL file that was created by using the [`/GENPROFILE`](reference/genprofile-fastgenprofile-generate-profiling-instrumented-build.md), [`/FASTGENPROFILE`](reference/genprofile-fastgenprofile-generate-profiling-instrumented-build.md), or [`/LTCG:PGINSTRUMENT`](reference/ltcg-link-time-code-generation.md) option.

*pgcfile*\
The PGC file where this command writes out the data counts.

## Remarks

The **pgosweep** command works on programs that were built by using the [/GENPROFILE or /FASTGENPROFILE](reference/genprofile-fastgenprofile-generate-profiling-instrumented-build.md) option, or the deprecated [/LTCG:PGINSTRUMENT](reference/ltcg-link-time-code-generation.md) option. It interrupts a running program and writes the profile data to a new .pgc file. By default, the command resets counts after each write operation. If you specify the **/noreset** option, the command will record the values, but not reset them in the running program. This option gives you duplicate data if you retrieve the profile data later.
The **`pgosweep`** command works on programs that were built by using the [`/GENPROFILE` or `/FASTGENPROFILE`](reference/genprofile-fastgenprofile-generate-profiling-instrumented-build.md) option, or the deprecated [`/LTCG:PGINSTRUMENT`](reference/ltcg-link-time-code-generation.md) option. It interrupts a running program and writes the profile data to a new PGC file. By default, the command resets counts after each write operation. If you specify the **`/noreset`** option, the command will record the values, but not reset them in the running program. This option gives you duplicate data if you retrieve the profile data later.

An alternative use for **pgosweep** is to retrieve profile information just for the normal operation of the application. For example, you could run **pgosweep** shortly after you start the application and discard that file. This would remove profile data associated with startup costs. Then, you can run **pgosweep** before ending the application. Now the collected data has profile information only from the time the user could interact with the program.
An alternative use for **`pgosweep`** is to retrieve profile information just for the normal operation of the application. For example, you could run **`pgosweep`** shortly after you start the application and discard that file. This command would remove profile data associated with startup costs. Then, you can run **`pgosweep`** before ending the application. Now the collected data has profile information only from the time the user could interact with the program.

When you name a .pgc file (by using the *pgcfile* parameter) you can use the standard format, which is *appname!n*.pgc. If you use this format, the compiler automatically finds this data in the **/LTCG /USEPROFILE** or **/LTCG:PGO** phase. If you do not use the standard format, you must use [pgomgr](pgomgr.md) to merge the .pgc files.
When you name a PGC file (by using the *pgcfile* parameter) you can use the standard format, which is *`appname!n.pgc`*. The *n* represents an increasing numeric value for each file. If you use this format, the compiler automatically finds this data in the **`/LTCG /USEPROFILE`** or **`/LTCG:PGO`** phase. If you don't use the standard format, you must use [`pgomgr`](pgomgr.md) to merge the PGC files.

> [!NOTE]
> You can start this tool only from a Visual Studio developer command prompt. You cannot start it from a system command prompt or from File Explorer.
> You can start this tool only from a Visual Studio developer command prompt. You can't start it from a system command prompt or from File Explorer.

For information on how to capture the profile data from within your executable, see [PgoAutoSweep](pgoautosweep.md).
For information on how to capture the profile data from within your executable, see [`PgoAutoSweep`](pgoautosweep.md).

## Example

In this example command, **pgosweep** writes the current profile information for myapp.exe to myapp!1.pgc.
In this example command, **`pgosweep`** writes the current profile information for *`myapp.exe`* to *`myapp!1.pgc`*.

`pgosweep myapp.exe myapp!1.pgc`

## See also

[Profile-Guided Optimizations](profile-guided-optimizations.md)<br/>
[PgoAutoSweep](pgoautosweep.md)<br/>
[Profile-Guided Optimizations](profile-guided-optimizations.md)\
[PgoAutoSweep](pgoautosweep.md)
20 changes: 11 additions & 9 deletions docs/code-quality/c26400.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
---
title: C26400
ms.date: 08/02/2017
ms.topic: "conceptual"
description: "Describes the Microsoft C/C++ code analysis warning C26400, its causes, and how to address it."
ms.date: 10/23/2020
f1_keywords: ["C26400"]
helpviewer_keywords: ["C26400"]
ms.assetid: b27e1c6d-8b52-40b3-9760-b93afef19c7a
---
# C26400 NO_RAW_POINTER_ASSIGNMENT

This check helps to enforce the *rule I.11: Never transfer ownership by a raw pointer (T\*)*, which is a subset of the rule *R.3: A raw pointer (a T\*) is non-owning.* Specifically, it warns on any call to operator `new` which saves its result in a variable of raw pointer type. It also warns on calls to functions that return `gsl::owner<T>` if their results are assigned to raw pointers. The idea here is that you should clearly state ownership of memory resources. For more information, see the [C++ Core Guidelines](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#r-resource-management).
This check helps to enforce the *rule I.11: Never transfer ownership by a raw pointer (T\*)*, which is a subset of the rule *R.3: A raw pointer (a T\*) is non-owning*. Specifically, it warns on any call to `operator new`, which saves its result in a variable of raw pointer type. It also warns on calls to functions that return `gsl::owner<T>` if their results are assigned to raw pointers. The idea here is that you should clearly state ownership of memory resources. For more information, see the [C++ Core Guidelines](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#r-resource-management).

The easiest way to fix this is to use **`auto`** declaration if the resource is assigned immediately at the variable declaration. If this is not possible, then we suggest that you use the type `gsl::owner<T>`. The **`auto`** declarations initialized with operator **`new`** are "owners" because we assume that the result of any allocation is implicitly an owner pointer. We transfer this assumption to the **`auto`** variable and treat it as `owner<T>`.
The easiest way to fix this warning is to use **`auto`** declaration if the resource is assigned immediately at the variable declaration. If this fix isn't possible, then we suggest that you use the type `gsl::owner<T>`. The **`auto`** declarations initialized with operator **`new`** are "owners" because we assume that the result of any allocation is implicitly an owner pointer. We transfer this assumption to the **`auto`** variable and treat it as `owner<T>`.

If this check flags a call to a function which returns `owner<T>`, this may be an indication of a legitimate bug in code. Basically, it points to a place where the code leaks an explicit notion of ownership (and maybe the resource itself).
If this check flags a call to a function that returns `owner<T>`, it may be an indication of a legitimate bug in the code. Basically, it points to a place where the code leaks an explicit notion of ownership (and maybe the resource itself).

## Remarks

This rule currently checks only local variables. If allocation is assigned to a formal parameter, global variable, class member, and so on, it is not flagged. Appropriate coverage of such scenarios is a part of future work.
This rule currently checks only local variables. If you assign an allocation to a formal parameter, global variable, class member, and so on, it's not flagged. Appropriate coverage of such scenarios is planned for future work.

## Example 1: Simple allocation

Expand All @@ -28,15 +27,18 @@ else
buffer = new char[bufferSize]; // C26400
```

## Example 2: Simple allocation (fixed with gsl::owner\<T>)
## Example 2: Simple allocation (fixed with `gsl::owner<T>`)

```cpp
gsl::owner<char*> buffer = nullptr;
if (useCache)
buffer = GetCache();
else
buffer = new char[bufferSize]; // OK
```

## Example 3: Simple allocation (fixed with `auto`)

Example 3: Simple allocation (fixed with auto)
```cpp
auto buffer = useCache ? GetCache() : new char[bufferSize]; // OK
```
5 changes: 3 additions & 2 deletions docs/code-quality/c28230.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: C28230
ms.date: 11/04/2016
description: "Understand the causes of Microsoft C/C++ code analysis warning C28230, and learn how to fix them."
ms.date: 10/23/2020
ms.topic: reference
f1_keywords: ["C28230"]
helpviewer_keywords: ["C28230"]
Expand All @@ -24,7 +25,7 @@ struct MyStruct
};

// Oops, the name of the member is spelled wrong so it will not be found
void f(_Out_writes_(value.usefulMember) int *buffer, MyStruct value)
void f(_Out_writes_(value.usefulmember) int *buffer, MyStruct value)
{
for(int i = 0 ; i < value.usefulMember; i++)
{
Expand Down
4 changes: 3 additions & 1 deletion docs/code-quality/c6308.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: C6308
ms.date: 11/04/2016
description: "Understand the causes of Microsoft C/C++ code analysis warning C6308, and learn how to fix them."
ms.date: 10/23/2020
ms.topic: reference
f1_keywords: ["C6308"]
helpviewer_keywords: ["C6308"]
Expand Down Expand Up @@ -52,6 +53,7 @@ void f()
{
x = tmp;
}
// code...
free(x);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: "How to: Create a Classic COM Component Using WRL"
ms.date: "11/04/2016"
description: "Use the Windows Runtime C++ Template Library (WRL) to create basic classic COM components for use in desktop apps."
ms.date: 10/23/2020
ms.topic: "reference"
ms.assetid: 5efe7690-90d5-4c3c-9e53-11a14cefcb19
---
# How to: Create a Classic COM Component Using WRL

Expand Down Expand Up @@ -30,7 +30,7 @@ This document shows how to use the Windows Runtime C++ Template Library to creat

[!code-cpp[wrl-classic-com-component#3](../codesnippet/CPP/how-to-create-a-classic-com-component-using-wrl_3.cpp)]

7. Add a **Module-Definition File (.def)** file to the project. Name the file, for example, `CalculatorComponent.def`. This file gives the linker the names of the functions to be exported.
7. Add a **Module-Definition File (.def)** file to the project. Name the file, for example, `CalculatorComponent.def`. This file gives the linker the names of the functions to be exported. Open the **Property Pages** dialog for your project, then under **Configuration Properties** > **Linker** > **Input**, set the **Module Definition File** property to your DEF file.

8. Add this code to CalculatorComponent.def:

Expand All @@ -43,7 +43,7 @@ This document shows how to use the Windows Runtime C++ Template Library to creat
DllCanUnloadNow PRIVATE
```

9. Add runtimeobject.lib to the linker line. To learn how, see [.Lib Files as Linker Input](../../build/reference/dot-lib-files-as-linker-input.md).
9. Add runtimeobject.lib to the linker line. To learn how, see [`.Lib` Files as Linker Input](../../build/reference/dot-lib-files-as-linker-input.md).

### To consume the COM component from a desktop app

Expand Down
38 changes: 16 additions & 22 deletions docs/extensions/literal-cpp-component-extensions.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
title: "literal (C++/CLI and C++/CX)"
ms.date: "10/12/2018"
title: "literal (C++/CLI)"
description: "The literal keyword is a Microsoft C++/CLI context-sensitive keyword for a compile-time constant."
ms.date: 10/20/2020
ms.topic: "reference"
f1_keywords: ["literal", "literal_cpp"]
helpviewer_keywords: ["literal keyword [C++]"]
ms.assetid: 6b1a1f36-2e1d-4a23-8eb6-172f4f3c477f
---
# literal (C++/CLI and C++/CX)
# `literal` (C++/CLI)

A variable (data member) marked as **literal** in a **/clr** compilation is the native equivalent of a **static const** variable.
A variable (data member) marked as **`literal`** in a **`/clr`** compilation is a compile-time constant. It's the native equivalent of a C# [`const`](/dotnet/csharp/language-reference/keywords/const) variable.

## All Platforms

Expand All @@ -22,27 +22,21 @@ A variable (data member) marked as **literal** in a **/clr** compilation is the

(There are no remarks for this language feature that apply to only the Windows Runtime.)

### Requirements

Compiler option: `/ZW`

## Common Language Runtime

## Remarks

A data member marked as **literal** must be initialized when declared and the value must be a constant integral, enum, or string type. Conversion from the type of the initialization expression to the type of the static const data-member must not require a user-defined conversion.

No memory is allocated for the literal field at runtime; the compiler only inserts its value in the metadata for the class.
A data member marked as **`literal`** must be initialized when declared. And, the value must be a constant integral, enum, or string type. Conversion from the type of the initialization expression to the type of the **`literal`** data member can't require a user-defined conversion.

A variable marked **static const** will not be available in metadata to other compilers.
No memory is allocated for the **`literal`** field at runtime; the compiler only inserts its value in the metadata for the class. The **`literal`** value is treated as a compile-time constant. The closest equivalent in Standard C++ is **`constexpr`**, but a data member can't be **`constexpr`** in C++/CLI.

For more information, see [Static](../cpp/storage-classes-cpp.md) and [const](../cpp/const-cpp.md).
A variable marked as **`literal`** differs from one marked **`static const`**. A **`static const`** data member isn't made available in metadata to other compilers. For more information, see [`static`](../cpp/storage-classes-cpp.md) and [`const`](../cpp/const-cpp.md).

**literal** is a context-sensitive keyword. See [Context-Sensitive Keywords](context-sensitive-keywords-cpp-component-extensions.md) for more information.
**`literal`** is a context-sensitive keyword. For more information, see [Context-sensitive keywords](context-sensitive-keywords-cpp-component-extensions.md).

## Examples

This example shows that a **literal** variable implies **`static`**.
This example shows that a **`literal`** variable implies **`static`**.

```cpp
// mcppv2_literal.cpp
Expand All @@ -56,7 +50,7 @@ int main() {
}
```

The following sample shows the affect of literal in metadata:
The following sample shows the effect of **`literal`** in metadata:

```cpp
// mcppv2_literal2.cpp
Expand All @@ -69,15 +63,15 @@ public ref struct A {

Notice the difference in the metadata for `sc` and `lit`: the `modopt` directive is applied to `sc`, meaning it can be ignored by other compilers.

```
.field public static int32 modopt([mscorlib]System.Runtime.CompilerServices.IsConst) sc = int32(0x0000000A)
```MSIL
.field public static int32 modopt([mscorlib]System.Runtime.CompilerServices.IsConst) sc = int32(0x00000001)
```

```
.field public static literal int32 lit = int32(0x0000000A)
```MSIL
.field public static literal int32 lit = int32(0x00000000)
```

The following sample, authored in C#, references the metadata created in the previous sample and shows the affect of **literal** and **static const** variables:
The following sample, authored in C#, references the metadata created in the previous sample and shows the effect of **`literal`** and **`static const`** variables:

```csharp
// mcppv2_literal3.cs
Expand Down
5 changes: 3 additions & 2 deletions docs/windows/universal-crt-deployment.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
title: "Universal CRT deployment"
ms.date: "05/11/2018"
description: "Learn how, when, and where to deploy the Universal CRT library for your app."
ms.date: 10/23/2020
helpviewer_keywords: ["deploying the CRT [C++]", "application CRT deployment [C++]"]
---
# Universal CRT deployment

From Visual Studio .NET through Visual Studio 2013, each major release of the C++ compiler and tools has included a new, standalone version of the Microsoft C Runtime (CRT) library. These standalone versions of the CRT were independent from, and to various degrees, incompatible with each other. For example, the CRT library used by Visual Studio 2012 was version 11, named msvcr110.dll, and the CRT used by Visual Studio 2013 was version 12, named msvcr120.dll. Beginning in Visual Studio 2015, it's no longer the case. Visual Studio 2015 and later versions of Visual Studio all use one Universal CRT.

The Universal CRT is a Microsoft Windows operating system component included as part of the operating system in Windows 10. It's available for older operating systems, Windows Vista through Windows 8.1, by using Windows Update. Local deployment of the Universal CRT is supported, with some restrictions.
The Universal CRT (UCRT) is a Microsoft Windows operating system component. It's included as part of the operating system in Windows 10 and Windows Server 2016 or later. The UCRT is available by using Windows Update on older operating systems that are still in extended support. Local deployment of the Universal CRT is supported, with some restrictions.

## Central deployment

Expand Down