[PATCH] D67536: [WIP] [clangd] Add support for an inactive regions notification

2019-09-12 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

For reference, I also posted a proof-of-concept client impl in D67537 
, which I used to test/validate this patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67536/new/

https://reviews.llvm.org/D67536



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67537: [WIP] [clangd] Client-side support for inactive regions

2019-09-12 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

This is not for review yet, I'm just posting it to illustrate the client side 
of D67536 .


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67537/new/

https://reviews.llvm.org/D67537



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67537: [WIP] [clangd] Client-side support for inactive regions

2019-09-12 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67537

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
  clang-tools-extra/clangd/clients/clangd-vscode/src/inactive-regions.ts

Index: clang-tools-extra/clangd/clients/clangd-vscode/src/inactive-regions.ts
===
--- /dev/null
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/inactive-regions.ts
@@ -0,0 +1,83 @@
+import * as vscode from 'vscode';
+import * as vscodelc from 'vscode-languageclient';
+import * as vscodelct from 'vscode-languageserver-types';
+
+// Parameters for the inactive regions (server-side) push notification.
+// Mirrors the structure in the inactive regions proposal for LSP.
+interface InactiveRegionsParams {
+  // The text document that has to be decorated with the inactive regions
+  // information.
+  textDocument: vscodelct.VersionedTextDocumentIdentifier;
+  // An array of inactive regions.
+  regions: vscodelc.Range[];
+}
+
+// Language server push notification providing the inactive regions
+// information for a text document.
+export const NotificationType =
+  new vscodelc.NotificationType(
+'textDocument/inactiveRegions');
+
+export class InactiveRegionsFeature implements vscodelc.StaticFeature {
+  private decorationType: vscode.TextEditorDecorationType;
+  private p2c: vscodelc.Protocol2CodeConverter;
+  private files: Map = new Map();
+  private subscriptions: vscode.Disposable[] = [];
+
+  constructor(client: vscodelc.LanguageClient) {
+this.p2c = client.protocol2CodeConverter;
+  }
+
+  fillClientCapabilities(capabilities: vscodelc.ClientCapabilities) {
+// Extend the ClientCapabilities type and add inactive regions
+// capability to the object.
+const textDocumentCapabilities: vscodelc.TextDocumentClientCapabilities &
+{ inactiveRegionsCapabilities?: { inactiveRegions: boolean } } =
+  capabilities.textDocument;
+textDocumentCapabilities.inactiveRegionsCapabilities = {
+  inactiveRegions: true,
+};
+  }
+  initialize(capabilities: vscodelc.ServerCapabilities,
+documentSelector: vscodelc.DocumentSelector | undefined) {
+  this.decorationType = vscode.window.createTextEditorDecorationType({
+isWholeLine: true,
+light: {
+  color: "rgb(100, 100, 100)",
+  backgroundColor: "rgba(220, 220, 220, 0.3)",
+},
+dark: {
+  color: "rgb(100, 100, 100)",
+  backgroundColor: "rgba(18, 18, 18, 0.3)",
+}
+  });
+  this.subscriptions.push(vscode.window.onDidChangeVisibleTextEditors(
+  (editors) => editors.forEach(
+  (e) => this.applyHighlights(e.document.uri.toString();
+  }
+
+  handleNotification(params: InactiveRegionsParams) {
+const fileUri = params.textDocument.uri;
+const ranges = params.regions.map(this.p2c.asRange);
+this.files.set(fileUri, ranges);
+this.applyHighlights(fileUri);
+  }
+
+  applyHighlights(fileUri: string) {
+if (!this.files.has(fileUri)) {
+  return;
+}
+const ranges = this.files.get(fileUri);
+vscode.window.visibleTextEditors.forEach((e) => {
+  if (e.document.uri.toString() !== fileUri)
+return;
+  e.setDecorations(this.decorationType, ranges);
+});
+  }
+
+  // Disposes of all disposable resources used by this object.
+  public dispose() {
+this.subscriptions.forEach((d) => d.dispose());
+this.subscriptions = [];
+  }
+}
\ No newline at end of file
Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -1,6 +1,7 @@
 import * as vscode from 'vscode';
 import * as vscodelc from 'vscode-languageclient';
 import * as semanticHighlighting from './semantic-highlighting';
+import * as inactiveRegions from './inactive-regions';
 
 /**
  * Method to get workspace configuration option
@@ -13,15 +14,15 @@
 }
 
 namespace SwitchSourceHeaderRequest {
-export const type =
-new vscodelc.RequestType('textDocument/switchSourceHeader');
+  export const type =
+new vscodelc.RequestType('textDocument/switchSourceHeader');
 }
 
 class FileStatus {
   private statuses = new Map();
   private readonly statusBarItem =
-  vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 10);
+vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 10);
 
   onFileUpdated(fileStatus: any) {
 const filePath = vscode.Uri.parse(fileStatus.uri);
@@ -58,7 +59,7 @@
   // prompt up the failure to users.
   logFailedRequest(rpcReply: vscodelc.RPCMessageType, error: any) {
 if (error instanceof vscodelc.ResponseError &&

[PATCH] D67536: [WIP] [clangd] Add support for an inactive regions notification

2019-09-12 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
nridge added reviewers: sammccall, ilya-biryukov, hokein.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay.
Herald added a project: clang.
nridge added a comment.

This patch adds server-side support for greying out code in inactive 
preprocessor branches (issue #132 
).

I didn't write test yet. I wanted to post the patch for feedback first, to see 
if the general approach is ok.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67536

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Compiler.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h

Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -85,6 +85,10 @@
 diffHighlightings(ArrayRef New,
   ArrayRef Old);
 
+// Returns all inactive regions from an AST. Only generates inactive regions
+// for the main AST.
+std::vector getInactiveRegions(ParsedAST );
+
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -479,5 +479,18 @@
   llvm_unreachable("unhandled HighlightingKind");
 }
 
+std::vector getInactiveRegions(ParsedAST ) {
+  std::vector Result;
+  const SourceManager  = AST.getSourceManager();
+  for (const SourceRange  :
+   AST.getPreprocessor().getPreprocessingRecord()->getSkippedRanges()) {
+if (isInsideMainFile(R.getBegin(), SM)) {
+  Result.push_back({sourceLocToPosition(SM, R.getBegin()),
+sourceLocToPosition(SM, R.getEnd())});
+}
+  }
+  return Result;
+}
+
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -1222,6 +1222,15 @@
 };
 llvm::json::Value toJSON(const SemanticHighlightingParams );
 
+/// Parameters for the inactive regions (server-side) push notification.
+struct InactiveRegionsParams {
+  /// The textdocument these inactive regions belong to.
+  TextDocumentIdentifier TextDocument;
+  /// The inactive regions that should be sent.
+  std::vector InactiveRegions;
+};
+llvm::json::Value toJSON(const InactiveRegionsParams );
+
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -1073,5 +1073,11 @@
   };
 }
 
+llvm::json::Value toJSON(const InactiveRegionsParams ) {
+  return llvm::json::Object{
+  {"textDocument", InactiveRegions.TextDocument},
+  {"regions", std::move(InactiveRegions.InactiveRegions)}};
+}
+
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Compiler.cpp
===
--- clang-tools-extra/clangd/Compiler.cpp
+++ clang-tools-extra/clangd/Compiler.cpp
@@ -63,6 +63,7 @@
   // createInvocationFromCommandLine sets DisableFree.
   CI->getFrontendOpts().DisableFree = false;
   CI->getLangOpts()->CommentOpts.ParseAllComments = true;
+  CI->getPreprocessorOpts().DetailedRecord = true;
   return CI;
 }
 
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -52,11 +52,13 @@
   virtual void onFileUpdated(PathRef File, const TUStatus ){};
 
   /// Called by ClangdServer when some \p Highlightings for \p File are ready.
-  /// \p NumLines are the number of lines in the file where the highlightings
-  /// where generated from.
   virtual void
   onHighlightingsReady(PathRef File,
std::vector Highlightings) {}
+
+  /// Called by ClangdServer when some \p InactiveRegions for \p File are ready.
+  virtual void onInactiveRegionsReady(PathRef File,
+  std::vector InactiveRegions) {}
 };
 
 /// When set, used by ClangdServer to get clang-tidy options for each particular
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -53,9 +53,10 @@
 // Update 

[PATCH] D67536: [WIP] [clangd] Add support for an inactive regions notification

2019-09-12 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

This patch adds server-side support for greying out code in inactive 
preprocessor branches (issue #132 
).

I didn't write test yet. I wanted to post the patch for feedback first, to see 
if the general approach is ok.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67536/new/

https://reviews.llvm.org/D67536



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67490: [Clang][ASTImporter] Added visibility check for FunctionTemplateDecl.

2019-09-12 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin accepted this revision.
a_sidorin added a comment.
This revision is now accepted and ready to land.

Looks good!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67490/new/

https://reviews.llvm.org/D67490



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r371816 - Fix interaction between r371813 and r371814.

2019-09-12 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Sep 12 22:29:16 2019
New Revision: 371816

URL: http://llvm.org/viewvc/llvm-project?rev=371816=rev
Log:
Fix interaction between r371813 and r371814.

Modified:
cfe/trunk/test/CodeGen/builtins-ppc-altivec.c

Modified: cfe/trunk/test/CodeGen/builtins-ppc-altivec.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ppc-altivec.c?rev=371816=371815=371816=diff
==
--- cfe/trunk/test/CodeGen/builtins-ppc-altivec.c (original)
+++ cfe/trunk/test/CodeGen/builtins-ppc-altivec.c Thu Sep 12 22:29:16 2019
@@ -1,10 +1,10 @@
 // REQUIRES: powerpc-registered-target
 // RUN: %clang_cc1 -target-feature +altivec -triple powerpc-unknown-unknown 
-emit-llvm %s \
-// RUN:-flax-vector-conversions=none -o - | FileCheck %s
+// RUN:-fno-lax-vector-conversions -o - | FileCheck %s
 // RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown 
-emit-llvm %s \
-// RUN:-flax-vector-conversions=none -o - | FileCheck %s
+// RUN:-fno-lax-vector-conversions -o - | FileCheck %s
 // RUN: %clang_cc1 -target-feature +altivec -triple 
powerpc64le-unknown-unknown -emit-llvm %s \
-// RUN:-flax-vector-conversions=none -o - | FileCheck %s 
-check-prefix=CHECK-LE
+// RUN:-fno-lax-vector-conversions -o - | FileCheck %s 
-check-prefix=CHECK-LE
 // RUN: not %clang_cc1 -triple powerpc64le-unknown-unknown -emit-llvm %s \
 // RUN:-ferror-limit 0 -DNO_ALTIVEC -o - 2>&1 \
 // RUN:| FileCheck %s -check-prefix=CHECK-NOALTIVEC


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r371814 - Remove reliance on lax vector conversions from altivec.h and its test.

2019-09-12 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Sep 12 22:19:12 2019
New Revision: 371814

URL: http://llvm.org/viewvc/llvm-project?rev=371814=rev
Log:
Remove reliance on lax vector conversions from altivec.h and its test.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsPPC.def
cfe/trunk/lib/Headers/altivec.h
cfe/trunk/test/CodeGen/builtins-ppc-altivec.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsPPC.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsPPC.def?rev=371814=371813=371814=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsPPC.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsPPC.def Thu Sep 12 22:19:12 2019
@@ -50,8 +50,8 @@ BUILTIN(__builtin_altivec_vavguw, "V4UiV
 
 BUILTIN(__builtin_altivec_vrfip, "V4fV4f", "")
 
-BUILTIN(__builtin_altivec_vcfsx, "V4fV4iIi", "")
-BUILTIN(__builtin_altivec_vcfux, "V4fV4iIi", "")
+BUILTIN(__builtin_altivec_vcfsx, "V4fV4SiIi", "")
+BUILTIN(__builtin_altivec_vcfux, "V4fV4UiIi", "")
 BUILTIN(__builtin_altivec_vctsxs, "V4SiV4fIi", "")
 BUILTIN(__builtin_altivec_vctuxs, "V4UiV4fIi", "")
 

Modified: cfe/trunk/lib/Headers/altivec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/altivec.h?rev=371814=371813=371814=diff
==
--- cfe/trunk/lib/Headers/altivec.h (original)
+++ cfe/trunk/lib/Headers/altivec.h Thu Sep 12 22:19:12 2019
@@ -2876,9 +2876,10 @@ static __inline__ vector double __ATTRS_
 #ifdef __VSX__
 #define vec_ctf(__a, __b)  
\
   _Generic((__a), vector int   
\
-   : (vector float)__builtin_altivec_vcfsx((__a), (__b)),  
\
+   : (vector float)__builtin_altivec_vcfsx((vector int)(__a), (__b)),  
\
  vector unsigned int   
\
-   : (vector float)__builtin_altivec_vcfux((vector int)(__a), (__b)),  
\
+   : (vector float)__builtin_altivec_vcfux((vector unsigned int)(__a), 
\
+   (__b)), 
\
  vector unsigned long long 
\
: (__builtin_convertvector((vector unsigned long long)(__a),
\
   vector double) * 
\
@@ -2892,9 +2893,10 @@ static __inline__ vector double __ATTRS_
 #else
 #define vec_ctf(__a, __b)  
\
   _Generic((__a), vector int   
\
-   : (vector float)__builtin_altivec_vcfsx((__a), (__b)),  
\
+   : (vector float)__builtin_altivec_vcfsx((vector int)(__a), (__b)),  
\
  vector unsigned int   
\
-   : (vector float)__builtin_altivec_vcfux((vector int)(__a), (__b)))
+   : (vector float)__builtin_altivec_vcfux((vector unsigned int)(__a), 
\
+   (__b)))
 #endif
 
 /* vec_vcfsx */
@@ -16423,27 +16425,27 @@ vec_xl(signed long long __offset, unsign
 #ifdef __LITTLE_ENDIAN__
 static __inline__ vector signed char __ATTRS_o_ai
 vec_xl_be(signed long long __offset, signed char *__ptr) {
-  vector signed char __vec = __builtin_vsx_lxvd2x_be(__offset, __ptr);
+  vector signed char __vec = (vector signed 
char)__builtin_vsx_lxvd2x_be(__offset, __ptr);
   return __builtin_shufflevector(__vec, __vec, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14,
  13, 12, 11, 10, 9, 8);
 }
 
 static __inline__ vector unsigned char __ATTRS_o_ai
 vec_xl_be(signed long long __offset, unsigned char *__ptr) {
-  vector unsigned char __vec = __builtin_vsx_lxvd2x_be(__offset, __ptr);
+  vector unsigned char __vec = (vector unsigned 
char)__builtin_vsx_lxvd2x_be(__offset, __ptr);
   return __builtin_shufflevector(__vec, __vec, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14,
  13, 12, 11, 10, 9, 8);
 }
 
 static __inline__ vector signed short  __ATTRS_o_ai
 vec_xl_be(signed long long __offset, signed short *__ptr) {
-  vector signed short __vec = __builtin_vsx_lxvd2x_be(__offset, __ptr);
+  vector signed short __vec = (vector signed 
short)__builtin_vsx_lxvd2x_be(__offset, __ptr);
   return __builtin_shufflevector(__vec, __vec, 3, 2, 1, 0, 7, 6, 5, 4);
 }
 
 static __inline__ vector unsigned short __ATTRS_o_ai
 vec_xl_be(signed long long __offset, unsigned short *__ptr) {
-  vector unsigned short __vec = __builtin_vsx_lxvd2x_be(__offset, __ptr);
+  vector unsigned short __vec = (vector unsigned 
short)__builtin_vsx_lxvd2x_be(__offset, __ptr);
   return __builtin_shufflevector(__vec, __vec, 3, 2, 1, 0, 7, 6, 5, 4);
 }
 
@@ -16581,7 +16583,8 @@ static __inline__ void __ATTRS_o_ai vec_
   vector signed char __tmp =
  

r371813 - Revert "For PR17164: split -fno-lax-vector-conversion into three different"

2019-09-12 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Thu Sep 12 22:16:59 2019
New Revision: 371813

URL: http://llvm.org/viewvc/llvm-project?rev=371813=rev
Log:
Revert "For PR17164: split -fno-lax-vector-conversion into three different"

This breaks the LLDB build. I tried reaching out to Richard, but haven't
gotten a reply yet.

Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CodeGen/builtins-systemz-vector.c
cfe/trunk/test/CodeGen/builtins-systemz-vector2.c
cfe/trunk/test/CodeGen/builtins-systemz-vector3.c
cfe/trunk/test/CodeGen/builtins-systemz-zvector-error.c
cfe/trunk/test/CodeGen/builtins-systemz-zvector.c
cfe/trunk/test/CodeGen/builtins-systemz-zvector2-error.c
cfe/trunk/test/CodeGen/builtins-systemz-zvector2.c
cfe/trunk/test/CodeGen/builtins-systemz-zvector3-error.c
cfe/trunk/test/CodeGen/builtins-systemz-zvector3.c
cfe/trunk/test/CodeGen/builtins-wasm.c
cfe/trunk/test/CodeGenCXX/builtins-systemz-zvector.cpp
cfe/trunk/test/Headers/altivec-header.c
cfe/trunk/test/Headers/arm-neon-header.c
cfe/trunk/test/Headers/x86-intrinsics-headers-clean.cpp
cfe/trunk/test/Headers/x86-intrinsics-headers.c
cfe/trunk/test/Headers/x86intrin-2.c
cfe/trunk/test/Headers/x86intrin.c
cfe/trunk/test/Sema/ext_vector_casts.c
cfe/trunk/test/Sema/typedef-retain.c
cfe/trunk/test/Sema/zvector.c
cfe/trunk/test/Sema/zvector2.c
cfe/trunk/test/SemaCXX/altivec.cpp
cfe/trunk/test/SemaCXX/vector-no-lax.cpp
cfe/trunk/test/SemaCXX/vector.cpp

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=371813=371812=371813=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Thu Sep 12 22:16:59 2019
@@ -119,8 +119,7 @@ LANGOPT(AppleKext , 1, 0, "Apple
 BENIGN_LANGOPT(PascalStrings, 1, 0, "Pascal string support")
 LANGOPT(WritableStrings   , 1, 0, "writable string support")
 LANGOPT(ConstStrings  , 1, 0, "const-qualified string support")
-ENUM_LANGOPT(LaxVectorConversions, LaxVectorConversionKind, 2,
- LaxVectorConversionKind::All, "lax vector conversions")
+LANGOPT(LaxVectorConversions , 1, 1, "lax vector conversions")
 LANGOPT(AltiVec   , 1, 0, "AltiVec-style vector initializers")
 LANGOPT(ZVector   , 1, 0, "System z vector extensions")
 LANGOPT(Exceptions, 1, 0, "exception handling")

Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=371813=371812=371813=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Thu Sep 12 22:16:59 2019
@@ -184,16 +184,6 @@ public:
 FEA_On
   };
 
-  enum class LaxVectorConversionKind {
-/// Permit no implicit vector bitcasts.
-None,
-/// Permit vector bitcasts between integer vectors with different numbers
-/// of elements but the same total bit-width.
-Integer,
-/// Permit vector bitcasts between all vectors with the same total
-/// bit-width.
-All,
-  };
 
 public:
   /// Set of enabled sanitizers.

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=371813=371812=371813=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Sep 12 22:16:59 2019
@@ -1274,10 +1274,7 @@ def fno_fine_grained_bitfield_accesses :
   HelpText<"Use large-integer access for consecutive bitfield runs.">;
 
 def flat__namespace : Flag<["-"], "flat_namespace">;
-def flax_vector_conversions_EQ : Joined<["-"], "flax-vector-conversions=">, 
Group,
-  HelpText<"Enable implicit vector bit-casts">, Values<"none,integer,all">, 
Flags<[CC1Option]>;
-def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, 
Group,
-  Alias, AliasArgs<["integer"]>;
+def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, 
Group;
 def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, 
Group;
 def fapple_link_rtlib : Flag<["-"], "fapple-link-rtlib">, Group,
   HelpText<"Force linking the clang builtins runtime library">;
@@ -1451,7 +1448,7 @@ def fno_experimental_new_pass_manager :
 def fveclib : Joined<["-"], "fveclib=">, Group, Flags<[CC1Option]>,
 HelpText<"Use the given vector functions library">, 
Values<"Accelerate,MASSV,SVML,none">;
 def 

[PATCH] D67399: [ARM] Follow AACPS standard for volatile bitfields

2019-09-12 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I have to say that I disagree.  The ABI certainly doesn't get to control the 
language and define what constitutes a volatile access, but when the language 
has decided that a volatile access is actually performed, I think ABIs 
absolutely ought to define how they should be compiled.  Volatile accesses are 
quite unusual in that they are used for a purpose — memory-mapped I/O — that is 
extremely dependent for correctness on the exact instructions used to implement 
it.  IIRC there are architectures that for whatever reason provide two 
different load instructions where only one of those instructions actually 
performs memory-mapped I/O correctly.  Certainly the exact width of load or 
store is critical for correctness.  So while I have certainly seen ABI 
overreach before and pushed back on it, for this one case I think ABI 
involvement is totally appropriate, and in fact I wish more ABIs specified how 
they expect volatile accesses to be performed.

It is, of course, somewhat unfortunate that a corner-case use case like 
memory-mapped I/O has been privileged with such a core position in the 
language, but that's how it is.

I do think that AAPCS's specific request that the compiler emit spurious loads 
when storing to volatile bit-fields is a bad idea, and I think it would be fine 
to push back on that part, and perhaps also on the idea that compound 
assignments and increments should load twice.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67399/new/

https://reviews.llvm.org/D67399



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r371805 - For PR17164: split -fno-lax-vector-conversion into three different

2019-09-12 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Sep 12 19:20:00 2019
New Revision: 371805

URL: http://llvm.org/viewvc/llvm-project?rev=371805=rev
Log:
For PR17164: split -fno-lax-vector-conversion into three different
levels:

 -- none: no lax vector conversions [new GCC default]
 -- integer: only conversions between integer vectors [old GCC default]
 -- all: all conversions between same-size vectors [Clang default]

For now, Clang still defaults to "all" mode, but per my proposal on
cfe-dev (2019-04-10) the default will be changed to "integer" as soon as
that doesn't break lots of testcases. (Eventually I'd like to change the
default to "none" to match GCC and general sanity.)

Following GCC's behavior, the driver flag -flax-vector-conversions is
translated to -flax-vector-conversions=integer.

Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CodeGen/builtins-systemz-vector.c
cfe/trunk/test/CodeGen/builtins-systemz-vector2.c
cfe/trunk/test/CodeGen/builtins-systemz-vector3.c
cfe/trunk/test/CodeGen/builtins-systemz-zvector-error.c
cfe/trunk/test/CodeGen/builtins-systemz-zvector.c
cfe/trunk/test/CodeGen/builtins-systemz-zvector2-error.c
cfe/trunk/test/CodeGen/builtins-systemz-zvector2.c
cfe/trunk/test/CodeGen/builtins-systemz-zvector3-error.c
cfe/trunk/test/CodeGen/builtins-systemz-zvector3.c
cfe/trunk/test/CodeGen/builtins-wasm.c
cfe/trunk/test/CodeGenCXX/builtins-systemz-zvector.cpp
cfe/trunk/test/Headers/altivec-header.c
cfe/trunk/test/Headers/arm-neon-header.c
cfe/trunk/test/Headers/x86-intrinsics-headers-clean.cpp
cfe/trunk/test/Headers/x86-intrinsics-headers.c
cfe/trunk/test/Headers/x86intrin-2.c
cfe/trunk/test/Headers/x86intrin.c
cfe/trunk/test/Sema/ext_vector_casts.c
cfe/trunk/test/Sema/typedef-retain.c
cfe/trunk/test/Sema/zvector.c
cfe/trunk/test/Sema/zvector2.c
cfe/trunk/test/SemaCXX/altivec.cpp
cfe/trunk/test/SemaCXX/vector-no-lax.cpp
cfe/trunk/test/SemaCXX/vector.cpp

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=371805=371804=371805=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Thu Sep 12 19:20:00 2019
@@ -119,7 +119,8 @@ LANGOPT(AppleKext , 1, 0, "Apple
 BENIGN_LANGOPT(PascalStrings, 1, 0, "Pascal string support")
 LANGOPT(WritableStrings   , 1, 0, "writable string support")
 LANGOPT(ConstStrings  , 1, 0, "const-qualified string support")
-LANGOPT(LaxVectorConversions , 1, 1, "lax vector conversions")
+ENUM_LANGOPT(LaxVectorConversions, LaxVectorConversionKind, 2,
+ LaxVectorConversionKind::All, "lax vector conversions")
 LANGOPT(AltiVec   , 1, 0, "AltiVec-style vector initializers")
 LANGOPT(ZVector   , 1, 0, "System z vector extensions")
 LANGOPT(Exceptions, 1, 0, "exception handling")

Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=371805=371804=371805=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Thu Sep 12 19:20:00 2019
@@ -184,6 +184,16 @@ public:
 FEA_On
   };
 
+  enum class LaxVectorConversionKind {
+/// Permit no implicit vector bitcasts.
+None,
+/// Permit vector bitcasts between integer vectors with different numbers
+/// of elements but the same total bit-width.
+Integer,
+/// Permit vector bitcasts between all vectors with the same total
+/// bit-width.
+All,
+  };
 
 public:
   /// Set of enabled sanitizers.

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=371805=371804=371805=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Sep 12 19:20:00 2019
@@ -1274,7 +1274,10 @@ def fno_fine_grained_bitfield_accesses :
   HelpText<"Use large-integer access for consecutive bitfield runs.">;
 
 def flat__namespace : Flag<["-"], "flat_namespace">;
-def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, 
Group;
+def flax_vector_conversions_EQ : Joined<["-"], "flax-vector-conversions=">, 
Group,
+  HelpText<"Enable implicit vector bit-casts">, Values<"none,integer,all">, 
Flags<[CC1Option]>;
+def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, 

[PATCH] D67515: [Sema][Typo Correction] Fix potential infite loop on ambiguity checks

2019-09-12 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: test/Sema/typo-correction-ambiguity.cpp:7
+
+namespace AmibguousCorrection
+{

Is the typo in "Ambiguous" here intentional? :)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67515/new/

https://reviews.llvm.org/D67515



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67425: [WebAssembly] Narrowing and widening SIMD ops

2019-09-12 Thread Thomas Lively via Phabricator via cfe-commits
tlively added a comment.

In D67425#1668831 , @aheejin wrote:

> LGTM.
>
> - Maybe we can lower these 
> 
>  to these new instructions later? (I'm not very sure what the difference 
> between versions with and without `VECTOR`, because the versions without 
> `VECTOR` seem to be able to take vector arguments as well.)
> - Will this simplify the complicated lowering of `SIGN_EXTEND_INREG` 
> ?


Yes, good points. I will make a note to go back and clean these up once we are 
able to emit these instructions without explicit user opt-in.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67425/new/

https://reviews.llvm.org/D67425



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67425: [WebAssembly] Narrowing and widening SIMD ops

2019-09-12 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin accepted this revision.
aheejin added a comment.
This revision is now accepted and ready to land.

LGTM.

- Maybe we can lower these 

 to these new instructions later? (I'm not very sure what the difference 
between versions with and without `VECTOR`, because the versions without 
`VECTOR` seem to be able to take vector arguments as well.)
- Will this simplify the complicated lowering of `SIGN_EXTEND_INREG` 
?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67425/new/

https://reviews.llvm.org/D67425



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67399: [ARM] Follow AACPS standard for volatile bitfields

2019-09-12 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D67399#1668759 , @rjmccall wrote:

> The exact sequence of volatile accesses is observable behavior, and it's the 
> ABI's right to define correct behavior for compliant implementations, so we 
> do need to do this.


I'm not convinced; I think the AAPCS is overstepping its bounds here by trying 
to specify this. Whether you get a volatile load for a full-width bitfield 
access doesn't seem to have anything to do with ABI; implementations that 
differ on this detail will be able to produce code that links together and 
works together just fine. I think this is instead a question of what guarantees 
the implementation wants to give about how it treats volatile operations and 
how it lowers them to hardware. That should be specified, sure (and in fact C++ 
at least requires us to document what we do), but it's not ABI any more than 
(for example) the choice of whether a volatile access to a local variable must 
actually issue load / store instructions -- or which instructions must be 
produced -- is ABI. I have no particular opinion on whether we should make this 
change -- volatile bit-fields are pretty weird and broken regardless. But I 
don't think we should view it as being part of the ABI, and just as with the 
question of whether plain bit-fields are signed, we should tell the psABI folks 
that the question of what constitutes a volatile access and the semantics of 
such an access is not ABI and not up to them.

(Similar example: on Windows x86 targets, `volatile` accesses are atomic by 
default (controlled by compiler switch). `clang-cl` follows `cl` in this 
regard, but we don't consider it to be part of the ABI, and in the regular 
clang driver, we do not treat `volatile` accesses as atomic when targeting 
Windows x86.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67399/new/

https://reviews.llvm.org/D67399



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61717: Fix arm_neon.h to be clean under -fno-lax-vector-conversions.

2019-09-12 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith abandoned this revision.
rsmith added a comment.

This patch doesn't work, and the ARM NEON intrinsic header emitter is too 
opaque and mysterious for me to be able to fix this, and it's not even clear 
that the generator knows what the actual parameter types of the compiler 
builtins are. For now I think the best I can do is to leave ARM targets with 
lax vector conversions enabled, and disable it for all the other targets. :-(

(It's also completely ridiculous that we're generating a 63K LoC (2.1MB) header 
file for this; our approach to intrinsics headers is unreasonable in the 
extreme. But I digress.)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61717/new/

https://reviews.llvm.org/D61717



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r371799 - Revert r371785.

2019-09-12 Thread Manoj Gupta via cfe-commits
Author: manojgupta
Date: Thu Sep 12 17:28:37 2019
New Revision: 371799

URL: http://llvm.org/viewvc/llvm-project?rev=371799=rev
Log:
Revert r371785.

r371785 is causing fails on clang-hexagon-elf buildbots.

Removed:
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/
cfe/trunk/test/Frontend/warning-poison-system-directories.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=371799=371798=371799=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Thu Sep 12 17:28:37 
2019
@@ -315,9 +315,4 @@ def err_unknown_analyzer_checker_or_pack
 "no analyzer checkers or packages are associated with '%0'">;
 def note_suggest_disabling_all_checkers : Note<
 "use -analyzer-disable-all-checks to disable all static analyzer 
checkers">;
-
-// Poison system directories.
-def warn_poison_system_directories : Warning <
-  "include location '%0' is unsafe for cross-compilation">,
-  InGroup>, DefaultIgnore;
 }

Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=371799=371798=371799=diff
==
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Thu Sep 12 17:28:37 2019
@@ -137,13 +137,6 @@ bool InitHeaderSearch::AddUnmappedPath(c
   SmallString<256> MappedPathStorage;
   StringRef MappedPathStr = Path.toStringRef(MappedPathStorage);
 
-  // If use system headers while cross-compiling, emit the warning.
-  if (HasSysroot && (MappedPathStr.startswith("/usr/include") ||
- MappedPathStr.startswith("/usr/local/include"))) {
-Headers.getDiags().Report(diag::warn_poison_system_directories)
-<< MappedPathStr;
-  }
-
   // Compute the DirectoryLookup type.
   SrcMgr::CharacteristicKind Type;
   if (Group == Quoted || Group == Angled || Group == IndexHeaderMap) {

Removed: cfe/trunk/test/Frontend/warning-poison-system-directories.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/warning-poison-system-directories.c?rev=371798=auto
==
--- cfe/trunk/test/Frontend/warning-poison-system-directories.c (original)
+++ cfe/trunk/test/Frontend/warning-poison-system-directories.c (removed)
@@ -1,27 +0,0 @@
-// System directory and sysroot option causes warning.
-// RUN: %clang -Wpoison-system-directories -target x86_64 -I/usr/include 
--sysroot %S/Inputs/sysroot_x86_64_cross_linux_tree -c -o - %s 2> %t.1.stderr
-// RUN: FileCheck -check-prefix=WARN < %t.1.stderr %s
-// RUN: %clang -Wpoison-system-directories -target x86_64 
-cxx-isystem/usr/include --sysroot %S/Inputs/sysroot_x86_64_cross_linux_tree -c 
-o - %s 2> %t.1.stderr
-// RUN: FileCheck -check-prefix=WARN < %t.1.stderr %s
-// RUN: %clang -Wpoison-system-directories -target x86_64 
-iquote/usr/local/include --sysroot %S/Inputs/sysroot_x86_64_cross_linux_tree 
-c -o - %s 2> %t.1.stderr
-// RUN: FileCheck -check-prefix=WARN < %t.1.stderr %s
-// RUN: %clang -Wpoison-system-directories -target x86_64 
-isystem/usr/local/include --sysroot %S/Inputs/sysroot_x86_64_cross_linux_tree 
-c -o - %s 2> %t.1.stderr
-// RUN: FileCheck -check-prefix=WARN < %t.1.stderr %s
-
-// Missing target but included sysroot still causes the warning.
-// RUN: %clang -Wpoison-system-directories -I/usr/include --sysroot 
%S/Inputs/sysroot_x86_64_cross_linux_tree -c -o - %s 2> %t.2.stderr
-// RUN: FileCheck -check-prefix=WARN < %t.2.stderr %s
-
-// With -Werror the warning causes the failure.
-// RUN: not %clang -Werror=poison-system-directories -target x86_64 
-I/usr/include --sysroot %S/Inputs/sysroot_x86_64_cross_linux_tree -c -o - %s 
2> %t.3.stderr
-// RUN: FileCheck -check-prefix=ERROR < %t.3.stderr %s
-
-// Cros target without sysroot causes no warning.
-// RUN: %clang -Wpoison-system-directories -Werror -target x86_64 
-I/usr/include -c -o - %s
-
-// By default the warning is off.
-// RUN: %clang -Werror -target x86_64 -I/usr/include --sysroot 
%S/Inputs/sysroot_x86_64_cross_linux_tree -c -o - %s
-
-// WARN: warning: include location {{[^ ]+}} is unsafe for cross-compilation 
[-Wpoison-system-directories]
-
-// ERROR: error: include location {{[^ ]+}} is unsafe for cross-compilation 
[-Werror,-Wpoison-system-directories]


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67409: [RISCV] enable LTO support, pass some options to linker.

2019-09-12 Thread Kuan Hsu Chen via Phabricator via cfe-commits
khchen added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/RISCV.cpp:387
+
+void riscv::addGoldOptions(const ToolChain ,
+   const llvm::opt::ArgList ,

kito-cheng wrote:
> MaskRay wrote:
> > gold doesn't support RISC-V, does it?
> Gold doesn't support RISC-V , but ld.bfd supported same plugin API, so this 
> made clang can run LTO with ld.bfd.
I reference `AddGoldPlugin` to naming this function, is it confusing?



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67409/new/

https://reviews.llvm.org/D67409



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67399: [ARM] Follow AACPS standard for volatile bitfields

2019-09-12 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

The exact sequence of volatile accesses is observable behavior, and it's the 
ABI's right to define correct behavior for compliant implementations, so we do 
need to do this.

Diogo, IRGen breaks up bit-field storage units in 
CGRecordLowering::accumulateBitFields.  I'm sure there's some reasonable way to 
add target-specific adjustments to that so that we break things up by storage 
unit.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67399/new/

https://reviews.llvm.org/D67399



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r371794 - [libclang] Fix UninstallAbortingLLVMFatalErrorHandler test

2019-09-12 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Thu Sep 12 16:51:48 2019
New Revision: 371794

URL: http://llvm.org/viewvc/llvm-project?rev=371794=rev
Log:
[libclang] Fix UninstallAbortingLLVMFatalErrorHandler test

Modified:
cfe/trunk/unittests/libclang/CrashTests/LibclangCrashTest.cpp

Modified: cfe/trunk/unittests/libclang/CrashTests/LibclangCrashTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/libclang/CrashTests/LibclangCrashTest.cpp?rev=371794=371793=371794=diff
==
--- cfe/trunk/unittests/libclang/CrashTests/LibclangCrashTest.cpp (original)
+++ cfe/trunk/unittests/libclang/CrashTests/LibclangCrashTest.cpp Thu Sep 12 
16:51:48 2019
@@ -31,6 +31,7 @@ TEST_F(LibclangParseTest, UninstallAbort
   std::string Main = "main.h";
   WriteFile(Main, "#pragma clang __debug llvm_fatal_error");
 
-  EXPECT_NO_FATAL_FAILURE(clang_parseTranslationUnit(
-  Index, Main.c_str(), nullptr, 0, nullptr, 0, TUFlags));
+  EXPECT_EXIT(clang_parseTranslationUnit(
+  Index, Main.c_str(), nullptr, 0, nullptr, 0, TUFlags),
+  ::testing::ExitedWithCode(1), "ERROR");
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63031: DebugInfo: Render the canonical name of a class template specialization, even when nested in another class template specialization

2019-09-12 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Some more ping (:


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63031/new/

https://reviews.llvm.org/D63031



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r371787 - [libclang] Expose abort()-ing LLVM fatal error handler

2019-09-12 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Thu Sep 12 15:55:55 2019
New Revision: 371787

URL: http://llvm.org/viewvc/llvm-project?rev=371787=rev
Log:
[libclang] Expose abort()-ing LLVM fatal error handler

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

Added:
cfe/trunk/include/clang-c/FatalErrorHandler.h
cfe/trunk/tools/libclang/FatalErrorHandler.cpp
cfe/trunk/unittests/libclang/CrashTests/
cfe/trunk/unittests/libclang/CrashTests/CMakeLists.txt
cfe/trunk/unittests/libclang/CrashTests/LibclangCrashTest.cpp
Modified:
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CMakeLists.txt
cfe/trunk/tools/libclang/libclang.exports
cfe/trunk/unittests/libclang/CMakeLists.txt

Added: cfe/trunk/include/clang-c/FatalErrorHandler.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/FatalErrorHandler.h?rev=371787=auto
==
--- cfe/trunk/include/clang-c/FatalErrorHandler.h (added)
+++ cfe/trunk/include/clang-c/FatalErrorHandler.h Thu Sep 12 15:55:55 2019
@@ -0,0 +1,33 @@
+/*===-- clang-c/FatalErrorHandler.h - Fatal Error Handling *- C 
-*-===*\
+|*
*|
+|* Part of the LLVM Project, under the Apache License v2.0 with LLVM  
*|
+|* Exceptions.
*|
+|* See https://llvm.org/LICENSE.txt for license information.  
*|
+|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*|
+|*
*|
+\*===--===*/
+
+#ifndef LLVM_CLANG_C_FATAL_ERROR_HANDLER_H
+#define LLVM_CLANG_C_FATAL_ERROR_HANDLER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Installs error handler that prints error message to stderr and calls 
abort().
+ * Replaces currently installed error handler (if any).
+ */
+void clang_install_aborting_llvm_fatal_error_handler();
+
+/**
+ * Removes currently installed error handler (if any).
+ * If no error handler is intalled, the default strategy is to print error
+ * message to stderr and call exit(1).
+ */
+void clang_uninstall_llvm_fatal_error_handler();
+
+#ifdef __cplusplus
+}
+#endif
+#endif

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=371787=371786=371787=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Thu Sep 12 15:55:55 2019
@@ -20,6 +20,7 @@
 #include "CXTranslationUnit.h"
 #include "CXType.h"
 #include "CursorVisitor.h"
+#include "clang-c/FatalErrorHandler.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/StmtVisitor.h"
@@ -3243,18 +3244,10 @@ RefNamePieces buildPieces(unsigned NameF
 // Misc. API hooks.
 
//===--===//
   
 
-static void fatal_error_handler(void *user_data, const std::string& reason,
-bool gen_crash_diag) {
-  // Write the result out to stderr avoiding errs() because raw_ostreams can
-  // call report_fatal_error.
-  fprintf(stderr, "LIBCLANG FATAL ERROR: %s\n", reason.c_str());
-  ::abort();
-}
-
 namespace {
 struct RegisterFatalErrorHandler {
   RegisterFatalErrorHandler() {
-llvm::install_fatal_error_handler(fatal_error_handler, nullptr);
+clang_install_aborting_llvm_fatal_error_handler();
   }
 };
 }

Modified: cfe/trunk/tools/libclang/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CMakeLists.txt?rev=371787=371786=371787=diff
==
--- cfe/trunk/tools/libclang/CMakeLists.txt (original)
+++ cfe/trunk/tools/libclang/CMakeLists.txt Thu Sep 12 15:55:55 2019
@@ -19,6 +19,7 @@ set(SOURCES
   CXString.cpp
   CXType.cpp
   Indexing.cpp
+  FatalErrorHandler.cpp
 
   ADDITIONAL_HEADERS
   CIndexDiagnostic.h
@@ -43,6 +44,7 @@ set(LIBS
   clangSema
   clangSerialization
   clangTooling
+  LLVMSupport
 )
 
 if (CLANG_ENABLE_ARCMT)

Added: cfe/trunk/tools/libclang/FatalErrorHandler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/FatalErrorHandler.cpp?rev=371787=auto
==
--- cfe/trunk/tools/libclang/FatalErrorHandler.cpp (added)
+++ cfe/trunk/tools/libclang/FatalErrorHandler.cpp Thu Sep 12 15:55:55 2019
@@ -0,0 +1,28 @@
+/*===-- clang-c/FatalErrorHandler.cpp - Fatal Error Handling --*- C 
-*-===*\
+|*
*|
+|* Part of the LLVM Project, under the Apache License v2.0 with LLVM  
*|
+|* Exceptions. 

[PATCH] D52524: Add -Wpoison-system-directories warning

2019-09-12 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta closed this revision.
manojgupta added a comment.

Submitted as https://reviews.llvm.org/rL371785.
Thanks for the patch!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D52524/new/

https://reviews.llvm.org/D52524



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r371785 - Add -Wpoison-system-directories warning

2019-09-12 Thread Manoj Gupta via cfe-commits
Author: manojgupta
Date: Thu Sep 12 15:36:13 2019
New Revision: 371785

URL: http://llvm.org/viewvc/llvm-project?rev=371785=rev
Log:
Add -Wpoison-system-directories warning

When using clang as a cross-compiler, we should not use system
headers to do the compilation.
This CL adds support of a new warning flag -Wpoison-system-directories which
emits warnings if --sysroot is set and headers from common host system location
are used.
By default the warning is disabled.

The intention of the warning is to catch bad includes which are usually
generated by third party build system not targeting cross-compilation.
Such cases happen in Chrome OS when someone imports a new package or upgrade
one to a newer version from upstream.

Patch by: denik (Denis Nikitin)

Added:
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/lib/
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/lib/.keep
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/include/

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/include/c++/

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/include/c++/.keep
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/lib/
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/lib/gcc/

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/lib/gcc/.keep
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/local/

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/local/include/

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/local/include/.keep

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/local/lib/

cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/local/lib/.keep
cfe/trunk/test/Frontend/warning-poison-system-directories.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=371785=371784=371785=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Thu Sep 12 15:36:13 
2019
@@ -315,4 +315,9 @@ def err_unknown_analyzer_checker_or_pack
 "no analyzer checkers or packages are associated with '%0'">;
 def note_suggest_disabling_all_checkers : Note<
 "use -analyzer-disable-all-checks to disable all static analyzer 
checkers">;
+
+// Poison system directories.
+def warn_poison_system_directories : Warning <
+  "include location '%0' is unsafe for cross-compilation">,
+  InGroup>, DefaultIgnore;
 }

Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=371785=371784=371785=diff
==
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Thu Sep 12 15:36:13 2019
@@ -137,6 +137,13 @@ bool InitHeaderSearch::AddUnmappedPath(c
   SmallString<256> MappedPathStorage;
   StringRef MappedPathStr = Path.toStringRef(MappedPathStorage);
 
+  // If use system headers while cross-compiling, emit the warning.
+  if (HasSysroot && (MappedPathStr.startswith("/usr/include") ||
+ MappedPathStr.startswith("/usr/local/include"))) {
+Headers.getDiags().Report(diag::warn_poison_system_directories)
+<< MappedPathStr;
+  }
+
   // Compute the DirectoryLookup type.
   SrcMgr::CharacteristicKind Type;
   if (Group == Quoted || Group == Angled || Group == IndexHeaderMap) {

Added: cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/lib/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/lib/.keep?rev=371785=auto
==
(empty)

Added: 
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/include/c++/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/include/c%2B%2B/.keep?rev=371785=auto
==
(empty)

Added: 
cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/lib/gcc/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/lib/gcc/.keep?rev=371785=auto
==
(empty)

Added: 

[PATCH] D59516: [analyzer] Add custom filter functions for GenericTaintChecker

2019-09-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:517
+if (V)
+  State = addTaint(State, *V, TaintTagNotTainted);
+  }

Why not simply remove taint?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59516/new/

https://reviews.llvm.org/D59516



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64146: [Clang Interpreter] Initial patch for the constexpr interpreter

2019-09-12 Thread JF Bastien via Phabricator via cfe-commits
jfb accepted this revision.
jfb added a comment.

Sounds like this is ready to land again! Thanks for fixing everything.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64146/new/

https://reviews.llvm.org/D64146



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66714: [analyzer] Don't run the analyzer for -analyzer-list-enabled-checkers

2019-09-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

rC371781 .


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66714/new/

https://reviews.llvm.org/D66714



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r371781 - [analyzer] Fix the 'analyzer-enabled-checkers.c' test on non-linux machines.

2019-09-12 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Sep 12 15:11:15 2019
New Revision: 371781

URL: http://llvm.org/viewvc/llvm-project?rev=371781=rev
Log:
[analyzer] Fix the 'analyzer-enabled-checkers.c' test on non-linux machines.

'-Xclang -triple' doesn't seem to override the default target triple
as reliably as '--target'. This leads to test failing due to
platform-specific checks getting unexpectedly enabled.

Modified:
cfe/trunk/test/Analysis/analyzer-enabled-checkers.c

Modified: cfe/trunk/test/Analysis/analyzer-enabled-checkers.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/analyzer-enabled-checkers.c?rev=371781=371780=371781=diff
==
--- cfe/trunk/test/Analysis/analyzer-enabled-checkers.c (original)
+++ cfe/trunk/test/Analysis/analyzer-enabled-checkers.c Thu Sep 12 15:11:15 2019
@@ -1,5 +1,4 @@
-// RUN: %clang --analyze %s \
-// RUN:   -Xclang -triple -Xclang x86_64-pc-linux-gnu \
+// RUN: %clang --analyze %s --target=x86_64-pc-linux-gnu \
 // RUN:   -Xclang -analyzer-list-enabled-checkers \
 // RUN:   -Xclang -analyzer-display-progress \
 // RUN:   2>&1 | FileCheck %s --implicit-check-not=ANALYZE \


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66714: [analyzer] Don't run the analyzer for -analyzer-list-enabled-checkers

2019-09-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Umm, this test fails for me locally because i see `osx` checkers displayed in 
the list. Which is weird because they're supposed to be enabled based on the 
target platform, not on the host platform.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66714/new/

https://reviews.llvm.org/D66714



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67414: [AST] Treat "inline gnu_inline" the same way as "extern inline gnu_inline" in C++ mode

2019-09-12 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D67414#1668475 , @mstorsjo wrote:

> In D67414#1668443 , @rsmith wrote:
>
> > Seems very surprising to me that the `gnu_inline` attribute has different 
> > behavior in their C and C++ frontends. That said, it looks like it's a 
> > behavior that they document; their documentation says "In C++, this 
> > attribute does not depend on extern in any way, but it still requires the 
> > inline keyword to enable its special behavior." and that matches their 
> > observed behavior. And they behave this way even for functions in `extern 
> > "C"` blocks. The question for us, then, is do we want to be compatible with 
> > C source code built as C++ (that is, the status quo) and C++ source code 
> > using this attribute and targeting older versions of Clang, or with g++?
>
>
> I think it's a rather uncommon combination (I think most use of gnu_inline is 
> together with extern), so I wouldn't think that there's a lot of users 
> relying on the current behaviour (in clang-only codebases), but I have no 
> data to back it up with.
>
> > Is Clang's current behavior actually causing problems for some real use 
> > case? Changing this behavior is not without risk, and the old behavior is 
> > certainly defensible.
>
> It did come up in mingw-w64 recently; new header additions (that were 
> developed with gcc) broke when built with clang (due to multiple definitions 
> of a symbol). It's been rectified for now by avoiding this combination (for 
> compatibility with existing clang versions) though.


OK. If this is causing compatibility pain in practice, following GCC here seems 
reasonable. We should at least produce a warning on `gnu_inline` without 
`extern` in C++ mode, though.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67414/new/

https://reviews.llvm.org/D67414



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67460: clang-tidy: modernize-use-using work with multi-argument templates

2019-09-12 Thread Jonathan Meier via Phabricator via cfe-commits
jonathanmeier added a comment.

Nice! I don't have commit access, so we'll need someone else have another look. 
@alexfh, since you previously worked on this, would you mind taking a look at 
this patch?


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67460/new/

https://reviews.llvm.org/D67460



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67480: [analyzer] Add 'freopen' support to SimpleStreamChecker.

2019-09-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

`SimpleStreamChecker` is a historical tutorial example 
, i don't think we should be 
updating it other than for modernizing checker API use. It was supposed to 
handle a few simple examples correctly but it wasn't supposed to support all 
sorts of different APIs.

I'd recommend improving `StreamChecker` instead if you're interested in having 
a production-quality checker for everyday use.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67480/new/

https://reviews.llvm.org/D67480



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67460: clang-tidy: modernize-use-using work with multi-argument templates

2019-09-12 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc updated this revision to Diff 220007.
poelmanc added a comment.

Sorry one more test at the end to make sure a multi-typedef with all that 
Variadic stuff still doesn't get changed to using.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67460/new/

https://reviews.llvm.org/D67460

Files:
  clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
  clang-tools-extra/test/clang-tidy/modernize-use-using.cpp

Index: clang-tools-extra/test/clang-tidy/modernize-use-using.cpp
===
--- clang-tools-extra/test/clang-tidy/modernize-use-using.cpp
+++ clang-tools-extra/test/clang-tidy/modernize-use-using.cpp
@@ -183,3 +183,67 @@
   void f() override { super::f(); }
 };
 }
+
+template 
+class TwoArgTemplate {
+  typedef TwoArgTemplate self;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef'
+  // CHECK-FIXES: using self = TwoArgTemplate;
+};
+
+template 
+struct S {};
+
+typedef S<(0 > 0), int> S_t, *S_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: typedef S<(0 > 0), int> S_t, *S_p;
+
+typedef S<(0 < 0), int> S2_t, *S2_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: typedef S<(0 < 0), int> S2_t, *S2_p;
+
+typedef S<(0 > 0 && (3 > 1) && (1 < 1)), int> S3_t;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using S3_t = S<(0 > 0 && (3 > 1) && (1 < 1)), int>;
+
+template 
+struct Q {};
+
+constexpr bool b[1] = {true};
+
+typedef Q Q_t, *Q_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: typedef Q Q_t, *Q_p;
+
+typedef Q Q2_t;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using Q2_t = Q;
+
+struct T {
+  constexpr T(bool) {}
+
+  static constexpr bool b = true;
+};
+
+typedef Q Q3_t, *Q3_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: typedef Q Q3_t, *Q3_p;
+
+typedef Q Q3_t;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using Q3_t = Q;
+
+typedef TwoArgTemplate >, S<(0 < 0), Q > > Nested_t;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using Nested_t = TwoArgTemplate >, S<(0 < 0), Q > >;
+
+template 
+class Variadic {};
+
+typedef Variadic >, S<(0 < 0), Variadic > > > Variadic_t;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using Variadic_t = Variadic >, S<(0 < 0), Variadic > > >
+
+typedef Variadic >, S<(0 < 0), Variadic > > > Variadic_t, *Variadic_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: typedef Variadic >, S<(0 < 0), Variadic > > > Variadic_t, *Variadic_p;
Index: clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -39,25 +39,46 @@
   File.begin(), TokenBegin, File.end());
 
   Token Tok;
-  int ParenLevel = 0;
+  int NestingLevel = 0; // Parens, braces, and square brackets
+  int AngleBracketLevel = 0;
   bool FoundTypedef = false;
 
   while (!DeclLexer.LexFromRawLexer(Tok) && !Tok.is(tok::semi)) {
 switch (Tok.getKind()) {
 case tok::l_brace:
-case tok::r_brace:
-  // This might be the `typedef struct {...} T;` case.
-  return false;
+  if (NestingLevel == 0 && AngleBracketLevel == 0) {
+// At top level, this might be the `typedef struct {...} T;` case.
+// Inside parens, square brackets, or angle brackets it's not.
+return false;
+  }
+  NestingLevel++;
+  break;
 case tok::l_paren:
-  ParenLevel++;
+case tok::l_square:
+  NestingLevel++;
   break;
+case tok::r_brace:
 case tok::r_paren:
-  ParenLevel--;
+case tok::r_square:
+  NestingLevel--;
+  break;
+case tok::less:
+  // If not nested in paren/brace/square bracket, treat as opening angle bracket.
+  if (NestingLevel == 0)
+AngleBracketLevel++;
+  break;
+case tok::greater:
+  // Per C++ 17 Draft N4659, Section 17.2/3
+  //   https://timsong-cpp.github.io/cppwp/n4659/temp.names#3:
+  // "When parsing a template-argument-list, the first non-nested > is
+  // taken as the ending delimiter rather than a greater-than operator."
+  // If not nested in paren/brace/square bracket, treat as closing angle bracket.
+  if (NestingLevel == 0)
+AngleBracketLevel--;
   break;
 case tok::comma:
-  if (ParenLevel == 0) {
-// If there is comma and we are not between open parenthesis then it is
-// two or more declarations in this chain.
+  

[PATCH] D67460: clang-tidy: modernize-use-using work with multi-argument templates

2019-09-12 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc updated this revision to Diff 220002.
poelmanc added a comment.

Nice catch, that simplifies the code quite a bit! I added two more nested, 
complex multiple-template-argument tests and am happy to add more.

(We could do a case fallthrough after tok::l_brace, though some linters warn 
about them.)


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67460/new/

https://reviews.llvm.org/D67460

Files:
  clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
  clang-tools-extra/test/clang-tidy/modernize-use-using.cpp

Index: clang-tools-extra/test/clang-tidy/modernize-use-using.cpp
===
--- clang-tools-extra/test/clang-tidy/modernize-use-using.cpp
+++ clang-tools-extra/test/clang-tidy/modernize-use-using.cpp
@@ -183,3 +183,63 @@
   void f() override { super::f(); }
 };
 }
+
+template 
+class TwoArgTemplate {
+  typedef TwoArgTemplate self;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef'
+  // CHECK-FIXES: using self = TwoArgTemplate;
+};
+
+template 
+struct S {};
+
+typedef S<(0 > 0), int> S_t, *S_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: typedef S<(0 > 0), int> S_t, *S_p;
+
+typedef S<(0 < 0), int> S2_t, *S2_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: typedef S<(0 < 0), int> S2_t, *S2_p;
+
+typedef S<(0 > 0 && (3 > 1) && (1 < 1)), int> S3_t;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using S3_t = S<(0 > 0 && (3 > 1) && (1 < 1)), int>;
+
+template 
+struct Q {};
+
+constexpr bool b[1] = {true};
+
+typedef Q Q_t, *Q_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: typedef Q Q_t, *Q_p;
+
+typedef Q Q2_t;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using Q2_t = Q;
+
+struct T {
+  constexpr T(bool) {}
+
+  static constexpr bool b = true;
+};
+
+typedef Q Q3_t, *Q3_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: typedef Q Q3_t, *Q3_p;
+
+typedef Q Q3_t;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using Q3_t = Q;
+
+typedef TwoArgTemplate >, S<(0 < 0), Q > > Nested_t;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using Nested_t = TwoArgTemplate >, S<(0 < 0), Q > >;
+
+template 
+class Variadic {};
+
+typedef Variadic >, S<(0 < 0), Variadic > > > Variadic_t;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using Variadic_t = Variadic >, S<(0 < 0), Variadic > > >
Index: clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -39,25 +39,46 @@
   File.begin(), TokenBegin, File.end());
 
   Token Tok;
-  int ParenLevel = 0;
+  int NestingLevel = 0; // Parens, braces, and square brackets
+  int AngleBracketLevel = 0;
   bool FoundTypedef = false;
 
   while (!DeclLexer.LexFromRawLexer(Tok) && !Tok.is(tok::semi)) {
 switch (Tok.getKind()) {
 case tok::l_brace:
-case tok::r_brace:
-  // This might be the `typedef struct {...} T;` case.
-  return false;
+  if (NestingLevel == 0 && AngleBracketLevel == 0) {
+// At top level, this might be the `typedef struct {...} T;` case.
+// Inside parens, square brackets, or angle brackets it's not.
+return false;
+  }
+  NestingLevel++;
+  break;
 case tok::l_paren:
-  ParenLevel++;
+case tok::l_square:
+  NestingLevel++;
   break;
+case tok::r_brace:
 case tok::r_paren:
-  ParenLevel--;
+case tok::r_square:
+  NestingLevel--;
+  break;
+case tok::less:
+  // If not nested in paren/brace/square bracket, treat as opening angle bracket.
+  if (NestingLevel == 0)
+AngleBracketLevel++;
+  break;
+case tok::greater:
+  // Per C++ 17 Draft N4659, Section 17.2/3
+  //   https://timsong-cpp.github.io/cppwp/n4659/temp.names#3:
+  // "When parsing a template-argument-list, the first non-nested > is
+  // taken as the ending delimiter rather than a greater-than operator."
+  // If not nested in paren/brace/square bracket, treat as closing angle bracket.
+  if (NestingLevel == 0)
+AngleBracketLevel--;
   break;
 case tok::comma:
-  if (ParenLevel == 0) {
-// If there is comma and we are not between open parenthesis then it is
-// two or more declarations in this chain.
+  if (NestingLevel == 0 && AngleBracketLevel == 0) {
+// If there is a non-nested comma we have two or more declarations in 

[PATCH] D67140: [analyzer][NFC] Fix inconsistent references to checkers as "checks"

2019-09-12 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Yes, thank you! I've been keeping my mailbox open and commiting slowly, it 
seems like the buildbots have a wrong email address set up for me.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67140/new/

https://reviews.llvm.org/D67140



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67140: [analyzer][NFC] Fix inconsistent references to checkers as "checks"

2019-09-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a subscriber: timshen.
NoQ added a comment.

rL371773  - thanks @timshen!


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67140/new/

https://reviews.llvm.org/D67140



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67420: [analyzer] NFC: Separate PathDiagnosticConsumer options from AnalyzerOptions.

2019-09-12 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D67420#1668474 , @NoQ wrote:

> It's not that `AnalyzerOptions` is //necessary// to construct this, it's more 
> like //sufficient//.


*sudden enlightenment*

Ah, okay, right, I'm a dummie, I think I got what's happening here! :) In that 
case, the idea sounds great. I'll take a second look on the code later (I have 
a feeling that we should delete the default ctor of 
`PathDiagnosticConsumerOptions`, etc), but I'm just a tad too tired atm :)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67420/new/

https://reviews.llvm.org/D67420



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r371773 - [ClangTidy] Adjust the name getCheckName to getCheckerName due to API change.

2019-09-12 Thread Tim Shen via cfe-commits
Author: timshen
Date: Thu Sep 12 14:18:44 2019
New Revision: 371773

URL: http://llvm.org/viewvc/llvm-project?rev=371773=rev
Log:
[ClangTidy] Adjust the name getCheckName to getCheckerName due to API change.

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=371773=371772=371773=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Thu Sep 12 14:18:44 2019
@@ -72,7 +72,7 @@ public:
 FilesMade *filesMade) override {
 for (const ento::PathDiagnostic *PD : Diags) {
   SmallString<64> CheckName(AnalyzerCheckNamePrefix);
-  CheckName += PD->getCheckName();
+  CheckName += PD->getCheckerName();
   Context.diag(CheckName, PD->getLocation().asLocation(),
PD->getShortDescription())
   << PD->path.back()->getRanges();


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67420: [analyzer] NFC: Separate PathDiagnosticConsumer options from AnalyzerOptions.

2019-09-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D67420#1668099 , @Szelethus wrote:

> ...and the second is similar in nature, but in the actual code -- it doesn't 
> doesn't feel natural to me that `AnalyzerOptions` is required to construct 
> this, while at the same time we're trying to make diagnostics construction 
> independent of the analyzer.


It's not that `AnalyzerOptions` is //necessary// to construct this, it's more 
like //sufficient//. `PathDiagnosticConsumerOptions` is a plain de-encapsulated 
aggregate and anybody can aggregate-initialize or mutate it. But in the realm 
of the Analyzer it has "accidentally" turned out that `AnalyzerOptions` has 
just the right amount of information to fill it in.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67420/new/

https://reviews.llvm.org/D67420



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67414: [AST] Treat "inline gnu_inline" the same way as "extern inline gnu_inline" in C++ mode

2019-09-12 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D67414#1668443 , @rsmith wrote:

> Seems very surprising to me that the `gnu_inline` attribute has different 
> behavior in their C and C++ frontends. That said, it looks like it's a 
> behavior that they document; their documentation says "In C++, this attribute 
> does not depend on extern in any way, but it still requires the inline 
> keyword to enable its special behavior." and that matches their observed 
> behavior. And they behave this way even for functions in `extern "C"` blocks. 
> The question for us, then, is do we want to be compatible with C source code 
> built as C++ (that is, the status quo) and C++ source code using this 
> attribute and targeting older versions of Clang, or with g++?


I think it's a rather uncommon combination (I think most use of gnu_inline is 
together with extern), so I wouldn't think that there's a lot of users relying 
on the current behaviour (in clang-only codebases), but I have no data to back 
it up with.

> Is Clang's current behavior actually causing problems for some real use case? 
> Changing this behavior is not without risk, and the old behavior is certainly 
> defensible.

It did come up in mingw-w64 recently; new header additions (that were developed 
with gcc) broke when built with clang (due to multiple definitions of a 
symbol). It's been rectified for now by avoiding this combination (for 
compatibility with existing clang versions) though.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67414/new/

https://reviews.llvm.org/D67414



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67414: [AST] Treat "inline gnu_inline" the same way as "extern inline gnu_inline" in C++ mode

2019-09-12 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Seems very surprising to me that the `gnu_inline` attribute has different 
behavior in their C and C++ frontends. That said, it looks like it's a behavior 
that they document; their documentation says "In C++, this attribute does not 
depend on extern in any way, but it still requires the inline keyword to enable 
its special behavior." and that matches their observed behavior. And they 
behave this way even for functions in `extern "C"` blocks. The question for us, 
then, is do we want to be compatible with C source code built as C++ (that is, 
the status quo) and C++ source code using this attribute and targeting older 
versions of Clang, or with g++?

Is Clang's current behavior actually causing problems for some real use case? 
Changing this behavior is not without risk, and the old behavior is certainly 
defensible.

If we want to match GCC's behavior for `gnu_inline` in C++ mode, we should 
think about whether we also want to permit things like:

  __attribute__((__gnu_inline__)) extern inline int externinlinefunc() { return 
0; }
  int externinlinefunc() { return 1; }

(with or without the `extern`), which g++ allows and clang rejects.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67414/new/

https://reviews.llvm.org/D67414



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67409: [RISCV] enable LTO support, pass some options to linker.

2019-09-12 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/RISCV.cpp:387
+
+void riscv::addGoldOptions(const ToolChain ,
+   const llvm::opt::ArgList ,

MaskRay wrote:
> gold doesn't support RISC-V, does it?
Gold doesn't support RISC-V , but ld.bfd supported same plugin API, so this 
made clang can run LTO with ld.bfd.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67409/new/

https://reviews.llvm.org/D67409



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67414: [AST] Treat "inline gnu_inline" the same way as "extern inline gnu_inline" in C++ mode

2019-09-12 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo marked 2 inline comments as done.
mstorsjo added inline comments.



Comment at: lib/AST/Decl.cpp:3283
 
   if (Context.getLangOpts().CPlusPlus)
 return false;

nickdesaulniers wrote:
> I would have thought the existing case here would handle your change.  If it 
> doesn't, why not?  Should your change also remove this (essentially moving it 
> earlier)?
With the `gnu_inline` attribute on a function, the block above can end up 
returning `FoundBody = true`.

So yes, I guess one would get the same effect by just moving the existing if 
statement up past the gnu inline block.



Comment at: lib/AST/Decl.cpp:3381
   // The rest of this function is C-only.
   assert(!Context.getLangOpts().CPlusPlus &&
  "should not use C inline rules in C++");

nickdesaulniers wrote:
> Ditto.
Hmm, if moved above, I guess we should convert the assert to a plain `if 
(CPlusPlus) return false;` instead?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67414/new/

https://reviews.llvm.org/D67414



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67414: [AST] Treat "inline gnu_inline" the same way as "extern inline gnu_inline" in C++ mode

2019-09-12 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: lib/AST/Decl.cpp:3283
 
   if (Context.getLangOpts().CPlusPlus)
 return false;

I would have thought the existing case here would handle your change.  If it 
doesn't, why not?  Should your change also remove this (essentially moving it 
earlier)?



Comment at: lib/AST/Decl.cpp:3381
   // The rest of this function is C-only.
   assert(!Context.getLangOpts().CPlusPlus &&
  "should not use C inline rules in C++");

Ditto.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67414/new/

https://reviews.llvm.org/D67414



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62731: [RFC] Add support for options -frounding-math, -fp-model=, and -fp-exception-behavior=, : Specify floating point behavior

2019-09-12 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

In D62731#1663748 , @rjmccall wrote:

> Hmm, you know, there are enough different FP options that I think we should 
> probably split them all out into their own section in the manual instead of 
> just listing them under "code generation".  That will also give us an obvious 
> place to describe the basic model, i.e. all the stuff about it mostly coming 
> down to different strictness and exception models.  Could you prepare a patch 
> that *just* does that reorganization without adding any new features, and 
> then we can add the new options on top of that?


I uploaded a patch to move floating point options to a new documentation 
section here, https://reviews.llvm.org/D67517


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62731/new/

https://reviews.llvm.org/D62731



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67516: [clang] Enable GNU Toolchain to find musl GCC installations

2019-09-12 Thread Elliot Saba via Phabricator via cfe-commits
staticfloat created this revision.
staticfloat added reviewers: rsmith, fedor.sergeev.
staticfloat added a project: clang.
Herald added a subscriber: cfe-commits.

The GNU Toolchain GCCDetector misses GCC installations with the triplet 
`x86_64-linux-musl`, looking only instead for `x86_64-unknown-linux-musl` 
because it does not have the built-in shortcut that it does for glibc-based 
systems.  This patch, taken from the void-linux patch set at 
https://github.com/void-linux/void-packages/blob/ced162673bf1e824529eb04d8c33a4e30dcfb68e/srcpkgs/llvm8/files/patches/cfe/cfe-004-add-musl-triples.patch
 improves clang's ability to find these shorter triplets on `musl`.  This is 
necessary also for environments such as the Julia project's BinaryBuilder, 
which comprises a large collection of cross-compilers, each installed within a 
specific multiarch triplet.


Repository:
  rC Clang

https://reviews.llvm.org/D67516

Files:
  b/lib/Driver/ToolChains/Gnu.cpp


Index: b/lib/Driver/ToolChains/Gnu.cpp
===
--- b/lib/Driver/ToolChains/Gnu.cpp
+++ b/lib/Driver/ToolChains/Gnu.cpp
@@ -1882,7 +1882,8 @@
   static const char *const ARMHFTriples[] = {"arm-linux-gnueabihf",
  "armv7hl-redhat-linux-gnueabi",
  "armv6hl-suse-linux-gnueabi",
- "armv7hl-suse-linux-gnueabi"};
+ "armv7hl-suse-linux-gnueabi",
+ "armv7l-linux-gnueabihf"};
   static const char *const ARMebLibDirs[] = {"/lib"};
   static const char *const ARMebTriples[] = {"armeb-linux-gnueabi",
  "armeb-linux-androideabi"};
@@ -2014,6 +2015,78 @@
 return;
   }
 
+  if (TargetTriple.isMusl()) {
+static const char *const AArch64MuslTriples[] = {"aarch64-linux-musl"};
+static const char *const ARMHFMuslTriples[] = {
+"arm-linux-musleabihf", "armv7l-linux-musleabihf"
+};
+static const char *const ARMMuslTriples[] = {"arm-linux-musleabi"};
+static const char *const X86_64MuslTriples[] = {"x86_64-linux-musl"};
+static const char *const X86MuslTriples[] = {"i686-linux-musl"};
+static const char *const MIPSMuslTriples[] = {
+"mips-linux-musl", "mipsel-linux-musl",
+"mipsel-linux-muslhf", "mips-linux-muslhf"
+};
+static const char *const PPCMuslTriples[] = {"powerpc-linux-musl"};
+static const char *const PPC64MuslTriples[] = {"powerpc64-linux-musl"};
+static const char *const PPC64LEMuslTriples[] = {"powerpc64le-linux-musl"};
+
+switch (TargetTriple.getArch()) {
+case llvm::Triple::aarch64:
+  LibDirs.append(begin(AArch64LibDirs), end(AArch64LibDirs));
+  TripleAliases.append(begin(AArch64MuslTriples), end(AArch64MuslTriples));
+  BiarchLibDirs.append(begin(AArch64LibDirs), end(AArch64LibDirs));
+  BiarchTripleAliases.append(begin(AArch64MuslTriples), 
end(AArch64MuslTriples));
+  break;
+case llvm::Triple::arm:
+  LibDirs.append(begin(ARMLibDirs), end(ARMLibDirs));
+  if (TargetTriple.getEnvironment() == llvm::Triple::MuslEABIHF) {
+TripleAliases.append(begin(ARMHFMuslTriples), end(ARMHFMuslTriples));
+  } else {
+TripleAliases.append(begin(ARMMuslTriples), end(ARMMuslTriples));
+  }
+  break;
+case llvm::Triple::x86_64:
+  LibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
+  TripleAliases.append(begin(X86_64MuslTriples), end(X86_64MuslTriples));
+  BiarchLibDirs.append(begin(X86LibDirs), end(X86LibDirs));
+  BiarchTripleAliases.append(begin(X86MuslTriples), end(X86MuslTriples));
+  break;
+case llvm::Triple::x86:
+  LibDirs.append(begin(X86LibDirs), end(X86LibDirs));
+  TripleAliases.append(begin(X86MuslTriples), end(X86MuslTriples));
+  BiarchLibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
+  BiarchTripleAliases.append(begin(X86_64MuslTriples), 
end(X86_64MuslTriples));
+  break;
+case llvm::Triple::mips:
+  LibDirs.append(begin(MIPSLibDirs), end(MIPSLibDirs));
+  TripleAliases.append(begin(MIPSMuslTriples), end(MIPSMuslTriples));
+  break;
+case llvm::Triple::ppc:
+  LibDirs.append(begin(PPCLibDirs), end(PPCLibDirs));
+  TripleAliases.append(begin(PPCMuslTriples), end(PPCMuslTriples));
+  BiarchLibDirs.append(begin(PPC64LibDirs), end(PPC64LibDirs));
+  BiarchTripleAliases.append(begin(PPC64MuslTriples), 
end(PPC64MuslTriples));
+  break;
+case llvm::Triple::ppc64:
+  LibDirs.append(begin(PPC64LibDirs), end(PPC64LibDirs));
+  TripleAliases.append(begin(PPC64MuslTriples), end(PPC64MuslTriples));
+  BiarchLibDirs.append(begin(PPCLibDirs), end(PPCLibDirs));
+  BiarchTripleAliases.append(begin(PPCMuslTriples), end(PPCMuslTriples));
+  break;
+case llvm::Triple::ppc64le:
+  

[PATCH] D59516: [analyzer] Add custom filter functions for GenericTaintChecker

2019-09-12 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I'd like the test cases to actually demonstrate the correct use of the filters 
and the correct behavior of the Analyzer when the filters are annotated 
correctly, but it looks to me that they either demonstrate behavior when the 
annotation is //not// used correctly, or we disagree about how the taint should 
work in the first place. Testing the behavior when the annotation is misplaced 
is fine (with enough comments and probably FIXMEs where applicable), but 
"positive" tests are more valuable because they are the actual common cases 
(hopefully).




Comment at: clang/test/Analysis/taint-generic.c:381-385
+void testConfigurationFilter1() {
+  int x = mySource1();
+  myFilter1();
+  Buffer[x] = 1; // no-warning
+}

`myFilter1` will create a new conjured symbol within `x` when evaluated 
conservatively. In this case there clearly shouldn't be a warning on `Buffer[x] 
= 1`, because nobody marked the new symbol as tainted to begin with. Therefore 
i think that this test doesn't really test the new functionality.



Comment at: clang/test/Analysis/taint-generic.c:387-391
+void testConfigurationFilter2() {
+  int x = mySource1();
+  myFilter2();
+  Buffer[x] = 1; // no-warning
+}

Assuming `myFilter2` is inlined, we have two execution paths here. On one of 
them `x` is reset to a concrete 0. Because concrete values cannot carry taint 
to begin with, this execution path doesn't test the new functionality. On the 
other path `x` indeed has the old tainted value but it's now constrained to 
`[0, INT_MAX]`. Because it's still not constrained to be less than `BUFSIZE`, 
i'd say this looks more like a false negative and the new functionality makes 
the analysis worse. So this test does test the new functionality, but it kinda 
makes the new functionality look bad rather than good.



Comment at: clang/test/Analysis/taint-generic.c:393-397
+void testConfigurationFilter3() {
+  int x = mySource1();
+  myFilter3();
+  Buffer[x] = 1; // no-warning
+}

In this example `myFilter3` promises not to alter the value of `x` due to 
`const`-qualifier on the pointee type of the parameter. Additionally, the 
function has no chance of preventing the program from reaching the buffer 
overflow line, other than crashing the program (given that it's C and there are 
no exceptions). Therefore i'd say this is also a false negative.

A better motivational example that doesn't immediately look like a false 
negative may look like this:
```lang=c
void testConfigurationFilter3() {
  int x = mySource1();
  if (isOutOfRange(x)) // the filter function
return;
  Buffer[x] = 1; // no-warning
}
```
In this case the function looks at the value of `x` (there's really no need to 
pass it by pointer) and notifies the caller through its return value that it is 
unsafe to access the buffer with such index. This is probably the only 
situation where a "filter" annotation is actually worth it.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59516/new/

https://reviews.llvm.org/D59516



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67460: clang-tidy: modernize-use-using work with multi-argument templates

2019-09-12 Thread Jonathan Meier via Phabricator via cfe-commits
jonathanmeier added a comment.

Thanks, this looks much better now. I think there's no need to track nesting of 
parenthesis, brackets and braces separately, so we can collapse `ParenLevel`, 
`BraceLevel` and `SquareBracketLevel` into a single `NestingLevel`, which 
simplifies all the conditions quite a bit.

Also consider adding a few more testcases, especially with nested templates and 
multiple template arguments (the reason for this patch, after all! ;-) ). You 
can easily test (different numbers of) multiple template arguments by just 
adding a few more template parameters with default arguments to e.g. 
`TwoArgTemplate`, `S` or `Q`.




Comment at: clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp:90
+  AngleBracketLevel == 0) {
+// If there is comma not nested then it is two or more declarations in 
this chain.
 return false;

change to `If there is a non-nested comma we have two or more declarations in 
this chain.`


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67460/new/

https://reviews.llvm.org/D67460



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67135: [clang-tidy] performance-inefficient-vector-operation: Support proto repeated field

2019-09-12 Thread Cong Liu via Phabricator via cfe-commits
congliu updated this revision to Diff 219988.
congliu marked an inline comment as done.
congliu added a comment.

Addressed Haojian's comment.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67135/new/

https://reviews.llvm.org/D67135

Files:
  clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp
  clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
  clang-tools-extra/test/clang-tidy/performance-inefficient-vector-operation.cpp

Index: clang-tools-extra/test/clang-tidy/performance-inefficient-vector-operation.cpp
===
--- clang-tools-extra/test/clang-tidy/performance-inefficient-vector-operation.cpp
+++ clang-tools-extra/test/clang-tidy/performance-inefficient-vector-operation.cpp
@@ -1,4 +1,7 @@
-// RUN: %check_clang_tidy %s performance-inefficient-vector-operation %t -- -format-style=llvm
+// RUN: %check_clang_tidy %s performance-inefficient-vector-operation %t -- \
+// RUN: -format-style=llvm \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: performance-inefficient-vector-operation.EnableProto, value: 1}]}'
 
 namespace std {
 
@@ -62,13 +65,35 @@
 
 int Op(int);
 
+namespace proto2 {
+class MessageLite {};
+class Message : public MessageLite {};
+} // namespace proto2
+
+class FooProto : public proto2::Message {
+ public:
+  int *add_x();  // repeated int x;
+  void add_x(int x);
+  void mutable_x();
+  void mutable_y();
+  int add_z() const; // optional int add_z;
+};
+
+class BarProto : public proto2::Message {
+ public:
+  int *add_x();
+  void add_x(int x);
+  void mutable_x();
+  void mutable_y();
+};
+
 void f(std::vector& t) {
   {
 std::vector v0;
 // CHECK-FIXES: v0.reserve(10);
 for (int i = 0; i < 10; ++i)
   v0.push_back(i);
-  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called inside a loop; consider pre-allocating the vector capacity before the loop
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called inside a loop; consider pre-allocating the container capacity before the loop
   }
   {
 std::vector v1;
@@ -162,6 +187,15 @@
 }
   }
 
+  {
+FooProto foo;
+// CHECK-FIXES: foo.mutable_x()->Reserve(5);
+for (int i = 0; i < 5; i++) {
+  foo.add_x(i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'add_x' is called inside a loop; consider pre-allocating the container capacity before the loop
+}
+  }
+
   //  Non-fixed Cases 
   {
 std::vector z0;
@@ -274,4 +308,54 @@
   z12.push_back(e);
 }
   }
+
+  {
+FooProto foo;
+foo.mutable_x();
+// CHECK-FIXES-NOT: foo.mutable_x()->Reserve(5);
+for (int i = 0; i < 5; i++) {
+  foo.add_x(i);
+}
+  }
+  {
+FooProto foo;
+// CHECK-FIXES-NOT: foo.mutable_x()->Reserve(5);
+for (int i = 0; i < 5; i++) {
+  foo.add_x(i);
+  foo.add_x(i);
+}
+  }
+  {
+FooProto foo;
+// CHECK-FIXES-NOT: foo.mutable_x()->Reserve(5);
+foo.add_x(-1);
+for (int i = 0; i < 5; i++) {
+  foo.add_x(i);
+}
+  }
+  {
+FooProto foo;
+BarProto bar;
+bar.mutable_x();
+// CHECK-FIXES-NOT: foo.mutable_x()->Reserve(5);
+for (int i = 0; i < 5; i++) {
+  foo.add_x();
+  bar.add_x();
+}
+  }
+  {
+FooProto foo;
+foo.mutable_y();
+// CHECK-FIXES-NOT: foo.mutable_x()->Reserve(5);
+for (int i = 0; i < 5; i++) {
+  foo.add_x(i);
+}
+  }
+  {
+FooProto foo;
+// CHECK-FIXES-NOT: foo.mutable_z()->Reserve(5);
+for (int i = 0; i < 5; i++) {
+  foo.add_z();
+}
+  }
 }
Index: clang-tools-extra/docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
+++ clang-tools-extra/docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
@@ -6,6 +6,10 @@
 Finds possible inefficient ``std::vector`` operations (e.g. ``push_back``,
 ``emplace_back``) that may cause unnecessary memory reallocations.
 
+It can also find calls that add element to protobuf repeated field in a loop
+without calling Reserve() before the loop. Calling Reserve() first can avoid
+unnecessary memory reallocations.
+
 Currently, the check only detects following kinds of loops with a single
 statement body:
 
@@ -21,6 +25,13 @@
 // statement before the for statement.
   }
 
+  SomeProto p;
+  for (int i = 0; i < n; ++i) {
+p.add_xxx(n);
+// This will trigger the warning since the add_xxx may cause multiple memory
+// relloacations. This can be avoid by inserting a
+// 'p.mutable_xxx().Reserve(n)' statement before the for statement.
+  }
 
 * For-range loops like ``for (range-declaration : range_expression)``, the type
   of ``range_expression`` can be ``std::vector``, ``std::array``,
@@ -47,3 

[PATCH] D67429: Improve code generation for thread_local variables:

2019-09-12 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371767: Improve code generation for thread_local variables: 
(authored by rsmith, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67429?vs=219652=219983#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67429/new/

https://reviews.llvm.org/D67429

Files:
  cfe/trunk/include/clang/Basic/Linkage.h
  cfe/trunk/lib/CodeGen/CGCXXABI.h
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
  cfe/trunk/test/CodeGen/windows-on-arm-itanium-thread-local.c
  cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp
  cfe/trunk/test/CodeGenCXX/cxx2a-thread-local-constinit.cpp
  cfe/trunk/test/CodeGenCXX/tls-init-funcs.cpp
  cfe/trunk/test/CodeGenCXX/windows-on-arm-itanium-thread-local.cpp
  cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp

Index: cfe/trunk/include/clang/Basic/Linkage.h
===
--- cfe/trunk/include/clang/Basic/Linkage.h
+++ cfe/trunk/include/clang/Basic/Linkage.h
@@ -82,6 +82,12 @@
   return L <= GVA_DiscardableODR;
 }
 
+/// Do we know that this will be the only definition of this symbol (excluding
+/// inlining-only definitions)?
+inline bool isUniqueGVALinkage(GVALinkage L) {
+  return L == GVA_Internal || L == GVA_StrongExternal;
+}
+
 inline bool isExternallyVisible(Linkage L) {
   return L >= VisibleNoLinkage;
 }
Index: cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp
===
--- cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp
+++ cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp
@@ -101,8 +101,7 @@
   // LAMBDA: define{{.*}} internal{{.*}} void [[OUTER_LAMBDA]](
   // LAMBDA: call {{.*}}void {{.+}} @__kmpc_fork_call({{.+}}, i32 0, {{.+}}* [[OMP_REGION:@.+]] to {{.+}})
 
-  // TLS-LAMBDA: [[G_CPY_VAL:%.+]] = call{{( cxx_fast_tlscc)?}} i{{[0-9]+}}* [[G_CTOR:@.+]]()
-  // TLS-LAMBDA: call {{.*}}void {{.+}} @__kmpc_fork_call({{.+}}, i32 1, {{.+}}* [[OMP_REGION:@.+]] to {{.+}}, i32* [[G_CPY_VAL]])
+  // TLS-LAMBDA: call {{.*}}void {{.+}} @__kmpc_fork_call({{.+}}, i32 1, {{.+}}* [[OMP_REGION:@.+]] to {{.+}}, i32* @g)
 
 #pragma omp parallel copyin(g)
   {
@@ -120,14 +119,12 @@
 // LAMBDA: [[DONE]]
 
 // TLS-LAMBDA-DAG: [[G_CAPTURE_SRC:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** %
-// TLS-LAMBDA-DAG: [[G_CAPTURE_DST:%.+]] = call{{( cxx_fast_tlscc)?}} i{{[0-9]+}}* [[G_CTOR]]()
 // TLS-LAMBDA-DAG: [[G_CAPTURE_SRCC:%.+]] = ptrtoint i{{[0-9]+}}* [[G_CAPTURE_SRC]] to i{{[0-9]+}}
-// TLS-LAMBDA-DAG: [[G_CAPTURE_DSTC:%.+]] = ptrtoint i{{[0-9]+}}* [[G_CAPTURE_DST]] to i{{[0-9]+}}
-// TLS-LAMBDA: icmp ne i{{[0-9]+}} {{%.+}}, {{%.+}}
+// TLS-LAMBDA: icmp ne i{{[0-9]+}} {{%.+}}, ptrtoint (i{{[0-9]+}}* @g to i{{[0-9]+}})
 // TLS-LAMBDA: br i1 %{{.+}}, label %[[NOT_MASTER:.+]], label %[[DONE:.+]]
 // TLS-LAMBDA: [[NOT_MASTER]]
 // TLS-LAMBDA: load i{{[0-9]+}}, i{{[0-9]+}}* [[G_CAPTURE_SRC]],
-// TLS-LAMBDA: store volatile i{{[0-9]+}} %{{.+}}, i{{[0-9]+}}* [[G_CAPTURE_DST]], align 128
+// TLS-LAMBDA: store volatile i{{[0-9]+}} %{{.+}}, i{{[0-9]+}}* @g, align 128
 // TLS-LAMBDA: [[DONE]]
 
 // LAMBDA: call {{.*}}void @__kmpc_barrier(
@@ -136,18 +133,13 @@
 // LAMBDA: call{{.*}} void [[INNER_LAMBDA:@.+]](%{{.+}}*
 // TLS-LAMBDA: call{{.*}} void [[INNER_LAMBDA:@.+]](%{{.+}}*
 
-// TLS-LAMBDA: define {{.*}}i{{[0-9]+}}* [[G_CTOR]]()
-// TLS-LAMBDA: ret i{{[0-9]+}}* [[G]]
-// TLS-LAMBDA: }
-
 [&]() {
   // LAMBDA: define {{.+}} void [[INNER_LAMBDA]](%{{.+}}* [[ARG_PTR:%.+]])
   // LAMBDA: store %{{.+}}* [[ARG_PTR]], %{{.+}}** [[ARG_PTR_REF:%.+]],
   g = 2;
   // LAMBDA: [[ARG_PTR:%.+]] = load %{{.+}}*, %{{.+}}** [[ARG_PTR_REF]]
 
-  // TLS-LAMBDA: [[G_CAPTURE_DST:%.+]] = call{{( cxx_fast_tlscc)?}} i{{[0-9]+}}* [[G_CTOR]]()
-  // TLS-LAMBDA: store volatile i{{[0-9]+}} 2, i{{[0-9]+}}* [[G_CAPTURE_DST]], align 128
+  // TLS-LAMBDA: store volatile i{{[0-9]+}} 2, i{{[0-9]+}}* @g, align 128
 }();
   }
   }();
@@ -164,8 +156,7 @@
   // BLOCKS: define{{.*}} internal{{.*}} void {{.+}}(i8*
   // BLOCKS: call {{.*}}void {{.+}} @__kmpc_fork_call({{.+}}, i32 0, {{.+}}* [[OMP_REGION:@.+]] to {{.+}})
 
-  // TLS-BLOCKS: [[G_CPY_VAL:%.+]] = call{{( cxx_fast_tlscc)?}} i{{[0-9]+}}* [[G_CTOR:@.+]]()
-  // TLS-BLOCKS: call {{.*}}void {{.+}} @__kmpc_fork_call({{.+}}, i32 1, {{.+}}* [[OMP_REGION:@.+]] to {{.+}}, i32* [[G_CPY_VAL]])
+  // TLS-BLOCKS: call {{.*}}void {{.+}} @__kmpc_fork_call({{.+}}, i32 1, {{.+}}* [[OMP_REGION:@.+]] to {{.+}}, i32* @g)
 
 #pragma omp parallel copyin(g)
   {
@@ -183,14 +174,12 @@
 // BLOCKS: [[DONE]]
 
 // TLS-BLOCKS-DAG: [[G_CAPTURE_SRC:%.+]] = load i{{[0-9]+}}*, 

[PATCH] D59516: [analyzer] Add custom filter functions for GenericTaintChecker

2019-09-12 Thread Borsik Gábor via Phabricator via cfe-commits
boga95 updated this revision to Diff 219981.
boga95 marked 4 inline comments as done.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59516/new/

https://reviews.llvm.org/D59516

Files:
  clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/Taint.cpp
  clang/lib/StaticAnalyzer/Checkers/Taint.h
  clang/test/Analysis/Inputs/taint-generic-config.yaml
  clang/test/Analysis/taint-generic.c

Index: clang/test/Analysis/taint-generic.c
===
--- clang/test/Analysis/taint-generic.c
+++ clang/test/Analysis/taint-generic.c
@@ -346,6 +346,12 @@
 void myScanf(const char*, ...);
 int myPropagator(int, int*);
 int mySnprintf(char*, size_t, const char*, ...);
+void myFilter1(int*);
+void myFilter2(int* x) {
+  if (*x < 0)
+*x = 0;
+}
+void myFilter3(const int*);
 void mySink(int, int, int);
 
 void testConfigurationSources1() {
@@ -372,6 +378,24 @@
   Buffer[y] = 1; // expected-warning {{Out of bound memory access }}
 }
 
+void testConfigurationFilter1() {
+  int x = mySource1();
+  myFilter1();
+  Buffer[x] = 1; // no-warning
+}
+
+void testConfigurationFilter2() {
+  int x = mySource1();
+  myFilter2();
+  Buffer[x] = 1; // no-warning
+}
+
+void testConfigurationFilter3() {
+  int x = mySource1();
+  myFilter3();
+  Buffer[x] = 1; // no-warning
+}
+
 void testConfigurationSinks() {
   int x = mySource1();
   mySink(x, 1, 2);
Index: clang/test/Analysis/Inputs/taint-generic-config.yaml
===
--- clang/test/Analysis/Inputs/taint-generic-config.yaml
+++ clang/test/Analysis/Inputs/taint-generic-config.yaml
@@ -36,8 +36,12 @@
 # A list of filter functions
 Filters:
   # int x; // x is tainted
-  # myFilter(); // x is not tainted anymore
-  - Name: myFilter
+  # myFilter1(); // x is not tainted anymore
+  - Name: myFilter1
+Args: [0]
+  - Name: myFilter2
+Args: [0]
+  - Name: myFilter3
 Args: [0]
 
 # A list of sink functions
Index: clang/lib/StaticAnalyzer/Checkers/Taint.h
===
--- clang/lib/StaticAnalyzer/Checkers/Taint.h
+++ clang/lib/StaticAnalyzer/Checkers/Taint.h
@@ -24,37 +24,35 @@
 /// taint.
 using TaintTagType = unsigned;
 
-static constexpr TaintTagType TaintTagGeneric = 0;
+static constexpr TaintTagType TaintTagNotTainted = 0;
+static constexpr TaintTagType TaintTagGeneric = 1;
 
 /// Create a new state in which the value of the statement is marked as tainted.
-LLVM_NODISCARD ProgramStateRef
-addTaint(ProgramStateRef State, const Stmt *S, const LocationContext *LCtx,
- TaintTagType Kind = TaintTagGeneric);
+LLVM_NODISCARD ProgramStateRef addTaint(ProgramStateRef State, const Stmt *S,
+const LocationContext *LCtx,
+TaintTagType Kind = TaintTagGeneric);
 
 /// Create a new state in which the value is marked as tainted.
-LLVM_NODISCARD ProgramStateRef
-addTaint(ProgramStateRef State, SVal V,
- TaintTagType Kind = TaintTagGeneric);
+LLVM_NODISCARD ProgramStateRef addTaint(ProgramStateRef State, SVal V,
+TaintTagType Kind = TaintTagGeneric);
 
 /// Create a new state in which the symbol is marked as tainted.
-LLVM_NODISCARD ProgramStateRef
-addTaint(ProgramStateRef State, SymbolRef Sym,
- TaintTagType Kind = TaintTagGeneric);
+LLVM_NODISCARD ProgramStateRef addTaint(ProgramStateRef State, SymbolRef Sym,
+TaintTagType Kind = TaintTagGeneric);
 
 /// Create a new state in which the pointer represented by the region
 /// is marked as tainted.
-LLVM_NODISCARD ProgramStateRef
-addTaint(ProgramStateRef State, const MemRegion *R,
- TaintTagType Kind = TaintTagGeneric);
+LLVM_NODISCARD ProgramStateRef addTaint(ProgramStateRef State,
+const MemRegion *R,
+TaintTagType Kind = TaintTagGeneric);
 
 /// Create a new state in a which a sub-region of a given symbol is tainted.
 /// This might be necessary when referring to regions that can not have an
 /// individual symbol, e.g. if they are represented by the default binding of
 /// a LazyCompoundVal.
-LLVM_NODISCARD ProgramStateRef
-addPartialTaint(ProgramStateRef State,
-SymbolRef ParentSym, const SubRegion *SubRegion,
-TaintTagType Kind = TaintTagGeneric);
+LLVM_NODISCARD ProgramStateRef addPartialTaint(
+ProgramStateRef State, SymbolRef ParentSym, const SubRegion *SubRegion,
+TaintTagType Kind = TaintTagGeneric);
 
 /// Check if the statement has a tainted value in the given state.
 bool isTainted(ProgramStateRef State, const Stmt *S,
@@ -99,4 +97,3 @@
 } // namespace clang
 
 #endif
-
Index: clang/lib/StaticAnalyzer/Checkers/Taint.cpp
===
--- 

r371767 - Improve code generation for thread_local variables:

2019-09-12 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Sep 12 13:00:24 2019
New Revision: 371767

URL: http://llvm.org/viewvc/llvm-project?rev=371767=rev
Log:
Improve code generation for thread_local variables:

Summary:
 * Don't bother using a thread wrapper when the variable is known to
   have constant initialization.
 * Emit the thread wrapper as discardable-if-unused in TUs that don't
   contain a definition of the thread_local variable.
 * Don't emit the thread wrapper at all if the thread_local variable
   is unused and discardable; it will be emitted by all TUs that need
   it.

Reviewers: rjmccall, jdoerfert

Subscribers: cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/CodeGenCXX/cxx2a-thread-local-constinit.cpp
cfe/trunk/test/CodeGenCXX/windows-on-arm-itanium-thread-local.cpp
  - copied, changed from r371766, 
cfe/trunk/test/CodeGen/windows-on-arm-itanium-thread-local.c
Removed:
cfe/trunk/test/CodeGen/windows-on-arm-itanium-thread-local.c
Modified:
cfe/trunk/include/clang/Basic/Linkage.h
cfe/trunk/lib/CodeGen/CGCXXABI.h
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp
cfe/trunk/test/CodeGenCXX/tls-init-funcs.cpp
cfe/trunk/test/OpenMP/parallel_copyin_codegen.cpp

Modified: cfe/trunk/include/clang/Basic/Linkage.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Linkage.h?rev=371767=371766=371767=diff
==
--- cfe/trunk/include/clang/Basic/Linkage.h (original)
+++ cfe/trunk/include/clang/Basic/Linkage.h Thu Sep 12 13:00:24 2019
@@ -82,6 +82,12 @@ inline bool isDiscardableGVALinkage(GVAL
   return L <= GVA_DiscardableODR;
 }
 
+/// Do we know that this will be the only definition of this symbol (excluding
+/// inlining-only definitions)?
+inline bool isUniqueGVALinkage(GVALinkage L) {
+  return L == GVA_Internal || L == GVA_StrongExternal;
+}
+
 inline bool isExternallyVisible(Linkage L) {
   return L >= VisibleNoLinkage;
 }

Modified: cfe/trunk/lib/CodeGen/CGCXXABI.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXXABI.h?rev=371767=371766=371767=diff
==
--- cfe/trunk/lib/CodeGen/CGCXXABI.h (original)
+++ cfe/trunk/lib/CodeGen/CGCXXABI.h Thu Sep 12 13:00:24 2019
@@ -577,7 +577,7 @@ public:
 
   // Determine if references to thread_local global variables can be made
   // directly or require access through a thread wrapper function.
-  virtual bool usesThreadWrapperFunction() const = 0;
+  virtual bool usesThreadWrapperFunction(const VarDecl *VD) const = 0;
 
   /// Emit a reference to a non-local thread_local variable (including
   /// triggering the initialization of all thread_local variables in its

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=371767=371766=371767=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Sep 12 13:00:24 2019
@@ -2361,7 +2361,7 @@ static LValue EmitGlobalVarDeclLValue(Co
 
   // If it's thread_local, emit a call to its wrapper function instead.
   if (VD->getTLSKind() == VarDecl::TLS_Dynamic &&
-  CGF.CGM.getCXXABI().usesThreadWrapperFunction())
+  CGF.CGM.getCXXABI().usesThreadWrapperFunction(VD))
 return CGF.CGM.getCXXABI().EmitThreadLocalVarDeclLValue(CGF, VD, T);
   // Check if the variable is marked as declare target with link clause in
   // device codegen.

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=371767=371766=371767=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Thu Sep 12 13:00:24 2019
@@ -43,6 +43,10 @@ class ItaniumCXXABI : public CodeGen::CG
   /// VTables - All the vtables which have been defined.
   llvm::DenseMap VTables;
 
+  /// All the thread wrapper functions that have been used.
+  llvm::SmallVector, 8>
+  ThreadWrappers;
+
 protected:
   bool UseARMMethodPtrABI;
   bool UseARMGuardVarABI;
@@ -322,7 +326,42 @@ public:
   ArrayRef CXXThreadLocalInits,
   ArrayRef CXXThreadLocalInitVars) override;
 
-  bool usesThreadWrapperFunction() const override { return true; }
+  /// Determine whether we will definitely emit this variable with a constant
+  /// initializer, either because the language semantics demand it or because
+  /// we know that the initializer is a constant.
+  bool isEmittedWithConstantInitializer(const VarDecl *VD) const {
+VD = VD->getMostRecentDecl();
+if (VD->hasAttr())
+  return true;
+
+// All 

[PATCH] D66715: [CFG] Add dumps for CFGElement and CFGElementRef

2019-09-12 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371765: [CFG] Add dumps for CFGElement and CFGElementRef 
(authored by Szelethus, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66715?vs=217040=219979#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66715/new/

https://reviews.llvm.org/D66715

Files:
  cfe/trunk/include/clang/Analysis/CFG.h
  cfe/trunk/lib/Analysis/CFG.cpp

Index: cfe/trunk/lib/Analysis/CFG.cpp
===
--- cfe/trunk/lib/Analysis/CFG.cpp
+++ cfe/trunk/lib/Analysis/CFG.cpp
@@ -4999,6 +4999,8 @@
 public:
   StmtPrinterHelper(const CFG* cfg, const LangOptions )
   : LangOpts(LO) {
+if (!cfg)
+  return;
 for (CFG::const_iterator I = cfg->begin(), E = cfg->end(); I != E; ++I ) {
   unsigned j = 1;
   for (CFGBlock::const_iterator BI = (*I)->begin(), BEnd = (*I)->end() ;
@@ -5321,9 +5323,21 @@
 }
 
 static void print_elem(raw_ostream , StmtPrinterHelper ,
+   const CFGElement );
+
+void CFGElement::dumpToStream(llvm::raw_ostream ) const {
+  StmtPrinterHelper Helper(nullptr, {});
+  print_elem(OS, Helper, *this);
+}
+
+static void print_elem(raw_ostream , StmtPrinterHelper ,
const CFGElement ) {
-  if (Optional CS = E.getAs()) {
-const Stmt *S = CS->getStmt();
+  switch (E.getKind()) {
+  case CFGElement::Kind::Statement:
+  case CFGElement::Kind::CXXRecordTypedCall:
+  case CFGElement::Kind::Constructor: {
+CFGStmt CS = E.castAs();
+const Stmt *S = CS.getStmt();
 assert(S != nullptr && "Expecting non-null Stmt");
 
 // special printing for statement-expressions.
@@ -5375,12 +5389,18 @@
 // Expressions need a newline.
 if (isa(S))
   OS << '\n';
-  } else if (Optional IE = E.getAs()) {
-print_initializer(OS, Helper, IE->getInitializer());
+
+break;
+  }
+
+  case CFGElement::Kind::Initializer:
+print_initializer(OS, Helper, E.castAs().getInitializer());
 OS << '\n';
-  } else if (Optional DE =
- E.getAs()) {
-const VarDecl *VD = DE->getVarDecl();
+break;
+
+  case CFGElement::Kind::AutomaticObjectDtor: {
+CFGAutomaticObjDtor DE = E.castAs();
+const VarDecl *VD = DE.getVarDecl();
 Helper.handleDecl(VD, OS);
 
 QualType T = VD->getType();
@@ -5390,53 +5410,75 @@
 OS << ".~";
 T.getUnqualifiedType().print(OS, PrintingPolicy(Helper.getLangOpts()));
 OS << "() (Implicit destructor)\n";
-  } else if (Optional DE = E.getAs()) {
-const VarDecl *VD = DE->getVarDecl();
-Helper.handleDecl(VD, OS);
+break;
+  }
 
+  case CFGElement::Kind::LifetimeEnds:
+Helper.handleDecl(E.castAs().getVarDecl(), OS);
 OS << " (Lifetime ends)\n";
-  } else if (Optional LE = E.getAs()) {
-const Stmt *LoopStmt = LE->getLoopStmt();
-OS << LoopStmt->getStmtClassName() << " (LoopExit)\n";
-  } else if (Optional SB = E.getAs()) {
+break;
+
+  case CFGElement::Kind::LoopExit:
+OS << E.castAs().getLoopStmt()->getStmtClassName() << " (LoopExit)\n";
+break;
+
+  case CFGElement::Kind::ScopeBegin:
 OS << "CFGScopeBegin(";
-if (const VarDecl *VD = SB->getVarDecl())
+if (const VarDecl *VD = E.castAs().getVarDecl())
   OS << VD->getQualifiedNameAsString();
 OS << ")\n";
-  } else if (Optional SE = E.getAs()) {
+break;
+
+  case CFGElement::Kind::ScopeEnd:
 OS << "CFGScopeEnd(";
-if (const VarDecl *VD = SE->getVarDecl())
+if (const VarDecl *VD = E.castAs().getVarDecl())
   OS << VD->getQualifiedNameAsString();
 OS << ")\n";
-  } else if (Optional NE = E.getAs()) {
+break;
+
+  case CFGElement::Kind::NewAllocator:
 OS << "CFGNewAllocator(";
-if (const CXXNewExpr *AllocExpr = NE->getAllocatorExpr())
+if (const CXXNewExpr *AllocExpr = E.castAs().getAllocatorExpr())
   AllocExpr->getType().print(OS, PrintingPolicy(Helper.getLangOpts()));
 OS << ")\n";
-  } else if (Optional DE = E.getAs()) {
-const CXXRecordDecl *RD = DE->getCXXRecordDecl();
+break;
+
+  case CFGElement::Kind::DeleteDtor: {
+CFGDeleteDtor DE = E.castAs();
+const CXXRecordDecl *RD = DE.getCXXRecordDecl();
 if (!RD)
   return;
 CXXDeleteExpr *DelExpr =
-const_cast(DE->getDeleteExpr());
+const_cast(DE.getDeleteExpr());
 Helper.handledStmt(cast(DelExpr->getArgument()), OS);
 OS << "->~" << RD->getName().str() << "()";
 OS << " (Implicit destructor)\n";
-  } else if (Optional BE = E.getAs()) {
-const CXXBaseSpecifier *BS = BE->getBaseSpecifier();
+break;
+  }
+
+  case CFGElement::Kind::BaseDtor: {
+const CXXBaseSpecifier *BS = E.castAs().getBaseSpecifier();
 OS << "~" << BS->getType()->getAsCXXRecordDecl()->getName() << "()";
 OS << " (Base object destructor)\n";
-  } else if (Optional ME = E.getAs()) {
-

r371766 - [Clang][CodeGen] support alias attribute w/ gnu_inline

2019-09-12 Thread Nick Desaulniers via cfe-commits
Author: nickdesaulniers
Date: Thu Sep 12 12:53:35 2019
New Revision: 371766

URL: http://llvm.org/viewvc/llvm-project?rev=371766=rev
Log:
[Clang][CodeGen] support alias attribute w/ gnu_inline

Summary:
r369705 did not consider the addition of gnu_inline on function
declarations of alias attributed functions. This resulted in a reported
regression in the clang-9-rc4 release from the Zig developers building
glibc, which was observable as a failed assertion:

llvm-project/clang/lib/AST/Decl.cpp:3336: bool
clang::FunctionDecl::isInlineDefinitionExternallyVisible() const:
Assertion `(doesThisDeclarationHaveABody() || willHaveBody()) && "Must
be a function definition"' failed.

Alias function declarations do not have bodies, so allow us to proceed
if we have the alias function attribute but no body/definition, and add
a test case.  The emitted symbols and their linkage matches GCC for the
added test case.

Link: https://bugs.llvm.org/show_bug.cgi?id=43268

Reviewers: aaron.ballman, rsmith, erichkeane, andrewrk

Reviewed By: andrewrk

Subscribers: cfe-commits, andrewrk, hans, srhines

Tags: #clang

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

Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/test/CodeGen/alias.c

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=371766=371765=371766=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Thu Sep 12 12:53:35 2019
@@ -3348,7 +3348,8 @@ SourceRange FunctionDecl::getExceptionSp
 /// an externally visible symbol, but "extern inline" will not create an
 /// externally visible symbol.
 bool FunctionDecl::isInlineDefinitionExternallyVisible() const {
-  assert((doesThisDeclarationHaveABody() || willHaveBody()) &&
+  assert((doesThisDeclarationHaveABody() || willHaveBody() ||
+  hasAttr()) &&
  "Must be a function definition");
   assert(isInlined() && "Function must be inline");
   ASTContext  = getASTContext();

Modified: cfe/trunk/test/CodeGen/alias.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/alias.c?rev=371766=371765=371766=diff
==
--- cfe/trunk/test/CodeGen/alias.c (original)
+++ cfe/trunk/test/CodeGen/alias.c Thu Sep 12 12:53:35 2019
@@ -99,3 +99,8 @@ static int test10_foo __attribute__((ali
 // CHECKGLOBALS-NOT: @test11_foo = dso_local
 void test11(void) {}
 static void test11_foo(void) __attribute__((alias("test11")));
+
+// Test that gnu_inline+alias work.
+// CHECKGLOBALS: @test12_alias = alias void (), void ()* @test12
+void test12(void) {}
+inline void test12_alias(void) __attribute__((gnu_inline, alias("test12")));


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67455: [Clang][CodeGen] support alias attribute w/ gnu_inline

2019-09-12 Thread Nick Desaulniers via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371766: [Clang][CodeGen] support alias attribute w/ 
gnu_inline (authored by nickdesaulniers, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67455?vs=219790=219980#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67455/new/

https://reviews.llvm.org/D67455

Files:
  cfe/trunk/lib/AST/Decl.cpp
  cfe/trunk/test/CodeGen/alias.c


Index: cfe/trunk/test/CodeGen/alias.c
===
--- cfe/trunk/test/CodeGen/alias.c
+++ cfe/trunk/test/CodeGen/alias.c
@@ -99,3 +99,8 @@
 // CHECKGLOBALS-NOT: @test11_foo = dso_local
 void test11(void) {}
 static void test11_foo(void) __attribute__((alias("test11")));
+
+// Test that gnu_inline+alias work.
+// CHECKGLOBALS: @test12_alias = alias void (), void ()* @test12
+void test12(void) {}
+inline void test12_alias(void) __attribute__((gnu_inline, alias("test12")));
Index: cfe/trunk/lib/AST/Decl.cpp
===
--- cfe/trunk/lib/AST/Decl.cpp
+++ cfe/trunk/lib/AST/Decl.cpp
@@ -3348,7 +3348,8 @@
 /// an externally visible symbol, but "extern inline" will not create an
 /// externally visible symbol.
 bool FunctionDecl::isInlineDefinitionExternallyVisible() const {
-  assert((doesThisDeclarationHaveABody() || willHaveBody()) &&
+  assert((doesThisDeclarationHaveABody() || willHaveBody() ||
+  hasAttr()) &&
  "Must be a function definition");
   assert(isInlined() && "Function must be inline");
   ASTContext  = getASTContext();


Index: cfe/trunk/test/CodeGen/alias.c
===
--- cfe/trunk/test/CodeGen/alias.c
+++ cfe/trunk/test/CodeGen/alias.c
@@ -99,3 +99,8 @@
 // CHECKGLOBALS-NOT: @test11_foo = dso_local
 void test11(void) {}
 static void test11_foo(void) __attribute__((alias("test11")));
+
+// Test that gnu_inline+alias work.
+// CHECKGLOBALS: @test12_alias = alias void (), void ()* @test12
+void test12(void) {}
+inline void test12_alias(void) __attribute__((gnu_inline, alias("test12")));
Index: cfe/trunk/lib/AST/Decl.cpp
===
--- cfe/trunk/lib/AST/Decl.cpp
+++ cfe/trunk/lib/AST/Decl.cpp
@@ -3348,7 +3348,8 @@
 /// an externally visible symbol, but "extern inline" will not create an
 /// externally visible symbol.
 bool FunctionDecl::isInlineDefinitionExternallyVisible() const {
-  assert((doesThisDeclarationHaveABody() || willHaveBody()) &&
+  assert((doesThisDeclarationHaveABody() || willHaveBody() ||
+  hasAttr()) &&
  "Must be a function definition");
   assert(isInlined() && "Function must be inline");
   ASTContext  = getASTContext();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r371765 - [CFG] Add dumps for CFGElement and CFGElementRef

2019-09-12 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Thu Sep 12 12:52:34 2019
New Revision: 371765

URL: http://llvm.org/viewvc/llvm-project?rev=371765=rev
Log:
[CFG] Add dumps for CFGElement and CFGElementRef

Seems like we never had these, so here we go! I also did some refactoring as I
was chasing a bug unrelated to this revision.

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

Modified:
cfe/trunk/include/clang/Analysis/CFG.h
cfe/trunk/lib/Analysis/CFG.cpp

Modified: cfe/trunk/include/clang/Analysis/CFG.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CFG.h?rev=371765=371764=371765=diff
==
--- cfe/trunk/include/clang/Analysis/CFG.h (original)
+++ cfe/trunk/include/clang/Analysis/CFG.h Thu Sep 12 12:52:34 2019
@@ -121,6 +121,12 @@ public:
 x |= Data1.getInt();
 return (Kind) x;
   }
+
+  void dumpToStream(llvm::raw_ostream ) const;
+
+  void dump() const {
+dumpToStream(llvm::errs());
+  }
 };
 
 class CFGStmt : public CFGElement {
@@ -650,8 +656,17 @@ class CFGBlock {
 }
 
 bool operator!=(ElementRefImpl Other) const { return !(*this == Other); }
-CFGElement operator*() { return (*Parent)[Index]; }
-CFGElementPtr operator->() { return &*(Parent->begin() + Index); }
+CFGElement operator*() const { return (*Parent)[Index]; }
+CFGElementPtr operator->() const { return &*(Parent->begin() + Index); }
+
+void dumpToStream(llvm::raw_ostream ) const {
+  OS << getIndexInBlock() + 1 << ": ";
+  (*this)->dumpToStream(OS);
+}
+
+void dump() const {
+  dumpToStream(llvm::errs());
+}
   };
 
   template  class ElementRefIterator {

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=371765=371764=371765=diff
==
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Thu Sep 12 12:52:34 2019
@@ -4999,6 +4999,8 @@ class StmtPrinterHelper : public Printer
 public:
   StmtPrinterHelper(const CFG* cfg, const LangOptions )
   : LangOpts(LO) {
+if (!cfg)
+  return;
 for (CFG::const_iterator I = cfg->begin(), E = cfg->end(); I != E; ++I ) {
   unsigned j = 1;
   for (CFGBlock::const_iterator BI = (*I)->begin(), BEnd = (*I)->end() ;
@@ -5321,9 +5323,21 @@ static void print_construction_context(r
 }
 
 static void print_elem(raw_ostream , StmtPrinterHelper ,
+   const CFGElement );
+
+void CFGElement::dumpToStream(llvm::raw_ostream ) const {
+  StmtPrinterHelper Helper(nullptr, {});
+  print_elem(OS, Helper, *this);
+}
+
+static void print_elem(raw_ostream , StmtPrinterHelper ,
const CFGElement ) {
-  if (Optional CS = E.getAs()) {
-const Stmt *S = CS->getStmt();
+  switch (E.getKind()) {
+  case CFGElement::Kind::Statement:
+  case CFGElement::Kind::CXXRecordTypedCall:
+  case CFGElement::Kind::Constructor: {
+CFGStmt CS = E.castAs();
+const Stmt *S = CS.getStmt();
 assert(S != nullptr && "Expecting non-null Stmt");
 
 // special printing for statement-expressions.
@@ -5375,12 +5389,18 @@ static void print_elem(raw_ostream ,
 // Expressions need a newline.
 if (isa(S))
   OS << '\n';
-  } else if (Optional IE = E.getAs()) {
-print_initializer(OS, Helper, IE->getInitializer());
+
+break;
+  }
+
+  case CFGElement::Kind::Initializer:
+print_initializer(OS, Helper, E.castAs().getInitializer());
 OS << '\n';
-  } else if (Optional DE =
- E.getAs()) {
-const VarDecl *VD = DE->getVarDecl();
+break;
+
+  case CFGElement::Kind::AutomaticObjectDtor: {
+CFGAutomaticObjDtor DE = E.castAs();
+const VarDecl *VD = DE.getVarDecl();
 Helper.handleDecl(VD, OS);
 
 QualType T = VD->getType();
@@ -5390,53 +5410,75 @@ static void print_elem(raw_ostream ,
 OS << ".~";
 T.getUnqualifiedType().print(OS, PrintingPolicy(Helper.getLangOpts()));
 OS << "() (Implicit destructor)\n";
-  } else if (Optional DE = E.getAs()) {
-const VarDecl *VD = DE->getVarDecl();
-Helper.handleDecl(VD, OS);
+break;
+  }
 
+  case CFGElement::Kind::LifetimeEnds:
+Helper.handleDecl(E.castAs().getVarDecl(), OS);
 OS << " (Lifetime ends)\n";
-  } else if (Optional LE = E.getAs()) {
-const Stmt *LoopStmt = LE->getLoopStmt();
-OS << LoopStmt->getStmtClassName() << " (LoopExit)\n";
-  } else if (Optional SB = E.getAs()) {
+break;
+
+  case CFGElement::Kind::LoopExit:
+OS << E.castAs().getLoopStmt()->getStmtClassName() << " 
(LoopExit)\n";
+break;
+
+  case CFGElement::Kind::ScopeBegin:
 OS << "CFGScopeBegin(";
-if (const VarDecl *VD = SB->getVarDecl())
+if (const VarDecl *VD = E.castAs().getVarDecl())
   OS << VD->getQualifiedNameAsString();
 OS << ")\n";
-  } else if (Optional SE = E.getAs()) {
+break;
+
+  case 

[PATCH] D67515: [Sema][Typo Correction] Fix potential infite loop on ambiguity checks

2019-09-12 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 219978.
dgoldman added a comment.

- Fix method name in test


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67515/new/

https://reviews.llvm.org/D67515

Files:
  lib/Sema/SemaExprCXX.cpp
  test/Sema/typo-correction-ambiguity.cpp


Index: test/Sema/typo-correction-ambiguity.cpp
===
--- /dev/null
+++ test/Sema/typo-correction-ambiguity.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Check the following typo correction behavior in namespaces:
+// - no typos are diagnosed when an expression has ambiguous (multiple) 
corrections
+// - proper iteration through multiple potentially ambiguous corrections
+
+namespace AmibguousCorrection
+{
+  void method_Bar();
+  void method_Foo();
+  void method_Zoo();
+};
+
+void testAmbiguousNoSuggestions()
+{
+  AmibguousCorrection::method_Ace(); // expected-error {{no member named 
'method_Ace' in namespace 'AmibguousCorrection'}}
+}
+
+namespace MultipleCorrectionsButNotAmbiguous
+{
+  int PrefixType_Name(int value);  // expected-note {{'PrefixType_Name' 
declared here}}
+  int PrefixType_MIN();
+  int PrefixType_MAX();
+};
+
+int testMultipleCorrectionsButNotAmbiguous() {
+  int val = MultipleCorrectionsButNotAmbiguous::PrefixType_Enum(0);  // 
expected-error {{no member named 'PrefixType_Enum' in namespace 
'MultipleCorrectionsButNotAmbiguous'; did you mean 'PrefixType_Name'?}}
+  return val;
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -7755,6 +7755,10 @@
 TypoCorrection TC = 
SemaRef.getTypoExprState(TE).Consumer->peekNextCorrection();
 TypoCorrection Next;
 do {
+  // Fetch the next correction by erasing the typo from the cache and 
calling
+  // `TryTransform` which will iterate through corrections in
+  // `TransformTypoExpr`.
+  TransformCache.erase(TE);
   ExprResult AmbigRes = CheckForRecursiveTypos(TryTransform(E), 
IsAmbiguous);
 
   if (!AmbigRes.isInvalid() || IsAmbiguous) {


Index: test/Sema/typo-correction-ambiguity.cpp
===
--- /dev/null
+++ test/Sema/typo-correction-ambiguity.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Check the following typo correction behavior in namespaces:
+// - no typos are diagnosed when an expression has ambiguous (multiple) corrections
+// - proper iteration through multiple potentially ambiguous corrections
+
+namespace AmibguousCorrection
+{
+  void method_Bar();
+  void method_Foo();
+  void method_Zoo();
+};
+
+void testAmbiguousNoSuggestions()
+{
+  AmibguousCorrection::method_Ace(); // expected-error {{no member named 'method_Ace' in namespace 'AmibguousCorrection'}}
+}
+
+namespace MultipleCorrectionsButNotAmbiguous
+{
+  int PrefixType_Name(int value);  // expected-note {{'PrefixType_Name' declared here}}
+  int PrefixType_MIN();
+  int PrefixType_MAX();
+};
+
+int testMultipleCorrectionsButNotAmbiguous() {
+  int val = MultipleCorrectionsButNotAmbiguous::PrefixType_Enum(0);  // expected-error {{no member named 'PrefixType_Enum' in namespace 'MultipleCorrectionsButNotAmbiguous'; did you mean 'PrefixType_Name'?}}
+  return val;
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -7755,6 +7755,10 @@
 TypoCorrection TC = SemaRef.getTypoExprState(TE).Consumer->peekNextCorrection();
 TypoCorrection Next;
 do {
+  // Fetch the next correction by erasing the typo from the cache and calling
+  // `TryTransform` which will iterate through corrections in
+  // `TransformTypoExpr`.
+  TransformCache.erase(TE);
   ExprResult AmbigRes = CheckForRecursiveTypos(TryTransform(E), IsAmbiguous);
 
   if (!AmbigRes.isInvalid() || IsAmbiguous) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67091: Fix for headers having the same name as a directory

2019-09-12 Thread Kousik Kumar via Phabricator via cfe-commits
kousikk added a comment.

> I was unable to reproduce the failures when I moved the check to createFile. 
> What kind of failures did you see? Did you move it right to the start of the 
> function? I would recommend rebasing the patch and retrying.

I saw an assertion error - but I realize now that it was because it was not at 
the top of the function. I had put it after `Entry->getContents()` which was 
throwing an assertion. I now realize that for `getContents()` to work, the 
entry needs to be a file. Thanks for correcting me!

> Also, could you please rename headerwithdirname.cpp to 
> headerwithdirname_input.cpp when copying it to ensure FileCheck can match the 
> filename without matching the temporary path (see 
> https://reviews.llvm.org/D67379 for test fixes that @jkorous applied).

Done


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67091/new/

https://reviews.llvm.org/D67091



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67091: Fix for headers having the same name as a directory

2019-09-12 Thread Kousik Kumar via Phabricator via cfe-commits
kousikk updated this revision to Diff 219976.
kousikk added a comment.

- Add validation inside the createFile() function


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67091/new/

https://reviews.llvm.org/D67091

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
  clang/test/ClangScanDeps/Inputs/foodir
  clang/test/ClangScanDeps/Inputs/headerwithdirname.json
  clang/test/ClangScanDeps/headerwithdirname.cpp


Index: clang/test/ClangScanDeps/headerwithdirname.cpp
===
--- /dev/null
+++ clang/test/ClangScanDeps/headerwithdirname.cpp
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.dir/foodir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: mkdir -p %t.dir/foodir
+// RUN: cp %s %t.dir/headerwithdirname_input.cpp
+// RUN: mkdir %t.dir/Inputs
+// RUN: cp %S/Inputs/foodir %t.dir/Inputs/foodir
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/headerwithdirname.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck %s
+
+#include 
+
+// CHECK: headerwithdirname_input.o
+// CHECK-NEXT: headerwithdirname_input.cpp
+// CHECK-NEXT: Inputs{{/|\\}}foodir
Index: clang/test/ClangScanDeps/Inputs/headerwithdirname.json
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/headerwithdirname.json
@@ -0,0 +1,7 @@
+[
+{
+  "directory": "DIR",
+  "command": "clang -c -IDIR -IDIR/foodir -IInputs 
DIR/headerwithdirname_input.cpp",
+  "file": "DIR/headerwithdirname_input.cpp"
+}
+]
Index: clang/test/ClangScanDeps/Inputs/foodir
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/foodir
@@ -0,0 +1 @@
+// A C++ header with same name as that of a directory in the include path.
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -193,6 +193,8 @@
 llvm::ErrorOr>
 createFile(const CachedFileSystemEntry *Entry,
ExcludedPreprocessorDirectiveSkipMapping *PPSkipMappings) {
+  if (Entry->isDirectory())
+return 
llvm::ErrorOr>(std::make_error_code(std::errc::is_a_directory));
   llvm::ErrorOr Contents = Entry->getContents();
   if (!Contents)
 return Contents.getError();
Index: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
===
--- 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
+++ 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
@@ -56,6 +56,11 @@
   /// \returns True if the entry is valid.
   bool isValid() const { return !MaybeStat || MaybeStat->isStatusKnown(); }
 
+  /// \returns True if the current entry points to a directory.
+  bool isDirectory() const {
+return MaybeStat && MaybeStat->isDirectory();
+  }
+
   /// \returns The error or the file's contents.
   llvm::ErrorOr getContents() const {
 if (!MaybeStat)


Index: clang/test/ClangScanDeps/headerwithdirname.cpp
===
--- /dev/null
+++ clang/test/ClangScanDeps/headerwithdirname.cpp
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.dir/foodir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: mkdir -p %t.dir/foodir
+// RUN: cp %s %t.dir/headerwithdirname_input.cpp
+// RUN: mkdir %t.dir/Inputs
+// RUN: cp %S/Inputs/foodir %t.dir/Inputs/foodir
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/headerwithdirname.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck %s
+
+#include 
+
+// CHECK: headerwithdirname_input.o
+// CHECK-NEXT: headerwithdirname_input.cpp
+// CHECK-NEXT: Inputs{{/|\\}}foodir
Index: clang/test/ClangScanDeps/Inputs/headerwithdirname.json
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/headerwithdirname.json
@@ -0,0 +1,7 @@
+[
+{
+  "directory": "DIR",
+  "command": "clang -c -IDIR -IDIR/foodir -IInputs DIR/headerwithdirname_input.cpp",
+  "file": "DIR/headerwithdirname_input.cpp"
+}
+]
Index: clang/test/ClangScanDeps/Inputs/foodir
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/foodir
@@ -0,0 +1 @@
+// A C++ header with same name as that of a directory in the include path.
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
===
--- 

[PATCH] D67091: Fix for headers having the same name as a directory

2019-09-12 Thread Kousik Kumar via Phabricator via cfe-commits
kousikk updated this revision to Diff 219975.
kousikk added a comment.

- Add validation inside the createFile() function


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67091/new/

https://reviews.llvm.org/D67091

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
  clang/test/ClangScanDeps/Inputs/foodir
  clang/test/ClangScanDeps/Inputs/headerwithdirname.json
  clang/test/ClangScanDeps/headerwithdirname.cpp


Index: clang/test/ClangScanDeps/headerwithdirname.cpp
===
--- /dev/null
+++ clang/test/ClangScanDeps/headerwithdirname.cpp
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.dir/foodir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: mkdir -p %t.dir/foodir
+// RUN: cp %s %t.dir/headerwithdirname_input.cpp
+// RUN: mkdir %t.dir/Inputs
+// RUN: cp %S/Inputs/foodir %t.dir/Inputs/foodir
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/headerwithdirname.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck %s
+
+#include 
+
+// CHECK: headerwithdirname_input.o
+// CHECK-NEXT: headerwithdirname_input.cpp
+// CHECK-NEXT: Inputs{{/|\\}}foodir
Index: clang/test/ClangScanDeps/Inputs/headerwithdirname.json
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/headerwithdirname.json
@@ -0,0 +1,7 @@
+[
+{
+  "directory": "DIR",
+  "command": "clang -c -IDIR -IDIR/foodir -IInputs 
DIR/headerwithdirname_input.cpp",
+  "file": "DIR/headerwithdirname_input.cpp"
+}
+]
Index: clang/test/ClangScanDeps/Inputs/foodir
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/foodir
@@ -0,0 +1 @@
+// A C++ header with same name as that of a directory in the include path.
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -193,6 +193,8 @@
 llvm::ErrorOr>
 createFile(const CachedFileSystemEntry *Entry,
ExcludedPreprocessorDirectiveSkipMapping *PPSkipMappings) {
+  if (Entry->isDirectory())
+return 
llvm::ErrorOr>(std::make_error_code(std::errc::is_a_directory));
   llvm::ErrorOr Contents = Entry->getContents();
   if (!Contents)
 return Contents.getError();
@@ -215,8 +217,9 @@
   StringRef Filename = Path.toStringRef(OwnedFilename);
 
   // Check the local cache first.
-  if (const CachedFileSystemEntry *Entry = getCachedEntry(Filename))
+  if (const CachedFileSystemEntry *Entry = getCachedEntry(Filename)) {
 return createFile(Entry, PPSkipMappings);
+  }
 
   // FIXME: Handle PCM/PCH files.
   // FIXME: Handle module map files.
Index: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
===
--- 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
+++ 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
@@ -56,6 +56,11 @@
   /// \returns True if the entry is valid.
   bool isValid() const { return !MaybeStat || MaybeStat->isStatusKnown(); }
 
+  /// \returns True if the current entry points to a directory.
+  bool isDirectory() const {
+return MaybeStat && MaybeStat->isDirectory();
+  }
+
   /// \returns The error or the file's contents.
   llvm::ErrorOr getContents() const {
 if (!MaybeStat)


Index: clang/test/ClangScanDeps/headerwithdirname.cpp
===
--- /dev/null
+++ clang/test/ClangScanDeps/headerwithdirname.cpp
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.dir/foodir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: mkdir -p %t.dir/foodir
+// RUN: cp %s %t.dir/headerwithdirname_input.cpp
+// RUN: mkdir %t.dir/Inputs
+// RUN: cp %S/Inputs/foodir %t.dir/Inputs/foodir
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/headerwithdirname.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck %s
+
+#include 
+
+// CHECK: headerwithdirname_input.o
+// CHECK-NEXT: headerwithdirname_input.cpp
+// CHECK-NEXT: Inputs{{/|\\}}foodir
Index: clang/test/ClangScanDeps/Inputs/headerwithdirname.json
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/headerwithdirname.json
@@ -0,0 +1,7 @@
+[
+{
+  "directory": "DIR",
+  "command": "clang -c -IDIR -IDIR/foodir -IInputs DIR/headerwithdirname_input.cpp",
+  "file": "DIR/headerwithdirname_input.cpp"
+}
+]
Index: clang/test/ClangScanDeps/Inputs/foodir

[PATCH] D67515: [Sema][Typo Correction] Fix potential infite loop on ambiguity checks

2019-09-12 Thread David Goldman via Phabricator via cfe-commits
dgoldman created this revision.
dgoldman added a reviewer: rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This fixes a bug introduced in D62648 , where 
Clang could infinite loop
if it became stuck on a single TypoCorrection when it was supposed to
be testing ambiguous corrections. Although not a common case, it could
happen if there are multiple possible corrections with the same edit
distance.

The fix is simply to wipe the TypoExpr from the `TransformCache` so that
the call to `TransformTypoExpr` doesn't use the `CachedEntry`.


Repository:
  rC Clang

https://reviews.llvm.org/D67515

Files:
  lib/Sema/SemaExprCXX.cpp
  test/Sema/typo-correction-ambiguity.cpp


Index: test/Sema/typo-correction-ambiguity.cpp
===
--- /dev/null
+++ test/Sema/typo-correction-ambiguity.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Check the following typo correction behavior in namespaces:
+// - no typos are diagnosed when an expression has ambiguous (multiple) 
corrections
+// - proper iteration through multiple potentially ambiguous corrections
+
+namespace AmibguousCorrection
+{
+  void method_Bar();
+  void method_Foo();
+  void method_Zoo();
+};
+
+void testAmbiguousNoSuggestions()
+{
+  AmibguousCorrection::method_Ace(); // expected-error {{no member named 
'method_Ace' in namespace 'AmibguousCorrection'}}
+}
+
+namespace MultipleCorrectionsButNotAmbiguous
+{
+  int PrefixType_Name(int value);  // expected-note {{'PrefixType_Name' 
declared here}}
+  int PrefixType_MIN();
+  int PrefixType_MAX();
+};
+
+int testDirectAmbiguousCorrection() {
+  int val = MultipleCorrectionsButNotAmbiguous::PrefixType_Enum(0);  // 
expected-error {{no member named 'PrefixType_Enum' in namespace 
'MultipleCorrectionsButNotAmbiguous'; did you mean 'PrefixType_Name'?}}
+  return val;
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -7755,6 +7755,10 @@
 TypoCorrection TC = 
SemaRef.getTypoExprState(TE).Consumer->peekNextCorrection();
 TypoCorrection Next;
 do {
+  // Fetch the next correction by erasing the typo from the cache and 
calling
+  // `TryTransform` which will iterate through corrections in
+  // `TransformTypoExpr`.
+  TransformCache.erase(TE);
   ExprResult AmbigRes = CheckForRecursiveTypos(TryTransform(E), 
IsAmbiguous);
 
   if (!AmbigRes.isInvalid() || IsAmbiguous) {


Index: test/Sema/typo-correction-ambiguity.cpp
===
--- /dev/null
+++ test/Sema/typo-correction-ambiguity.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Check the following typo correction behavior in namespaces:
+// - no typos are diagnosed when an expression has ambiguous (multiple) corrections
+// - proper iteration through multiple potentially ambiguous corrections
+
+namespace AmibguousCorrection
+{
+  void method_Bar();
+  void method_Foo();
+  void method_Zoo();
+};
+
+void testAmbiguousNoSuggestions()
+{
+  AmibguousCorrection::method_Ace(); // expected-error {{no member named 'method_Ace' in namespace 'AmibguousCorrection'}}
+}
+
+namespace MultipleCorrectionsButNotAmbiguous
+{
+  int PrefixType_Name(int value);  // expected-note {{'PrefixType_Name' declared here}}
+  int PrefixType_MIN();
+  int PrefixType_MAX();
+};
+
+int testDirectAmbiguousCorrection() {
+  int val = MultipleCorrectionsButNotAmbiguous::PrefixType_Enum(0);  // expected-error {{no member named 'PrefixType_Enum' in namespace 'MultipleCorrectionsButNotAmbiguous'; did you mean 'PrefixType_Name'?}}
+  return val;
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -7755,6 +7755,10 @@
 TypoCorrection TC = SemaRef.getTypoExprState(TE).Consumer->peekNextCorrection();
 TypoCorrection Next;
 do {
+  // Fetch the next correction by erasing the typo from the cache and calling
+  // `TryTransform` which will iterate through corrections in
+  // `TransformTypoExpr`.
+  TransformCache.erase(TE);
   ExprResult AmbigRes = CheckForRecursiveTypos(TryTransform(E), IsAmbiguous);
 
   if (!AmbigRes.isInvalid() || IsAmbiguous) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67509: [CUDA][HIP] Diagnose defaulted constructor only if it is used

2019-09-12 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

Example of the actual error produced by clang: https://godbolt.org/z/Dl1FfC

Ugh. Another corner case of the way we're dealing with implicit `__host__ 
__device__` functions. :-(
LGTM for postponing the error until actual use.




Comment at: test/SemaCUDA/default-ctor.cu:1
+// RUN: %clang_cc1 -std=c++11 -triple nvptx64-nvidia-cuda -fsyntax-only 
-fcuda-is-device -verify %s
+

It would be good to add host-side compilation, too. 



Comment at: test/SemaCUDA/default-ctor.cu:4
+#define __host__ __attribute__((host))
+#define __device__ __attribute__((device))
+

Use `#include "Inputs/cuda.h"` instead.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67509/new/

https://reviews.llvm.org/D67509



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67140: [analyzer][NFC] Fix inconsistent references to checkers as "checks"

2019-09-12 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371760: [analyzer][NFC] Fix inconsistent references to 
checkers as checks (authored by Szelethus, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67140?vs=218583=219968#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67140/new/

https://reviews.llvm.org/D67140

Files:
  cfe/trunk/include/clang/Analysis/PathDiagnostic.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  cfe/trunk/lib/Analysis/PathDiagnostic.cpp
  cfe/trunk/lib/Analysis/plugins/SampleAnalyzer/MainCallChecker.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/DeleteWithNonVirtualDtorChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/ValistChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/Checker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/CheckerManager.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
  cfe/trunk/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -1312,7 +1312,7 @@
 generateDiagnosticForBasicReport(const BasicBugReport *R) {
   const BugType  = R->getBugType();
   return std::make_unique(
-  BT.getCheckName(), R->getDeclWithIssue(), BT.getName(),
+  BT.getCheckerName(), R->getDeclWithIssue(), BT.getDescription(),
   R->getDescription(), R->getShortDescription(/*UseFallback=*/false),
   BT.getCategory(), R->getUniqueingLocation(), R->getUniqueingDecl(),
   std::make_unique());
@@ -1323,7 +1323,7 @@
  const SourceManager ) {
   const BugType  = R->getBugType();
   return std::make_unique(
-  BT.getCheckName(), R->getDeclWithIssue(), BT.getName(),
+  BT.getCheckerName(), R->getDeclWithIssue(), BT.getDescription(),
   R->getDescription(), R->getShortDescription(/*UseFallback=*/false),
   BT.getCategory(), R->getUniqueingLocation(), R->getUniqueingDecl(),
   findExecutedLines(SM, R->getErrorNode()));
@@ -3235,12 +3235,12 @@
   PathDiagnosticLocation Loc,
   ArrayRef Ranges,
   ArrayRef Fixits) {
-  EmitBasicReport(DeclWithIssue, Checker->getCheckName(), Name, Category, Str,
+  EmitBasicReport(DeclWithIssue, Checker->getCheckerName(), Name, Category, Str,
   Loc, Ranges, Fixits);
 }
 
 void BugReporter::EmitBasicReport(const Decl *DeclWithIssue,
-  CheckName CheckName,
+  CheckerNameRef CheckName,
   StringRef name, StringRef category,
   StringRef str, PathDiagnosticLocation Loc,
   ArrayRef Ranges,
@@ -3256,8 +3256,8 @@
   emitReport(std::move(R));
 }
 
-BugType *BugReporter::getBugTypeForName(CheckName CheckName, StringRef name,
-StringRef category) {
+BugType *BugReporter::getBugTypeForName(CheckerNameRef CheckName,
+StringRef name, StringRef category) {
   SmallString<136> fullDesc;
   llvm::raw_svector_ostream(fullDesc) << CheckName.getName() << ":" << name
   << ":" << category;
Index: cfe/trunk/lib/StaticAnalyzer/Core/CheckerManager.cpp

r371760 - [analyzer][NFC] Fix inconsistent references to checkers as "checks"

2019-09-12 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Thu Sep 12 12:09:24 2019
New Revision: 371760

URL: http://llvm.org/viewvc/llvm-project?rev=371760=rev
Log:
[analyzer][NFC] Fix inconsistent references to checkers as "checks"

Traditionally, clang-tidy uses the term check, and the analyzer uses checker,
but in the very early years, this wasn't the case, and code originating from the
early 2010's still incorrectly refer to checkers as checks.

This patch attempts to hunt down most of these, aiming to refer to checkers as
checkers, but preserve references to callback functions (like checkPreCall) as
checks.

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

Modified:
cfe/trunk/include/clang/Analysis/PathDiagnostic.h
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h
cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/trunk/lib/Analysis/PathDiagnostic.cpp
cfe/trunk/lib/Analysis/plugins/SampleAnalyzer/MainCallChecker.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/DeleteWithNonVirtualDtorChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ValistChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Core/Checker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CheckerManager.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
cfe/trunk/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp

Modified: cfe/trunk/include/clang/Analysis/PathDiagnostic.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathDiagnostic.h?rev=371760=371759=371760=diff
==
--- cfe/trunk/include/clang/Analysis/PathDiagnostic.h (original)
+++ cfe/trunk/include/clang/Analysis/PathDiagnostic.h Thu Sep 12 12:09:24 2019
@@ -725,7 +725,7 @@ using FilesToLineNumsMap = std::maphttp://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h?rev=371760=371759=371760=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Thu Sep 12 
12:09:24 2019
@@ -163,41 +163,15 @@ class AnalyzerOptions : public RefCounte
 public:
   using ConfigTable = llvm::StringMap;
 
+  /// Retrieves the list of checkers generated from Checkers.td. This doesn't
+  /// contain statically linked but non-generated checkers and plugin checkers!
   static std::vector
-  getRegisteredCheckers(bool IncludeExperimental = false) {
-static const StringRef StaticAnalyzerChecks[] = {
-#define GET_CHECKERS
-#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN) FULLNAME,
-#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
-#undef CHECKER
-#undef GET_CHECKERS
-};
-std::vector Checkers;
-for (StringRef CheckerName : StaticAnalyzerChecks) {
-  if (!CheckerName.startswith("debug.") &&
-  (IncludeExperimental || !CheckerName.startswith("alpha.")))
-Checkers.push_back(CheckerName);
-}
-return Checkers;
-  }
+  getRegisteredCheckers(bool IncludeExperimental = false);
 
+  /// Retrieves the list of packages generated from Checkers.td. This doesn't
+  /// contain statically linked but non-generated packages and plugin packages!
   static std::vector
-  getRegisteredPackages(bool IncludeExperimental = false) {
-static const StringRef StaticAnalyzerPackages[] = {
-#define GET_PACKAGES
-#define PACKAGE(FULLNAME) FULLNAME,
-#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
-#undef PACKAGE
-#undef GET_PACKAGES
-};
-std::vector Packages;
-for (StringRef PackageName : 

r371759 - NFC, add missing cl::cat option category to clang-scan-deps options to ensure they show up in -help

2019-09-12 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Sep 12 12:00:32 2019
New Revision: 371759

URL: http://llvm.org/viewvc/llvm-project?rev=371759=rev
Log:
NFC, add missing cl::cat option category to clang-scan-deps options to ensure 
they show up in -help

Modified:
cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp

Modified: cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp?rev=371759=371758=371759=diff
==
--- cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp (original)
+++ cfe/trunk/tools/clang-scan-deps/ClangScanDeps.cpp Thu Sep 12 12:00:32 2019
@@ -150,13 +150,14 @@ static llvm::cl::opt ScanM
 clEnumValN(ScanningMode::CanonicalPreprocessing, "preprocess",
"The set of dependencies is computed by preprocessing the "
"unmodified source files")),
-llvm::cl::init(ScanningMode::MinimizedSourcePreprocessing));
+llvm::cl::init(ScanningMode::MinimizedSourcePreprocessing),
+llvm::cl::cat(DependencyScannerCategory));
 
 llvm::cl::opt
 NumThreads("j", llvm::cl::Optional,
llvm::cl::desc("Number of worker threads to use (default: use "
   "all concurrent threads)"),
-   llvm::cl::init(0));
+   llvm::cl::init(0), llvm::cl::cat(DependencyScannerCategory));
 
 llvm::cl::opt
 CompilationDB("compilation-database",


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66714: [analyzer] Don't run the analyzer for -analyzer-list-enabled-checkers

2019-09-12 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371756: [analyzer] Dont run the analyzer for 
-analyzer-list-enabled-checkers (authored by Szelethus, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66714?vs=217039=219961#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66714/new/

https://reviews.llvm.org/D66714

Files:
  cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  cfe/trunk/test/Analysis/analyzer-enabled-checkers.c


Index: cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -270,6 +270,7 @@
   AnOpts,
   Clang->getDiagnostics(),
   Clang->getLangOpts());
+return true;
   }
 
   // Honor -analyzer-config-help.
Index: cfe/trunk/test/Analysis/analyzer-enabled-checkers.c
===
--- cfe/trunk/test/Analysis/analyzer-enabled-checkers.c
+++ cfe/trunk/test/Analysis/analyzer-enabled-checkers.c
@@ -1,20 +1,55 @@
-// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 %s -o /dev/null 
-analyzer-checker=core -analyzer-list-enabled-checkers > %t 2>&1
-// RUN: FileCheck --input-file=%t %s
+// RUN: %clang --analyze %s \
+// RUN:   -Xclang -triple -Xclang x86_64-pc-linux-gnu \
+// RUN:   -Xclang -analyzer-list-enabled-checkers \
+// RUN:   -Xclang -analyzer-display-progress \
+// RUN:   2>&1 | FileCheck %s --implicit-check-not=ANALYZE \
+// RUN:   --implicit-check-not=\.
 
-// CHECK: OVERVIEW: Clang Static Analyzer Enabled Checkers List
-// CHECK: core.CallAndMessage
-// CHECK: core.DivideZero
-// CHECK: core.DynamicTypePropagation
-// CHECK: core.NonNullParamChecker
-// CHECK: core.NullDereference
-// CHECK: core.StackAddressEscape
-// CHECK: core.UndefinedBinaryOperatorResult
-// CHECK: core.VLASize
-// CHECK: core.builtin.BuiltinFunctions
-// CHECK: core.builtin.NoReturnFunctions
-// CHECK: core.uninitialized.ArraySubscript
-// CHECK: core.uninitialized.Assign
-// CHECK: core.uninitialized.Branch
-// CHECK: core.uninitialized.CapturedBlockVariable
-// CHECK: core.uninitialized.UndefReturn
+// CHECK:  OVERVIEW: Clang Static Analyzer Enabled Checkers List
+// CHECK-EMPTY:
+// CHECK-NEXT: apiModeling.StdCLibraryFunctions
+// CHECK-NEXT: apiModeling.TrustNonnull
+// CHECK-NEXT: apiModeling.llvm.CastValue
+// CHECK-NEXT: apiModeling.llvm.ReturnValue
+// CHECK-NEXT: core.CallAndMessage
+// CHECK-NEXT: core.DivideZero
+// CHECK-NEXT: core.DynamicTypePropagation
+// CHECK-NEXT: core.NonNullParamChecker
+// CHECK-NEXT: core.NonnilStringConstants
+// CHECK-NEXT: core.NullDereference
+// CHECK-NEXT: core.StackAddrEscapeBase
+// CHECK-NEXT: core.StackAddressEscape
+// CHECK-NEXT: core.UndefinedBinaryOperatorResult
+// CHECK-NEXT: core.VLASize
+// CHECK-NEXT: core.builtin.BuiltinFunctions
+// CHECK-NEXT: core.builtin.NoReturnFunctions
+// CHECK-NEXT: core.uninitialized.ArraySubscript
+// CHECK-NEXT: core.uninitialized.Assign
+// CHECK-NEXT: core.uninitialized.Branch
+// CHECK-NEXT: core.uninitialized.CapturedBlockVariable
+// CHECK-NEXT: core.uninitialized.UndefReturn
+// CHECK-NEXT: deadcode.DeadStores
+// CHECK-NEXT: nullability.NullabilityBase
+// CHECK-NEXT: nullability.NullPassedToNonnull
+// CHECK-NEXT: nullability.NullReturnedFromNonnull
+// CHECK-NEXT: security.insecureAPI.SecuritySyntaxChecker
+// CHECK-NEXT: security.insecureAPI.UncheckedReturn
+// CHECK-NEXT: security.insecureAPI.getpw
+// CHECK-NEXT: security.insecureAPI.gets
+// CHECK-NEXT: security.insecureAPI.mkstemp
+// CHECK-NEXT: security.insecureAPI.mktemp
+// CHECK-NEXT: security.insecureAPI.vfork
+// CHECK-NEXT: unix.API
+// CHECK-NEXT: unix.cstring.CStringModeling
+// CHECK-NEXT: unix.DynamicMemoryModeling
+// CHECK-NEXT: unix.Malloc
+// CHECK-NEXT: unix.MallocSizeof
+// CHECK-NEXT: unix.MismatchedDeallocator
+// CHECK-NEXT: unix.Vfork
+// CHECK-NEXT: unix.cstring.BadSizeArg
+// CHECK-NEXT: unix.cstring.NullArg
 
+int main() {
+  int i;
+  (void)(10 / i);
+}


Index: cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -270,6 +270,7 @@
   AnOpts,
   Clang->getDiagnostics(),
   Clang->getLangOpts());
+return true;
   }
 
   // Honor -analyzer-config-help.
Index: cfe/trunk/test/Analysis/analyzer-enabled-checkers.c
===
--- 

[PATCH] D66981: Fix driver tests when `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR` is `ON`

2019-09-12 Thread Sergej Jaskiewicz via Phabricator via cfe-commits
broadwaylamb added a comment.

In D66981#1651897 , @phosek wrote:

> LGTM


Can you please commit this? I don't have commit access.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66981/new/

https://reviews.llvm.org/D66981



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r371756 - [analyzer] Don't run the analyzer for -analyzer-list-enabled-checkers

2019-09-12 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Thu Sep 12 11:53:48 2019
New Revision: 371756

URL: http://llvm.org/viewvc/llvm-project?rev=371756=rev
Log:
[analyzer] Don't run the analyzer for -analyzer-list-enabled-checkers

Short and sweet. Whenever I use -analyzer-list-enabled-checkers, I'm only
interested about the configuration, not about the analysis.

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

Modified:
cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
cfe/trunk/test/Analysis/analyzer-enabled-checkers.c

Modified: cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp?rev=371756=371755=371756=diff
==
--- cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp (original)
+++ cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp Thu Sep 12 
11:53:48 2019
@@ -270,6 +270,7 @@ bool ExecuteCompilerInvocation(CompilerI
   AnOpts,
   Clang->getDiagnostics(),
   Clang->getLangOpts());
+return true;
   }
 
   // Honor -analyzer-config-help.

Modified: cfe/trunk/test/Analysis/analyzer-enabled-checkers.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/analyzer-enabled-checkers.c?rev=371756=371755=371756=diff
==
--- cfe/trunk/test/Analysis/analyzer-enabled-checkers.c (original)
+++ cfe/trunk/test/Analysis/analyzer-enabled-checkers.c Thu Sep 12 11:53:48 2019
@@ -1,20 +1,55 @@
-// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 %s -o /dev/null 
-analyzer-checker=core -analyzer-list-enabled-checkers > %t 2>&1
-// RUN: FileCheck --input-file=%t %s
+// RUN: %clang --analyze %s \
+// RUN:   -Xclang -triple -Xclang x86_64-pc-linux-gnu \
+// RUN:   -Xclang -analyzer-list-enabled-checkers \
+// RUN:   -Xclang -analyzer-display-progress \
+// RUN:   2>&1 | FileCheck %s --implicit-check-not=ANALYZE \
+// RUN:   --implicit-check-not=\.
 
-// CHECK: OVERVIEW: Clang Static Analyzer Enabled Checkers List
-// CHECK: core.CallAndMessage
-// CHECK: core.DivideZero
-// CHECK: core.DynamicTypePropagation
-// CHECK: core.NonNullParamChecker
-// CHECK: core.NullDereference
-// CHECK: core.StackAddressEscape
-// CHECK: core.UndefinedBinaryOperatorResult
-// CHECK: core.VLASize
-// CHECK: core.builtin.BuiltinFunctions
-// CHECK: core.builtin.NoReturnFunctions
-// CHECK: core.uninitialized.ArraySubscript
-// CHECK: core.uninitialized.Assign
-// CHECK: core.uninitialized.Branch
-// CHECK: core.uninitialized.CapturedBlockVariable
-// CHECK: core.uninitialized.UndefReturn
+// CHECK:  OVERVIEW: Clang Static Analyzer Enabled Checkers List
+// CHECK-EMPTY:
+// CHECK-NEXT: apiModeling.StdCLibraryFunctions
+// CHECK-NEXT: apiModeling.TrustNonnull
+// CHECK-NEXT: apiModeling.llvm.CastValue
+// CHECK-NEXT: apiModeling.llvm.ReturnValue
+// CHECK-NEXT: core.CallAndMessage
+// CHECK-NEXT: core.DivideZero
+// CHECK-NEXT: core.DynamicTypePropagation
+// CHECK-NEXT: core.NonNullParamChecker
+// CHECK-NEXT: core.NonnilStringConstants
+// CHECK-NEXT: core.NullDereference
+// CHECK-NEXT: core.StackAddrEscapeBase
+// CHECK-NEXT: core.StackAddressEscape
+// CHECK-NEXT: core.UndefinedBinaryOperatorResult
+// CHECK-NEXT: core.VLASize
+// CHECK-NEXT: core.builtin.BuiltinFunctions
+// CHECK-NEXT: core.builtin.NoReturnFunctions
+// CHECK-NEXT: core.uninitialized.ArraySubscript
+// CHECK-NEXT: core.uninitialized.Assign
+// CHECK-NEXT: core.uninitialized.Branch
+// CHECK-NEXT: core.uninitialized.CapturedBlockVariable
+// CHECK-NEXT: core.uninitialized.UndefReturn
+// CHECK-NEXT: deadcode.DeadStores
+// CHECK-NEXT: nullability.NullabilityBase
+// CHECK-NEXT: nullability.NullPassedToNonnull
+// CHECK-NEXT: nullability.NullReturnedFromNonnull
+// CHECK-NEXT: security.insecureAPI.SecuritySyntaxChecker
+// CHECK-NEXT: security.insecureAPI.UncheckedReturn
+// CHECK-NEXT: security.insecureAPI.getpw
+// CHECK-NEXT: security.insecureAPI.gets
+// CHECK-NEXT: security.insecureAPI.mkstemp
+// CHECK-NEXT: security.insecureAPI.mktemp
+// CHECK-NEXT: security.insecureAPI.vfork
+// CHECK-NEXT: unix.API
+// CHECK-NEXT: unix.cstring.CStringModeling
+// CHECK-NEXT: unix.DynamicMemoryModeling
+// CHECK-NEXT: unix.Malloc
+// CHECK-NEXT: unix.MallocSizeof
+// CHECK-NEXT: unix.MismatchedDeallocator
+// CHECK-NEXT: unix.Vfork
+// CHECK-NEXT: unix.cstring.BadSizeArg
+// CHECK-NEXT: unix.cstring.NullArg
 
+int main() {
+  int i;
+  (void)(10 / i);
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67091: Fix for headers having the same name as a directory

2019-09-12 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a subscriber: jkorous.
arphaman added a comment.

In D67091#1667821 , @kousikk wrote:

> Sorry about the delay on this - I was OOO (back now).
>
> 1. I added tests.
> 2. I couldn't add isDirectory() check to createFile() since that resulted in 
> failures to normal scenarios where it was previously passing.
>
>   PTAL!


I was unable to reproduce the failures when I moved the check to `createFile`. 
What kind of failures did you see? Did you move it right to the start of the 
function? I would recommend rebasing the patch and retrying.

Also, could you please rename `headerwithdirname.cpp` to 
`headerwithdirname_input.cpp` when copying it to ensure FileCheck can match the 
filename without matching the temporary path (see 
https://reviews.llvm.org/D67379 for test fixes that @jkorous applied).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67091/new/

https://reviews.llvm.org/D67091



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67460: clang-tidy: modernize-use-using work with multi-argument templates

2019-09-12 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc updated this revision to Diff 219957.
poelmanc added a comment.

Thanks for the stressing test cases. I reverted to your original test case with 
a single >, added a separate one with a single <, and expanded the final case 
to have a non-balanced number of > and <. I added all your new cases, with 
variations for non-fixed (multiple typedef) and fixed (single typedef) examples.

To make the braces example pass, we now only abandon the fix when encountering 
a non-nested open brace.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67460/new/

https://reviews.llvm.org/D67460

Files:
  clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
  clang-tools-extra/test/clang-tidy/modernize-use-using.cpp

Index: clang-tools-extra/test/clang-tidy/modernize-use-using.cpp
===
--- clang-tools-extra/test/clang-tidy/modernize-use-using.cpp
+++ clang-tools-extra/test/clang-tidy/modernize-use-using.cpp
@@ -182,4 +182,53 @@
 class E : public C {
   void f() override { super::f(); }
 };
+
+template 
+class TwoArgTemplate {
+  typedef TwoArgTemplate self;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef'
+  // CHECK-FIXES: using self = TwoArgTemplate;
+};
 }
+
+template 
+struct S {};
+
+typedef S<(0 > 0), int> S_t, *S_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: typedef S<(0 > 0), int> S_t, *S_p;
+
+typedef S<(0 < 0), int> S2_t, *S2_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: typedef S<(0 < 0), int> S2_t, *S2_p;
+
+typedef S<(0 > 0 && (3 > 1) && (1 < 1)), int> S3_t;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using S3_t = S<(0 > 0 && (3 > 1) && (1 < 1)), int>;
+
+template 
+struct Q {};
+
+constexpr bool b[1] = {true};
+
+typedef Q Q_t, *Q_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: typedef Q Q_t, *Q_p;
+
+typedef Q Q2_t;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using Q2_t = Q;
+
+struct T {
+  constexpr T(bool) {}
+
+  static constexpr bool b = true;
+};
+
+typedef Q Q3_t, *Q3_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: typedef Q Q3_t, *Q3_p;
+
+typedef Q Q3_t;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using Q3_t = Q;
Index: clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -40,24 +40,54 @@
 
   Token Tok;
   int ParenLevel = 0;
+  int BraceLevel = 0;
+  int AngleBracketLevel = 0;
+  int SquareBracketLevel = 0;
   bool FoundTypedef = false;
 
   while (!DeclLexer.LexFromRawLexer(Tok) && !Tok.is(tok::semi)) {
 switch (Tok.getKind()) {
 case tok::l_brace:
+  if (ParenLevel == 0 && SquareBracketLevel == 0 && AngleBracketLevel == 0) {
+// At top level, this might be the `typedef struct {...} T;` case.
+// Inside parens, square brackets, or angle brackets it's not.
+return false;
+  }
+  BraceLevel++;
+  break;
 case tok::r_brace:
-  // This might be the `typedef struct {...} T;` case.
-  return false;
+  BraceLevel--;
+  break;
 case tok::l_paren:
   ParenLevel++;
   break;
 case tok::r_paren:
   ParenLevel--;
   break;
+case tok::l_square:
+  SquareBracketLevel++;
+  break;
+case tok::r_square:
+  SquareBracketLevel--;
+  break;
+case tok::less:
+  // If not nested, treat as opening angle bracket.
+  if (ParenLevel == 0 && SquareBracketLevel == 0 && BraceLevel == 0)
+AngleBracketLevel++;
+  break;
+case tok::greater:
+  // Per C++ 17 Draft N4659, Section 17.2/3
+  //   https://timsong-cpp.github.io/cppwp/n4659/temp.names#3:
+  // "When parsing a template-argument-list, the first non-nested > is
+  // taken as the ending delimiter rather than a greater-than operator."
+  // If not nested, treat as closing angle bracket.
+  if (ParenLevel == 0 && SquareBracketLevel == 0 && BraceLevel == 0)
+AngleBracketLevel--;
+  break;
 case tok::comma:
-  if (ParenLevel == 0) {
-// If there is comma and we are not between open parenthesis then it is
-// two or more declarations in this chain.
+  if (ParenLevel == 0 && SquareBracketLevel == 0 && BraceLevel == 0 &&
+  AngleBracketLevel == 0) {
+// If there is comma not nested then it is two or more declarations in this chain.
 return false;
   }
   break;
@@ -88,8 +118,7 @@
   if (StartLoc.isMacroID() && IgnoreMacros)
 return;
 
-  auto Diag =

[PATCH] D67463: [MS] Warn when shadowing template parameters under -fms-compatibility

2019-09-12 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371753: [MS] Warn when shadowing template parameters under 
-fms-compatibility (authored by rnk, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67463?vs=219780=219956#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67463/new/

https://reviews.llvm.org/D67463

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaTemplate.cpp
  cfe/trunk/test/Parser/DelayedTemplateParsing.cpp
  cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp


Index: cfe/trunk/lib/Sema/SemaTemplate.cpp
===
--- cfe/trunk/lib/Sema/SemaTemplate.cpp
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp
@@ -849,15 +849,14 @@
 void Sema::DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl) 
{
   assert(PrevDecl->isTemplateParameter() && "Not a template parameter");
 
-  // Microsoft Visual C++ permits template parameters to be shadowed.
-  if (getLangOpts().MicrosoftExt)
-return;
-
   // C++ [temp.local]p4:
   //   A template-parameter shall not be redeclared within its
   //   scope (including nested scopes).
-  Diag(Loc, diag::err_template_param_shadow)
-<< cast(PrevDecl)->getDeclName();
+  //
+  // Make this a warning when MSVC compatibility is requested.
+  unsigned DiagId = getLangOpts().MSVCCompat ? diag::ext_template_param_shadow
+ : diag::err_template_param_shadow;
+  Diag(Loc, DiagId) << cast(PrevDecl)->getDeclName();
   Diag(PrevDecl->getLocation(), diag::note_template_param_here);
 }
 
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -4000,6 +4000,8 @@
 // C++ Template Declarations
 def err_template_param_shadow : Error<
   "declaration of %0 shadows template parameter">;
+def ext_template_param_shadow : ExtWarn<
+  err_template_param_shadow.Text>, InGroup;
 def note_template_param_here : Note<"template parameter is declared here">;
 def warn_template_export_unsupported : Warning<
   "exported templates are unsupported">;
Index: cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp
===
--- cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp
+++ cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp
@@ -366,3 +366,21 @@
 int S::fn() { return 0; } // expected-warning {{is missing exception 
specification}}
 }
 
+namespace PR43265 {
+template  // expected-note {{template parameter is declared here}}
+struct Foo {
+  static const int N = 42; // expected-warning {{declaration of 'N' shadows 
template parameter}}
+};
+}
+
+namespace Inner_Outer_same_template_param_name {
+template  // expected-note {{template parameter is declared here}}
+struct Outmost {
+  template  // expected-warning {{declaration of 'T' shadows 
template parameter}}
+  struct Inner {
+void f() {
+  T *var;
+}
+  };
+};
+}
Index: cfe/trunk/test/Parser/DelayedTemplateParsing.cpp
===
--- cfe/trunk/test/Parser/DelayedTemplateParsing.cpp
+++ cfe/trunk/test/Parser/DelayedTemplateParsing.cpp
@@ -48,22 +48,6 @@
 
   
 
-namespace Inner_Outer_same_template_param_name {  
-
-template 
-class Outmost {
-public:
-template 
-class Inner {
-public:
-void f() {
-T* var;
-}
-   };
-};
-
-}
-
 
 namespace PR11931 {
 


Index: cfe/trunk/lib/Sema/SemaTemplate.cpp
===
--- cfe/trunk/lib/Sema/SemaTemplate.cpp
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp
@@ -849,15 +849,14 @@
 void Sema::DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl) {
   assert(PrevDecl->isTemplateParameter() && "Not a template parameter");
 
-  // Microsoft Visual C++ permits template parameters to be shadowed.
-  if (getLangOpts().MicrosoftExt)
-return;
-
   // C++ [temp.local]p4:
   //   A template-parameter shall not be redeclared within its
   //   scope (including nested scopes).
-  Diag(Loc, diag::err_template_param_shadow)
-<< cast(PrevDecl)->getDeclName();
+  //
+  // Make this a warning when MSVC compatibility is requested.
+  unsigned DiagId = getLangOpts().MSVCCompat ? diag::ext_template_param_shadow
+ : diag::err_template_param_shadow;
+  Diag(Loc, DiagId) << cast(PrevDecl)->getDeclName();
   Diag(PrevDecl->getLocation(), diag::note_template_param_here);
 }
 
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- 

[PATCH] D67509: [CUDA][HIP] Diagnose defaulted constructor only if it is used

2019-09-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, rjmccall.

Clang infers defaulted ctor as `__device__ __host__` and virtual dtor as 
`__host__`.

It diagnose the following code in device compilation as B() references ~A() 
implicitly.

  struct A {  virtual ~A(); };
  struct B: public A { B(); };
  B::B() = default;

Clang should not diagnose the above code since B() may be used in host function 
only.
Clang should diagnose only if B() is used in device function or kernel.

This patch fixes that by assuming defaulted class member as not always emitted. 
Therefore
a definition of defaulted special member function does not trigger a 
diagnostic, unless
the defaulted special member function is really called.


https://reviews.llvm.org/D67509

Files:
  lib/Sema/SemaCUDA.cpp
  test/SemaCUDA/default-ctor.cu


Index: test/SemaCUDA/default-ctor.cu
===
--- /dev/null
+++ test/SemaCUDA/default-ctor.cu
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++11 -triple nvptx64-nvidia-cuda -fsyntax-only 
-fcuda-is-device -verify %s
+
+#define __host__ __attribute__((host))
+#define __device__ __attribute__((device))
+
+struct Base {
+  virtual ~Base(); // expected-note {{'~Base' declared here}}
+};
+
+struct Unused : public Base {
+  Unused();
+};
+
+// Unused defaulted constructor should not cause diagnostics.
+Unused::Unused() = default;
+
+struct Used : public Base // expected-note {{'~Used' declared here}}
+{
+  Used();
+};
+
+Used::Used() = default; // expected-error {{reference to __host__ function 
'~Base' in __host__ __device__ function}}
+
+__device__ void f() {
+  Used x; // expected-error {{reference to __host__ function '~Used' in 
__device__ function}}
+  // expected-note@-1 {{called by 'f'}}
+}
Index: lib/Sema/SemaCUDA.cpp
===
--- lib/Sema/SemaCUDA.cpp
+++ lib/Sema/SemaCUDA.cpp
@@ -611,8 +611,12 @@
   // emitted, because (say) the definition could include "inline".
   FunctionDecl *Def = FD->getDefinition();
 
+  CXXMethodDecl *MD = dyn_cast_or_null(FD);
+
   if (Def &&
-  
!isDiscardableGVALinkage(S.getASTContext().GetGVALinkageForFunction(Def)))
+  !isDiscardableGVALinkage(
+  S.getASTContext().GetGVALinkageForFunction(Def)) &&
+  !(MD && MD->isDefaulted()))
 return true;
 
   // Otherwise, the function is known-emitted if it's in our set of


Index: test/SemaCUDA/default-ctor.cu
===
--- /dev/null
+++ test/SemaCUDA/default-ctor.cu
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++11 -triple nvptx64-nvidia-cuda -fsyntax-only -fcuda-is-device -verify %s
+
+#define __host__ __attribute__((host))
+#define __device__ __attribute__((device))
+
+struct Base {
+  virtual ~Base(); // expected-note {{'~Base' declared here}}
+};
+
+struct Unused : public Base {
+  Unused();
+};
+
+// Unused defaulted constructor should not cause diagnostics.
+Unused::Unused() = default;
+
+struct Used : public Base // expected-note {{'~Used' declared here}}
+{
+  Used();
+};
+
+Used::Used() = default; // expected-error {{reference to __host__ function '~Base' in __host__ __device__ function}}
+
+__device__ void f() {
+  Used x; // expected-error {{reference to __host__ function '~Used' in __device__ function}}
+  // expected-note@-1 {{called by 'f'}}
+}
Index: lib/Sema/SemaCUDA.cpp
===
--- lib/Sema/SemaCUDA.cpp
+++ lib/Sema/SemaCUDA.cpp
@@ -611,8 +611,12 @@
   // emitted, because (say) the definition could include "inline".
   FunctionDecl *Def = FD->getDefinition();
 
+  CXXMethodDecl *MD = dyn_cast_or_null(FD);
+
   if (Def &&
-  !isDiscardableGVALinkage(S.getASTContext().GetGVALinkageForFunction(Def)))
+  !isDiscardableGVALinkage(
+  S.getASTContext().GetGVALinkageForFunction(Def)) &&
+  !(MD && MD->isDefaulted()))
 return true;
 
   // Otherwise, the function is known-emitted if it's in our set of
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r371753 - [MS] Warn when shadowing template parameters under -fms-compatibility

2019-09-12 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Sep 12 11:26:34 2019
New Revision: 371753

URL: http://llvm.org/viewvc/llvm-project?rev=371753=rev
Log:
[MS] Warn when shadowing template parameters under -fms-compatibility

Summary:
C++ does not allow shadowing template parameters, but previously we
allowed it under -fms-extensions. Now this behavior is controlled by
-fms-compatibility, and we emit a -Wmicrosoft-template warning when it
happens.

Fixes PR43265

Reviewers: thakis, hans

Subscribers: amccarth, rsmith, STL_MSFT, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/Parser/DelayedTemplateParsing.cpp
cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=371753=371752=371753=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Sep 12 11:26:34 
2019
@@ -4000,6 +4000,8 @@ def err_ovl_no_viable_literal_operator :
 // C++ Template Declarations
 def err_template_param_shadow : Error<
   "declaration of %0 shadows template parameter">;
+def ext_template_param_shadow : ExtWarn<
+  err_template_param_shadow.Text>, InGroup;
 def note_template_param_here : Note<"template parameter is declared here">;
 def warn_template_export_unsupported : Warning<
   "exported templates are unsupported">;

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=371753=371752=371753=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Sep 12 11:26:34 2019
@@ -849,15 +849,14 @@ bool Sema::DiagnoseUninstantiableTemplat
 void Sema::DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl) 
{
   assert(PrevDecl->isTemplateParameter() && "Not a template parameter");
 
-  // Microsoft Visual C++ permits template parameters to be shadowed.
-  if (getLangOpts().MicrosoftExt)
-return;
-
   // C++ [temp.local]p4:
   //   A template-parameter shall not be redeclared within its
   //   scope (including nested scopes).
-  Diag(Loc, diag::err_template_param_shadow)
-<< cast(PrevDecl)->getDeclName();
+  //
+  // Make this a warning when MSVC compatibility is requested.
+  unsigned DiagId = getLangOpts().MSVCCompat ? diag::ext_template_param_shadow
+ : diag::err_template_param_shadow;
+  Diag(Loc, DiagId) << cast(PrevDecl)->getDeclName();
   Diag(PrevDecl->getLocation(), diag::note_template_param_here);
 }
 

Modified: cfe/trunk/test/Parser/DelayedTemplateParsing.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/DelayedTemplateParsing.cpp?rev=371753=371752=371753=diff
==
--- cfe/trunk/test/Parser/DelayedTemplateParsing.cpp (original)
+++ cfe/trunk/test/Parser/DelayedTemplateParsing.cpp Thu Sep 12 11:26:34 2019
@@ -48,22 +48,6 @@ template  void foo5() {} // exp
 
   
 
-namespace Inner_Outer_same_template_param_name {  
-
-template 
-class Outmost {
-public:
-template 
-class Inner {
-public:
-void f() {
-T* var;
-}
-   };
-};
-
-}
-
 
 namespace PR11931 {
 

Modified: cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp?rev=371753=371752=371753=diff
==
--- cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp Thu Sep 12 11:26:34 2019
@@ -366,3 +366,21 @@ struct S {
 int S::fn() { return 0; } // expected-warning {{is missing exception 
specification}}
 }
 
+namespace PR43265 {
+template  // expected-note {{template parameter is declared here}}
+struct Foo {
+  static const int N = 42; // expected-warning {{declaration of 'N' shadows 
template parameter}}
+};
+}
+
+namespace Inner_Outer_same_template_param_name {
+template  // expected-note {{template parameter is declared here}}
+struct Outmost {
+  template  // expected-warning {{declaration of 'T' shadows 
template parameter}}
+  struct Inner {
+void f() {
+  T *var;
+}
+  };
+};
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r371663 - Start porting ivfsoverlay tests to Windows

2019-09-12 Thread Reid Kleckner via cfe-commits
Thanks, that seems like the correct fix. The property that makes them fail
is the native system path style, not the default target.

On Thu, Sep 12, 2019 at 5:03 AM Jeremy Morse 
wrote:

> On Thu, Sep 12, 2019 at 11:24 AM Jeremy Morse
>  wrote:
> > Assuming no-one else is looking at this, I'll commit a fix in ~30 mins.
>
> r371726
>
> --
> Thanks,
> Jeremy
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-09-12 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

> I see some problems with using llvm-objcopy for that. First issue is that 
> symbols created by llvm-objcopy for embedded data depend on the input file 
> name. As you know these symbols are referenced from the offload registration 
> code that is currently added to an object by the clang at compile time. I not 
> sure how you can guarantee that symbol names will match.

That seems solvable by renaming the input file / passing a string to clang.

> And another, more important problem is that it won't work on Windows because 
> llvm-objcopy produces ELF object according to the description.

objcopy works with coff in the meantime, and we already need a bunch of unix 
tools to build llvm on windows.

> Anyway I am going to change entries section name to "omp_offloading_entries", 
> remove omptargetbegin.o/omptargetend.o and upload the revised patch.

Thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64943/new/

https://reviews.llvm.org/D64943



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r371751 - [clang-scan-deps] remove dots and dots dots from the reported file dependency paths

2019-09-12 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Sep 12 11:03:24 2019
New Revision: 371751

URL: http://llvm.org/viewvc/llvm-project?rev=371751=rev
Log:
[clang-scan-deps] remove dots and dots dots from the reported file dependency 
paths

This resolves differences observed on LLVM + Clang when running the comparison 
between canonical
dependencies (full preprocessing, no file manager reused), and dependencies 
obtained
when the file manager was reused between the full preprocessing invocations.

Modified:
cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
cfe/trunk/test/ClangScanDeps/Inputs/subframework_header_dir_symlink_cdb.json

Modified: cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp?rev=371751=371750=371751=diff
==
--- cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp 
(original)
+++ cfe/trunk/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp Thu 
Sep 12 11:03:24 2019
@@ -30,8 +30,12 @@ public:
   : DependencyFileGenerator(*Opts), Opts(std::move(Opts)), C(C) {}
 
   void finishedMainFile(DiagnosticsEngine ) override {
-for (const auto  : getDependencies())
-  C.handleFileDependency(*Opts, File);
+llvm::SmallString<256> CanonPath;
+for (const auto  : getDependencies()) {
+  CanonPath = File;
+  llvm::sys::path::remove_dots(CanonPath, /*remove_dot_dot=*/true);
+  C.handleFileDependency(*Opts, CanonPath);
+}
   }
 
 private:

Modified: 
cfe/trunk/test/ClangScanDeps/Inputs/subframework_header_dir_symlink_cdb.json
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ClangScanDeps/Inputs/subframework_header_dir_symlink_cdb.json?rev=371751=371750=371751=diff
==
--- 
cfe/trunk/test/ClangScanDeps/Inputs/subframework_header_dir_symlink_cdb.json 
(original)
+++ 
cfe/trunk/test/ClangScanDeps/Inputs/subframework_header_dir_symlink_cdb.json 
Thu Sep 12 11:03:24 2019
@@ -6,7 +6,7 @@
 },
 {
   "directory": "DIR",
-  "command": "clang -E DIR/subframework_header_dir_symlink_input2.m 
-FInputs/frameworks -iframework Inputs/frameworks_symlink",
+  "command": "clang -E DIR/subframework_header_dir_symlink_input2.m 
-FInputs/frameworks -iframework 
Inputs/frameworks_symlink/../frameworks_symlink",
   "file": "DIR/subframework_header_dir_symlink_input2.m"
 }
 ]


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-09-12 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev added a comment.

In D64943#1668006 , @JonChesterfield 
wrote:

> >> Does this diff mix getting rid of the linker script with other changes? 
> >> E.g. it looks like the metadata generation is moving from clang to the new 
> >> tool, but that seems orthogonal to dropping the linker script.
> > 
> > Metadata is still generated by the clang, there are no changes in this 
> > area. What is moving to a wrapper tool is the generation of the offload 
> > registration code. Let me just attach the slides that I presented on the 
> > inter company meeting were the proposal was discussed. It'll probably 
> > answer most of your questions. F9983224: openmp_linker_script.pdf 
> > 
>
> It does indeed, thanks. I see the motivation for delaying offload 
> registration code. I'm pretty sure that is indeed orthogonal to removing the 
> linker script.
>
> How would you feel about using objcopy to embed the device binary?


I see some problems with using llvm-objcopy for that. First issue is that 
symbols created by llvm-objcopy for embedded data depend on the input file 
name. As you know these symbols are referenced from the offload registration 
code that is currently added to an object by the clang at compile time. I not 
sure how you can guarantee that symbol names will match. And another, more 
important problem is that it won't work on Windows because llvm-objcopy 
produces ELF object according to the description.

Anyway I am going to change entries section name to "omp_offloading_entries", 
remove omptargetbegin.o/omptargetend.o and upload the revised patch.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64943/new/

https://reviews.llvm.org/D64943



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67426: Don't warn about selectany on implicitly inline variables

2019-09-12 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb00a49d1b3a1: Dont warn about selectany on implicitly 
inline variables (authored by rnk).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67426/new/

https://reviews.llvm.org/D67426

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaCXX/declspec-selectany.cpp


Index: clang/test/SemaCXX/declspec-selectany.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/declspec-selectany.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-windows-msvc -fdeclspec -verify
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-windows-msvc -fdeclspec -verify
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-scei-ps4 -fdeclspec -verify
+
+// MSVC emits this error too.
+const int __declspec(selectany) test1 = 0; // expected-error {{'selectany' can 
only be applied to data items with external linkage}}
+
+extern const int test2;
+const int test2 = 42; // expected-note {{previous definition is here}}
+extern __declspec(selectany) const int test2; // expected-warning {{attribute 
declaration must precede definition}}
+
+extern const int test3;
+const int __declspec(selectany) test3 = 42; // Standard usage.
+
+struct Test4 {
+  static constexpr int sdm = 0;
+};
+__declspec(selectany) constexpr int Test4::sdm; // no warning
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -2652,6 +2652,15 @@
 --E;
 continue;
   }
+} else if (isa(NewAttribute) &&
+   cast(New)->isInline() &&
+   !cast(New)->isInlineSpecified()) {
+  // Don't warn about applying selectany to implicitly inline variables.
+  // Older compilers and language modes would require the use of selectany
+  // to make such variables inline, and it would have no effect if we
+  // honored it.
+  ++I;
+  continue;
 }
 
 S.Diag(NewAttribute->getLocation(),


Index: clang/test/SemaCXX/declspec-selectany.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/declspec-selectany.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-windows-msvc -fdeclspec -verify
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-windows-msvc -fdeclspec -verify
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-scei-ps4 -fdeclspec -verify
+
+// MSVC emits this error too.
+const int __declspec(selectany) test1 = 0; // expected-error {{'selectany' can only be applied to data items with external linkage}}
+
+extern const int test2;
+const int test2 = 42; // expected-note {{previous definition is here}}
+extern __declspec(selectany) const int test2; // expected-warning {{attribute declaration must precede definition}}
+
+extern const int test3;
+const int __declspec(selectany) test3 = 42; // Standard usage.
+
+struct Test4 {
+  static constexpr int sdm = 0;
+};
+__declspec(selectany) constexpr int Test4::sdm; // no warning
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -2652,6 +2652,15 @@
 --E;
 continue;
   }
+} else if (isa(NewAttribute) &&
+   cast(New)->isInline() &&
+   !cast(New)->isInlineSpecified()) {
+  // Don't warn about applying selectany to implicitly inline variables.
+  // Older compilers and language modes would require the use of selectany
+  // to make such variables inline, and it would have no effect if we
+  // honored it.
+  ++I;
+  continue;
 }
 
 S.Diag(NewAttribute->getLocation(),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r371749 - Don't warn about selectany on implicitly inline variables

2019-09-12 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Sep 12 10:55:48 2019
New Revision: 371749

URL: http://llvm.org/viewvc/llvm-project?rev=371749=rev
Log:
Don't warn about selectany on implicitly inline variables

Summary:
This avoids a -Wignored-attribute warning on the code pattern Microsoft
recommends for integral const static data members defined in headers
here:
https://docs.microsoft.com/en-us/cpp/build/reference/microsoft-extensions-to-c-and-cpp?view=vs-2019

The attribute is redundant, but it is necessary when compiling in C++14
modes with /Za, which disables MSVC's extension that treats such
variables as implicitly inline.

Fixes PR43270

Reviewers: epastor, thakis, hans

Subscribers: cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/SemaCXX/declspec-selectany.cpp
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=371749=371748=371749=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Sep 12 10:55:48 2019
@@ -2652,6 +2652,15 @@ static void checkNewAttributesAfterDef(S
 --E;
 continue;
   }
+} else if (isa(NewAttribute) &&
+   cast(New)->isInline() &&
+   !cast(New)->isInlineSpecified()) {
+  // Don't warn about applying selectany to implicitly inline variables.
+  // Older compilers and language modes would require the use of selectany
+  // to make such variables inline, and it would have no effect if we
+  // honored it.
+  ++I;
+  continue;
 }
 
 S.Diag(NewAttribute->getLocation(),

Added: cfe/trunk/test/SemaCXX/declspec-selectany.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/declspec-selectany.cpp?rev=371749=auto
==
--- cfe/trunk/test/SemaCXX/declspec-selectany.cpp (added)
+++ cfe/trunk/test/SemaCXX/declspec-selectany.cpp Thu Sep 12 10:55:48 2019
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-windows-msvc -fdeclspec -verify
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-windows-msvc -fdeclspec -verify
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-scei-ps4 -fdeclspec -verify
+
+// MSVC emits this error too.
+const int __declspec(selectany) test1 = 0; // expected-error {{'selectany' can 
only be applied to data items with external linkage}}
+
+extern const int test2;
+const int test2 = 42; // expected-note {{previous definition is here}}
+extern __declspec(selectany) const int test2; // expected-warning {{attribute 
declaration must precede definition}}
+
+extern const int test3;
+const int __declspec(selectany) test3 = 42; // Standard usage.
+
+struct Test4 {
+  static constexpr int sdm = 0;
+};
+__declspec(selectany) constexpr int Test4::sdm; // no warning


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64146: [Clang Interpreter] Initial patch for the constexpr interpreter

2019-09-12 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

In D64146#1667567 , @nand wrote:

> Thanks for looking into the problem - sorry for the delay!


No problem, you still need a specialist to approve the patch though


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64146/new/

https://reviews.llvm.org/D64146



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67420: [analyzer] NFC: Separate PathDiagnosticConsumer options from AnalyzerOptions.

2019-09-12 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D67420#1666578 , @NoQ wrote:

> In D67420#1666141 , @Szelethus wrote:
>
> > I do!
>
>
> Hmm, it sounds like you want to force both Clang frontend and Clang-Tidy to 
> use the same set of flags to control these options (?) Much like 
> `-analyzer-config`, these flags will have different "style" compared to other 
> flags in the tool. Which is probably not too bad for hidden frontend flags 
> that control the Analyzer because they're anyway set by a separate GUI 
> checkbox, but the inconsistency with other flags would be super glaring in 
> case of Clang-Tidy CLI. Do we really want to go in that direction? I'll be 
> much more comfortable with letting each tool deal with its flags the way it 
> prefers - this doesn't look like a good place for code reuse to me.


There are two things I wanted to touch on, but kinda failed to emphasize it. 
First is the topic of whether `-analyzer-config` flags are fitting for a 
feature no longer specific to the analyzer, and the second is similar in 
nature, but in the actual code -- it doesn't doesn't feel natural to me that 
`AnalyzerOptions` is required to construct this, while at the same time we're 
trying to make diagnostics construction independent of the analyzer. But I 
really wouldn't like to overengineer this just for the sake of it :^)

On the first, I'm kinda meh, even if we went for it, it would be a separate 
revision I guess, but the second has me concerned, unless I'm not following 
something right.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67420/new/

https://reviews.llvm.org/D67420



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67368: [NFCI]Create CommonAttributeInfo Type as base type of *Attr and ParsedAttr.

2019-09-12 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked an inline comment as done.
erichkeane added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:2266
   let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">,
-   C2x<"", "maybe_unused">];
+   C2x<"", "maybe_unused">, Pragma<"", "unused">];
   let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label,

aaron.ballman wrote:
> I'm surprised to see this as part of an NFC refactoring. Hopefully it will 
> become more obvious later. :-D
Yep, was a separate bug I found while going through things.  I'll take it out 
and do it later.



Comment at: clang/include/clang/Basic/AttributeCommonInfo.h:66-69
+  unsigned AttrKind : 16;
+  /// Corresponds to the Syntax enum.
+  unsigned SyntaxUsed : 3;
+  unsigned SpellingIndex : 4;

aaron.ballman wrote:
> Do you want to do `= 0` here to give them in-class initializers? (well, 
> `SpellingIndex` should probably be `SpellingNotCalculated`).
Bitfield in-class initializers are a C++2a feature.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67368/new/

https://reviews.llvm.org/D67368



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67409: [RISCV] enable LTO support, pass some options to linker.

2019-09-12 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/RISCV.cpp:387
+
+void riscv::addGoldOptions(const ToolChain ,
+   const llvm::opt::ArgList ,

gold doesn't support RISC-V, does it?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67409/new/

https://reviews.llvm.org/D67409



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67409: [RISCV] enable LTO support, pass some options to linker.

2019-09-12 Thread Kuan Hsu Chen via Phabricator via cfe-commits
khchen updated this revision to Diff 219941.
khchen added a comment.

@lenary Yes, you are right. add LTO support for Linux platform.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67409/new/

https://reviews.llvm.org/D67409

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.h
  clang/test/Driver/gold-lto.c

Index: clang/test/Driver/gold-lto.c
===
--- clang/test/Driver/gold-lto.c
+++ clang/test/Driver/gold-lto.c
@@ -26,3 +26,21 @@
 // RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-ANDROID
 // CHECK-X86-ANDROID: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
+//
+// RUN: %clang -target riscv64-unknown-elf -### %t.o -flto 2>&1 \
+// RUN: -march=rv64imf -mabi=lp64f \
+// RUN: | FileCheck %s --check-prefix=CHECK-RISCV-BAREMETAL
+// CHECK-RISCV-BAREMETAL: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
+// CHECK-RISCV-BAREMETAL: "-plugin-opt=--mattr=+m"
+// CHECK-RISCV-BAREMETAL: "-plugin-opt=--mattr=+f"
+// CHECK-RISCV-BAREMETAL: "-plugin-opt=--mattr=+relax"
+// CHECK-RISCV-BAREMETAL: "-plugin-opt=-target-abi=lp64f"
+//
+// RUN: %clang -target riscv64-unknown-linux-gnu -### %t.o -flto 2>&1 \
+// RUN: -march=rv64imf -mabi=lp64f \
+// RUN: | FileCheck %s --check-prefix=CHECK-RISCV-LINUX
+// CHECK-RISCV-LINUX: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
+// CHECK-RISCV-LINUX: "-plugin-opt=--mattr=+m"
+// CHECK-RISCV-LINUX: "-plugin-opt=--mattr=+f"
+// CHECK-RISCV-LINUX: "-plugin-opt=--mattr=+relax"
+// CHECK-RISCV-LINUX: "-plugin-opt=-target-abi=lp64f"
Index: clang/lib/Driver/ToolChains/RISCVToolchain.h
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.h
+++ clang/lib/Driver/ToolChains/RISCVToolchain.h
@@ -25,6 +25,7 @@
   void addClangTargetOptions(const llvm::opt::ArgList ,
  llvm::opt::ArgStringList ,
  Action::OffloadKind) const override;
+  bool HasNativeLLVMSupport() const override { return true; }
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const override;
Index: clang/lib/Driver/ToolChains/RISCVToolchain.cpp
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.cpp
+++ clang/lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "RISCVToolchain.h"
+#include "Arch/RISCV.h"
 #include "CommonArgs.h"
 #include "InputInfo.h"
 #include "clang/Driver/Compilation.h"
@@ -100,6 +101,13 @@
 
   std::string Linker = getToolChain().GetProgramPath(getShortName());
 
+  if (D.isUsingLTO()) {
+assert(!Inputs.empty() && "Must have at least one input.");
+AddGoldPlugin(ToolChain, Args, CmdArgs, Output, Inputs[0],
+  D.getLTOMode() == LTOK_Thin);
+tools::riscv::addGoldOptions(ToolChain, Args, CmdArgs);
+  }
+
   bool WantCRTs =
   !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);
 
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -514,6 +514,15 @@
 assert(!Inputs.empty() && "Must have at least one input.");
 AddGoldPlugin(ToolChain, Args, CmdArgs, Output, Inputs[0],
   D.getLTOMode() == LTOK_Thin);
+switch (ToolChain.getArch()) {
+default:
+  break;
+case llvm::Triple::riscv32:
+case llvm::Triple::riscv64: {
+  tools::riscv::addGoldOptions(ToolChain, Args, CmdArgs);
+  break;
+}
+}
   }
 
   if (Args.hasArg(options::OPT_Z_Xlinker__no_demangle))
Index: clang/lib/Driver/ToolChains/Arch/RISCV.h
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.h
+++ clang/lib/Driver/ToolChains/Arch/RISCV.h
@@ -23,6 +23,8 @@
 std::vector );
 StringRef getRISCVABI(const llvm::opt::ArgList ,
   const llvm::Triple );
+void addGoldOptions(const ToolChain , const llvm::opt::ArgList ,
+llvm::opt::ArgStringList );
 } // end namespace riscv
 } // namespace tools
 } // end namespace driver
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -383,3 +383,42 @@
   // expanded to select ilp32f, ilp32d, lp64f, lp64d when appropriate.
   return Triple.getArch() == llvm::Triple::riscv32 ? "ilp32" : "lp64";
 }
+
+void 

[PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-09-12 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

>> Does this diff mix getting rid of the linker script with other changes? E.g. 
>> it looks like the metadata generation is moving from clang to the new tool, 
>> but that seems orthogonal to dropping the linker script.
> 
> Metadata is still generated by the clang, there are no changes in this area. 
> What is moving to a wrapper tool is the generation of the offload 
> registration code. Let me just attach the slides that I presented on the 
> inter company meeting were the proposal was discussed. It'll probably answer 
> most of your questions. F9983224: openmp_linker_script.pdf 
> 

It does indeed, thanks. I see the motivation for delaying offload registration 
code. I'm pretty sure that is indeed orthogonal to removing the linker script.

How would you feel about using objcopy to embed the device binary?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64943/new/

https://reviews.llvm.org/D64943



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64943: [Clang][OpenMP offload] Eliminate use of OpenMP linker script

2019-09-12 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev added a comment.

In D64943#1667469 , @JonChesterfield 
wrote:

> I'm on board with getting rid of the linker script. Gold's limited support 
> for that seems conclusive.
>
> I believe the current script does two things:
>  1/ takes a binary and embeds it in a section named 
> .omp_offloading.amdgcn-amd-amdhsa
>  2/ provides start/end symbols for that section and for 
> .omp_offloading.entries.
>
> 2/ is discussed above.
>  1/ can be implemented as a call to (llvm-)objcopy
>
> > If binary is used as the value for --input-target, the input file will be 
> > embedded as a data section in an ELF relocatable object, with symbols 
> > _binary__start, _binary__end, and 
> > _binary__size representing the start, end and size of the data, 
> > where  is the path of the input file as specified on the command 
> > line with non-alphanumeric characters converted to _.
>
> I think dropping the linker script means that cmake will need to invoke an 
> extra executable. As far as I can see, that tool can be objcopy instead of 
> clang-offload-wrapper.
>
> Does this diff mix getting rid of the linker script with other changes? E.g. 
> it looks like the metadata generation is moving from clang to the new tool, 
> but that seems orthogonal to dropping the linker script.


Metadata is still generated by the clang, there are no changes in this area. 
What is moving to a wrapper tool is the generation of the offload registration 
code. Let me just attach the slides that I presented on the inter company 
meeting were the proposal was discussed. It'll probably answer most of your 
questions. F9983224: openmp_linker_script.pdf 



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64943/new/

https://reviews.llvm.org/D64943



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52524: Add -Wpoison-system-directories warning

2019-09-12 Thread Denis Nikitin via Phabricator via cfe-commits
denik marked 2 inline comments as done.
denik added inline comments.



Comment at: clang/lib/Frontend/InitHeaderSearch.cpp:141-143
+  if (HasSysroot) {
+if (MappedPathStr.startswith("/usr/include") ||
+MappedPathStr.startswith("/usr/local/include")) {

aaron.ballman wrote:
> These should be combined into a single if statement:
> ```
> if (HasSysroot && (MappedPathStr.startswith(...) || 
> MappedPathStr.startswith(...))) {
> ```
Done.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D52524/new/

https://reviews.llvm.org/D52524



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52524: Add -Wpoison-system-directories warning

2019-09-12 Thread Denis Nikitin via Phabricator via cfe-commits
denik updated this revision to Diff 219924.
denik added a comment.

Combined two if into one.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D52524/new/

https://reviews.llvm.org/D52524

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/lib/Frontend/InitHeaderSearch.cpp
  clang/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/lib/.keep
  
clang/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/include/c++/.keep
  clang/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/lib/gcc/.keep
  
clang/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/local/include/.keep
  clang/test/Frontend/Inputs/sysroot_x86_64_cross_linux_tree/usr/local/lib/.keep
  clang/test/Frontend/warning-poison-system-directories.c


Index: clang/test/Frontend/warning-poison-system-directories.c
===
--- /dev/null
+++ clang/test/Frontend/warning-poison-system-directories.c
@@ -0,0 +1,27 @@
+// System directory and sysroot option causes warning.
+// RUN: %clang -Wpoison-system-directories -target x86_64 -I/usr/include 
--sysroot %S/Inputs/sysroot_x86_64_cross_linux_tree -c -o - %s 2> %t.1.stderr
+// RUN: FileCheck -check-prefix=WARN < %t.1.stderr %s
+// RUN: %clang -Wpoison-system-directories -target x86_64 
-cxx-isystem/usr/include --sysroot %S/Inputs/sysroot_x86_64_cross_linux_tree -c 
-o - %s 2> %t.1.stderr
+// RUN: FileCheck -check-prefix=WARN < %t.1.stderr %s
+// RUN: %clang -Wpoison-system-directories -target x86_64 
-iquote/usr/local/include --sysroot %S/Inputs/sysroot_x86_64_cross_linux_tree 
-c -o - %s 2> %t.1.stderr
+// RUN: FileCheck -check-prefix=WARN < %t.1.stderr %s
+// RUN: %clang -Wpoison-system-directories -target x86_64 
-isystem/usr/local/include --sysroot %S/Inputs/sysroot_x86_64_cross_linux_tree 
-c -o - %s 2> %t.1.stderr
+// RUN: FileCheck -check-prefix=WARN < %t.1.stderr %s
+
+// Missing target but included sysroot still causes the warning.
+// RUN: %clang -Wpoison-system-directories -I/usr/include --sysroot 
%S/Inputs/sysroot_x86_64_cross_linux_tree -c -o - %s 2> %t.2.stderr
+// RUN: FileCheck -check-prefix=WARN < %t.2.stderr %s
+
+// With -Werror the warning causes the failure.
+// RUN: not %clang -Werror=poison-system-directories -target x86_64 
-I/usr/include --sysroot %S/Inputs/sysroot_x86_64_cross_linux_tree -c -o - %s 
2> %t.3.stderr
+// RUN: FileCheck -check-prefix=ERROR < %t.3.stderr %s
+
+// Cros target without sysroot causes no warning.
+// RUN: %clang -Wpoison-system-directories -Werror -target x86_64 
-I/usr/include -c -o - %s
+
+// By default the warning is off.
+// RUN: %clang -Werror -target x86_64 -I/usr/include --sysroot 
%S/Inputs/sysroot_x86_64_cross_linux_tree -c -o - %s
+
+// WARN: warning: include location {{[^ ]+}} is unsafe for cross-compilation 
[-Wpoison-system-directories]
+
+// ERROR: error: include location {{[^ ]+}} is unsafe for cross-compilation 
[-Werror,-Wpoison-system-directories]
Index: clang/lib/Frontend/InitHeaderSearch.cpp
===
--- clang/lib/Frontend/InitHeaderSearch.cpp
+++ clang/lib/Frontend/InitHeaderSearch.cpp
@@ -137,6 +137,13 @@
   SmallString<256> MappedPathStorage;
   StringRef MappedPathStr = Path.toStringRef(MappedPathStorage);
 
+  // If use system headers while cross-compiling, emit the warning.
+  if (HasSysroot && (MappedPathStr.startswith("/usr/include") ||
+ MappedPathStr.startswith("/usr/local/include"))) {
+Headers.getDiags().Report(diag::warn_poison_system_directories)
+<< MappedPathStr;
+  }
+
   // Compute the DirectoryLookup type.
   SrcMgr::CharacteristicKind Type;
   if (Group == Quoted || Group == Angled || Group == IndexHeaderMap) {
Index: clang/include/clang/Basic/DiagnosticCommonKinds.td
===
--- clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -315,4 +315,9 @@
 "no analyzer checkers or packages are associated with '%0'">;
 def note_suggest_disabling_all_checkers : Note<
 "use -analyzer-disable-all-checks to disable all static analyzer 
checkers">;
+
+// Poison system directories.
+def warn_poison_system_directories : Warning <
+  "include location '%0' is unsafe for cross-compilation">,
+  InGroup>, DefaultIgnore;
 }


Index: clang/test/Frontend/warning-poison-system-directories.c
===
--- /dev/null
+++ clang/test/Frontend/warning-poison-system-directories.c
@@ -0,0 +1,27 @@
+// System directory and sysroot option causes warning.
+// RUN: %clang -Wpoison-system-directories -target x86_64 -I/usr/include --sysroot %S/Inputs/sysroot_x86_64_cross_linux_tree -c -o - %s 2> %t.1.stderr
+// RUN: FileCheck -check-prefix=WARN < %t.1.stderr %s
+// RUN: %clang -Wpoison-system-directories -target x86_64 -cxx-isystem/usr/include --sysroot 

r371742 - [Alignment] Move OffsetToAlignment to Alignment.h

2019-09-12 Thread Guillaume Chatelet via cfe-commits
Author: gchatelet
Date: Thu Sep 12 08:20:36 2019
New Revision: 371742

URL: http://llvm.org/viewvc/llvm-project?rev=371742=rev
Log:
[Alignment] Move OffsetToAlignment to Alignment.h

Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: 
http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet, JDevlieghere, alexshap, rupprecht, jhenderson

Subscribers: sdardis, nemanjai, hiraditya, kbarton, jakehehrlich, jrtc27, 
MaskRay, atanasyan, jsji, seiya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Modified:
cfe/trunk/lib/AST/DeclBase.cpp

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=371742=371741=371742=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Thu Sep 12 08:20:36 2019
@@ -100,7 +100,7 @@ void *Decl::operator new(std::size_t Siz
 // Ensure required alignment of the resulting object by adding extra
 // padding at the start if required.
 size_t ExtraAlign =
-llvm::OffsetToAlignment(sizeof(Module *), alignof(Decl));
+llvm::offsetToAlignment(sizeof(Module *), llvm::Align(alignof(Decl)));
 auto *Buffer = reinterpret_cast(
 ::operator new(ExtraAlign + sizeof(Module *) + Size + Extra, Ctx));
 Buffer += ExtraAlign;


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67499: [Alignment] Move OffsetToAlignment to Alignment.h

2019-09-12 Thread Guillaume Chatelet via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371742: [Alignment] Move OffsetToAlignment to Alignment.h 
(authored by gchatelet, committed by ).
Herald added a subscriber: kristina.

Changed prior to commit:
  https://reviews.llvm.org/D67499?vs=219923=219925#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67499/new/

https://reviews.llvm.org/D67499

Files:
  cfe/trunk/lib/AST/DeclBase.cpp
  llvm/trunk/include/llvm/Support/Alignment.h
  llvm/trunk/include/llvm/Support/MathExtras.h
  llvm/trunk/include/llvm/Support/OnDiskHashTable.h
  llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/trunk/lib/CodeGen/BranchRelaxation.cpp
  llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
  llvm/trunk/lib/MC/ELFObjectWriter.cpp
  llvm/trunk/lib/MC/MCAssembler.cpp
  llvm/trunk/lib/MC/MachObjectWriter.cpp
  llvm/trunk/lib/Object/ArchiveWriter.cpp
  llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp
  llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
  llvm/trunk/lib/Target/Mips/MipsConstantIslandPass.cpp
  llvm/trunk/lib/Target/Mips/MipsSEISelDAGToDAG.cpp
  llvm/trunk/lib/Target/Mips/MipsSERegisterInfo.cpp
  llvm/trunk/lib/Target/PowerPC/PPCBranchSelector.cpp
  llvm/trunk/tools/dsymutil/DwarfStreamer.cpp
  llvm/trunk/tools/llvm-cov/TestingSupport.cpp
  llvm/trunk/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp

Index: llvm/trunk/include/llvm/Support/MathExtras.h
===
--- llvm/trunk/include/llvm/Support/MathExtras.h
+++ llvm/trunk/include/llvm/Support/MathExtras.h
@@ -712,13 +712,6 @@
   return (Value - Skew) / Align * Align + Skew;
 }
 
-/// Returns the offset to the next integer (mod 2**64) that is greater than
-/// or equal to \p Value and is a multiple of \p Align. \p Align must be
-/// non-zero.
-inline uint64_t OffsetToAlignment(uint64_t Value, uint64_t Align) {
-  return alignTo(Value, Align) - Value;
-}
-
 /// Sign-extend the number in the bottom B bits of X to a 32-bit integer.
 /// Requires 0 < B <= 32.
 template  constexpr inline int32_t SignExtend32(uint32_t X) {
Index: llvm/trunk/include/llvm/Support/Alignment.h
===
--- llvm/trunk/include/llvm/Support/Alignment.h
+++ llvm/trunk/include/llvm/Support/Alignment.h
@@ -133,6 +133,12 @@
   return A ? alignTo(Size, A.getValue()) : Size;
 }
 
+/// Returns the offset to the next integer (mod 2**64) that is greater than
+/// or equal to \p Value and is a multiple of \p Align.
+inline uint64_t offsetToAlignment(uint64_t Value, llvm::Align Align) {
+  return alignTo(Value, Align) - Value;
+}
+
 /// Returns the log2 of the alignment.
 inline unsigned Log2(Align A) { return A.ShiftValue; }
 
Index: llvm/trunk/include/llvm/Support/OnDiskHashTable.h
===
--- llvm/trunk/include/llvm/Support/OnDiskHashTable.h
+++ llvm/trunk/include/llvm/Support/OnDiskHashTable.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_SUPPORT_ONDISKHASHTABLE_H
 #define LLVM_SUPPORT_ONDISKHASHTABLE_H
 
+#include "llvm/Support/Alignment.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/DataTypes.h"
 #include "llvm/Support/EndianStream.h"
@@ -207,7 +208,8 @@
 
 // Pad with zeros so that we can start the hashtable at an aligned address.
 offset_type TableOff = Out.tell();
-uint64_t N = llvm::OffsetToAlignment(TableOff, alignof(offset_type));
+uint64_t N =
+llvm::offsetToAlignment(TableOff, llvm::Align(alignof(offset_type)));
 TableOff += N;
 while (N--)
   LE.write(0);
Index: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
===
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
@@ -17,6 +17,7 @@
 #include "RuntimeDyldMachO.h"
 #include "llvm/Object/COFF.h"
 #include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Support/Alignment.h"
 #include "llvm/Support/MSVCErrorWorkarounds.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/MathExtras.h"
@@ -737,7 +738,8 @@
   return NameOrErr.takeError();
 if (Align) {
   // This symbol has an alignment requirement.
-  uint64_t AlignOffset = OffsetToAlignment((uint64_t)Addr, Align);
+  uint64_t AlignOffset =
+  offsetToAlignment((uint64_t)Addr, llvm::Align(Align));
   Addr += AlignOffset;
   Offset += AlignOffset;
 }
Index: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp
===
--- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp
+++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp
@@ -1016,14 +1016,14 @@
   BBInfoVector  = BBUtils->getBBInfo();
   unsigned CPELogAlign = getCPELogAlign(U.CPEMI);
   unsigned CPEOffset = BBInfo[Water->getNumber()].postOffset(CPELogAlign);
-  unsigned 

[PATCH] D67499: [Alignment] Move OffsetToAlignment to Alignment.h

2019-09-12 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet updated this revision to Diff 219923.
gchatelet marked an inline comment as done.
gchatelet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67499/new/

https://reviews.llvm.org/D67499

Files:
  clang/lib/AST/DeclBase.cpp
  llvm/include/llvm/Support/Alignment.h
  llvm/include/llvm/Support/MathExtras.h
  llvm/include/llvm/Support/OnDiskHashTable.h
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/lib/CodeGen/BranchRelaxation.cpp
  llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
  llvm/lib/MC/ELFObjectWriter.cpp
  llvm/lib/MC/MCAssembler.cpp
  llvm/lib/MC/MachObjectWriter.cpp
  llvm/lib/Object/ArchiveWriter.cpp
  llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
  llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
  llvm/lib/Target/Mips/MipsConstantIslandPass.cpp
  llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp
  llvm/lib/Target/Mips/MipsSERegisterInfo.cpp
  llvm/lib/Target/PowerPC/PPCBranchSelector.cpp
  llvm/tools/dsymutil/DwarfStreamer.cpp
  llvm/tools/llvm-cov/TestingSupport.cpp
  llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp

Index: llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
===
--- llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
+++ llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "MachOLayoutBuilder.h"
+#include "llvm/Support/Alignment.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/ErrorHandling.h"
 
@@ -145,7 +146,7 @@
   Sec.Offset = 0;
 } else {
   uint64_t PaddingSize =
-  OffsetToAlignment(SegFileSize, 1ull << Sec.Align);
+  offsetToAlignment(SegFileSize, llvm::Align(1ull << Sec.Align));
   Sec.Offset = SegOffset + SegFileSize + PaddingSize;
   Sec.Size = Sec.Content.size();
   SegFileSize += PaddingSize + Sec.Size;
Index: llvm/tools/llvm-cov/TestingSupport.cpp
===
--- llvm/tools/llvm-cov/TestingSupport.cpp
+++ llvm/tools/llvm-cov/TestingSupport.cpp
@@ -8,6 +8,7 @@
 
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/ProfileData/InstrProf.h"
+#include "llvm/Support/Alignment.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/LEB128.h"
 #include "llvm/Support/raw_ostream.h"
@@ -99,7 +100,7 @@
   encodeULEB128(ProfileNamesAddress, OS);
   OS << ProfileNamesData;
   // Coverage mapping data is expected to have an alignment of 8.
-  for (unsigned Pad = OffsetToAlignment(OS.tell(), 8); Pad; --Pad)
+  for (unsigned Pad = offsetToAlignment(OS.tell(), llvm::Align(8)); Pad; --Pad)
 OS.write(uint8_t(0));
   OS << CoverageMappingData;
 
Index: llvm/tools/dsymutil/DwarfStreamer.cpp
===
--- llvm/tools/dsymutil/DwarfStreamer.cpp
+++ llvm/tools/dsymutil/DwarfStreamer.cpp
@@ -339,7 +339,7 @@
 sizeof(int8_t);   // Segment Size (in bytes)
 
 unsigned TupleSize = AddressSize * 2;
-unsigned Padding = OffsetToAlignment(HeaderSize, TupleSize);
+unsigned Padding = offsetToAlignment(HeaderSize, llvm::Align(TupleSize));
 
 Asm->EmitLabelDifference(EndLabel, BeginLabel, 4); // Arange length
 Asm->OutStreamer->EmitLabel(BeginLabel);
Index: llvm/lib/Target/PowerPC/PPCBranchSelector.cpp
===
--- llvm/lib/Target/PowerPC/PPCBranchSelector.cpp
+++ llvm/lib/Target/PowerPC/PPCBranchSelector.cpp
@@ -88,13 +88,13 @@
   const llvm::Align ParentAlign = MBB.getParent()->getAlignment();
 
   if (Align <= ParentAlign)
-return OffsetToAlignment(Offset, Align.value());
+return offsetToAlignment(Offset, Align);
 
   // The alignment of this MBB is larger than the function's alignment, so we
   // can't tell whether or not it will insert nops. Assume that it will.
   if (FirstImpreciseBlock < 0)
 FirstImpreciseBlock = MBB.getNumber();
-  return Align.value() + OffsetToAlignment(Offset, Align.value());
+  return Align.value() + offsetToAlignment(Offset, Align);
 }
 
 /// We need to be careful about the offset of the first block in the function
Index: llvm/lib/Target/Mips/MipsSERegisterInfo.cpp
===
--- llvm/lib/Target/Mips/MipsSERegisterInfo.cpp
+++ llvm/lib/Target/Mips/MipsSERegisterInfo.cpp
@@ -212,11 +212,9 @@
 // element size), otherwise it is a 16-bit signed immediate.
 unsigned OffsetBitSize =
 getLoadStoreOffsetSizeInBits(MI.getOpcode(), MI.getOperand(OpNo - 1));
-unsigned OffsetAlign = getLoadStoreOffsetAlign(MI.getOpcode());
-
+const llvm::Align OffsetAlign(getLoadStoreOffsetAlign(MI.getOpcode()));
 if (OffsetBitSize < 16 && isInt<16>(Offset) &&
-(!isIntN(OffsetBitSize, Offset) ||
- OffsetToAlignment(Offset, 

[PATCH] D67499: [Alignment] Move OffsetToAlignment to Alignment.h

2019-09-12 Thread Clement Courbet via Phabricator via cfe-commits
courbet added inline comments.



Comment at: llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1024
 NextBlockOffset = BBInfo[Water->getNumber()].postOffset();
-NextBlockLogAlignment = 0;
+NextBlockAlignment = llvm::Align();
   } else {

this statement is now useless.



Comment at: llvm/lib/Target/Mips/MipsSERegisterInfo.cpp:216
+const llvm::Align OffsetAlign =
+llvm::Align(getLoadStoreOffsetAlign(MI.getOpcode()));
 

what about:

```
const llvm::Align OffsetAlign =
llvm::Align(llvm::Align(getLoadStoreOffsetAlign(MI.getOpcode();
```

:)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67499/new/

https://reviews.llvm.org/D67499



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67501: [clang-tidy] Fix relative path in header-filter.

2019-09-12 Thread Yubo Xie via Phabricator via cfe-commits
xyb created this revision.
xyb added a reviewer: alexfh.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

Clang-tidy supports output diagnostics from header files if user
specifies --header-filter. But it can't handle relative path well.
For example, the folder structure of a project is:

  // a.h is in /src/a/a.h
  #include "../b/b.h"
  
  // b.h is in /src/b/b.h
  ...
  
  // c.cpp is in /src/c.cpp
  #include "a/a.h"

Now, we set --header-filter as --header-filter=/a/. That means we only
want to check header files under /src/a/ path, and ignore header files
uder /src/b/ path, but in current implementation, clang-tidy will check
/src/b/b.h also, because the name of b.h used in clang-tidy is
/src/a/../b/b.h.

This change tries to fix this issue.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D67501

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/test/clang-tidy/Inputs/file-filter/subfolder_a/header.h
  clang-tools-extra/test/clang-tidy/Inputs/file-filter/subfolder_b/header.h
  clang-tools-extra/test/clang-tidy/Inputs/file-filter/subfolder_c/header.h
  clang-tools-extra/test/clang-tidy/file-filter.cpp

Index: clang-tools-extra/test/clang-tidy/file-filter.cpp
===
--- clang-tools-extra/test/clang-tidy/file-filter.cpp
+++ clang-tools-extra/test/clang-tidy/file-filter.cpp
@@ -9,6 +9,12 @@
 //   file-filter\header*.h due to code order between '/' and '\\'.
 // RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -system-headers %s -- -I %S/Inputs/file-filter/system/.. -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK4 %s
 // RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -system-headers -quiet %s -- -I %S/Inputs/file-filter/system/.. -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK4-QUIET %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='subfolder_a' %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK5 %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='subfolder_a' -quiet %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK5-QUIET %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='subfolder_b' %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK6 %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='subfolder_b' -quiet %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK6-QUIET %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='subfolder_c' %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK7 %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='subfolder_c' -quiet %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK7-QUIET %s
 
 #include "header1.h"
 // CHECK-NOT: warning:
@@ -19,6 +25,12 @@
 // CHECK3-QUIET-NOT: warning:
 // CHECK4: header1.h:1:12: warning: single-argument constructors
 // CHECK4-QUIET: header1.h:1:12: warning: single-argument constructors
+// CHECK5-NOT: warning:
+// CHECK5-QUIET-NOT: warning:
+// CHECK6-NOT: warning:
+// CHECK6-QUIET-NOT: warning:
+// CHECK7-NOT: warning:
+// CHECK7-QUIET-NOT: warning:
 
 #include "header2.h"
 // CHECK-NOT: warning:
@@ -29,6 +41,44 @@
 // CHECK3-QUIET: header2.h:1:12: warning: single-argument constructors
 // CHECK4: header2.h:1:12: warning: single-argument constructors
 // CHECK4-QUIET: header2.h:1:12: warning: single-argument constructors
+// CHECK5-NOT: warning:
+// CHECK5-QUIET-NOT: warning:
+// CHECK6-NOT: warning:
+// CHECK6-QUIET-NOT: warning:
+// CHECK7-NOT: warning:
+// CHECK7-QUIET-NOT: warning:
+
+#include "subfolder_a/header.h"
+// CHECK-NOT: warning:
+// CHECK-QUIET-NOT: warning:
+// CHECK2: header.h:1:12: warning: single-argument constructors must be marked explicit
+// CHECK2-QUIET: header.h:1:12: warning: single-argument constructors must be marked explicit
+// CHECK3-NOT: warning:
+// CHECK3-QUIET-NOT: warning:
+// CHECK4: header.h:1:12: warning: single-argument constructors must be marked explicit
+// CHECK4-QUIET: header.h:1:12: warning: single-argument constructors must be marked explicit
+// CHECK5: header.h:3:12: warning: single-argument constructors must be marked explicit
+// CHECK5-QUIET: header.h:3:12: warning: single-argument constructors must be marked explicit
+// CHECK6: header.h:1:12: warning: single-argument constructors must be marked explicit
+// CHECK6-QUIET: header.h:1:12: warning: single-argument constructors must be marked explicit
+// CHECK7-NOT: warning:
+// 

[PATCH] D67091: Fix for headers having the same name as a directory

2019-09-12 Thread Kousik Kumar via Phabricator via cfe-commits
kousikk added a comment.

Sorry about the delay on this - I was OOO (back now).

1. I added tests.
2. I couldn't add isDirectory() check to createFile() since that resulted in 
failures to normal scenarios where it was previously passing.

PTAL!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67091/new/

https://reviews.llvm.org/D67091



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67091: Fix for headers having the same name as a directory

2019-09-12 Thread Kousik Kumar via Phabricator via cfe-commits
kousikk updated this revision to Diff 219918.
kousikk added a comment.

- Add validation inside the createFile() function


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67091/new/

https://reviews.llvm.org/D67091

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
  clang/test/ClangScanDeps/Inputs/foodir
  clang/test/ClangScanDeps/Inputs/headerwithdirname.json
  clang/test/ClangScanDeps/headerwithdirname.cpp


Index: clang/test/ClangScanDeps/headerwithdirname.cpp
===
--- /dev/null
+++ clang/test/ClangScanDeps/headerwithdirname.cpp
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.dir/foodir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: mkdir -p %t.dir/foodir
+// RUN: cp %s %t.dir/headerwithdirname.cpp
+// RUN: mkdir %t.dir/Inputs
+// RUN: cp %S/Inputs/foodir %t.dir/Inputs/foodir
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/headerwithdirname.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck %s
+
+#include 
+
+// CHECK: clang-scan-deps dependency
+// CHECK-NEXT: headerwithdirname.cpp
+// CHECK-NEXT: Inputs{{/|\\}}foodir
\ No newline at end of file
Index: clang/test/ClangScanDeps/Inputs/headerwithdirname.json
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/headerwithdirname.json
@@ -0,0 +1,7 @@
+[
+{
+  "directory": "DIR",
+  "command": "clang -c -IDIR -IDIR/foodir -IInputs 
DIR/headerwithdirname.cpp",
+  "file": "DIR/headerwithdirname.cpp"
+}
+]
Index: clang/test/ClangScanDeps/Inputs/foodir
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/foodir
@@ -0,0 +1 @@
+// A C++ header with same name as that of a directory in the include path.
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -190,8 +190,11 @@
   StringRef Filename = Path.toStringRef(OwnedFilename);
 
   // Check the local cache first.
-  if (const CachedFileSystemEntry *Entry = getCachedEntry(Filename))
+  if (const CachedFileSystemEntry *Entry = getCachedEntry(Filename)) {
+if (Entry->isDirectory())
+  return 
llvm::ErrorOr>(std::make_error_code(std::errc::is_a_directory));
 return createFile(Entry);
+  }
 
   // FIXME: Handle PCM/PCH files.
   // FIXME: Handle module map files.
Index: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
===
--- 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
+++ 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
@@ -55,6 +55,11 @@
   /// \returns True if the entry is valid.
   bool isValid() const { return !MaybeStat || MaybeStat->isStatusKnown(); }
 
+  /// \returns True if the current entry points to a directory.
+  bool isDirectory() const {
+return MaybeStat && MaybeStat->isDirectory();
+  }
+
   /// \returns The error or the file's contents.
   llvm::ErrorOr getContents() const {
 if (!MaybeStat)


Index: clang/test/ClangScanDeps/headerwithdirname.cpp
===
--- /dev/null
+++ clang/test/ClangScanDeps/headerwithdirname.cpp
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.dir/foodir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: mkdir -p %t.dir/foodir
+// RUN: cp %s %t.dir/headerwithdirname.cpp
+// RUN: mkdir %t.dir/Inputs
+// RUN: cp %S/Inputs/foodir %t.dir/Inputs/foodir
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/headerwithdirname.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck %s
+
+#include 
+
+// CHECK: clang-scan-deps dependency
+// CHECK-NEXT: headerwithdirname.cpp
+// CHECK-NEXT: Inputs{{/|\\}}foodir
\ No newline at end of file
Index: clang/test/ClangScanDeps/Inputs/headerwithdirname.json
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/headerwithdirname.json
@@ -0,0 +1,7 @@
+[
+{
+  "directory": "DIR",
+  "command": "clang -c -IDIR -IDIR/foodir -IInputs DIR/headerwithdirname.cpp",
+  "file": "DIR/headerwithdirname.cpp"
+}
+]
Index: clang/test/ClangScanDeps/Inputs/foodir
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/foodir
@@ -0,0 +1 @@
+// A C++ header with same name as that of a directory in the include path.
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp

[PATCH] D67091: Fix for headers having the same name as a directory

2019-09-12 Thread Kousik Kumar via Phabricator via cfe-commits
kousikk updated this revision to Diff 219917.
kousikk added a comment.

- Add tests and remove the fix inside createFile since it fails in other cases


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67091/new/

https://reviews.llvm.org/D67091

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
  clang/test/ClangScanDeps/Inputs/foodir
  clang/test/ClangScanDeps/Inputs/headerwithdirname.json
  clang/test/ClangScanDeps/headerwithdirname.cpp


Index: clang/test/ClangScanDeps/headerwithdirname.cpp
===
--- /dev/null
+++ clang/test/ClangScanDeps/headerwithdirname.cpp
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.dir/foodir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: mkdir -p %t.dir/foodir
+// RUN: cp %s %t.dir/headerwithdirname.cpp
+// RUN: mkdir %t.dir/Inputs
+// RUN: cp %S/Inputs/foodir %t.dir/Inputs/foodir
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/headerwithdirname.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck %s
+
+#include 
+
+// CHECK: clang-scan-deps dependency
+// CHECK-NEXT: headerwithdirname.cpp
+// CHECK-NEXT: Inputs{{/|\\}}foodir
\ No newline at end of file
Index: clang/test/ClangScanDeps/Inputs/headerwithdirname.json
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/headerwithdirname.json
@@ -0,0 +1,7 @@
+[
+{
+  "directory": "DIR",
+  "command": "clang -c -IDIR -IDIR/foodir -IInputs 
DIR/headerwithdirname.cpp",
+  "file": "DIR/headerwithdirname.cpp"
+}
+]
Index: clang/test/ClangScanDeps/Inputs/foodir
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/foodir
@@ -0,0 +1 @@
+// A C++ header with same name as that of a directory in the include path.
\ No newline at end of file
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -190,8 +190,11 @@
   StringRef Filename = Path.toStringRef(OwnedFilename);
 
   // Check the local cache first.
-  if (const CachedFileSystemEntry *Entry = getCachedEntry(Filename))
+  if (const CachedFileSystemEntry *Entry = getCachedEntry(Filename)) {
+if (Entry->isDirectory())
+  return 
llvm::ErrorOr>(std::make_error_code(std::errc::is_a_directory));
 return createFile(Entry);
+  }
 
   // FIXME: Handle PCM/PCH files.
   // FIXME: Handle module map files.
Index: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
===
--- 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
+++ 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
@@ -55,6 +55,11 @@
   /// \returns True if the entry is valid.
   bool isValid() const { return !MaybeStat || MaybeStat->isStatusKnown(); }
 
+  /// \returns True if the current entry points to a directory.
+  bool isDirectory() const {
+return MaybeStat && MaybeStat->isDirectory();
+  }
+
   /// \returns The error or the file's contents.
   llvm::ErrorOr getContents() const {
 if (!MaybeStat)


Index: clang/test/ClangScanDeps/headerwithdirname.cpp
===
--- /dev/null
+++ clang/test/ClangScanDeps/headerwithdirname.cpp
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.dir/foodir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: mkdir -p %t.dir/foodir
+// RUN: cp %s %t.dir/headerwithdirname.cpp
+// RUN: mkdir %t.dir/Inputs
+// RUN: cp %S/Inputs/foodir %t.dir/Inputs/foodir
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/headerwithdirname.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck %s
+
+#include 
+
+// CHECK: clang-scan-deps dependency
+// CHECK-NEXT: headerwithdirname.cpp
+// CHECK-NEXT: Inputs{{/|\\}}foodir
\ No newline at end of file
Index: clang/test/ClangScanDeps/Inputs/headerwithdirname.json
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/headerwithdirname.json
@@ -0,0 +1,7 @@
+[
+{
+  "directory": "DIR",
+  "command": "clang -c -IDIR -IDIR/foodir -IInputs DIR/headerwithdirname.cpp",
+  "file": "DIR/headerwithdirname.cpp"
+}
+]
Index: clang/test/ClangScanDeps/Inputs/foodir
===
--- /dev/null
+++ clang/test/ClangScanDeps/Inputs/foodir
@@ -0,0 +1 @@
+// A C++ header with same name as that of a directory in the include path.
\ No newline at end of 

[PATCH] D67499: [Alignment] Move OffsetToAlignment to Alignment.h

2019-09-12 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet created this revision.
gchatelet added a reviewer: courbet.
Herald added subscribers: llvm-commits, cfe-commits, seiya, jsji, atanasyan, 
MaskRay, jrtc27, jakehehrlich, kbarton, hiraditya, nemanjai, sdardis.
Herald added a reviewer: JDevlieghere.
Herald added a reviewer: alexshap.
Herald added a reviewer: rupprecht.
Herald added a reviewer: jhenderson.
Herald added projects: clang, LLVM.

This is patch is part of a series to introduce an Alignment type.
See this thread for context: 
http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67499

Files:
  clang/lib/AST/DeclBase.cpp
  llvm/include/llvm/Support/Alignment.h
  llvm/include/llvm/Support/MathExtras.h
  llvm/include/llvm/Support/OnDiskHashTable.h
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/lib/CodeGen/BranchRelaxation.cpp
  llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
  llvm/lib/MC/ELFObjectWriter.cpp
  llvm/lib/MC/MCAssembler.cpp
  llvm/lib/MC/MachObjectWriter.cpp
  llvm/lib/Object/ArchiveWriter.cpp
  llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
  llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
  llvm/lib/Target/Mips/MipsConstantIslandPass.cpp
  llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp
  llvm/lib/Target/Mips/MipsSERegisterInfo.cpp
  llvm/lib/Target/PowerPC/PPCBranchSelector.cpp
  llvm/tools/dsymutil/DwarfStreamer.cpp
  llvm/tools/llvm-cov/TestingSupport.cpp
  llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp

Index: llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
===
--- llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
+++ llvm/tools/llvm-objcopy/MachO/MachOLayoutBuilder.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "MachOLayoutBuilder.h"
+#include "llvm/Support/Alignment.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/ErrorHandling.h"
 
@@ -145,7 +146,7 @@
   Sec.Offset = 0;
 } else {
   uint64_t PaddingSize =
-  OffsetToAlignment(SegFileSize, 1ull << Sec.Align);
+  offsetToAlignment(SegFileSize, llvm::Align(1ull << Sec.Align));
   Sec.Offset = SegOffset + SegFileSize + PaddingSize;
   Sec.Size = Sec.Content.size();
   SegFileSize += PaddingSize + Sec.Size;
Index: llvm/tools/llvm-cov/TestingSupport.cpp
===
--- llvm/tools/llvm-cov/TestingSupport.cpp
+++ llvm/tools/llvm-cov/TestingSupport.cpp
@@ -8,6 +8,7 @@
 
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/ProfileData/InstrProf.h"
+#include "llvm/Support/Alignment.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/LEB128.h"
 #include "llvm/Support/raw_ostream.h"
@@ -99,7 +100,7 @@
   encodeULEB128(ProfileNamesAddress, OS);
   OS << ProfileNamesData;
   // Coverage mapping data is expected to have an alignment of 8.
-  for (unsigned Pad = OffsetToAlignment(OS.tell(), 8); Pad; --Pad)
+  for (unsigned Pad = offsetToAlignment(OS.tell(), llvm::Align(8)); Pad; --Pad)
 OS.write(uint8_t(0));
   OS << CoverageMappingData;
 
Index: llvm/tools/dsymutil/DwarfStreamer.cpp
===
--- llvm/tools/dsymutil/DwarfStreamer.cpp
+++ llvm/tools/dsymutil/DwarfStreamer.cpp
@@ -339,7 +339,7 @@
 sizeof(int8_t);   // Segment Size (in bytes)
 
 unsigned TupleSize = AddressSize * 2;
-unsigned Padding = OffsetToAlignment(HeaderSize, TupleSize);
+unsigned Padding = offsetToAlignment(HeaderSize, llvm::Align(TupleSize));
 
 Asm->EmitLabelDifference(EndLabel, BeginLabel, 4); // Arange length
 Asm->OutStreamer->EmitLabel(BeginLabel);
Index: llvm/lib/Target/PowerPC/PPCBranchSelector.cpp
===
--- llvm/lib/Target/PowerPC/PPCBranchSelector.cpp
+++ llvm/lib/Target/PowerPC/PPCBranchSelector.cpp
@@ -88,13 +88,13 @@
   const llvm::Align ParentAlign = MBB.getParent()->getAlignment();
 
   if (Align <= ParentAlign)
-return OffsetToAlignment(Offset, Align.value());
+return offsetToAlignment(Offset, Align);
 
   // The alignment of this MBB is larger than the function's alignment, so we
   // can't tell whether or not it will insert nops. Assume that it will.
   if (FirstImpreciseBlock < 0)
 FirstImpreciseBlock = MBB.getNumber();
-  return Align.value() + OffsetToAlignment(Offset, Align.value());
+  return Align.value() + offsetToAlignment(Offset, Align);
 }
 
 /// We need to be careful about the offset of the first block in the function
Index: llvm/lib/Target/Mips/MipsSERegisterInfo.cpp
===
--- llvm/lib/Target/Mips/MipsSERegisterInfo.cpp
+++ llvm/lib/Target/Mips/MipsSERegisterInfo.cpp
@@ -212,11 +212,11 @@
 // element 

[PATCH] D64695: [clang-format] Modified SortIncludes and IncludeCategories to priority for sorting #includes within the Group Category.

2019-09-12 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.



> Yes, it would be good if it is landed. And can I know the procedure for 
> getting commit access

https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64695/new/

https://reviews.llvm.org/D64695



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D65744: [PR42707][OpenCL] Fix addr space deduction for auto

2019-09-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked 2 inline comments as done.
Anastasia added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:5998
+QualType Type = Var->getType();
+if (Type->isSamplerT() || Type->isVoidType())
+  return;

I don't seem to need a check for dependent or auto types because the 
substitution happens using type info rather than getting type from the 
declaration. Not sure if I should explain it here or add the checks just in 
case?



Comment at: clang/lib/Sema/SemaType.cpp:7460
+  // the initializing expression type during the type deduction.
+  (T->isUndeducedAutoType() && IsPointee) ||
   // OpenCL spec v2.0 s6.9.b:

rjmccall wrote:
> Okay, I understand why you're doing this now, and it makes sense.  I would 
> like to propose changing the entire way `deduceOpenCLImplicitAddrSpace` 
> works.  Why don't we do it more like how ObjC ARC infers its implicit 
> ownership qualifiers:
> 
> - In SemaType, we add the default address space to non-qualified, 
> non-dependent, non-undeduced-`auto` pointees when parsing a pointer or 
> reference type.
> - In SemaType, we add the default address space to non-qualified pointees 
> when building a pointer or reference type.
> - We add the default address space at the top level when when building a 
> variable.
> 
> Then all of this context-specific logic where we're looking at different 
> declarator chunks and trying to infer the relationship of the current chunk 
> to the overall type being parsed can just go away or get pushed into a more 
> appropriate position.
Ok, it mainly works, however I still need a bit of parsing horribleness when 
deducing addr space of declarations with parenthesis  in 
`GetFullTypeForDeclarator`. This is the case for block pointers or 
pointers/references to arrays. It is incorrect to add address spaces on 
ParenType while building a pointer or references so I have to detect this as 
special case.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65744/new/

https://reviews.llvm.org/D65744



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64695: [clang-format] Modified SortIncludes and IncludeCategories to priority for sorting #includes within the Group Category.

2019-09-12 Thread Manikishan Ghantasala via Phabricator via cfe-commits
Manikishan added a comment.

>>! In D64695#1667696 , 
>>@MyDeveloperDay wrote:

> Does this need landing? given that you have a number of patches in flight 
> perhaps it would be good to request commit access

Yes, it would be good if it is landed. And can I know the procedure for getting 
commit access


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64695/new/

https://reviews.llvm.org/D64695



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >