[PATCH] D54026: [CMake][Fuchsia] Set -fuse-ld=lld explicitly for Linux runtimes

2018-11-02 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: mcgrathr.
Herald added subscribers: cfe-commits, mgorny.

We set lld as the default linker on non-Darwin platforms, but we still
need to set -fuse-ld=lld explicitly in to support cross-compiling Linux
runtimes on Darwin.


Repository:
  rC Clang

https://reviews.llvm.org/D54026

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -40,12 +40,18 @@
 set(BUILTINS_${target}-linux-gnu_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
 set(BUILTINS_${target}-linux-gnu_CMAKE_BUILD_TYPE Release CACHE STRING "")
 set(BUILTINS_${target}-linux-gnu_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} 
CACHE STRING "")
+set(BUILTINS_${target}-linux-gnu_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" 
CACHE STRING "")
+set(BUILTINS_${target}-linux-gnu_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" 
CACHE STRING "")
+set(BUILTINS_${target}-linux-gnu_CMAKE_EXE_LINKER_FLAG "-fuse-ld=lld" 
CACHE STRING "")
 
 # Set the per-target runtimes options.
 list(APPEND RUNTIME_TARGETS "${target}-linux-gnu")
 set(RUNTIMES_${target}-linux-gnu_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
 set(RUNTIMES_${target}-linux-gnu_CMAKE_BUILD_TYPE Release CACHE STRING "")
 set(RUNTIMES_${target}-linux-gnu_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} 
CACHE STRING "")
+set(RUNTIMES_${target}-linux-gnu_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" 
CACHE STRING "")
+set(RUNTIMES_${target}-linux-gnu_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" 
CACHE STRING "")
+set(RUNTIMES_${target}-linux-gnu_CMAKE_EXE_LINKER_FLAGS "-fuse-ld=lld" 
CACHE STRING "")
 set(RUNTIMES_${target}-linux-gnu_LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(RUNTIMES_${target}-linux-gnu_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}-linux-gnu_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL 
"")
@@ -79,25 +85,25 @@
 list(APPEND BUILTIN_TARGETS "${target}-fuchsia")
 set(BUILTINS_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
 set(BUILTINS_${target}-fuchsia_CMAKE_BUILD_TYPE Release CACHE STRING "")
-set(BUILTINS_${target}-fuchsia_CMAKE_ASM_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE PATH "")
-set(BUILTINS_${target}-fuchsia_CMAKE_C_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE PATH "")
-set(BUILTINS_${target}-fuchsia_CMAKE_CXX_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE PATH "")
-set(BUILTINS_${target}-fuchsia_CMAKE_SHARED_LINKER_FLAGS 
${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "")
-set(BUILTINS_${target}-fuchsia_CMAKE_MODULE_LINKER_FLAGS 
${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "")
-set(BUILTINS_${target}-fuchsia_CMAKE_EXE_LINKER_FLAGS 
${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "")
+set(BUILTINS_${target}-fuchsia_CMAKE_ASM_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
+set(BUILTINS_${target}-fuchsia_CMAKE_C_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
+set(BUILTINS_${target}-fuchsia_CMAKE_CXX_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
+set(BUILTINS_${target}-fuchsia_CMAKE_SHARED_LINKER_FLAGS 
${FUCHSIA_${target}_LINKER_FLAGS} CACHE STRING "")
+set(BUILTINS_${target}-fuchsia_CMAKE_MODULE_LINKER_FLAGS 
${FUCHSIA_${target}_LINKER_FLAGS} CACHE STRING "")
+set(BUILTINS_${target}-fuchsia_CMAKE_EXE_LINKER_FLAGS 
${FUCHSIA_${target}_LINKER_FLAGS} CACHE STRING "")
 set(BUILTINS_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
 
 # Set the per-target runtimes options.
 list(APPEND RUNTIME_TARGETS "${target}-fuchsia")
 set(RUNTIMES_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
 set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_TYPE Release CACHE STRING "")
-set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE 
STRING "")
-set(RUNTIMES_${target}-fuchsia_CMAKE_ASM_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE PATH "")
-set(RUNTIMES_${target}-fuchsia_CMAKE_C_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE PATH "")
-set(RUNTIMES_${target}-fuchsia_CMAKE_CXX_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE PATH "")
-set(RUNTIMES_${target}-fuchsia_CMAKE_SHARED_LINKER_FLAGS 
${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "")
-set(RUNTIMES_${target}-fuchsia_CMAKE_MODULE_LINKER_FLAGS 
${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "")
-set(RUNTIMES_${target}-fuchsia_CMAKE_EXE_LINKER_FLAGS 
${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "")
+set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE 
BOOL "")
+set(RUNTIMES_${target}-fuchsia_CMAKE_ASM_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
+set(RUNTIMES_${target}-fuchsia_CMAKE_C_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
+set(RUNTIMES_${target}-fuchsia_CMAKE_CXX_FLAG

[PATCH] D53921: Compound literals, enums, et al require const expr

2018-11-02 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 172313.

Repository:
  rC Clang

https://reviews.llvm.org/D53921

Files:
  include/clang/AST/Expr.h
  include/clang/ASTMatchers/ASTMatchers.h
  lib/AST/ASTImporter.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/ASTMatchers/ASTMatchersInternal.cpp
  lib/ASTMatchers/Dynamic/Registry.cpp
  lib/Analysis/CFG.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaType.cpp
  lib/StaticAnalyzer/Core/Environment.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Import/switch-stmt/test.cpp
  test/Misc/ast-dump-attr.cpp
  test/Misc/ast-dump-c-attr.c
  test/Misc/ast-dump-color.cpp
  test/Misc/ast-dump-decl.c
  test/Misc/ast-dump-decl.cpp
  test/SemaCXX/compound-literal.cpp
  test/Tooling/clang-check-ast-dump.cpp
  unittests/AST/ASTImporterTest.cpp
  unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1574,13 +1574,16 @@
 ifStmt(has(switchStmt(forEachSwitchCase(defaultStmt()));
   EXPECT_TRUE(matches("void x() { switch(42) { case 1+1: case 4:; } }",
   switchStmt(forEachSwitchCase(
-caseStmt(hasCaseConstant(integerLiteral()));
+caseStmt(hasCaseConstant(
+constantExpr(has(integerLiteral();
   EXPECT_TRUE(notMatches("void x() { switch(42) { case 1+1: case 2+2:; } }",
  switchStmt(forEachSwitchCase(
-   caseStmt(hasCaseConstant(integerLiteral()));
+   caseStmt(hasCaseConstant(
+   constantExpr(has(integerLiteral();
   EXPECT_TRUE(notMatches("void x() { switch(42) { case 1 ... 2:; } }",
  switchStmt(forEachSwitchCase(
-   caseStmt(hasCaseConstant(integerLiteral()));
+   caseStmt(hasCaseConstant(
+   constantExpr(has(integerLiteral();
   EXPECT_TRUE(matchAndVerifyResultTrue(
 "void x() { switch (42) { case 1: case 2: case 3: default:; } }",
 switchStmt(forEachSwitchCase(caseStmt().bind("x"))),
Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -760,23 +760,23 @@
has(
  designatedInitExpr(
designatorCountIs(2),
-   has(floatLiteral(
+   hasDescendant(floatLiteral(
  equals(1.0))),
-   has(integerLiteral(
+   hasDescendant(integerLiteral(
  equals(2),
has(
  designatedInitExpr(
designatorCountIs(2),
-   has(floatLiteral(
+   hasDescendant(floatLiteral(
  equals(2.0))),
-   has(integerLiteral(
+   hasDescendant(integerLiteral(
  equals(2),
has(
  designatedInitExpr(
designatorCountIs(2),
-   has(floatLiteral(
+   hasDescendant(floatLiteral(
  equals(1.0))),
-   has(integerLiteral(
+   hasDescendant(integerLiteral(
  equals(0)
  );
 }
Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -140,6 +140,7 @@
 if (!Imported)
   return testing::AssertionFailure() << "Import failed, nullptr returned!";
 
+
 return Verifier.match(Imported, WrapperMatcher);
   }
 
@@ -502,7 +503,6 @@
   EXPECT_THAT(RedeclsD1, ::testing::ContainerEq(RedeclsD2));
 }
 
-
 TEST_P(ImportExpr, ImportStringLiteral) {
   MatchVerifier Verifier;
   testImport(
@@ -719,19 +719,18 @@
   initListExpr(
   has(designatedInitExpr(
   design

[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl

2018-11-02 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta updated this revision to Diff 172317.
takuto.ikuta added a comment.

Added cl driver flag test


https://reviews.llvm.org/D51340

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/CLCompatOptions.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp
  clang/test/Driver/cl-options.c

Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -490,6 +490,11 @@
 // RUN: %clang_cl /Zc:threadSafeInit /c -### -- %s 2>&1 | FileCheck -check-prefix=ThreadSafeStatics %s
 // ThreadSafeStatics-NOT: "-fno-threadsafe-statics"
 
+// RUN: %clang_cl /Zc:dllexportInlines- /c -### -- %s 2>&1 | FileCheck -check-prefix=NoDllExportInlines %s
+// NoDllExportInlines: "-fno-dllexport-inlines"
+// RUN: %clang_cl /Zc:dllexportInlines /c -### -- %s 2>&1 | FileCheck -check-prefix=DllExportInlines %s
+// DllExportInlines-NOT: "-fno-dllexport-inlines"
+
 // RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
 // Zi: "-gcodeview"
 // Zi: "-debug-info-kind=limited"
Index: clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp
@@ -0,0 +1,142 @@
+// RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc   \
+// RUN: -disable-llvm-passes\
+// RUN: -fno-dllexport-inlines -emit-llvm -O1 -o - |\
+// RUN: FileCheck --check-prefix=CHECK --check-prefix=NOEXPORTINLINE %s
+
+// RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc   \
+// RUN: -disable-llvm-passes\
+// RUN: -fno-dllexport-inlines -emit-llvm -O1 -o - |\
+// RUN: FileCheck --check-prefix=STATIC %s
+
+// RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc   \
+// RUN: -disable-llvm-passes\
+// RUN: -emit-llvm -O1 -o - |   \
+// RUN: FileCheck --check-prefix=CHECK %s
+
+// RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc   \
+// RUN: -disable-llvm-passes\
+// RUN: -emit-llvm -O1 -o - |   \
+// RUN: FileCheck --check-prefix=STATIC %s
+
+
+
+struct __declspec(dllexport) ExportedClass {
+
+  // NOEXPORTINLINE-NOT: ?InclassDefFunc@ExportedClass@@
+  // EXPORTINLINE-DAG: define weak_odr dso_local dllexport void @"?InclassDefFunc@ExportedClass@@
+  void InclassDefFunc() {}
+
+  // CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFuncWithStaticVariable@ExportedClass@@QEAAHXZ"
+  int InclassDefFuncWithStaticVariable() {
+// STATIC-DAG: @"?static_variable@?1??InclassDefFuncWithStaticVariable@ExportedClass@@QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
+static int static_variable = 0;
+++static_variable;
+return static_variable;
+  }
+
+  // CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFunctWithLambdaStaticVariable@ExportedClass@@QEAAHXZ"
+  int InclassDefFunctWithLambdaStaticVariable() {
+// STATIC-DAG: @"?static_x@?2???R@?0??InclassDefFunctWithLambdaStaticVariable@ExportedClass@@QEAAHXZ@QEBA?A?@@XZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
+return ([]() { static int static_x; return ++static_x; })();
+  }
+
+  // CHECK-NOT: InlineOutclassDefFuncWihtoutDefinition
+  inline void InlineOutclassDefFuncWihtoutDefinition();
+
+  // CHECK-DAG:define weak_odr dso_local dllexport void @"?InlineOutclassDefFunc@ExportedClass@@QEAAXXZ
+  inline void InlineOutclassDefFunc();
+
+  // CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InlineOutclassDefFuncWithStaticVariable@ExportedClass@@QEAAHXZ"
+  inline int InlineOutclassDefFuncWithStaticVariable();
+
+  // CHECK-DAG: define dso_local dllexport void @"?OutclassDefFunc@ExportedClass@@QEAAXXZ"
+  void OutclassDefFunc();
+};
+
+void ExportedClass::OutclassDefFunc() {}
+
+inline void ExportedClass::InlineOutclassDefFunc() {}
+
+inline int ExportedClass::InlineOutclassDefFuncWithStaticVariable() {
+  static int static_variable = 0;
+  return ++static_variable;
+}
+
+void __declspec(dllexport) ExportedClassUser() {
+  ExportedClass a;
+  a.InlineOutclassDefFunc();
+}
+
+template
+struct __declspec(dllexport) TemplateExportedClass {
+  void InclassDefFunc() {}
+};
+
+class A11{};
+class B22{};
+class C33{};
+class D44{};
+
+// EXPORTINLINE-DAG: define weak_odr dso_local dllexport void @"?InclassDefFunc@?$TemplateExportedClass@VA11AEAAX

[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl

2018-11-02 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta marked an inline comment as done.
takuto.ikuta added a comment.

I missed the comment about driver flag test.


https://reviews.llvm.org/D51340



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


[PATCH] D52998: [benchmark] Disable exceptions in Microsoft STL

2018-11-02 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

In https://reviews.llvm.org/D52998#1284312, @eandrews wrote:

> > Upstreaming it first might be better, especially since the change seems to 
> > be trivial. Is this line addition the only change proposed for the 
> > benchmark library?
>
> Yes this line is the only change.
>
> > Do you want me to submit the patch to the benchmark library? It seems that 
> > it would help to speedup the process.
>
> That would be helpful. Thank you!


Opened a PR https://github.com/google/benchmark/pull/715.


https://reviews.llvm.org/D52998



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


[PATCH] D53692: [analyzer] Evaluate all non-checker config options before analysis

2018-11-02 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

Also, thank you so much for the feedback on this, and almost every single other 
patch I made!


https://reviews.llvm.org/D53692



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


[PATCH] D53692: [analyzer] Evaluate all non-checker config options before analysis

2018-11-02 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

In https://reviews.llvm.org/D53692#1285091, @NoQ wrote:

> I guess i'm running out of steam for today :)
>
> > `Opts.shouldDoThat()` -> `Opts.ShouldDoThat.getValue()`
>
> Is this really unavoidable? Like, what makes them optional when they're 
> always non-optional? Maybe just somehow prevent un-eagerly-initialized 
> AnalyzerConfig from appearing anywhere in the program?


Thats a fair point, the reason why I kept `Optional` is the extra safety -- 
it took a good couple hours to make this patch, and it didn't took days thanks 
to the `hasValue()` assert, since, well, how macros get expanded is always a 
surprise. But sure, ideally it shouldn't be there.


https://reviews.llvm.org/D53692



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


[PATCH] D53417: [Clang][Sema][PowerPC] Choose a better candidate in overload function call if there is a compatible vector conversion instead of ambiguous call error

2018-11-02 Thread Zixuan Wu via Phabricator via cfe-commits
wuzish added inline comments.



Comment at: clang/lib/Sema/SemaOverload.cpp:3913
+for (auto Type : Types) {
+  if (S.Context.getCanonicalType(Type)->getTypeClass() != Type::Vector)
+return false;

hubert.reinterpretcast wrote:
> wuzish wrote:
> > hubert.reinterpretcast wrote:
> > > hubert.reinterpretcast wrote:
> > > > wuzish wrote:
> > > > > hubert.reinterpretcast wrote:
> > > > > > wuzish wrote:
> > > > > > > hubert.reinterpretcast wrote:
> > > > > > > > wuzish wrote:
> > > > > > > > > hubert.reinterpretcast wrote:
> > > > > > > > > > Considering that this is a local lambda called in one 
> > > > > > > > > > place, are we expecting cases where the canonical type is 
> > > > > > > > > > not something on which we can call getVectorKind()? If not, 
> > > > > > > > > > then we do not need this `if`.
> > > > > > > > > Well, that's for ExtVectorType. I encounter some testcase 
> > > > > > > > > failure because of that. So I just narrow the condition to 
> > > > > > > > > only handle Type::Vector.
> > > > > > > > > 
> > > > > > > > > As the following comment said, so I treat it separately.
> > > > > > > > > 
> > > > > > > > > /// ExtVectorType - Extended vector type. This type is 
> > > > > > > > > created using
> > > > > > > > > /// __attribute__((ext_vector_type(n)), where "n" is the 
> > > > > > > > > number of elements.
> > > > > > > > > /// Unlike vector_size, ext_vector_type is only allowed on 
> > > > > > > > > typedef's. This
> > > > > > > > > /// class enables syntactic extensions, like Vector 
> > > > > > > > > Components for accessing
> > > > > > > > > /// points (as .xyzw), colors (as .rgba), and textures 
> > > > > > > > > (modeled after OpenGL
> > > > > > > > > /// Shading Language).
> > > > > > > > An ExtVectorType is a VectorType, so what sort of failures are 
> > > > > > > > you hitting?
> > > > > > > Yes. But the TypeClass of ExtVectorType is ExtVector.
> > > > > > > 
> > > > > > > some test points check the error report for ambiguous call 
> > > > > > > because of too many implicit cast choices from ext_vector_type to 
> > > > > > > vector type. Such as blow.
> > > > > > > 
> > > > > > > 
> > > > > > > ```
> > > > > > > typedef char char16 __attribute__ ((__vector_size__ (16)));
> > > > > > > typedef long long longlong16 __attribute__ ((__vector_size__ 
> > > > > > > (16)));
> > > > > > > typedef char char16_e __attribute__ ((__ext_vector_type__ (16)));
> > > > > > > typedef long long longlong16_e __attribute__ 
> > > > > > > ((__ext_vector_type__ (2)));
> > > > > > > 
> > > > > > > 
> > > > > > > void f1_test(char16 c16, longlong16 ll16, char16_e c16e, 
> > > > > > > longlong16_e ll16e) {
> > > > > > >   int &ir1 = f1(c16);
> > > > > > >   float &fr1 = f1(ll16);
> > > > > > >   f1(c16e); // expected-error{{call to 'f1' is ambiguous}}
> > > > > > >   f1(ll16e); // expected-error{{call to 'f1' is ambiguous}}
> > > > > > > }
> > > > > > > ```
> > > > > > > 
> > > > > > > If we are gonna widen the condition, we can make a follow-up 
> > > > > > > patch. Or we need include this condition and do this together in 
> > > > > > > this patch?
> > > > > > The widening that has occurred is in allowing the scope of the 
> > > > > > change to encompass cases where AltiVec vectors are not 
> > > > > > sufficiently involved. The change in behaviour makes sense, and 
> > > > > > perhaps the community may want to pursue it; however, the mandate 
> > > > > > to make that level of change has not been given.
> > > > > > 
> > > > > > I do not believe that requiring that the TypeClass be VectorType is 
> > > > > > the correct narrowing of the scope. Instead, we may want to 
> > > > > > consider requiring that for each `SCS` in { `SCS1`, `SCS2` }, there 
> > > > > > is one AltiVec type and one generic vector type in { 
> > > > > > `SCS.getFromType()`, `SCS.getToType(2)` }.
> > > > > > 
> > > > > The key point is that ExtVector is a kind of typeclass, **and** its 
> > > > > vector kind is generic vector type.
> > > > > 
> > > > > So you think we should encompass ext_vector cases as a part of the 
> > > > > scope of this patch? And modify the above cases' expected behavior 
> > > > > (remove the **expected-error**)?
> > > > I gave a concrete suggested narrowing of the scope that does not 
> > > > exclude ExtVectorType or other derived types of VectorType. It also 
> > > > does not change the behaviour of the `f1_test` case above. We could 
> > > > pursue additional discussion over that case (separable from the current 
> > > > patch) on the mailing list.
> > > > 
> > > > I believe my suggestion does do something about this case:
> > > > ```
> > > > typedef unsigned int GccType __attribute__((__ext_vector_type__(16)));
> > > > typedef __vector unsigned int AltiVecType;
> > > > 
> > > > typedef float GccOtherType __attribute__((__vector_size__(16)));
> > > > 
> > > > void f(GccType);
> > > > void f(GccOtherType);
> > > > 
> > > > void g(AltiVecType v) { f(v);

[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl

2018-11-02 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Thanks! I don't think the new isThisDeclarationADefinition() and 
isImplicitlyInstantiable() checks are right. Besides that, I only have a few 
more comments about the test.




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:5715
+  (MD->isThisDeclarationADefinition() ||
+   MD->isImplicitlyInstantiable()) &&
+  TSK != TSK_ExplicitInstantiationDeclaration &&

The isThisDeclarationADefinition() and isImplicitlyInstantiable() checks don't 
look right. Just checking isInlined() should be enough.



Comment at: clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp:9
+// RUN: -fno-dllexport-inlines -emit-llvm -O1 -o - |\
+// RUN: FileCheck --check-prefix=STATIC %s
+

Why this separate STATIC invocation? It looks just the same as the invocation 
above.

Oh I see, it's because the test is mixing -DAG and -NOT lines, which breaks 
things.

I have a suggestion for avoiding the -NOT lines below, and that means this 
separate invocation to check for statics (and the other one below) can be 
removed.



Comment at: clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp:25
+
+  // NOEXPORTINLINE-NOT: ?InclassDefFunc@ExportedClass@@
+  // EXPORTINLINE-DAG: define weak_odr dso_local dllexport void 
@"?InclassDefFunc@ExportedClass@@

Instead of a -NOT check, it would be better to "use" the function somewhere so 
that it's emitted, and check that it's not dllexport. That will make it easier 
to see the difference between NOEXPORTINLINE and EXPORTINLINE.

Also it avoids -NOT checks, which don't interact well with -DAG checks, and 
would let you remove the separate STATIC invocation.



Comment at: clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp:44
+  // CHECK-NOT: InlineOutclassDefFuncWihtoutDefinition
+  inline void InlineOutclassDefFuncWihtoutDefinition();
+

Having an inline function and not defining it like this is not so great, 
especially in a dllexport class. I don't think there's any need to change the 
behaviour here or test for it.



Comment at: clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp:47
+  // CHECK-DAG:define weak_odr dso_local dllexport void 
@"?InlineOutclassDefFunc@ExportedClass@@QEAAXXZ
+  inline void InlineOutclassDefFunc();
+

But with -fno-dllexport-inlines, I don't think it should be exported.

It really doesn't matter if the body is inside or outside the class -- it's 
still an inline member function, and so the flag should apply.



Comment at: clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp:53
+  // CHECK-DAG: define dso_local dllexport void 
@"?OutclassDefFunc@ExportedClass@@QEAAXXZ"
+  void OutclassDefFunc();
+};

I'd suggest calling it "OutoflineDefFunc()" instead.



Comment at: clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp:65
+
+void __declspec(dllexport) ExportedClassUser() {
+  ExportedClass a;

I don't think there's any reason to dllexport the "user" function.



Comment at: clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp:81
+// EXPORTINLINE-DAG: define weak_odr dso_local dllexport void 
@"?InclassDefFunc@?$TemplateExportedClass@VA11AEAAXXZ"
+template class __declspec(dllexport) TemplateExportedClass;
+

I don't think this instantiation is different from the `​​template class 
TemplateExportedClass;` one below, so I think we can skip it.



Comment at: clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp:83
+
+// EXPORTINLINE-DAG: define weak_odr dso_local dllexport void 
@"?InclassDefFunc@?$TemplateExportedClass@VB22AEAAXXZ"
+template class TemplateExportedClass;

There should also be a check to make sure it's exported also in the 
NOEXPORTINLINE case.



Comment at: clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp:88
+// EXPORTINLINE-DAG: define weak_odr dso_local dllexport void 
@"?InclassDefFunc@?$TemplateExportedClass@VC33QEAAXXZ
+TemplateExportedClass c33;
+

Thanks, this is the implicit instantiation case. It would be good to have an 
inline function with a static local to make sure it does get exported even with 
the flag.


https://reviews.llvm.org/D51340



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


[PATCH] D53953: [clang-tidy] Get ClangTidyContext out of the business of storing diagnostics. NFC

2018-11-02 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.

> There is a test that asserts clang-tidy exits with 0 when processing a 
> nonexistent file (test added in https://reviews.llvm.org/D17335 which you 
> wrote/reviewed).

This seems like a bug to me, do I need to preserve this behavior? (See patch 
description for how this happens).

I think this is a bug, we should return non-zero code when processing a 
non-existing file. The new behavior seems better to me, though we need to 
polish the error message.




Comment at: clang-tidy/ClangTidy.h:247
 /// clang-format configuration file is found, the given \P FormatStyle is used.
-void handleErrors(ClangTidyContext &Context, bool Fix,
+void handleErrors(llvm::ArrayRef Diags,
+  ClangTidyContext &Context, bool Fix,

nit: maybe name it `Errors`, and we match the comment again (it is out-of-date 
at HEAD :().


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53953



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


[PATCH] D53953: [clang-tidy] Get ClangTidyContext out of the business of storing diagnostics. NFC

2018-11-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked an inline comment as done.
sammccall added a comment.

In https://reviews.llvm.org/D53953#1285244, @hokein wrote:

> I think this is a bug, we should return non-zero code when processing a 
> non-existing file. The new behavior seems better to me, though we need to 
> polish the error message.


Thanks. See https://reviews.llvm.org/D53958 for (most of) the needed error 
message improvements.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53953



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


[PATCH] D53953: [clang-tidy] Get ClangTidyContext out of the business of storing diagnostics. NFC

2018-11-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 172326.
sammccall added a comment.

Address comment, rebase


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53953

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidy.h
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tidy/tool/ClangTidyMain.cpp
  test/clang-tidy/clang-tidy-run-with-database.cpp
  unittests/clang-tidy/ClangTidyTest.h

Index: unittests/clang-tidy/ClangTidyTest.h
===
--- unittests/clang-tidy/ClangTidyTest.h
+++ unittests/clang-tidy/ClangTidyTest.h
@@ -118,15 +118,15 @@
   Invocation.setDiagnosticConsumer(&DiagConsumer);
   if (!Invocation.run()) {
 std::string ErrorText;
-for (const auto &Error : Context.getErrors()) {
+for (const auto &Error : DiagConsumer.take()) {
   ErrorText += Error.Message.Message + "\n";
 }
 llvm::report_fatal_error(ErrorText);
   }
 
-  DiagConsumer.finish();
   tooling::Replacements Fixes;
-  for (const ClangTidyError &Error : Context.getErrors()) {
+  std::vector Diags = DiagConsumer.take();
+  for (const ClangTidyError &Error : Diags) {
 for (const auto &FileAndFixes : Error.Fix) {
   for (const auto &Fix : FileAndFixes.second) {
 auto Err = Fixes.add(Fix);
@@ -139,7 +139,7 @@
 }
   }
   if (Errors)
-*Errors = Context.getErrors();
+*Errors = std::move(Diags);
   auto Result = tooling::applyAllReplacements(Code, Fixes);
   if (!Result) {
 // FIXME: propogate the error.
Index: test/clang-tidy/clang-tidy-run-with-database.cpp
===
--- test/clang-tidy/clang-tidy-run-with-database.cpp
+++ test/clang-tidy/clang-tidy-run-with-database.cpp
@@ -8,7 +8,13 @@
 // RUN: echo 'int *HP = 0;' > %T/compilation-database-test/include/header.h
 // RUN: echo '#include "header.h"' > %T/compilation-database-test/b/d.cpp
 // RUN: sed 's|test_dir|%/T/compilation-database-test|g' %S/Inputs/compilation-database/template.json > %T/compile_commands.json
-// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/b/not-exist -header-filter=.*
+
+// Regression test: shouldn't crash.
+// RUN: not clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/b/not-exist -header-filter=.* 2>&1 | FileCheck %s -check-prefix=CHECK-NOT-EXIST
+// CHECK-NOT-EXIST: Error while processing {{.*}}/not-exist.
+// CHECK-NOT-EXIST: unable to handle compilation
+// CHECK-NOT-EXIST: Found compiler error
+
 // RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/a/a.cpp %T/compilation-database-test/a/b.cpp %T/compilation-database-test/b/b.cpp %T/compilation-database-test/b/c.cpp %T/compilation-database-test/b/d.cpp -header-filter=.* -fix
 // RUN: FileCheck -input-file=%T/compilation-database-test/a/a.cpp %s -check-prefix=CHECK-FIX1
 // RUN: FileCheck -input-file=%T/compilation-database-test/a/b.cpp %s -check-prefix=CHECK-FIX2
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -422,9 +422,9 @@
 
   ClangTidyContext Context(std::move(OwningOptionsProvider),
AllowEnablingAnalyzerAlphaCheckers);
-  runClangTidy(Context, OptionsParser.getCompilations(), PathList, BaseFS,
-   EnableCheckProfile, ProfilePrefix);
-  ArrayRef Errors = Context.getErrors();
+  std::vector Errors =
+  runClangTidy(Context, OptionsParser.getCompilations(), PathList, BaseFS,
+   EnableCheckProfile, ProfilePrefix);
   bool FoundErrors = llvm::find_if(Errors, [](const ClangTidyError &E) {
return E.DiagLevel == ClangTidyError::Error;
  }) != Errors.end();
@@ -434,7 +434,7 @@
   unsigned WErrorCount = 0;
 
   // -fix-errors implies -fix.
-  handleErrors(Context, (FixErrors || Fix) && !DisableFixes, WErrorCount,
+  handleErrors(Errors, Context, (FixErrors || Fix) && !DisableFixes, WErrorCount,
BaseFS);
 
   if (!ExportFixes.empty() && !Errors.empty()) {
Index: clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -160,12 +160,6 @@
   /// counters.
   const ClangTidyStats &getStats() const { return Stats; }
 
-  /// \brief Returns all collected errors.
-  ArrayRef getErrors() const { return Errors; }
-
-  /// \brief Clears collected errors.
-  void clearErrors() { Errors.clear(); }
-
   /// \brief Control profile collection in clang-tidy.
   void setEnableProfiling(bool Profile);
   bool getEnableProfiling() const { return Profile; }
@@ -196,7 +190,6 @@
   friend class ClangTidyDiagnosticConsumer;
   friend class ClangTidyPluginAction;
 
-  std::vector Errors;
   DiagnosticsEngine *Diag

[PATCH] D53953: [clang-tidy] Get ClangTidyContext out of the business of storing diagnostics. NFC

2018-11-02 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE345961: [clang-tidy] Get ClangTidyContext out of the 
business of storing diagnostics. (authored by sammccall, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53953?vs=172326&id=172329#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53953

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidy.h
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tidy/tool/ClangTidyMain.cpp
  test/clang-tidy/clang-tidy-run-with-database.cpp
  unittests/clang-tidy/ClangTidyTest.h

Index: unittests/clang-tidy/ClangTidyTest.h
===
--- unittests/clang-tidy/ClangTidyTest.h
+++ unittests/clang-tidy/ClangTidyTest.h
@@ -118,15 +118,15 @@
   Invocation.setDiagnosticConsumer(&DiagConsumer);
   if (!Invocation.run()) {
 std::string ErrorText;
-for (const auto &Error : Context.getErrors()) {
+for (const auto &Error : DiagConsumer.take()) {
   ErrorText += Error.Message.Message + "\n";
 }
 llvm::report_fatal_error(ErrorText);
   }
 
-  DiagConsumer.finish();
   tooling::Replacements Fixes;
-  for (const ClangTidyError &Error : Context.getErrors()) {
+  std::vector Diags = DiagConsumer.take();
+  for (const ClangTidyError &Error : Diags) {
 for (const auto &FileAndFixes : Error.Fix) {
   for (const auto &Fix : FileAndFixes.second) {
 auto Err = Fixes.add(Fix);
@@ -139,7 +139,7 @@
 }
   }
   if (Errors)
-*Errors = Context.getErrors();
+*Errors = std::move(Diags);
   auto Result = tooling::applyAllReplacements(Code, Fixes);
   if (!Result) {
 // FIXME: propogate the error.
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -525,8 +525,7 @@
   return HeaderFilter.get();
 }
 
-void ClangTidyDiagnosticConsumer::removeIncompatibleErrors(
-SmallVectorImpl &Errors) const {
+void ClangTidyDiagnosticConsumer::removeIncompatibleErrors() {
   // Each error is modelled as the set of intervals in which it applies
   // replacements. To detect overlapping replacements, we use a sweep line
   // algorithm over these sets of intervals.
@@ -664,17 +663,13 @@
 };
 } // end anonymous namespace
 
-// Flushes the internal diagnostics buffer to the ClangTidyContext.
-void ClangTidyDiagnosticConsumer::finish() {
+std::vector ClangTidyDiagnosticConsumer::take() {
   finalizeLastError();
 
   std::sort(Errors.begin(), Errors.end(), LessClangTidyError());
   Errors.erase(std::unique(Errors.begin(), Errors.end(), EqualClangTidyError()),
Errors.end());
-
   if (RemoveIncompatibleErrors)
-removeIncompatibleErrors(Errors);
-
-  std::move(Errors.begin(), Errors.end(), std::back_inserter(Context.Errors));
-  Errors.clear();
+removeIncompatibleErrors();
+  return std::move(Errors);
 }
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -500,11 +500,12 @@
   return Factory.getCheckOptions();
 }
 
-void runClangTidy(clang::tidy::ClangTidyContext &Context,
-  const CompilationDatabase &Compilations,
-  ArrayRef InputFiles,
-  llvm::IntrusiveRefCntPtr BaseFS,
-  bool EnableCheckProfile, llvm::StringRef StoreCheckProfile) {
+std::vector
+runClangTidy(clang::tidy::ClangTidyContext &Context,
+ const CompilationDatabase &Compilations,
+ ArrayRef InputFiles,
+ llvm::IntrusiveRefCntPtr BaseFS,
+ bool EnableCheckProfile, llvm::StringRef StoreCheckProfile) {
   ClangTool Tool(Compilations, InputFiles,
  std::make_shared(), BaseFS);
 
@@ -586,9 +587,11 @@
 
   ActionFactory Factory(Context);
   Tool.run(&Factory);
+  return DiagConsumer.take();
 }
 
-void handleErrors(ClangTidyContext &Context, bool Fix,
+void handleErrors(llvm::ArrayRef Errors,
+  ClangTidyContext &Context, bool Fix,
   unsigned &WarningsAsErrorsCount,
   llvm::IntrusiveRefCntPtr BaseFS) {
   ErrorReporter Reporter(Context, Fix, BaseFS);
@@ -598,7 +601,7 @@
   if (!InitialWorkingDir)
 llvm::report_fatal_error("Cannot get current working path.");
 
-  for (const ClangTidyError &Error : Context.getErrors()) {
+  for (const ClangTidyError &Error : Errors) {
 if (!Error.BuildDirectory.empty()) {
   // By default, the working directory of file system is the current
   // clang-tidy running directory.
Index: clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -160,12 +160,6 @@
   /// counters.

[clang-tools-extra] r345961 - [clang-tidy] Get ClangTidyContext out of the business of storing diagnostics. NFC

2018-11-02 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Fri Nov  2 03:01:59 2018
New Revision: 345961

URL: http://llvm.org/viewvc/llvm-project?rev=345961&view=rev
Log:
[clang-tidy] Get ClangTidyContext out of the business of storing diagnostics. 
NFC

Summary:
Currently ClangTidyContext::diag() sends the diagnostics to a
DiagnosticsEngine, which probably delegates to a ClangTidyDiagnosticsConsumer,
which is supposed to go back and populate ClangTidyContext::Errors.

After this patch, the diagnostics are stored in the ClangTidyDiagnosticsConsumer
itself and can be retrieved from there.

Why?
 - the round-trip from context -> engine -> consumer -> context is confusing
   and makes it harder to establish layering between these things.
 - context does too many things, and makes it hard to use clang-tidy as a 
library
 - everyone who actually wants the diagnostics has access to the 
ClangTidyDiagnosticsConsumer

The most natural implementation (ClangTidyDiagnosticsConsumer::take()
finalizes diagnostics) causes a test failure: clang-tidy-run-with-database.cpp
asserts that clang-tidy exits successfully when trying to process a file
that doesn't exist.
In clang-tidy today, this happens because finish() is never called, so the
diagnostic is never flushed. This looks like a bug to me.
For now, this patch carefully preserves that behavior, but I'll ping the
authors to see whether it's deliberate and worth preserving.

Reviewers: hokein

Subscribers: xazax.hun, cfe-commits, alexfh

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

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidy.h
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-run-with-database.cpp
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h

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=345961&r1=345960&r2=345961&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Fri Nov  2 03:01:59 2018
@@ -500,11 +500,12 @@ getCheckOptions(const ClangTidyOptions &
   return Factory.getCheckOptions();
 }
 
-void runClangTidy(clang::tidy::ClangTidyContext &Context,
-  const CompilationDatabase &Compilations,
-  ArrayRef InputFiles,
-  llvm::IntrusiveRefCntPtr BaseFS,
-  bool EnableCheckProfile, llvm::StringRef StoreCheckProfile) {
+std::vector
+runClangTidy(clang::tidy::ClangTidyContext &Context,
+ const CompilationDatabase &Compilations,
+ ArrayRef InputFiles,
+ llvm::IntrusiveRefCntPtr BaseFS,
+ bool EnableCheckProfile, llvm::StringRef StoreCheckProfile) {
   ClangTool Tool(Compilations, InputFiles,
  std::make_shared(), BaseFS);
 
@@ -586,9 +587,11 @@ void runClangTidy(clang::tidy::ClangTidy
 
   ActionFactory Factory(Context);
   Tool.run(&Factory);
+  return DiagConsumer.take();
 }
 
-void handleErrors(ClangTidyContext &Context, bool Fix,
+void handleErrors(llvm::ArrayRef Errors,
+  ClangTidyContext &Context, bool Fix,
   unsigned &WarningsAsErrorsCount,
   llvm::IntrusiveRefCntPtr BaseFS) {
   ErrorReporter Reporter(Context, Fix, BaseFS);
@@ -598,7 +601,7 @@ void handleErrors(ClangTidyContext &Cont
   if (!InitialWorkingDir)
 llvm::report_fatal_error("Cannot get current working path.");
 
-  for (const ClangTidyError &Error : Context.getErrors()) {
+  for (const ClangTidyError &Error : Errors) {
 if (!Error.BuildDirectory.empty()) {
   // By default, the working directory of file system is the current
   // clang-tidy running directory.

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.h?rev=345961&r1=345960&r2=345961&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.h Fri Nov  2 03:01:59 2018
@@ -230,12 +230,13 @@ getCheckOptions(const ClangTidyOptions &
 /// \param StoreCheckProfile If provided, and EnableCheckProfile is true,
 /// the profile will not be output to stderr, but will instead be stored
 /// as a JSON file in the specified directory.
-void runClangTidy(clang::tidy::ClangTidyContext &Context,
-  const tooling::CompilationDatabase &Compilations,
-  ArrayRef InputFiles,
-  llvm::IntrusiveRefCntPtr BaseFS,
-  bool EnableCheckProfile = false,
-   

[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl

2018-11-02 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta updated this revision to Diff 172330.
takuto.ikuta marked 10 inline comments as done.
takuto.ikuta added a comment.

Address comment


https://reviews.llvm.org/D51340

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/CLCompatOptions.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp
  clang/test/Driver/cl-options.c

Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -490,6 +490,11 @@
 // RUN: %clang_cl /Zc:threadSafeInit /c -### -- %s 2>&1 | FileCheck -check-prefix=ThreadSafeStatics %s
 // ThreadSafeStatics-NOT: "-fno-threadsafe-statics"
 
+// RUN: %clang_cl /Zc:dllexportInlines- /c -### -- %s 2>&1 | FileCheck -check-prefix=NoDllExportInlines %s
+// NoDllExportInlines: "-fno-dllexport-inlines"
+// RUN: %clang_cl /Zc:dllexportInlines /c -### -- %s 2>&1 | FileCheck -check-prefix=DllExportInlines %s
+// DllExportInlines-NOT: "-fno-dllexport-inlines"
+
 // RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
 // Zi: "-gcodeview"
 // Zi: "-debug-info-kind=limited"
Index: clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp
@@ -0,0 +1,130 @@
+// RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc   \
+// RUN: -disable-llvm-passes\
+// RUN: -fno-dllexport-inlines -emit-llvm -O1 -o - |\
+// RUN: FileCheck --check-prefix=CHECK --check-prefix=NOEXPORTINLINE %s
+
+// RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc   \
+// RUN: -disable-llvm-passes\
+// RUN: -emit-llvm -O1 -o - |   \
+// RUN: FileCheck --check-prefix=CHECK %s
+
+
+struct __declspec(dllexport) ExportedClass {
+
+  // NOEXPORTINLINE-DAG: define linkonce_odr dso_local void @"?InclassDefFunc@ExportedClass@@
+  // EXPORTINLINE-DAG: define weak_odr dso_local dllexport void @"?InclassDefFunc@ExportedClass@@
+  void InclassDefFunc() {}
+
+  // CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFuncWithStaticVariable@ExportedClass@@QEAAHXZ"
+  int InclassDefFuncWithStaticVariable() {
+// CHECK-DAG: @"?static_variable@?1??InclassDefFuncWithStaticVariable@ExportedClass@@QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
+static int static_variable = 0;
+++static_variable;
+return static_variable;
+  }
+
+  // CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFunctWithLambdaStaticVariable@ExportedClass@@QEAAHXZ"
+  int InclassDefFunctWithLambdaStaticVariable() {
+// CHECK-DAG: @"?static_x@?2???R@?0??InclassDefFunctWithLambdaStaticVariable@ExportedClass@@QEAAHXZ@QEBA?A?@@XZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
+return ([]() { static int static_x; return ++static_x; })();
+  }
+
+  // NOEXPORTINLINE-DAG: define linkonce_odr dso_local void @"?InlineOutclassDefFunc@ExportedClass@@QEAAXXZ
+  // EXPORTINLINE-DAG: define weak_odr dso_local dllexport void @"?InlineOutclassDefFunc@ExportedClass@@QEAAXXZ
+  inline void InlineOutclassDefFunc();
+
+  // CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InlineOutclassDefFuncWithStaticVariable@ExportedClass@@QEAAHXZ"
+  inline int InlineOutclassDefFuncWithStaticVariable();
+
+  // CHECK-DAG: define dso_local dllexport void @"?OutoflineDefFunc@ExportedClass@@QEAAXXZ"
+  void OutoflineDefFunc();
+};
+
+void ExportedClass::OutoflineDefFunc() {}
+
+inline void ExportedClass::InlineOutclassDefFunc() {}
+
+inline int ExportedClass::InlineOutclassDefFuncWithStaticVariable() {
+  static int static_variable = 0;
+  return ++static_variable;
+}
+
+void ExportedClassUser() {
+  ExportedClass a;
+  a.InclassDefFunc();
+  a.InlineOutclassDefFunc();
+}
+
+template
+struct __declspec(dllexport) TemplateExportedClass {
+  void InclassDefFunc() {}
+
+  int InclassDefFuncWithStaticVariable() {
+// CHECK-DAG: @"?static_x@?2??InclassDefFuncWithStaticVariable@?$TemplateExportedClass@VA11QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
+static int static_x = 0;
+return ++static_x;
+  }
+};
+
+class A11{};
+class B22{};
+
+// CHECK-DAG: define weak_odr dso_local dllexport void @"?InclassDefFunc@?$TemplateExportedClass@VA11QEAAXXZ"
+// CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFuncWithStaticVariable@?$TemplateExportedClass@VA11QEAAHXZ"
+template class TemplateExportedClass;
+
+// NOEXPORTINLINE-DAG: define linkonce_odr dso_loca

[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl

2018-11-02 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta updated this revision to Diff 172331.
takuto.ikuta added a comment.

added a few more check


https://reviews.llvm.org/D51340

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/CLCompatOptions.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp
  clang/test/Driver/cl-options.c

Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -490,6 +490,11 @@
 // RUN: %clang_cl /Zc:threadSafeInit /c -### -- %s 2>&1 | FileCheck -check-prefix=ThreadSafeStatics %s
 // ThreadSafeStatics-NOT: "-fno-threadsafe-statics"
 
+// RUN: %clang_cl /Zc:dllexportInlines- /c -### -- %s 2>&1 | FileCheck -check-prefix=NoDllExportInlines %s
+// NoDllExportInlines: "-fno-dllexport-inlines"
+// RUN: %clang_cl /Zc:dllexportInlines /c -### -- %s 2>&1 | FileCheck -check-prefix=DllExportInlines %s
+// DllExportInlines-NOT: "-fno-dllexport-inlines"
+
 // RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
 // Zi: "-gcodeview"
 // Zi: "-debug-info-kind=limited"
Index: clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp
@@ -0,0 +1,133 @@
+// RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc   \
+// RUN: -disable-llvm-passes\
+// RUN: -fno-dllexport-inlines -emit-llvm -O1 -o - |\
+// RUN: FileCheck --check-prefix=CHECK --check-prefix=NOEXPORTINLINE %s
+
+// RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc   \
+// RUN: -disable-llvm-passes\
+// RUN: -emit-llvm -O1 -o - |   \
+// RUN: FileCheck --check-prefix=CHECK %s
+
+
+struct __declspec(dllexport) ExportedClass {
+
+  // NOEXPORTINLINE-DAG: define linkonce_odr dso_local void @"?InclassDefFunc@ExportedClass@@
+  // EXPORTINLINE-DAG: define weak_odr dso_local dllexport void @"?InclassDefFunc@ExportedClass@@
+  void InclassDefFunc() {}
+
+  // CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFuncWithStaticVariable@ExportedClass@@QEAAHXZ"
+  int InclassDefFuncWithStaticVariable() {
+// CHECK-DAG: @"?static_variable@?1??InclassDefFuncWithStaticVariable@ExportedClass@@QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
+static int static_variable = 0;
+++static_variable;
+return static_variable;
+  }
+
+  // CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFunctWithLambdaStaticVariable@ExportedClass@@QEAAHXZ"
+  int InclassDefFunctWithLambdaStaticVariable() {
+// CHECK-DAG: @"?static_x@?2???R@?0??InclassDefFunctWithLambdaStaticVariable@ExportedClass@@QEAAHXZ@QEBA?A?@@XZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
+return ([]() { static int static_x; return ++static_x; })();
+  }
+
+  // NOEXPORTINLINE-DAG: define linkonce_odr dso_local void @"?InlineOutclassDefFunc@ExportedClass@@QEAAXXZ
+  // EXPORTINLINE-DAG: define weak_odr dso_local dllexport void @"?InlineOutclassDefFunc@ExportedClass@@QEAAXXZ
+  inline void InlineOutclassDefFunc();
+
+  // CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InlineOutclassDefFuncWithStaticVariable@ExportedClass@@QEAAHXZ"
+  inline int InlineOutclassDefFuncWithStaticVariable();
+
+  // CHECK-DAG: define dso_local dllexport void @"?OutoflineDefFunc@ExportedClass@@QEAAXXZ"
+  void OutoflineDefFunc();
+};
+
+void ExportedClass::OutoflineDefFunc() {}
+
+inline void ExportedClass::InlineOutclassDefFunc() {}
+
+inline int ExportedClass::InlineOutclassDefFuncWithStaticVariable() {
+  static int static_variable = 0;
+  return ++static_variable;
+}
+
+void ExportedClassUser() {
+  ExportedClass a;
+  a.InclassDefFunc();
+  a.InlineOutclassDefFunc();
+}
+
+template
+struct __declspec(dllexport) TemplateExportedClass {
+  void InclassDefFunc() {}
+
+  int InclassDefFuncWithStaticVariable() {
+// CHECK-DAG: @"?static_x@?2??InclassDefFuncWithStaticVariable@?$TemplateExportedClass@VA11QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
+// CHECK-DAG: @"?static_x@?2??InclassDefFuncWithStaticVariable@?$TemplateExportedClass@VB22QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
+static int static_x = 0;
+return ++static_x;
+  }
+};
+
+class A11{};
+class B22{};
+
+// CHECK-DAG: define weak_odr dso_local dllexport void @"?InclassDefFunc@?$TemplateExportedClass@VA11QEAAXXZ"
+// CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFuncWithStaticVariable@?

[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl

2018-11-02 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta added a comment.

Thank you for quick review!




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:5715
+  (MD->isThisDeclarationADefinition() ||
+   MD->isImplicitlyInstantiable()) &&
+  TSK != TSK_ExplicitInstantiationDeclaration &&

hans wrote:
> The isThisDeclarationADefinition() and isImplicitlyInstantiable() checks 
> don't look right. Just checking isInlined() should be enough.
I see.


https://reviews.llvm.org/D51340



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


[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl

2018-11-02 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta updated this revision to Diff 172332.

https://reviews.llvm.org/D51340

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/CLCompatOptions.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp
  clang/test/Driver/cl-options.c

Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -490,6 +490,11 @@
 // RUN: %clang_cl /Zc:threadSafeInit /c -### -- %s 2>&1 | FileCheck -check-prefix=ThreadSafeStatics %s
 // ThreadSafeStatics-NOT: "-fno-threadsafe-statics"
 
+// RUN: %clang_cl /Zc:dllexportInlines- /c -### -- %s 2>&1 | FileCheck -check-prefix=NoDllExportInlines %s
+// NoDllExportInlines: "-fno-dllexport-inlines"
+// RUN: %clang_cl /Zc:dllexportInlines /c -### -- %s 2>&1 | FileCheck -check-prefix=DllExportInlines %s
+// DllExportInlines-NOT: "-fno-dllexport-inlines"
+
 // RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
 // Zi: "-gcodeview"
 // Zi: "-debug-info-kind=limited"
Index: clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp
@@ -0,0 +1,133 @@
+// RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc   \
+// RUN: -disable-llvm-passes\
+// RUN: -fno-dllexport-inlines -emit-llvm -O1 -o - |\
+// RUN: FileCheck --check-prefix=CHECK --check-prefix=NOEXPORTINLINE %s
+
+// RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc   \
+// RUN: -disable-llvm-passes\
+// RUN: -emit-llvm -O1 -o - |   \
+// RUN: FileCheck --check-prefix=CHECK %s
+
+
+struct __declspec(dllexport) ExportedClass {
+
+  // NOEXPORTINLINE-DAG: define linkonce_odr dso_local void @"?InclassDefFunc@ExportedClass@@
+  // EXPORTINLINE-DAG: define weak_odr dso_local dllexport void @"?InclassDefFunc@ExportedClass@@
+  void InclassDefFunc() {}
+
+  // CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFuncWithStaticVariable@ExportedClass@@QEAAHXZ"
+  int InclassDefFuncWithStaticVariable() {
+// CHECK-DAG: @"?static_variable@?1??InclassDefFuncWithStaticVariable@ExportedClass@@QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
+static int static_variable = 0;
+++static_variable;
+return static_variable;
+  }
+
+  // CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFunctWithLambdaStaticVariable@ExportedClass@@QEAAHXZ"
+  int InclassDefFunctWithLambdaStaticVariable() {
+// CHECK-DAG: @"?static_x@?2???R@?0??InclassDefFunctWithLambdaStaticVariable@ExportedClass@@QEAAHXZ@QEBA?A?@@XZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
+return ([]() { static int static_x; return ++static_x; })();
+  }
+
+  // NOEXPORTINLINE-DAG: define linkonce_odr dso_local void @"?InlineOutclassDefFunc@ExportedClass@@QEAAXXZ
+  // EXPORTINLINE-DAG: define weak_odr dso_local dllexport void @"?InlineOutclassDefFunc@ExportedClass@@QEAAXXZ
+  inline void InlineOutclassDefFunc();
+
+  // CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InlineOutclassDefFuncWithStaticVariable@ExportedClass@@QEAAHXZ"
+  inline int InlineOutclassDefFuncWithStaticVariable();
+
+  // CHECK-DAG: define dso_local dllexport void @"?OutoflineDefFunc@ExportedClass@@QEAAXXZ"
+  void OutoflineDefFunc();
+};
+
+void ExportedClass::OutoflineDefFunc() {}
+
+inline void ExportedClass::InlineOutclassDefFunc() {}
+
+inline int ExportedClass::InlineOutclassDefFuncWithStaticVariable() {
+  static int static_variable = 0;
+  return ++static_variable;
+}
+
+void ExportedClassUser() {
+  ExportedClass a;
+  a.InclassDefFunc();
+  a.InlineOutclassDefFunc();
+}
+
+template
+struct __declspec(dllexport) TemplateExportedClass {
+  void InclassDefFunc() {}
+
+  int InclassDefFuncWithStaticVariable() {
+static int static_x = 0;
+return ++static_x;
+  }
+};
+
+class A11{};
+class B22{};
+
+// CHECK-DAG: define weak_odr dso_local dllexport void @"?InclassDefFunc@?$TemplateExportedClass@VA11QEAAXXZ"
+// CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFuncWithStaticVariable@?$TemplateExportedClass@VA11QEAAHXZ"
+// CHECK-DAG: @"?static_x@?2??InclassDefFuncWithStaticVariable@?$TemplateExportedClass@VA11QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
+template class TemplateExportedClass;
+
+// NOEXPORTINLINE-DAG: define linkonce_odr dso_local void @"?InclassDefFunc@?$TemplateExportedClass@VB22QEAAXXZ"
+// EXPORTINLINE-DAG: define weak_

[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl

2018-11-02 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Assuming the test still passes when you put the EXPORTINLINE filecheck prefix 
back, looks good to me!




Comment at: clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp:9
+// RUN: -emit-llvm -O1 -o - |   \
+// RUN: FileCheck --check-prefix=CHECK %s
+

Did the "EXPORTINLINE" check-prefix get lost here?


https://reviews.llvm.org/D51340



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


[PATCH] D53949: [clang][CodeGen] Implicit Conversion Sanitizer: discover the world of CompoundAssign operators

2018-11-02 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 172335.
lebedev.ri added a comment.

And finish the test coverage.

(sidenote: will these follow-ups again be stuck for two months? let's see!)


Repository:
  rC Clang

https://reviews.llvm.org/D53949

Files:
  lib/CodeGen/CGExprScalar.cpp
  test/CodeGen/catch-implicit-integer-sign-changes-CompoundAssignOperator.c
  test/CodeGen/catch-implicit-integer-truncations-CompoundAssignOperator.c
  
test/CodeGen/catch-implicit-signed-integer-truncation-or-sign-change-CompoundAssignOperator.c



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


r345963 - Revert "Fix regression in behavior of clang -x c++-header -fmodule-name=XXX"

2018-11-02 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Fri Nov  2 03:50:26 2018
New Revision: 345963

URL: http://llvm.org/viewvc/llvm-project?rev=345963&view=rev
Log:
Revert "Fix regression in behavior of clang -x c++-header -fmodule-name=XXX"

This reverts commit r345803 and r345915 (a follow-up fix to r345803).

Reason: r345803 blocks our internal integrate because of the new
warnings showing up in too many places. The fix is actually correct,
we will reland it after figuring out how to integrate properly.

Removed:
cfe/trunk/test/Modules/strict-decluse-headers.cpp
Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/test/Driver/header-module.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=345963&r1=345962&r2=345963&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Nov  2 03:50:26 2018
@@ -3250,15 +3250,18 @@ void Clang::ConstructJob(Compilation &C,
   bool IsCuda = JA.isOffloading(Action::OFK_Cuda);
   bool IsHIP = JA.isOffloading(Action::OFK_HIP);
   bool IsOpenMPDevice = JA.isDeviceOffloading(Action::OFK_OpenMP);
+  bool IsModulePrecompile =
+  isa(JA) && JA.getType() == types::TY_ModuleFile;
   bool IsHeaderModulePrecompile = isa(JA);
 
   // A header module compilation doesn't have a main input file, so invent a
   // fake one as a placeholder.
+  // FIXME: Pick the language based on the header file language.
   const char *ModuleName = [&]{
 auto *ModuleNameArg = Args.getLastArg(options::OPT_fmodule_name_EQ);
 return ModuleNameArg ? ModuleNameArg->getValue() : "";
   }();
-  InputInfo HeaderModuleInput(Inputs[0].getType(), ModuleName, ModuleName);
+  InputInfo HeaderModuleInput(types::TY_CXXModule, ModuleName, ModuleName);
 
   const InputInfo &Input =
   IsHeaderModulePrecompile ? HeaderModuleInput : Inputs[0];
@@ -3269,9 +3272,10 @@ void Clang::ConstructJob(Compilation &C,
   for (const InputInfo &I : Inputs) {
 if (&I == &Input) {
   // This is the primary input.
-} else if (IsHeaderModulePrecompile &&
+} else if (IsModulePrecompile &&
types::getPrecompiledType(I.getType()) == types::TY_PCH) {
-  types::ID Expected = HeaderModuleInput.getType();
+  types::ID Expected =
+  types::lookupHeaderTypeForSourceType(Inputs[0].getType());
   if (I.getType() != Expected) {
 D.Diag(diag::err_drv_module_header_wrong_kind)
 << I.getFilename() << types::getTypeName(I.getType())

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=345963&r1=345962&r2=345963&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Fri Nov  2 03:50:26 2018
@@ -372,9 +372,6 @@ static void InitializeFileRemapping(Diag
 void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {
   const PreprocessorOptions &PPOpts = getPreprocessorOpts();
 
-  // The module manager holds a reference to the old preprocessor (if any).
-  ModuleManager.reset();
-
   // Create a PTH manager if we are using some form of a token cache.
   PTHManager *PTHMgr = nullptr;
   if (!PPOpts.TokenCache.empty())

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=345963&r1=345962&r2=345963&view=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Fri Nov  2 03:50:26 2018
@@ -523,7 +523,7 @@ void ModuleMap::diagnoseHeaderInclusion(
 
   // At this point, only non-modular includes remain.
 
-  if (RequestingModule && LangOpts.ModulesStrictDeclUse) {
+  if (LangOpts.ModulesStrictDeclUse) {
 Diags.Report(FilenameLoc, diag::err_undeclared_use_of_module)
 << RequestingModule->getTopLevelModule()->Name << Filename;
   } else if (RequestingModule && RequestingModuleIsModuleInterface &&

Modified: cfe/trunk/test/Driver/header-module.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/header-module.cpp?rev=345963&r1=345962&r2=345963&view=diff
==
--- cfe/trunk/test/Driver/header-module.cpp (original)
+++ cfe/trunk/test/Driver/header-module.cpp Fri Nov  2 03:50:26 2018
@@ -7,18 +7,7 @@
 // CHECK-PRECOMPILE-SAME: -fno-implicit-modules
 // CHECK-PRECOMPILE-SAME: -fmodule-name=foobar
 // CHECK-PRECOMPILE-SAME: -o {{.*}}.pcm
-// CHECK-PRECOMPILE-SAME: -x c++-header
+// CHECK-PRECOMPILE-SAME: -x c++
 // CHECK-PRECOMPILE-SAME: header1.h
 // CHECK-PRECOMPILE-SAME:

[PATCH] D52296: [Clang] - Add -gsingle-file-split-dwarf option.

2018-11-02 Thread George Rimar via Phabricator via cfe-commits
grimar added a comment.

In https://reviews.llvm.org/D52296#1284130, @probinson wrote:

> In https://reviews.llvm.org/D52296#1283691, @grimar wrote:
>
> > Nice :) 
> >  So seems the last unresolved question left is the naming of the new option?
> >  If we do not want to go with `-gsingle-file-split-dwarf` then what it 
> > should be?
> >
> > What about `-fdebug-fission` as an alias for `-gsplit-dwarf`.
> >  And `-fsingle-file-debug-fission` for the new option?
> >
> > Or, may be:
> >
> > `-fdebug-fission` for the new option and then
> >  `-fdebug-fission -fdebug-split-dwo` would work together as `-gsplit-dwarf`?
>
>
> Only DWARF supports this, correct?


I am not aware of any kind of debug information splitting except DWARF 
splitting.

> So I would suggest: `-fdwarf-fission[={split,single}]` where the parameter 
> defaults to `split`. Is there any particular value in having two separate 
> options?

Probably not. `-fdwarf-fission[={split,single}]` sounds good for me.


https://reviews.llvm.org/D52296



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


[PATCH] D53483: [analyzer] Restrict AnalyzerOptions' interface so that non-checker objects have to be registered

2018-11-02 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: include/clang/StaticAnalyzer/Core/AnalyzerOptions.h:146-149
+/// If you'd like to add a new -cc1 flag, add it to
+/// include/clang/Driver/CC1Options.td, add a new field to store the value of
+/// that flag in this class, and initialize it in
+/// lib/Frontend/CompilerInvocation.cpp.

NoQ wrote:
> Nono, don't add more -cc1 flags :)
Code review is there to stop adding unnecessary -cc1 flags. Are we sure we 
wouldn't even like to document it? I myself will add at least 2 more -cc1 flags 
in the future (-analyzer-config-help, -analyzer-checker-option-help), that 
undoubtedly belong there.



Comment at: lib/StaticAnalyzer/Core/AnalyzerOptions.cpp:172
+ .getAsInteger(10, *V);
+  assert(!HasFailed && "analyzer-config option should be numeric");
+  (void)HasFailed;

NoQ wrote:
> I guess @xazax.hun's comment also applies to this assert.
Which is sadly only going to be addressed in followup patches :/ Note that I 
merely moved code around in this patch, but have organized things in a way that 
emitting proper diagnostics will be super easy going forward. Since analyzer 
configs are mainly meant for developers, I think this is acceptable before I 
fix it (in any case, it has always been like this).


https://reviews.llvm.org/D53483



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


r345965 - [analyzer][CTU] Correctly signal in the function index generation tool if there was an error

2018-11-02 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Fri Nov  2 04:22:22 2018
New Revision: 345965

URL: http://llvm.org/viewvc/llvm-project?rev=345965&view=rev
Log:
[analyzer][CTU] Correctly signal in the function index generation tool if there 
was an error

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

Modified:
cfe/trunk/tools/clang-func-mapping/CMakeLists.txt
cfe/trunk/tools/clang-func-mapping/ClangFnMapGen.cpp

Modified: cfe/trunk/tools/clang-func-mapping/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-func-mapping/CMakeLists.txt?rev=345965&r1=345964&r2=345965&view=diff
==
--- cfe/trunk/tools/clang-func-mapping/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-func-mapping/CMakeLists.txt Fri Nov  2 04:22:22 2018
@@ -1,8 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   ${LLVM_TARGETS_TO_BUILD}
-  asmparser
   support
-  mc
   )
 
 add_clang_executable(clang-func-mapping
@@ -15,7 +13,6 @@ target_link_libraries(clang-func-mapping
   clangBasic
   clangCrossTU
   clangFrontend
-  clangIndex
   clangTooling
   )
 

Modified: cfe/trunk/tools/clang-func-mapping/ClangFnMapGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-func-mapping/ClangFnMapGen.cpp?rev=345965&r1=345964&r2=345965&view=diff
==
--- cfe/trunk/tools/clang-func-mapping/ClangFnMapGen.cpp (original)
+++ cfe/trunk/tools/clang-func-mapping/ClangFnMapGen.cpp Fri Nov  2 04:22:22 
2018
@@ -14,23 +14,16 @@
 
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/ASTContext.h"
-#include "clang/AST/GlobalDecl.h"
-#include "clang/AST/Mangle.h"
-#include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/SourceManager.h"
-#include "clang/Basic/TargetInfo.h"
 #include "clang/CrossTU/CrossTranslationUnit.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendActions.h"
-#include "clang/Index/USRGeneration.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/Path.h"
 #include "llvm/Support/Signals.h"
 #include 
 #include 
-#include 
 
 using namespace llvm;
 using namespace clang;
@@ -41,21 +34,22 @@ static cl::OptionCategory ClangFnMapGenC
 
 class MapFunctionNamesConsumer : public ASTConsumer {
 public:
-  MapFunctionNamesConsumer(ASTContext &Context) : Ctx(Context) {}
+  MapFunctionNamesConsumer(ASTContext &Context)
+  : SM(Context.getSourceManager()) {}
 
   ~MapFunctionNamesConsumer() {
 // Flush results to standard output.
 llvm::outs() << createCrossTUIndexString(Index);
   }
 
-  virtual void HandleTranslationUnit(ASTContext &Ctx) {
+  void HandleTranslationUnit(ASTContext &Ctx) override {
 handleDecl(Ctx.getTranslationUnitDecl());
   }
 
 private:
   void handleDecl(const Decl *D);
 
-  ASTContext &Ctx;
+  SourceManager &SM;
   llvm::StringMap Index;
   std::string CurrentFileName;
 };
@@ -67,8 +61,6 @@ void MapFunctionNamesConsumer::handleDec
   if (const auto *FD = dyn_cast(D)) {
 if (FD->isThisDeclarationADefinition()) {
   if (const Stmt *Body = FD->getBody()) {
-std::string LookupName = 
CrossTranslationUnitContext::getLookupName(FD);
-const SourceManager &SM = Ctx.getSourceManager();
 if (CurrentFileName.empty()) {
   CurrentFileName =
   SM.getFileEntryForID(SM.getMainFileID())->tryGetRealPathName();
@@ -80,8 +72,11 @@ void MapFunctionNamesConsumer::handleDec
 case ExternalLinkage:
 case VisibleNoLinkage:
 case UniqueExternalLinkage:
-  if (SM.isInMainFile(Body->getBeginLoc()))
+  if (SM.isInMainFile(Body->getBeginLoc())) {
+std::string LookupName =
+CrossTranslationUnitContext::getLookupName(FD);
 Index[LookupName] = CurrentFileName;
+  }
   break;
 default:
   break;
@@ -99,9 +94,7 @@ class MapFunctionNamesAction : public AS
 protected:
   std::unique_ptr CreateASTConsumer(CompilerInstance &CI,
  llvm::StringRef) {
-std::unique_ptr PFC(
-new MapFunctionNamesConsumer(CI.getASTContext()));
-return PFC;
+return llvm::make_unique(CI.getASTContext());
   }
 };
 
@@ -120,6 +113,6 @@ int main(int argc, const char **argv) {
 
   ClangTool Tool(OptionsParser.getCompilations(),
  OptionsParser.getSourcePathList());
-  Tool.run(newFrontendActionFactory().get());
-  return 0;
+
+  return Tool.run(newFrontendActionFactory().get());
 }


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


[PATCH] D53979: [analyzer][CTU] Correctly signal in the function index generation tool if there was an error

2018-11-02 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345965: [analyzer][CTU] Correctly signal in the function 
index generation tool if there… (authored by xazax, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53979?vs=172134&id=172337#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53979

Files:
  cfe/trunk/tools/clang-func-mapping/CMakeLists.txt
  cfe/trunk/tools/clang-func-mapping/ClangFnMapGen.cpp

Index: cfe/trunk/tools/clang-func-mapping/ClangFnMapGen.cpp
===
--- cfe/trunk/tools/clang-func-mapping/ClangFnMapGen.cpp
+++ cfe/trunk/tools/clang-func-mapping/ClangFnMapGen.cpp
@@ -14,23 +14,16 @@
 
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/ASTContext.h"
-#include "clang/AST/GlobalDecl.h"
-#include "clang/AST/Mangle.h"
-#include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/SourceManager.h"
-#include "clang/Basic/TargetInfo.h"
 #include "clang/CrossTU/CrossTranslationUnit.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendActions.h"
-#include "clang/Index/USRGeneration.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
-#include "llvm/Support/Path.h"
 #include "llvm/Support/Signals.h"
 #include 
 #include 
-#include 
 
 using namespace llvm;
 using namespace clang;
@@ -41,21 +34,22 @@
 
 class MapFunctionNamesConsumer : public ASTConsumer {
 public:
-  MapFunctionNamesConsumer(ASTContext &Context) : Ctx(Context) {}
+  MapFunctionNamesConsumer(ASTContext &Context)
+  : SM(Context.getSourceManager()) {}
 
   ~MapFunctionNamesConsumer() {
 // Flush results to standard output.
 llvm::outs() << createCrossTUIndexString(Index);
   }
 
-  virtual void HandleTranslationUnit(ASTContext &Ctx) {
+  void HandleTranslationUnit(ASTContext &Ctx) override {
 handleDecl(Ctx.getTranslationUnitDecl());
   }
 
 private:
   void handleDecl(const Decl *D);
 
-  ASTContext &Ctx;
+  SourceManager &SM;
   llvm::StringMap Index;
   std::string CurrentFileName;
 };
@@ -67,8 +61,6 @@
   if (const auto *FD = dyn_cast(D)) {
 if (FD->isThisDeclarationADefinition()) {
   if (const Stmt *Body = FD->getBody()) {
-std::string LookupName = CrossTranslationUnitContext::getLookupName(FD);
-const SourceManager &SM = Ctx.getSourceManager();
 if (CurrentFileName.empty()) {
   CurrentFileName =
   SM.getFileEntryForID(SM.getMainFileID())->tryGetRealPathName();
@@ -80,8 +72,11 @@
 case ExternalLinkage:
 case VisibleNoLinkage:
 case UniqueExternalLinkage:
-  if (SM.isInMainFile(Body->getBeginLoc()))
+  if (SM.isInMainFile(Body->getBeginLoc())) {
+std::string LookupName =
+CrossTranslationUnitContext::getLookupName(FD);
 Index[LookupName] = CurrentFileName;
+  }
   break;
 default:
   break;
@@ -99,9 +94,7 @@
 protected:
   std::unique_ptr CreateASTConsumer(CompilerInstance &CI,
  llvm::StringRef) {
-std::unique_ptr PFC(
-new MapFunctionNamesConsumer(CI.getASTContext()));
-return PFC;
+return llvm::make_unique(CI.getASTContext());
   }
 };
 
@@ -120,6 +113,6 @@
 
   ClangTool Tool(OptionsParser.getCompilations(),
  OptionsParser.getSourcePathList());
-  Tool.run(newFrontendActionFactory().get());
-  return 0;
+
+  return Tool.run(newFrontendActionFactory().get());
 }
Index: cfe/trunk/tools/clang-func-mapping/CMakeLists.txt
===
--- cfe/trunk/tools/clang-func-mapping/CMakeLists.txt
+++ cfe/trunk/tools/clang-func-mapping/CMakeLists.txt
@@ -1,8 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   ${LLVM_TARGETS_TO_BUILD}
-  asmparser
   support
-  mc
   )
 
 add_clang_executable(clang-func-mapping
@@ -15,7 +13,6 @@
   clangBasic
   clangCrossTU
   clangFrontend
-  clangIndex
   clangTooling
   )
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53692: [analyzer] Evaluate all non-checker config options before analysis

2018-11-02 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: lib/StaticAnalyzer/Core/AnalyzerOptions.cpp:227
-CTUDir = getStringOption("ctu-dir", "");
-if (!llvm::sys::fs::is_directory(*CTUDir))
-  CTUDir = "";

Szelethus wrote:
> This check should and will be moved to `parseConfigs` in a followup patch.
Just make sure to commit the patches together to not regress this check.


https://reviews.llvm.org/D53692



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


[PATCH] D52794: [analyzer][PlistMacroExpansion] Part 2.: Retrieving the macro name and primitive expansion

2018-11-02 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.

One question and one nit otherwise looks good. Feel free to commit once those 
are resolved without another round of reviews.




Comment at: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:805
+// macro.
+if (const MacroInfo *MI = PP.getMacroInfo(II)) {
+  getMacroNameAndPrintExpansion(Printer, T.getLocation(), PP);

Can't we have troubles with getMacroInfo + undefs here? Wouldn't 
`findDirectiveAtLoc` be a safer choice here?



Comment at: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:883
+
+inline void TokenPrinter::printToken(const Token &Tok) {
+  // If the tokens were already space separated, or if they must be to avoid

I would remove the inline keyword here. I rarely see this in clang codebase. 
Let's just trust the compiler :)


https://reviews.llvm.org/D52794



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


[PATCH] D52795: [analyzer][PlistMacroExpansion] Part 3.: Macro arguments are expanded

2018-11-02 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:685
   const MacroInfo *MI = nullptr;
+  llvm::Optional Args;
 

I wonder if the optional gives us any value here. An empty map could be just as 
great to represent that there are no arguments.


https://reviews.llvm.org/D52795



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


[PATCH] D54033: [clang-tidy] Untangle layering in ClangTidyDiagnosticConsumer somewhat. NFC

2018-11-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: cfe-commits, xazax.hun.

Clang's hierarchy is CompilerInstance -> DiagnosticsEngine -> 
DiagnosticConsumer.
(Ownership is optional/shared, but this structure is fairly clear).

Currently ClangTidyDiagnosticConsumer *owns* the DiagnosticsEngine:

- this inverts the hierarchy, which is confusing
- this means ClangTidyDiagnosticConsumer() mutates the passed-in context, which 
is both surprising and limits flexibility
- it's not possible to use a different DiagnosticsEngine with ClangTidy

This means a little bit more code in the places ClangTidy is used standalone,
but more flexibility in using ClangTidy with other diagnostics configurations.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54033

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tidy/plugin/ClangTidyPlugin.cpp
  unittests/clang-tidy/ClangTidyTest.h

Index: unittests/clang-tidy/ClangTidyTest.h
===
--- unittests/clang-tidy/ClangTidyTest.h
+++ unittests/clang-tidy/ClangTidyTest.h
@@ -83,6 +83,9 @@
   ClangTidyContext Context(llvm::make_unique(
   ClangTidyGlobalOptions(), Options));
   ClangTidyDiagnosticConsumer DiagConsumer(Context);
+  DiagnosticsEngine DE(new DiagnosticIDs(), new DiagnosticOptions,
+   &DiagConsumer, false);
+  Context.setDiagnosticsEngine(&DE);
 
   std::vector Args(1, "clang-tidy");
   Args.push_back("-fsyntax-only");
Index: clang-tidy/plugin/ClangTidyPlugin.cpp
===
--- clang-tidy/plugin/ClangTidyPlugin.cpp
+++ clang-tidy/plugin/ClangTidyPlugin.cpp
@@ -35,7 +35,7 @@
   std::unique_ptr CreateASTConsumer(CompilerInstance &Compiler,
  StringRef File) override {
 // Insert the current diagnostics engine.
-Context->DiagEngine = &Compiler.getDiagnostics();
+Context->setDiagnosticsEngine(&Compiler.getDiagnostics());
 
 // Create the AST consumer.
 ClangTidyASTConsumerFactory Factory(*Context);
Index: clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -102,6 +102,12 @@
   /// \brief Initializes \c ClangTidyContext instance.
   ClangTidyContext(std::unique_ptr OptionsProvider,
bool AllowEnablingAnalyzerAlphaCheckers = false);
+  /// Sets the DiagnosticsEngine that diag() will emit diagnostics to.
+  // FIXME: this is required initialization, and should be a constructor param.
+  // Fix the context -> diag engine -> consumer -> context initialization cycle.
+  void setDiagnosticsEngine(DiagnosticsEngine *DiagEngine) {
+this->DiagEngine = DiagEngine;
+  }
 
   ~ClangTidyContext();
 
@@ -186,9 +192,8 @@
   }
 
 private:
-  // Sets DiagEngine and Errors.
+  // Writes to Stats.
   friend class ClangTidyDiagnosticConsumer;
-  friend class ClangTidyPluginAction;
 
   DiagnosticsEngine *DiagEngine;
   std::unique_ptr OptionsProvider;
@@ -242,12 +247,11 @@
 
   /// \brief Updates \c LastErrorRelatesToUserCode and LastErrorPassesLineFilter
   /// according to the diagnostic \p Location.
-  void checkFilters(SourceLocation Location);
+  void checkFilters(SourceLocation Location, const SourceManager& Sources);
   bool passesLineFilter(StringRef FileName, unsigned LineNumber) const;
 
   ClangTidyContext &Context;
   bool RemoveIncompatibleErrors;
-  std::unique_ptr Diags;
   std::vector Errors;
   std::unique_ptr HeaderFilter;
   bool LastErrorRelatesToUserCode;
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -267,13 +267,7 @@
 ClangTidyContext &Ctx, bool RemoveIncompatibleErrors)
 : Context(Ctx), RemoveIncompatibleErrors(RemoveIncompatibleErrors),
   LastErrorRelatesToUserCode(false), LastErrorPassesLineFilter(false),
-  LastErrorWasIgnored(false) {
-  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
-  Diags = llvm::make_unique(
-  IntrusiveRefCntPtr(new DiagnosticIDs), &*DiagOpts, this,
-  /*ShouldOwnClient=*/false);
-  Context.DiagEngine = Diags.get();
-}
+  LastErrorWasIgnored(false) {}
 
 void ClangTidyDiagnosticConsumer::finalizeLastError() {
   if (!Errors.empty()) {
@@ -391,7 +385,7 @@
 
   if (Info.getLocation().isValid() && DiagLevel != DiagnosticsEngine::Error &&
   DiagLevel != DiagnosticsEngine::Fatal &&
-  LineIsMarkedWithNOLINTinMacro(Diags->getSourceManager(),
+  LineIsMarkedWithNOLINTinMacro(Info.getSourceManager(),
 Info.getLocation(), Info.getID(),
 Context)) {
 +

[PATCH] D52986: [analyzer][PlistMacroExpansion] Part 4.: Support for __VA_ARGS__

2018-11-02 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.

One question otherwise looks good.




Comment at: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:884
+  // even if we lex a tok::comma and ParanthesesDepth == 1.
+  const IdentifierInfo *__VA_ARGS__II = PP.getIdentifierInfo("__VA_ARGS__");
+

Is it possible to undef `__VA_ARGS__`? If so, can this cause problems? Should 
we use `findDirectiveAtLoc` instead?


https://reviews.llvm.org/D52986



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


Re: [clang-tools-extra] r345961 - [clang-tidy] Get ClangTidyContext out of the business of storing diagnostics. NFC

2018-11-02 Thread Tom Weaver via cfe-commits
Hiya Sam,

are you aware that r345961 caused a test failure on the following bot and
build

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/21169

is there any chance you could take a look please?

thanks
Tom

On Fri, 2 Nov 2018 at 10:04, Sam McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: sammccall
> Date: Fri Nov  2 03:01:59 2018
> New Revision: 345961
>
> URL: http://llvm.org/viewvc/llvm-project?rev=345961&view=rev
> Log:
> [clang-tidy] Get ClangTidyContext out of the business of storing
> diagnostics. NFC
>
> Summary:
> Currently ClangTidyContext::diag() sends the diagnostics to a
> DiagnosticsEngine, which probably delegates to a
> ClangTidyDiagnosticsConsumer,
> which is supposed to go back and populate ClangTidyContext::Errors.
>
> After this patch, the diagnostics are stored in the
> ClangTidyDiagnosticsConsumer
> itself and can be retrieved from there.
>
> Why?
>  - the round-trip from context -> engine -> consumer -> context is
> confusing
>and makes it harder to establish layering between these things.
>  - context does too many things, and makes it hard to use clang-tidy as a
> library
>  - everyone who actually wants the diagnostics has access to the
> ClangTidyDiagnosticsConsumer
>
> The most natural implementation (ClangTidyDiagnosticsConsumer::take()
> finalizes diagnostics) causes a test failure:
> clang-tidy-run-with-database.cpp
> asserts that clang-tidy exits successfully when trying to process a file
> that doesn't exist.
> In clang-tidy today, this happens because finish() is never called, so the
> diagnostic is never flushed. This looks like a bug to me.
> For now, this patch carefully preserves that behavior, but I'll ping the
> authors to see whether it's deliberate and worth preserving.
>
> Reviewers: hokein
>
> Subscribers: xazax.hun, cfe-commits, alexfh
>
> Differential Revision: https://reviews.llvm.org/D53953
>
> Modified:
> clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
> clang-tools-extra/trunk/clang-tidy/ClangTidy.h
> clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
> clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
> clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
>
> clang-tools-extra/trunk/test/clang-tidy/clang-tidy-run-with-database.cpp
> clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h
>
> 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=345961&r1=345960&r2=345961&view=diff
>
> ==
> --- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
> +++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Fri Nov  2 03:01:59
> 2018
> @@ -500,11 +500,12 @@ getCheckOptions(const ClangTidyOptions &
>return Factory.getCheckOptions();
>  }
>
> -void runClangTidy(clang::tidy::ClangTidyContext &Context,
> -  const CompilationDatabase &Compilations,
> -  ArrayRef InputFiles,
> -  llvm::IntrusiveRefCntPtr BaseFS,
> -  bool EnableCheckProfile, llvm::StringRef
> StoreCheckProfile) {
> +std::vector
> +runClangTidy(clang::tidy::ClangTidyContext &Context,
> + const CompilationDatabase &Compilations,
> + ArrayRef InputFiles,
> + llvm::IntrusiveRefCntPtr BaseFS,
> + bool EnableCheckProfile, llvm::StringRef StoreCheckProfile) {
>ClangTool Tool(Compilations, InputFiles,
>   std::make_shared(), BaseFS);
>
> @@ -586,9 +587,11 @@ void runClangTidy(clang::tidy::ClangTidy
>
>ActionFactory Factory(Context);
>Tool.run(&Factory);
> +  return DiagConsumer.take();
>  }
>
> -void handleErrors(ClangTidyContext &Context, bool Fix,
> +void handleErrors(llvm::ArrayRef Errors,
> +  ClangTidyContext &Context, bool Fix,
>unsigned &WarningsAsErrorsCount,
>llvm::IntrusiveRefCntPtr BaseFS)
> {
>ErrorReporter Reporter(Context, Fix, BaseFS);
> @@ -598,7 +601,7 @@ void handleErrors(ClangTidyContext &Cont
>if (!InitialWorkingDir)
>  llvm::report_fatal_error("Cannot get current working path.");
>
> -  for (const ClangTidyError &Error : Context.getErrors()) {
> +  for (const ClangTidyError &Error : Errors) {
>  if (!Error.BuildDirectory.empty()) {
>// By default, the working directory of file system is the current
>// clang-tidy running directory.
>
> Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.h
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.h?rev=345961&r1=345960&r2=345961&view=diff
>
> ==
> --- clang-tools-extra/trunk/clang-tidy/ClangTidy.h (original)
> +++ clang-tools-extra/trunk/clang-tidy/ClangTidy.h Fri Nov  2 03:01:59 2018
> @@

[PATCH] D52790: [analyzer][PlistMacroExpansion] New flag to convert macro expansions to events

2018-11-02 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

I also would like to see in a tool how this would look like as an event before 
committing :) Just a sanity check to make sure this feature makes sense. Could 
you post a screenshot of CodeChecker or any other tool using this feature?


https://reviews.llvm.org/D52790



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


[PATCH] D53995: [analyzer] Drastically simplify the tblgen files used for checkers

2018-11-02 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

LGTM, but let's wait for @NoQ  before committing.


Repository:
  rC Clang

https://reviews.llvm.org/D53995



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


r345967 - Add support for 'atomic_default_mem_order' clause on 'requires' directive. Also renamed test files relating to 'requires'. Differntial review: https://reviews.llvm.org/D53513

2018-11-02 Thread Patrick Lyster via cfe-commits
Author: plyster
Date: Fri Nov  2 05:18:11 2018
New Revision: 345967

URL: http://llvm.org/viewvc/llvm-project?rev=345967&view=rev
Log:
Add support for 'atomic_default_mem_order' clause on 'requires' directive. Also 
renamed test files relating to 'requires'. Differntial review: 
https://reviews.llvm.org/D53513

Added:
cfe/trunk/test/OpenMP/requires_acq_rel_print.cpp
cfe/trunk/test/OpenMP/requires_ast_print.cpp
cfe/trunk/test/OpenMP/requires_messages.cpp
cfe/trunk/test/OpenMP/requires_relaxed_print.cpp
Removed:
cfe/trunk/test/OpenMP/requires_unified_address_ast_print.cpp
cfe/trunk/test/OpenMP/requires_unified_address_messages.cpp
Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Basic/OpenMPKinds.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=345967&r1=345966&r2=345967&view=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Fri Nov  2 05:18:11 2018
@@ -859,6 +859,85 @@ public:
   }
 };
 
+/// This represents 'atomic_default_mem_order' clause in the '#pragma omp
+/// requires'  directive.
+///
+/// \code
+/// #pragma omp requires atomic_default_mem_order(seq_cst)
+/// \endcode
+/// In this example directive '#pragma omp requires' has simple
+/// atomic_default_mem_order' clause with kind 'seq_cst'.
+class OMPAtomicDefaultMemOrderClause final : public OMPClause {
+  friend class OMPClauseReader;
+
+  /// Location of '('
+  SourceLocation LParenLoc;
+
+  /// A kind of the 'atomic_default_mem_order' clause.
+  OpenMPAtomicDefaultMemOrderClauseKind Kind =
+  OMPC_ATOMIC_DEFAULT_MEM_ORDER_unknown;
+
+  /// Start location of the kind in source code.
+  SourceLocation KindKwLoc;
+
+  /// Set kind of the clause.
+  ///
+  /// \param K Kind of clause.
+  void setAtomicDefaultMemOrderKind(OpenMPAtomicDefaultMemOrderClauseKind K) {
+Kind = K;
+  }
+
+  /// Set clause kind location.
+  ///
+  /// \param KLoc Kind location.
+  void setAtomicDefaultMemOrderKindKwLoc(SourceLocation KLoc) {
+KindKwLoc = KLoc;
+  }
+
+public:
+  /// Build 'atomic_default_mem_order' clause with argument \a A ('seq_cst',
+  /// 'acq_rel' or 'relaxed').
+  ///
+  /// \param A Argument of the clause ('seq_cst', 'acq_rel' or 'relaxed').
+  /// \param ALoc Starting location of the argument.
+  /// \param StartLoc Starting location of the clause.
+  /// \param LParenLoc Location of '('.
+  /// \param EndLoc Ending location of the clause.
+  OMPAtomicDefaultMemOrderClause(OpenMPAtomicDefaultMemOrderClauseKind A,
+ SourceLocation ALoc, SourceLocation StartLoc,
+ SourceLocation LParenLoc,
+ SourceLocation EndLoc)
+  : OMPClause(OMPC_atomic_default_mem_order, StartLoc, EndLoc),
+LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {}
+
+  /// Build an empty clause.
+  OMPAtomicDefaultMemOrderClause()
+  : OMPClause(OMPC_atomic_default_mem_order, SourceLocation(),
+  SourceLocation()) {}
+
+  /// Sets the location of '('.
+  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
+
+  /// Returns the locaiton of '('.
+  SourceLocation getLParenLoc() const { return LParenLoc; }
+
+  /// Returns kind of the clause.
+  OpenMPAtomicDefaultMemOrderClauseKind getAtomicDefaultMemOrderKind() const {
+return Kind;
+  }
+
+  /// Returns location of clause kind.
+  SourceLocation getAtomicDefaultMemOrderKindKwLoc() const { return KindKwLoc; 
}
+
+  child_range children() {
+return child_range(child_iterator(), child_iterator());
+  }
+
+  static bool classof(const OMPClause *T) {
+return T->getClauseKind() == OMPC_atomic_default_mem_order;
+  }
+};
+
 /// This represents 'schedule' clause in the '#pragma omp ...' directive.
 ///
 /// \code

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=345967&r1=345966&r2=345967&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Fri Nov  2 05:18:11 2018

[clang-tools-extra] r345968 - [clangd] Only log ignored diagnostics with -log=verbose.

2018-11-02 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Fri Nov  2 05:51:26 2018
New Revision: 345968

URL: http://llvm.org/viewvc/llvm-project?rev=345968&view=rev
Log:
[clangd] Only log ignored diagnostics with -log=verbose.

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/Compiler.cpp

Modified: clang-tools-extra/trunk/clangd/Compiler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Compiler.cpp?rev=345968&r1=345967&r2=345968&view=diff
==
--- clang-tools-extra/trunk/clangd/Compiler.cpp (original)
+++ clang-tools-extra/trunk/clangd/Compiler.cpp Fri Nov  2 05:51:26 2018
@@ -20,6 +20,7 @@ namespace clangd {
 
 void IgnoreDiagnostics::log(DiagnosticsEngine::Level DiagLevel,
 const clang::Diagnostic &Info) {
+  // FIXME: format lazily, in case vlog is off.
   SmallString<64> Message;
   Info.FormatDiagnostic(Message);
 
@@ -32,7 +33,7 @@ void IgnoreDiagnostics::log(DiagnosticsE
 OS << ":";
   }
 
-  clangd::log("Ignored diagnostic. {0}{1}", Location, Message);
+  clangd::vlog("Ignored diagnostic. {0}{1}", Location, Message);
 }
 
 void IgnoreDiagnostics::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,


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


[PATCH] D53648: [clangd] Only log ignored diagnostics with -log=verbose.

2018-11-02 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345968: [clangd] Only log ignored diagnostics with 
-log=verbose. (authored by sammccall, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D53648

Files:
  clang-tools-extra/trunk/clangd/Compiler.cpp


Index: clang-tools-extra/trunk/clangd/Compiler.cpp
===
--- clang-tools-extra/trunk/clangd/Compiler.cpp
+++ clang-tools-extra/trunk/clangd/Compiler.cpp
@@ -20,6 +20,7 @@
 
 void IgnoreDiagnostics::log(DiagnosticsEngine::Level DiagLevel,
 const clang::Diagnostic &Info) {
+  // FIXME: format lazily, in case vlog is off.
   SmallString<64> Message;
   Info.FormatDiagnostic(Message);
 
@@ -32,7 +33,7 @@
 OS << ":";
   }
 
-  clangd::log("Ignored diagnostic. {0}{1}", Location, Message);
+  clangd::vlog("Ignored diagnostic. {0}{1}", Location, Message);
 }
 
 void IgnoreDiagnostics::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,


Index: clang-tools-extra/trunk/clangd/Compiler.cpp
===
--- clang-tools-extra/trunk/clangd/Compiler.cpp
+++ clang-tools-extra/trunk/clangd/Compiler.cpp
@@ -20,6 +20,7 @@
 
 void IgnoreDiagnostics::log(DiagnosticsEngine::Level DiagLevel,
 const clang::Diagnostic &Info) {
+  // FIXME: format lazily, in case vlog is off.
   SmallString<64> Message;
   Info.FormatDiagnostic(Message);
 
@@ -32,7 +33,7 @@
 OS << ":";
   }
 
-  clangd::log("Ignored diagnostic. {0}{1}", Location, Message);
+  clangd::vlog("Ignored diagnostic. {0}{1}", Location, Message);
 }
 
 void IgnoreDiagnostics::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54033: [clang-tidy] Untangle layering in ClangTidyDiagnosticConsumer somewhat. NFC

2018-11-02 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

This looks clearer!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54033



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


[clang-tools-extra] r345969 - [clangd] Remove didOpen extraFlags extension.

2018-11-02 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Fri Nov  2 06:06:55 2018
New Revision: 345969

URL: http://llvm.org/viewvc/llvm-project?rev=345969&view=rev
Log:
[clangd] Remove didOpen extraFlags extension.

Summary:
This was added in D34947 to support YCM, but YCM actually provides *all* args,
and this was never actually used.
Meanwhile, we grew another extension that allows specifying all args.

I did find one user of this extension: https://github.com/thomasjo/atom-ide-cpp.
I'll reach out, there are multiple good alternatives:
 - compile_commands.txt can serve the same purpose as .clang_complete there
 - we can add an extension to support setting the fallback command

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

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

Removed:
clang-tools-extra/trunk/test/clangd/extra-flags.test
Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdLSPServer.h
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=345969&r1=345968&r2=345969&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Fri Nov  2 06:06:55 2018
@@ -366,8 +366,6 @@ void ClangdLSPServer::onShutdown(const S
 void ClangdLSPServer::onDocumentDidOpen(
 const DidOpenTextDocumentParams &Params) {
   PathRef File = Params.textDocument.uri.file();
-  if (Params.metadata && !Params.metadata->extraFlags.empty())
-CDB->setExtraFlagsForFile(File, std::move(Params.metadata->extraFlags));
 
   const std::string &Contents = Params.textDocument.text;
 
@@ -811,17 +809,5 @@ bool ClangdLSPServer::CompilationDB::set
   ->setCompilationCommandForFile(File, std::move(CompilationCommand));
 }
 
-void ClangdLSPServer::CompilationDB::setExtraFlagsForFile(
-PathRef File, std::vector ExtraFlags) {
-  if (!IsDirectoryBased) {
-elog("Trying to set extra flags for {0} while using in-memory compilation "
- "database",
- File);
-return;
-  }
-  static_cast(CDB.get())
-  ->setExtraFlagsForFile(File, std::move(ExtraFlags));
-}
-
 } // namespace clangd
 } // namespace clang

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.h?rev=345969&r1=345968&r2=345969&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.h Fri Nov  2 06:06:55 2018
@@ -121,12 +121,6 @@ private:
 setCompilationCommandForFile(PathRef File,
  tooling::CompileCommand CompilationCommand);
 
-/// Adds extra compilation flags to the compilation command for a 
particular
-/// file. Only valid for directory-based CDB, no-op and error log on
-/// InMemoryCDB;
-void setExtraFlagsForFile(PathRef File,
-  std::vector ExtraFlags);
-
 /// Returns a CDB that should be used to get compile commands for the
 /// current instance of ClangdLSPServer.
 GlobalCompilationDatabase &getCDB() { return *CDB; }

Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp?rev=345969&r1=345968&r2=345969&view=diff
==
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp (original)
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Fri Nov  2 
06:06:55 2018
@@ -41,45 +41,14 @@ Optional
 DirectoryBasedGlobalCompilationDatabase::getCompileCommand(PathRef File) const 
{
   if (auto CDB = getCDBForFile(File)) {
 auto Candidates = CDB->getCompileCommands(File);
-if (!Candidates.empty()) {
-  addExtraFlags(File, Candidates.front());
+if (!Candidates.empty())
   return std::move(Candidates.front());
-}
   } else {
 log("Failed to find compilation database for {0}", File);
   }
   return None;
 }
 
-tooling::CompileCommand
-DirectoryBasedGlobalCompilationDatabase::getFallbackCommand(
-PathRef File) const {
-  auto C = GlobalCompilationDatabase::getFallbackCommand(File);
-  addExtraFlags(File, C);
-  return C;
-}
-
-void DirectoryBasedGlobalCompilationDatabase::setExtraFlagsForFile(
-PathRef File, std::vector ExtraFlags) {
-  std::lock_guard Lock(Mutex);
-  ExtraFlagsForFile[File] = std::move(ExtraFlags);
-}
-
-void Director

[PATCH] D53687: [clangd] Make in-memory CDB always available as an overlay, refactor.

2018-11-02 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE345970: [clangd] Make in-memory CDB always available as an 
overlay, refactor. (authored by sammccall, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53687?vs=171098&id=172342#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53687

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/GlobalCompilationDatabaseTests.cpp

Index: unittests/clangd/GlobalCompilationDatabaseTests.cpp
===
--- unittests/clangd/GlobalCompilationDatabaseTests.cpp
+++ unittests/clangd/GlobalCompilationDatabaseTests.cpp
@@ -33,6 +33,61 @@
testPath("foo/bar.h")));
 }
 
+static tooling::CompileCommand cmd(StringRef File, StringRef Arg) {
+  return tooling::CompileCommand(testRoot(), File, {"clang", Arg, File}, "");
+}
+
+class OverlayCDBTest : public ::testing::Test {
+  class BaseCDB : public GlobalCompilationDatabase {
+  public:
+Optional
+getCompileCommand(StringRef File) const override {
+  if (File == testPath("foo.cc"))
+return cmd(File, "-DA=1");
+  return None;
+}
+
+tooling::CompileCommand getFallbackCommand(StringRef File) const override {
+  return cmd(File, "-DA=2");
+}
+  };
+
+protected:
+  OverlayCDBTest() : Base(llvm::make_unique()) {}
+  std::unique_ptr Base;
+};
+
+TEST_F(OverlayCDBTest, GetCompileCommand) {
+  OverlayCDB CDB(Base.get());
+  EXPECT_EQ(CDB.getCompileCommand(testPath("foo.cc")),
+Base->getCompileCommand(testPath("foo.cc")));
+  EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), llvm::None);
+
+  auto Override = cmd(testPath("foo.cc"), "-DA=3");
+  CDB.setCompileCommand(testPath("foo.cc"), Override);
+  EXPECT_EQ(CDB.getCompileCommand(testPath("foo.cc")), Override);
+  EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), llvm::None);
+  CDB.setCompileCommand(testPath("missing.cc"), Override);
+  EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), Override);
+}
+
+TEST_F(OverlayCDBTest, GetFallbackCommand) {
+  OverlayCDB CDB(Base.get(), {"-DA=4"});
+  EXPECT_THAT(CDB.getFallbackCommand(testPath("bar.cc")).CommandLine,
+  ElementsAre("clang", "-DA=2", testPath("bar.cc"), "-DA=4"));
+}
+
+TEST_F(OverlayCDBTest, NoBase) {
+  OverlayCDB CDB(nullptr, {"-DA=6"});
+  EXPECT_EQ(CDB.getCompileCommand(testPath("bar.cc")), None);
+  auto Override = cmd(testPath("bar.cc"), "-DA=5");
+  CDB.setCompileCommand(testPath("bar.cc"), Override);
+  EXPECT_EQ(CDB.getCompileCommand(testPath("bar.cc")), Override);
+
+  EXPECT_THAT(CDB.getFallbackCommand(testPath("foo.cc")).CommandLine,
+  ElementsAre("clang", testPath("foo.cc"), "-DA=6"));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -322,7 +322,7 @@
   InputStyle);
   ClangdLSPServer LSPServer(
   *Transport, CCOpts, CompileCommandsDirPath,
-  /*ShouldUseInMemoryCDB=*/CompileArgsFrom == LSPCompileArgs, Opts);
+  /*UseDirBasedCDB=*/CompileArgsFrom == FilesystemCompileArgs, Opts);
   constexpr int NoShutdownRequestErrorCode = 1;
   set_thread_name("clangd.main");
   return LSPServer.run() ? 0 : NoShutdownRequestErrorCode;
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -305,11 +305,12 @@
   ErrorCode::InvalidRequest));
   if (const auto &Dir = Params.initializationOptions.compilationDatabasePath)
 CompileCommandsDir = Dir;
-  CDB.emplace(UseInMemoryCDB
-  ? CompilationDB::makeInMemory()
-  : CompilationDB::makeDirectoryBased(CompileCommandsDir));
-  Server.emplace(CDB->getCDB(), FSProvider,
- static_cast(*this), ClangdServerOpts);
+  if (UseDirBasedCDB)
+BaseCDB = llvm::make_unique(
+CompileCommandsDir);
+  CDB.emplace(BaseCDB.get());
+  Server.emplace(*CDB, FSProvider, static_cast(*this),
+ ClangdServerOpts);
   applyConfiguration(Params.initializationOptions.ConfigSettings);
 
   CCOpts.EnableSnippets = Params.capabilities.CompletionSnippets;
@@ -658,12 +659,14 @@
 /// The opened files need to be reparsed only when some existing
 /// entries are changed.
 PathRef File = Entry.first;
-if (!CDB->setCompilationCommandForFile(
-File, tooling::CompileCommand(
-  std::move(Entry.second.workingDirectory), File,
-  std::move(Entry.second.compilationCommand),
-  /*Output=*/"")))
-  ShouldReparseOpenFiles = true;
+

[PATCH] D53641: [clangd] Remove didOpen extraFlags extension.

2018-11-02 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE345969: [clangd] Remove didOpen extraFlags extension. 
(authored by sammccall, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53641?vs=170858&id=172341#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53641

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  test/clangd/extra-flags.test

Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -366,8 +366,6 @@
 void ClangdLSPServer::onDocumentDidOpen(
 const DidOpenTextDocumentParams &Params) {
   PathRef File = Params.textDocument.uri.file();
-  if (Params.metadata && !Params.metadata->extraFlags.empty())
-CDB->setExtraFlagsForFile(File, std::move(Params.metadata->extraFlags));
 
   const std::string &Contents = Params.textDocument.text;
 
@@ -811,17 +809,5 @@
   ->setCompilationCommandForFile(File, std::move(CompilationCommand));
 }
 
-void ClangdLSPServer::CompilationDB::setExtraFlagsForFile(
-PathRef File, std::vector ExtraFlags) {
-  if (!IsDirectoryBased) {
-elog("Trying to set extra flags for {0} while using in-memory compilation "
- "database",
- File);
-return;
-  }
-  static_cast(CDB.get())
-  ->setExtraFlagsForFile(File, std::move(ExtraFlags));
-}
-
 } // namespace clangd
 } // namespace clang
Index: clangd/GlobalCompilationDatabase.cpp
===
--- clangd/GlobalCompilationDatabase.cpp
+++ clangd/GlobalCompilationDatabase.cpp
@@ -41,45 +41,14 @@
 DirectoryBasedGlobalCompilationDatabase::getCompileCommand(PathRef File) const {
   if (auto CDB = getCDBForFile(File)) {
 auto Candidates = CDB->getCompileCommands(File);
-if (!Candidates.empty()) {
-  addExtraFlags(File, Candidates.front());
+if (!Candidates.empty())
   return std::move(Candidates.front());
-}
   } else {
 log("Failed to find compilation database for {0}", File);
   }
   return None;
 }
 
-tooling::CompileCommand
-DirectoryBasedGlobalCompilationDatabase::getFallbackCommand(
-PathRef File) const {
-  auto C = GlobalCompilationDatabase::getFallbackCommand(File);
-  addExtraFlags(File, C);
-  return C;
-}
-
-void DirectoryBasedGlobalCompilationDatabase::setExtraFlagsForFile(
-PathRef File, std::vector ExtraFlags) {
-  std::lock_guard Lock(Mutex);
-  ExtraFlagsForFile[File] = std::move(ExtraFlags);
-}
-
-void DirectoryBasedGlobalCompilationDatabase::addExtraFlags(
-PathRef File, tooling::CompileCommand &C) const {
-  std::lock_guard Lock(Mutex);
-
-  auto It = ExtraFlagsForFile.find(File);
-  if (It == ExtraFlagsForFile.end())
-return;
-
-  auto &Args = C.CommandLine;
-  assert(Args.size() >= 2 && "Expected at least [compiler, source file]");
-  // The last argument of CommandLine is the name of the input file.
-  // Add ExtraFlags before it.
-  Args.insert(Args.end() - 1, It->second.begin(), It->second.end());
-}
-
 tooling::CompilationDatabase *
 DirectoryBasedGlobalCompilationDatabase::getCDBInDirLocked(PathRef Dir) const {
   // FIXME(ibiryukov): Invalidate cached compilation databases on changes
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -175,11 +175,6 @@
 llvm::json::Value toJSON(const Location &);
 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Location &);
 
-struct Metadata {
-  std::vector extraFlags;
-};
-bool fromJSON(const llvm::json::Value &, Metadata &);
-
 struct TextEdit {
   /// The range of the text document to be manipulated. To insert
   /// text into a document create a range where start === end.
@@ -411,9 +406,6 @@
 struct DidOpenTextDocumentParams {
   /// The document that was opened.
   TextDocumentItem textDocument;
-
-  /// Extension storing per-file metadata, such as compilation flags.
-  llvm::Optional metadata;
 };
 bool fromJSON(const llvm::json::Value &, DidOpenTextDocumentParams &);
 
Index: clangd/ClangdLSPServer.h
===
--- clangd/ClangdLSPServer.h
+++ clangd/ClangdLSPServer.h
@@ -121,12 +121,6 @@
 setCompilationCommandForFile(PathRef File,
  tooling::CompileCommand CompilationCommand);
 
-/// Adds extra compilation flags to the compilation command for a particular
-/// file. Only valid for directory-based CDB, no-op and error log on
-/// InMemoryCDB;
-void setExtraFlagsForFile(PathRef File,
-  std::vector ExtraFlags);
-
 /// Returns a CDB that should be used to get compile commands for the
 /// current instance of ClangdLSPServer.
 GlobalCompilationDatabase &getCDB() { return *CD

[clang-tools-extra] r345970 - [clangd] Make in-memory CDB always available as an overlay, refactor.

2018-11-02 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Fri Nov  2 06:09:36 2018
New Revision: 345970

URL: http://llvm.org/viewvc/llvm-project?rev=345970&view=rev
Log:
[clangd] Make in-memory CDB always available as an overlay, refactor.

Summary:
The new implementation is a GlobalCompilationDatabase that overlays a base.
Normally this is the directory-based CDB.
To preserve the behavior of compile_args_from=LSP, the base may be null.

The OverlayCDB is always present, and so the extensions to populate it
are always supported.

It also allows overriding the flags of the fallback command. This is
just unit-tested for now, but the plan is to expose this as an extension
on the initialize message. This addresses use cases like
https://github.com/thomasjo/atom-ide-cpp/issues/16

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdLSPServer.h
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=345970&r1=345969&r2=345970&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Fri Nov  2 06:09:36 2018
@@ -305,11 +305,12 @@ void ClangdLSPServer::onInitialize(const
   ErrorCode::InvalidRequest));
   if (const auto &Dir = Params.initializationOptions.compilationDatabasePath)
 CompileCommandsDir = Dir;
-  CDB.emplace(UseInMemoryCDB
-  ? CompilationDB::makeInMemory()
-  : CompilationDB::makeDirectoryBased(CompileCommandsDir));
-  Server.emplace(CDB->getCDB(), FSProvider,
- static_cast(*this), ClangdServerOpts);
+  if (UseDirBasedCDB)
+BaseCDB = llvm::make_unique(
+CompileCommandsDir);
+  CDB.emplace(BaseCDB.get());
+  Server.emplace(*CDB, FSProvider, static_cast(*this),
+ ClangdServerOpts);
   applyConfiguration(Params.initializationOptions.ConfigSettings);
 
   CCOpts.EnableSnippets = Params.capabilities.CompletionSnippets;
@@ -658,12 +659,14 @@ void ClangdLSPServer::applyConfiguration
 /// The opened files need to be reparsed only when some existing
 /// entries are changed.
 PathRef File = Entry.first;
-if (!CDB->setCompilationCommandForFile(
-File, tooling::CompileCommand(
-  std::move(Entry.second.workingDirectory), File,
-  std::move(Entry.second.compilationCommand),
-  /*Output=*/"")))
-  ShouldReparseOpenFiles = true;
+auto Old = CDB->getCompileCommand(File);
+auto New =
+tooling::CompileCommand(std::move(Entry.second.workingDirectory), File,
+std::move(Entry.second.compilationCommand),
+/*Output=*/"");
+if (Old != New)
+  CDB->setCompileCommand(File, std::move(New));
+ShouldReparseOpenFiles = true;
   }
   if (ShouldReparseOpenFiles)
 reparseOpenedFiles();
@@ -684,12 +687,12 @@ void ClangdLSPServer::onReference(const
 ClangdLSPServer::ClangdLSPServer(class Transport &Transp,
  const clangd::CodeCompleteOptions &CCOpts,
  Optional CompileCommandsDir,
- bool ShouldUseInMemoryCDB,
+ bool UseDirBasedCDB,
  const ClangdServer::Options &Opts)
 : Transp(Transp), MsgHandler(new MessageHandler(*this)), CCOpts(CCOpts),
   SupportedSymbolKinds(defaultSymbolKinds()),
   SupportedCompletionItemKinds(defaultCompletionItemKinds()),
-  UseInMemoryCDB(ShouldUseInMemoryCDB),
+  UseDirBasedCDB(UseDirBasedCDB),
   CompileCommandsDir(std::move(CompileCommandsDir)),
   ClangdServerOpts(Opts) {
   // clang-format off
@@ -783,31 +786,5 @@ void ClangdLSPServer::reparseOpenedFiles
 WantDiagnostics::Auto);
 }
 
-ClangdLSPServer::CompilationDB ClangdLSPServer::CompilationDB::makeInMemory() {
-  return CompilationDB(llvm::make_unique(),
-   /*IsDirectoryBased=*/false);
-}
-
-ClangdLSPServer::CompilationDB
-ClangdLSPServer::CompilationDB::makeDirectoryBased(
-Optional CompileCommandsDir) {
-  auto CDB = llvm::make_unique(
-  std::move(CompileCommandsDir));
-  return CompilationDB(std::move(CDB),
-   /*IsDirectoryBased=*/true);
-}
-
-bool ClangdLSPServer::CompilationDB::setCompilationCommandForFile(

[PATCH] D53687: [clangd] Make in-memory CDB always available as an overlay, refactor.

2018-11-02 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345970: [clangd] Make in-memory CDB always available as an 
overlay, refactor. (authored by sammccall, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53687?vs=171098&id=172343#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53687

Files:
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  clang-tools-extra/trunk/clangd/ClangdLSPServer.h
  clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h
  clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
  clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/GlobalCompilationDatabaseTests.cpp
@@ -33,6 +33,61 @@
testPath("foo/bar.h")));
 }
 
+static tooling::CompileCommand cmd(StringRef File, StringRef Arg) {
+  return tooling::CompileCommand(testRoot(), File, {"clang", Arg, File}, "");
+}
+
+class OverlayCDBTest : public ::testing::Test {
+  class BaseCDB : public GlobalCompilationDatabase {
+  public:
+Optional
+getCompileCommand(StringRef File) const override {
+  if (File == testPath("foo.cc"))
+return cmd(File, "-DA=1");
+  return None;
+}
+
+tooling::CompileCommand getFallbackCommand(StringRef File) const override {
+  return cmd(File, "-DA=2");
+}
+  };
+
+protected:
+  OverlayCDBTest() : Base(llvm::make_unique()) {}
+  std::unique_ptr Base;
+};
+
+TEST_F(OverlayCDBTest, GetCompileCommand) {
+  OverlayCDB CDB(Base.get());
+  EXPECT_EQ(CDB.getCompileCommand(testPath("foo.cc")),
+Base->getCompileCommand(testPath("foo.cc")));
+  EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), llvm::None);
+
+  auto Override = cmd(testPath("foo.cc"), "-DA=3");
+  CDB.setCompileCommand(testPath("foo.cc"), Override);
+  EXPECT_EQ(CDB.getCompileCommand(testPath("foo.cc")), Override);
+  EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), llvm::None);
+  CDB.setCompileCommand(testPath("missing.cc"), Override);
+  EXPECT_EQ(CDB.getCompileCommand(testPath("missing.cc")), Override);
+}
+
+TEST_F(OverlayCDBTest, GetFallbackCommand) {
+  OverlayCDB CDB(Base.get(), {"-DA=4"});
+  EXPECT_THAT(CDB.getFallbackCommand(testPath("bar.cc")).CommandLine,
+  ElementsAre("clang", "-DA=2", testPath("bar.cc"), "-DA=4"));
+}
+
+TEST_F(OverlayCDBTest, NoBase) {
+  OverlayCDB CDB(nullptr, {"-DA=6"});
+  EXPECT_EQ(CDB.getCompileCommand(testPath("bar.cc")), None);
+  auto Override = cmd(testPath("bar.cc"), "-DA=5");
+  CDB.setCompileCommand(testPath("bar.cc"), Override);
+  EXPECT_EQ(CDB.getCompileCommand(testPath("bar.cc")), Override);
+
+  EXPECT_THAT(CDB.getFallbackCommand(testPath("foo.cc")).CommandLine,
+  ElementsAre("clang", testPath("foo.cc"), "-DA=6"));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h
===
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h
@@ -74,23 +74,30 @@
   llvm::Optional CompileCommandsDir;
 };
 
-/// Gets compile args from an in-memory mapping based on a filepath. Typically
-/// used by clients who provide the compile commands themselves.
-class InMemoryCompilationDb : public GlobalCompilationDatabase {
+/// Wraps another compilation database, and supports overriding the commands
+/// using an in-memory mapping.
+class OverlayCDB : public GlobalCompilationDatabase {
 public:
-  /// Gets compile command for \p File from the stored mapping.
+  // Base may be null, in which case no entries are inherited.
+  // FallbackFlags are added to the fallback compile command.
+  OverlayCDB(const GlobalCompilationDatabase *Base,
+ std::vector FallbackFlags = {})
+  : Base(Base), FallbackFlags(std::move(FallbackFlags)) {}
+
   llvm::Optional
   getCompileCommand(PathRef File) const override;
+  tooling::CompileCommand getFallbackCommand(PathRef File) const override;
 
-  /// Sets the compilation command for a particular file.
-  ///
-  /// \returns True if the File had no compilation command before.
-  bool setCompilationCommandForFile(PathRef File,
-tooling::CompileCommand CompilationCommand);
+  /// Sets or clears the compilation command for a particular file.
+  void
+  setCompileCommand(PathRef File,
+llvm::Optional CompilationCommand);
 
 private:
   mutable std::mutex Mutex;
   llvm::StringMap Commands; /* GUARDED_BY(Mut) */
+  const GlobalCo

[clang-tools-extra] r345971 - Reapply Logging: make os_log buffer size an integer constant expression.

2018-11-02 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Fri Nov  2 06:14:11 2018
New Revision: 345971

URL: http://llvm.org/viewvc/llvm-project?rev=345971&view=rev
Log:
Reapply Logging: make os_log buffer size an integer constant expression.

The size of an os_log buffer is known at any stage of compilation, so making it
a constant expression means that the common idiom of declaring a buffer for it
won't result in a VLA. That allows the compiler to skip saving and restoring
the stack pointer around such buffers.

This also moves the OSLog and other FormatString helpers from
libclangAnalysis to libclangAST to avoid a circular dependency.

Modified:
clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/cert/StrToNumCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt?rev=345971&r1=345970&r2=345971&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt Fri Nov  2 06:14:11 
2018
@@ -15,7 +15,6 @@ add_clang_library(clangTidyCERTModule
   VariadicFunctionDefCheck.cpp
 
   LINK_LIBS
-  clangAnalysis
   clangAST
   clangASTMatchers
   clangBasic

Modified: clang-tools-extra/trunk/clang-tidy/cert/StrToNumCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/StrToNumCheck.cpp?rev=345971&r1=345970&r2=345971&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/StrToNumCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/StrToNumCheck.cpp Fri Nov  2 
06:14:11 2018
@@ -10,7 +10,7 @@
 #include "StrToNumCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/Analysis/Analyses/FormatString.h"
+#include "clang/AST/FormatString.h"
 #include "llvm/ADT/StringSwitch.h"
 #include 
 


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


[PATCH] D53856: [analyzer] Put llvm.Conventions back in alpha

2018-11-02 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs added a comment.

In https://reviews.llvm.org/D53856#1280408, @Szelethus wrote:

> In https://reviews.llvm.org/D53856#1279887, @NoQ wrote:
>
> > This might be also covered by @rnkovacs's string buffer escape checker - 
> > either already or eventually, it'll become just yet another string view API 
> > that the checker supports.
>
>
> I thought about that too, adding some `StringRef` specific information to 
> that checker makes more sense then essentially duplicating the logic. 
> However, what @MTC mentioned about `ArrayRef` would be a neat addition 
> too, and maybe it isn't worth making `InnerPointerChecker` //that// general.
>
> @rnkovacs, any thoughts?


I agree, adding `StringRef` support to the buffer escape checker around the 
time we add `string_view` will be great. Also, we named it 
`InnerPointerChecker` to allow for covering more general structures in the 
future, so I guess `ArrayRef`s may also be added eventually. Unfortunately, I 
have some other tasks to finish before getting to these, so I think this patch 
is fine now as-is.


https://reviews.llvm.org/D53856



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


[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl

2018-11-02 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta updated this revision to Diff 172348.
takuto.ikuta marked an inline comment as done.
takuto.ikuta added a comment.

Fix check-prefix


https://reviews.llvm.org/D51340

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/CLCompatOptions.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp
  clang/test/Driver/cl-options.c

Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -490,6 +490,11 @@
 // RUN: %clang_cl /Zc:threadSafeInit /c -### -- %s 2>&1 | FileCheck -check-prefix=ThreadSafeStatics %s
 // ThreadSafeStatics-NOT: "-fno-threadsafe-statics"
 
+// RUN: %clang_cl /Zc:dllexportInlines- /c -### -- %s 2>&1 | FileCheck -check-prefix=NoDllExportInlines %s
+// NoDllExportInlines: "-fno-dllexport-inlines"
+// RUN: %clang_cl /Zc:dllexportInlines /c -### -- %s 2>&1 | FileCheck -check-prefix=DllExportInlines %s
+// DllExportInlines-NOT: "-fno-dllexport-inlines"
+
 // RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
 // Zi: "-gcodeview"
 // Zi: "-debug-info-kind=limited"
Index: clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp
@@ -0,0 +1,133 @@
+// RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc   \
+// RUN: -disable-llvm-passes\
+// RUN: -fno-dllexport-inlines -emit-llvm -O1 -o - |\
+// RUN: FileCheck --check-prefix=CHECK --check-prefix=NOEXPORTINLINE %s
+
+// RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc   \
+// RUN: -disable-llvm-passes\
+// RUN: -emit-llvm -O1 -o - |   \
+// RUN: FileCheck --check-prefix=CHECK  --check-prefix=EXPORTINLINE %s
+
+
+struct __declspec(dllexport) ExportedClass {
+
+  // NOEXPORTINLINE-DAG: define linkonce_odr dso_local void @"?InclassDefFunc@ExportedClass@@
+  // EXPORTINLINE-DAG: define weak_odr dso_local dllexport void @"?InclassDefFunc@ExportedClass@@
+  void InclassDefFunc() {}
+
+  // CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFuncWithStaticVariable@ExportedClass@@QEAAHXZ"
+  int InclassDefFuncWithStaticVariable() {
+// CHECK-DAG: @"?static_variable@?1??InclassDefFuncWithStaticVariable@ExportedClass@@QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
+static int static_variable = 0;
+++static_variable;
+return static_variable;
+  }
+
+  // CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFunctWithLambdaStaticVariable@ExportedClass@@QEAAHXZ"
+  int InclassDefFunctWithLambdaStaticVariable() {
+// CHECK-DAG: @"?static_x@?2???R@?0??InclassDefFunctWithLambdaStaticVariable@ExportedClass@@QEAAHXZ@QEBA?A?@@XZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
+return ([]() { static int static_x; return ++static_x; })();
+  }
+
+  // NOEXPORTINLINE-DAG: define linkonce_odr dso_local void @"?InlineOutclassDefFunc@ExportedClass@@QEAAXXZ
+  // EXPORTINLINE-DAG: define weak_odr dso_local dllexport void @"?InlineOutclassDefFunc@ExportedClass@@QEAAXXZ
+  inline void InlineOutclassDefFunc();
+
+  // CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InlineOutclassDefFuncWithStaticVariable@ExportedClass@@QEAAHXZ"
+  inline int InlineOutclassDefFuncWithStaticVariable();
+
+  // CHECK-DAG: define dso_local dllexport void @"?OutoflineDefFunc@ExportedClass@@QEAAXXZ"
+  void OutoflineDefFunc();
+};
+
+void ExportedClass::OutoflineDefFunc() {}
+
+inline void ExportedClass::InlineOutclassDefFunc() {}
+
+inline int ExportedClass::InlineOutclassDefFuncWithStaticVariable() {
+  static int static_variable = 0;
+  return ++static_variable;
+}
+
+void ExportedClassUser() {
+  ExportedClass a;
+  a.InclassDefFunc();
+  a.InlineOutclassDefFunc();
+}
+
+template
+struct __declspec(dllexport) TemplateExportedClass {
+  void InclassDefFunc() {}
+
+  int InclassDefFuncWithStaticVariable() {
+static int static_x = 0;
+return ++static_x;
+  }
+};
+
+class A11{};
+class B22{};
+
+// CHECK-DAG: define weak_odr dso_local dllexport void @"?InclassDefFunc@?$TemplateExportedClass@VA11QEAAXXZ"
+// CHECK-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFuncWithStaticVariable@?$TemplateExportedClass@VA11QEAAHXZ"
+// CHECK-DAG: @"?static_x@?2??InclassDefFuncWithStaticVariable@?$TemplateExportedClass@VA11QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
+template class TemplateExportedClass;
+
+// NOEXPORTINLINE-DAG: def

[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl

2018-11-02 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta added a comment.

Thank you! I'll submit this if other people does not have other comments.




Comment at: clang/test/CodeGenCXX/dllexport-no-dllexport-inlines.cpp:9
+// RUN: -emit-llvm -O1 -o - |   \
+// RUN: FileCheck --check-prefix=CHECK %s
+

hans wrote:
> Did the "EXPORTINLINE" check-prefix get lost here?
Good catch!


https://reviews.llvm.org/D51340



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


[PATCH] D45783: [DEBUGINFO, NVPTX] Render `-no-cuda-debug` LLVM option when required.

2018-11-02 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev abandoned this revision.
ABataev added a comment.

The patch is not required anymore as it is implemented in the different way


Repository:
  rC Clang

https://reviews.llvm.org/D45783



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


[PATCH] D53984: [mips] Fix broken MSA test

2018-11-02 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D53984



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


[clang-tools-extra] r345973 - [clangd] Add fallbackFlags initialization extension.

2018-11-02 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Fri Nov  2 07:07:51 2018
New Revision: 345973

URL: http://llvm.org/viewvc/llvm-project?rev=345973&view=rev
Log:
[clangd] Add fallbackFlags initialization extension.

Summary:
This allows customizing the flags used when no compile database is
available. It addresses some uses of the old extraFlags extension.

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=345973&r1=345972&r2=345973&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Fri Nov  2 07:07:51 2018
@@ -308,7 +308,7 @@ void ClangdLSPServer::onInitialize(const
   if (UseDirBasedCDB)
 BaseCDB = llvm::make_unique(
 CompileCommandsDir);
-  CDB.emplace(BaseCDB.get());
+  CDB.emplace(BaseCDB.get(), Params.initializationOptions.fallbackFlags);
   Server.emplace(*CDB, FSProvider, static_cast(*this),
  ClangdServerOpts);
   applyConfiguration(Params.initializationOptions.ConfigSettings);
@@ -664,9 +664,10 @@ void ClangdLSPServer::applyConfiguration
 tooling::CompileCommand(std::move(Entry.second.workingDirectory), File,
 std::move(Entry.second.compilationCommand),
 /*Output=*/"");
-if (Old != New)
+if (Old != New) {
   CDB->setCompileCommand(File, std::move(New));
-ShouldReparseOpenFiles = true;
+  ShouldReparseOpenFiles = true;
+}
   }
   if (ShouldReparseOpenFiles)
 reparseOpenedFiles();

Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=345973&r1=345972&r2=345973&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Fri Nov  2 07:07:51 2018
@@ -669,6 +669,7 @@ bool fromJSON(const json::Value &Params,
 
   fromJSON(Params, Opts.ConfigSettings);
   O.map("compilationDatabasePath", Opts.compilationDatabasePath);
+  O.map("fallbackFlags", Opts.fallbackFlags);
   return true;
 }
 

Modified: clang-tools-extra/trunk/clangd/Protocol.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.h?rev=345973&r1=345972&r2=345973&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.h (original)
+++ clang-tools-extra/trunk/clangd/Protocol.h Fri Nov  2 07:07:51 2018
@@ -368,6 +368,10 @@ struct InitializationOptions {
   ConfigurationSettings ConfigSettings;
 
   llvm::Optional compilationDatabasePath;
+  // Additional flags to be included in the "fallback command" used when
+  // the compilation database doesn't describe an opened file.
+  // The command used will be approximately `clang $FILE $fallbackFlags`.
+  std::vector fallbackFlags;
 };
 bool fromJSON(const llvm::json::Value &, InitializationOptions &);
 


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


[PATCH] D53688: [clangd] Add fallbackFlags initialization extension.

2018-11-02 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE345973: [clangd] Add fallbackFlags initialization 
extension. (authored by sammccall, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53688?vs=171036&id=172351#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53688

Files:
  clangd/ClangdLSPServer.cpp
  clangd/Protocol.cpp
  clangd/Protocol.h


Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -669,6 +669,7 @@
 
   fromJSON(Params, Opts.ConfigSettings);
   O.map("compilationDatabasePath", Opts.compilationDatabasePath);
+  O.map("fallbackFlags", Opts.fallbackFlags);
   return true;
 }
 
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -368,6 +368,10 @@
   ConfigurationSettings ConfigSettings;
 
   llvm::Optional compilationDatabasePath;
+  // Additional flags to be included in the "fallback command" used when
+  // the compilation database doesn't describe an opened file.
+  // The command used will be approximately `clang $FILE $fallbackFlags`.
+  std::vector fallbackFlags;
 };
 bool fromJSON(const llvm::json::Value &, InitializationOptions &);
 
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -308,7 +308,7 @@
   if (UseDirBasedCDB)
 BaseCDB = llvm::make_unique(
 CompileCommandsDir);
-  CDB.emplace(BaseCDB.get());
+  CDB.emplace(BaseCDB.get(), Params.initializationOptions.fallbackFlags);
   Server.emplace(*CDB, FSProvider, static_cast(*this),
  ClangdServerOpts);
   applyConfiguration(Params.initializationOptions.ConfigSettings);
@@ -664,9 +664,10 @@
 tooling::CompileCommand(std::move(Entry.second.workingDirectory), File,
 std::move(Entry.second.compilationCommand),
 /*Output=*/"");
-if (Old != New)
+if (Old != New) {
   CDB->setCompileCommand(File, std::move(New));
-ShouldReparseOpenFiles = true;
+  ShouldReparseOpenFiles = true;
+}
   }
   if (ShouldReparseOpenFiles)
 reparseOpenedFiles();


Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -669,6 +669,7 @@
 
   fromJSON(Params, Opts.ConfigSettings);
   O.map("compilationDatabasePath", Opts.compilationDatabasePath);
+  O.map("fallbackFlags", Opts.fallbackFlags);
   return true;
 }
 
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -368,6 +368,10 @@
   ConfigurationSettings ConfigSettings;
 
   llvm::Optional compilationDatabasePath;
+  // Additional flags to be included in the "fallback command" used when
+  // the compilation database doesn't describe an opened file.
+  // The command used will be approximately `clang $FILE $fallbackFlags`.
+  std::vector fallbackFlags;
 };
 bool fromJSON(const llvm::json::Value &, InitializationOptions &);
 
Index: clangd/ClangdLSPServer.cpp
===
--- clangd/ClangdLSPServer.cpp
+++ clangd/ClangdLSPServer.cpp
@@ -308,7 +308,7 @@
   if (UseDirBasedCDB)
 BaseCDB = llvm::make_unique(
 CompileCommandsDir);
-  CDB.emplace(BaseCDB.get());
+  CDB.emplace(BaseCDB.get(), Params.initializationOptions.fallbackFlags);
   Server.emplace(*CDB, FSProvider, static_cast(*this),
  ClangdServerOpts);
   applyConfiguration(Params.initializationOptions.ConfigSettings);
@@ -664,9 +664,10 @@
 tooling::CompileCommand(std::move(Entry.second.workingDirectory), File,
 std::move(Entry.second.compilationCommand),
 /*Output=*/"");
-if (Old != New)
+if (Old != New) {
   CDB->setCompileCommand(File, std::move(New));
-ShouldReparseOpenFiles = true;
+  ShouldReparseOpenFiles = true;
+}
   }
   if (ShouldReparseOpenFiles)
 reparseOpenedFiles();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52984: [analyzer] Checker reviewer's checklist

2018-11-02 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 172354.
xazax.hun added a comment.

This new version based on the bullets by NoQ. I also included some additional 
ones from other lists and added some new ones, e.g. the NamedDecl::getName will 
fail if the name of the decl is not a single token. I also reordered a bit. 
Advice that is more advanced and guidelines that are less likely to be violated 
should be closer to the bottom of the list.

Please let me know if I forgot something or the order of the list should be 
changed.


https://reviews.llvm.org/D52984

Files:
  www/analyzer/checker_dev_manual.html

Index: www/analyzer/checker_dev_manual.html
===
--- www/analyzer/checker_dev_manual.html
+++ www/analyzer/checker_dev_manual.html
@@ -714,6 +714,103 @@
 a lot of information.
 
 
+Making Your Check Better
+
+User facing documentation is important for adoption! Make sure the check list updated
+at the homepage of the analyzer. Also ensure that the description is good quality in
+Checkers.td.
+Introduce BugReporterVisitors to emit additional notes that better explain the found 
+bug to the user. There are some existing visitors that might be useful for your check,
+e.g. trackNullOrUndefValue. For example, SimpleStreamChecker should highlight
+the event of opening the file when reporting a file descriptor leak.
+If the check tracks anything in the program state, it needs to implement the
+checkDeadSymbolscallback to clean the state up.
+The check should handle correctly if a tracked symbol is passed to a function that is
+unknown to the analyzer. checkPointerEscape callback could help you handle
+that case.
+Use safe and convenient APIs!
+
+  Always use CheckerContext::generateErrorNode and
+CheckerContext::generateNonFatalErrorNode for emitting bug reports.
+Most importantly, never emit report against CheckerContext::getPredecessor.
+  Prefer checkPreCall and checkPostCall to
+checkPreStmt and checkPostStmt.
+  Use CallDescription to detect hardcoded API calls in the program.
+  Simplify C.getState()->getSVal(E, C.getLocationContext()) to C.getSVal(E).
+
+Common sources of crashes:
+
+  CallEvent::getOriginExpr is nullable - for example, it returns null for an
+automatic destructor of a variable. The same applies to all values generated while the
+call was modeled, eg. SymbolConjured::getStmt is nullable.
+  CallEvent::getDecl is nullable - for example, it returns null for a
+  call of symbolic function pointer.
+  addTransition, generateSink, generateNonFatalErrorNode,
+generateErrorNode are nullable because you can transition to a node that you have already visited.
+  Methods of CallExpr/FunctionDecl/CallEvent that
+return arguments crash when the argument is out-of-bounds. If you checked the function name,
+it doesn't mean that the function has the expected number of arguments!
+Which is why you should use CallDescription.
+  Nullability of different entities within different kinds of symbols and regions is usually
+  documented via assertions in their constructors.
+  NamedDecl::getName will fail if the name of the declaration is not a single token,
+e.g. for destructors. You could use NamedDecl::getNameAsString for those cases.
+Note that, this method is much slower and should be used sparringly, e.g. only when generating reports
+but not during analysis.
+
+The following checker code patterns are not wrong but suspicious:
+
+  A BugReporterVisitor that matches the AST to decide when to emit note instead of
+  examining/diffing the states.
+  In State->getSVal(Region), Region is not necessarily a TypedValueRegion
+  and the optional type argument is not specified. It is likely that the checker
+  may accidentally try to dereference a void pointer.
+  Checker logic depends on whether a certain value is a Loc or NonLoc.
+It should be immediately obvious whether the SVal is a Loc or a
+NonLoc depending on the AST that is being checked. Checking whether a value
+is Loc or Unknown/Undefined or whether the value is
+NonLoc or Unknown/Undefined is totally fine.
+  New symbols are constructed in the checker via direct calls to SymbolManager,
+unless they are of SymbolMetadata class tagged by the checker,
+or they represent newly created values such as the return value in evalCall.
+For modeling arithmetic/bitwise/comparison operations, SValBuilder should be used.
+  Custom ProgramPointTags are created within the checker. There is usually
+no good reason for a checker to chain multiple nodes together, because checkers aren't worklists.
+
+Checkers are encouraged to actively participate in the analysis by sharing
+  its knowledge about the program state with the rest of the analyzer,
+  but they should not be disrupting the analysis unnecessarily:
+
+  If a checker splits program state, this must be based

[PATCH] D51484: [OpenCL] Add support of cl_intel_device_side_avc_motion_estimation extension

2018-11-02 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin added inline comments.
Herald added a reviewer: shafik.



Comment at: lib/Sema/SemaInit.cpp:8073
+  assert((Step->Type->isEventT() || Step->Type->isQueueT() ||
+  Step->Type->isOCLIntelSubgroupAVCType) &&
  "Wrong type for initialization of OpenCL opaque type.");

`isOCLIntelSubgroupAVCType) -> isOCLIntelSubgroupAVCType())`


https://reviews.llvm.org/D51484



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


r345978 - [OPENMP][NVPTX]Improve emission of the globalized variables for

2018-11-02 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Nov  2 07:54:07 2018
New Revision: 345978

URL: http://llvm.org/viewvc/llvm-project?rev=345978&view=rev
Log:
[OPENMP][NVPTX]Improve emission of the globalized variables for
target/teams/distribute regions.

Target/teams/distribute regions exist for all the time the kernel is
executed. Thus, if the variable is declared in their context and then
escape it, we can allocate global memory statically instead of
allocating it dynamically.
Patch captures all the globalized variables in target/teams/distribute
contexts, merges them into the records, one per each target region.
Those records are then joined into the union, one per compilation unit
(to save the global memory). Those units are organized into
2 x dimensional arrays, where the first dimension is
the number of blocks per SM and the second one is the number of SMs.
Runtime functions manage this global memory space between the executing
teams.

Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/OpenMP/nvptx_data_sharing.cpp
cfe/trunk/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_parallel_for_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp

cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_teams_codegen.cpp

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=345978&r1=345977&r2=345978&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Fri Nov  2 07:54:07 2018
@@ -204,6 +204,8 @@ LANGOPT(OpenMPIsDevice, 1, 0, "Gener
 LANGOPT(OpenMPCUDAMode, 1, 0, "Generate code for OpenMP pragmas in 
SIMT/SPMD mode")
 LANGOPT(OpenMPCUDAForceFullRuntime , 1, 0, "Force to use full runtime in all 
constructs when offloading to CUDA devices")
 LANGOPT(OpenMPHostCXXExceptions, 1, 0, "C++ exceptions handling in the 
host code.")
+LANGOPT(OpenMPCUDANumSMs  , 32, 0, "Number of SMs for CUDA devices.")
+LANGOPT(OpenMPCUDABlocksPerSM  , 32, 0, "Number of blocks per SM for CUDA 
devices.")
 LANGOPT(RenderScript  , 1, 0, "RenderScript")
 
 LANGOPT(CUDAIsDevice  , 1, 0, "compiling for CUDA device")

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=345978&r1=345977&r2=345978&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Nov  2 07:54:07 2018
@@ -1546,6 +1546,10 @@ def fopenmp_cuda_force_full_runtime : Fl
   Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fno_openmp_cuda_force_full_runtime : Flag<["-"], 
"fno-openmp-cuda-force-full-runtime">, Group,
   Flags<[NoArgumentUnused, HelpHidden]>;
+def fopenmp_cuda_number_of_sm_EQ : Joined<["-"], 
"fopenmp-cuda-number-of-sm=">, Group,
+  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
+def fopenmp_cuda_blocks_per_sm_EQ : Joined<["-"], 
"fopenmp-cuda-blocks-per-sm=">, Group,
+  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, 
Group;
 def foptimize_sibling_calls : Flag<["-"], "foptimize-sibling-calls">, 
Group;
 def fno_escaping_block_tail_calls : Flag<["-"], 
"fno-escaping-block-tail-calls">, Group, Flags<[CC1Option]>;

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=345978&r1=345977&r2=345978&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Fri Nov  2 07:54:07 2018
@@ -17,6 +17,7 @@
 #include "clang/AST/DeclOpenMP.h"
 #include "clang/AST/StmtOpenMP.h"
 #include "clang/AST/StmtVisitor.h"
+#include "clang/Basic/Cuda.h"
 #include "llvm/ADT/SmallPtrSet.h"
 
 using namespace clang;
@@ -100,6 +101,11 @@ enum OpenMPRTLFunctionNVPTX {
   OMPRTL_NVPTX__kmpc_parallel_level,
   /// Call to int8_t __kmpc_is_spmd_exec_mode();
   OMPRTL_NVPTX__kmpc_is_spmd_exec_mode,
+  /// Call to void __kmpc_get_team_static_memory(const void *buf, size_t size,
+  /// int16_t is_shared, const void **res);
+  OMPRTL_NVPTX__kmpc_get_team_static_memory,
+  /// Call to void __kmpc_restore_team_static_memory(int16_t is_shared);
+  OMPRTL_NVPTX_

Re: r345971 - Reapply Logging: make os_log buffer size an integer constant expression.

2018-11-02 Thread Tim Northover via cfe-commits
Hi Sam,

On 2 Nov 2018, at 13:31, Sam McCall  wrote:
> The move of OSLog.h and FormatString.h to AST doesn't look obviously correct.
> Do these really belong in this layer? I think this patch needs review from 
> someone who knows AST/ better than myself... was there a review?

Eli reviewed the change for OSLog.h in https://reviews.llvm.org/D53514 
 so that it could be used for the main part of 
the change. After that it was discovered OSLog depends on the other format 
helpers so there was still a circular dependency; I decided adding the others 
was a minor enough change to just go ahead.

The only alternative I see would be an entirely new library (“MiniAnalysis”?), 
which seems quite excessive.

> (If the do belong here: the namespaces and comments don't seem to have been 
> updated)

Good point, I’ll get onto fixing that.

Cheers.

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


[clang-tools-extra] r345979 - [clang-tidy] .reset(new X) -> make_unique() in a comment. NFC

2018-11-02 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Nov  2 08:03:43 2018
New Revision: 345979

URL: http://llvm.org/viewvc/llvm-project?rev=345979&view=rev
Log:
[clang-tidy] .reset(new X) -> make_unique() in a comment. NFC

Modified:
clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.h

Modified: clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.h?rev=345979&r1=345978&r2=345979&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.h (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.h Fri Nov  2 
08:03:43 2018
@@ -31,8 +31,8 @@ namespace utils {
 /// class MyCheck : public ClangTidyCheck {
 ///  public:
 ///   void registerPPCallbacks(CompilerInstance& Compiler) override {
-/// Inserter.reset(new IncludeInserter(&Compiler.getSourceManager(),
-///&Compiler.getLangOpts()));
+/// Inserter = 
llvm::make_unique(&Compiler.getSourceManager(),
+///   &Compiler.getLangOpts());
 /// Compiler.getPreprocessor().addPPCallbacks(
 /// Inserter->CreatePPCallback());
 ///   }


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


Re: r345971 - Reapply Logging: make os_log buffer size an integer constant expression.

2018-11-02 Thread Tim Northover via cfe-commits


> On 2 Nov 2018, at 15:03, Tim Northover  wrote:
>> (If the do belong here: the namespaces and comments don't seem to have been 
>> updated)
> 
> Good point, I’ll get onto fixing that.

Actually, do you have any particular ones in mind? After going in to make 
changes, they still look pretty good to me; I don’t think libclangAnalysis 
should have the monopoly on the term.

Cheers.

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


[PATCH] D54036: [fix][clang-tidy] fix for r345961 that introduced a test failure on Windows builds

2018-11-02 Thread Tom Weaver via Phabricator via cfe-commits
TWeaver created this revision.
TWeaver added a reviewer: sammccall.
Herald added subscribers: llvm-commits, xazax.hun.

r345961 introduced a path check in 
.\tools\clang\tools\extra\test\clang-tidy\clang-tidy-run-with-database.cpp.

r345961 added a check line for a path that only handled / on unix machines and 
not \ on windows machines.

This patch handles both cases.


Repository:
  rL LLVM

https://reviews.llvm.org/D54036

Files:
  llvm/tools/clang/tools/extra/test/clang-tidy/clang-tidy-run-with-database.cpp


Index: 
llvm/tools/clang/tools/extra/test/clang-tidy/clang-tidy-run-with-database.cpp
===
--- 
llvm/tools/clang/tools/extra/test/clang-tidy/clang-tidy-run-with-database.cpp
+++ 
llvm/tools/clang/tools/extra/test/clang-tidy/clang-tidy-run-with-database.cpp
@@ -11,7 +11,7 @@
 
 // Regression test: shouldn't crash.
 // RUN: not clang-tidy --checks=-*,modernize-use-nullptr -p %T 
%T/compilation-database-test/b/not-exist -header-filter=.* 2>&1 | FileCheck %s 
-check-prefix=CHECK-NOT-EXIST
-// CHECK-NOT-EXIST: Error while processing {{.*}}/not-exist.
+// CHECK-NOT-EXIST: Error while processing {{.*[/\\]}}not-exist.
 // CHECK-NOT-EXIST: unable to handle compilation
 // CHECK-NOT-EXIST: Found compiler error
 


Index: llvm/tools/clang/tools/extra/test/clang-tidy/clang-tidy-run-with-database.cpp
===
--- llvm/tools/clang/tools/extra/test/clang-tidy/clang-tidy-run-with-database.cpp
+++ llvm/tools/clang/tools/extra/test/clang-tidy/clang-tidy-run-with-database.cpp
@@ -11,7 +11,7 @@
 
 // Regression test: shouldn't crash.
 // RUN: not clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/b/not-exist -header-filter=.* 2>&1 | FileCheck %s -check-prefix=CHECK-NOT-EXIST
-// CHECK-NOT-EXIST: Error while processing {{.*}}/not-exist.
+// CHECK-NOT-EXIST: Error while processing {{.*[/\\]}}not-exist.
 // CHECK-NOT-EXIST: unable to handle compilation
 // CHECK-NOT-EXIST: Found compiler error
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r345982 - [OPENMP]Change the mapping type for lambda captures.

2018-11-02 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Nov  2 08:25:06 2018
New Revision: 345982

URL: http://llvm.org/viewvc/llvm-project?rev=345982&view=rev
Log:
[OPENMP]Change the mapping type for lambda captures.

The previously used combination `PTR_AND_OBJ | PRIVATE` could be used for 
mapping of some data in Fortran. Changed it to `PTR_AND_OBJ | LITERAL`.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/nvptx_lambda_capturing.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=345982&r1=345981&r2=345982&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Nov  2 08:25:06 2018
@@ -7556,7 +7556,7 @@ public:
   BasePointers.push_back(VDLVal.getPointer());
   Pointers.push_back(ThisLVal.getPointer());
   Sizes.push_back(CGF.getTypeSize(CGF.getContext().VoidPtrTy));
-  Types.push_back(OMP_MAP_PTR_AND_OBJ | OMP_MAP_PRIVATE |
+  Types.push_back(OMP_MAP_PTR_AND_OBJ | OMP_MAP_LITERAL |
   OMP_MAP_MEMBER_OF | OMP_MAP_IMPLICIT);
 }
 for (const LambdaCapture &LC : RD->captures()) {
@@ -7570,7 +7570,7 @@ public:
   Pointers.push_back(VarLVal.getPointer());
   Sizes.push_back(CGF.getTypeSize(
   VD->getType().getCanonicalType().getNonReferenceType()));
-  Types.push_back(OMP_MAP_PTR_AND_OBJ | OMP_MAP_PRIVATE |
+  Types.push_back(OMP_MAP_PTR_AND_OBJ | OMP_MAP_LITERAL |
   OMP_MAP_MEMBER_OF | OMP_MAP_IMPLICIT);
 }
   }
@@ -7581,7 +7581,7 @@ public:
MapFlagsArrayTy &Types) const {
 for (unsigned I = 0, E = Types.size(); I < E; ++I) {
   // Set correct member_of idx for all implicit lambda captures.
-  if (Types[I] != (OMP_MAP_PTR_AND_OBJ | OMP_MAP_PRIVATE |
+  if (Types[I] != (OMP_MAP_PTR_AND_OBJ | OMP_MAP_LITERAL |
OMP_MAP_MEMBER_OF | OMP_MAP_IMPLICIT))
 continue;
   llvm::Value *BasePtr = *BasePointers[I];

Modified: cfe/trunk/test/OpenMP/nvptx_lambda_capturing.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_lambda_capturing.cpp?rev=345982&r1=345981&r2=345982&view=diff
==
--- cfe/trunk/test/OpenMP/nvptx_lambda_capturing.cpp (original)
+++ cfe/trunk/test/OpenMP/nvptx_lambda_capturing.cpp Fri Nov  2 08:25:06 2018
@@ -13,13 +13,13 @@
 #define HEADER
 
 // HOST-DAG: = private unnamed_addr constant [11 x i64] [i64 4, i64 4, i64 0, 
i64 4, i64 40, i64 4, i64 4, i64 4, i64 8, i64 4, i64 4]
-// HOST-DAG: = private unnamed_addr constant [11 x i64] [i64 547, i64 547, i64 
544, i64 33, i64 673, i64 1407374883553936, i64 1407374883553936, i64 
1407374883553936, i64 1407374883553936, i64 1407374883553936, i64 800]
+// HOST-DAG: = private unnamed_addr constant [11 x i64] [i64 547, i64 547, i64 
544, i64 33, i64 673, i64 1407374883554064, i64 1407374883554064, i64 
1407374883554064, i64 1407374883554064, i64 1407374883554064, i64 800]
 // HOST-DAG: = private unnamed_addr constant [11 x i64] [i64 4, i64 4, i64 4, 
i64 0, i64 4, i64 40, i64 4, i64 4, i64 4, i64 8, i64 4]
-// HOST-DAG: = private unnamed_addr constant [11 x i64] [i64 547, i64 547, i64 
547, i64 544, i64 547, i64 673, i64 1688849860264592, i64 1688849860264592, i64 
1688849860264592, i64 1688849860264592, i64 1688849860264592]
+// HOST-DAG: = private unnamed_addr constant [11 x i64] [i64 547, i64 547, i64 
547, i64 544, i64 547, i64 673, i64 1688849860264720, i64 1688849860264720, i64 
1688849860264720, i64 1688849860264720, i64 1688849860264720]
 // HOST-DAG: = private unnamed_addr constant [3 x i64] [i64 4, i64 8, i64 8]
-// HOST-DAG: = private unnamed_addr constant [3 x i64] [i64 547, i64 673, i64 
562949953421968]
+// HOST-DAG: = private unnamed_addr constant [3 x i64] [i64 547, i64 673, i64 
562949953422096]
 // HOST-DAG: = private unnamed_addr constant [3 x i64] [i64 4, i64 8, i64 8]
-// HOST-DAG: = private unnamed_addr constant [3 x i64] [i64 547, i64 673, i64 
562949953421968]
+// HOST-DAG: = private unnamed_addr constant [3 x i64] [i64 547, i64 673, i64 
562949953422096]
 // CHECK-DAG: [[S:%.+]] = type { i32 }
 // CHECK-DAG: [[CAP1:%.+]] = type { [[S]]* }
 // CHECK-DAG: [[CAP2:%.+]] = type { i32*, i32*, i32*, i32**, i32* }


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


Re: r345971 - Reapply Logging: make os_log buffer size an integer constant expression.

2018-11-02 Thread Sam McCall via cfe-commits
On Fri, Nov 2, 2018 at 4:08 PM Tim Northover  wrote:

> After that it was discovered OSLog depends on the other format helpers so
> there was still a circular dependency; I decided adding the others was a
> minor enough change to just go ahead.
>
Thanks - I missed the review.

> On 2 Nov 2018, at 15:03, Tim Northover  wrote:
> >> (If the do belong here: the namespaces and comments don't seem to have
> been updated)
> >
> > Good point, I’ll get onto fixing that.
>
> Actually, do you have any particular ones in mind? After going in to make
> changes, they still look pretty good to me; I don’t think libclangAnalysis
> should have the monopoly on the term.
>
Thanks for looking at this!

>From my (very limited) understanding of os_log and AST, it's going to rely
on __builtin_os_log_format_buffer_size being computed at compile-time, so
AST now needs to understand the semantics of format strings.
In that case, I don't think it makes sense to think of the format string
parser as part of the analyzer - as the build deps suggest, it's now part
of AST and gets reused by analyzer. (Similar to how the analyzer uses other
bits of AST/clang). If there are parts only relevant to analyzer, it'd be
nice to move them out of the AST library, but I don't know to what extent
that's feasible.

So it does seem to me like all the uses of analyzer namespaces are suspect
- moving code from Analyzer to AST is a semantic difference (the layers
aren't *just* about making the linker happy, after all!)

Cheers, Sam
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54036: [fix][clang-tidy] fix for r345961 that introduced a test failure on Windows builds

2018-11-02 Thread Tom Weaver via Phabricator via cfe-commits
TWeaver added a comment.

The test failed on the following build bot:

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/21169


Repository:
  rL LLVM

https://reviews.llvm.org/D54036



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


Re: [clang-tools-extra] r345961 - [clang-tidy] Get ClangTidyContext out of the business of storing diagnostics. NFC

2018-11-02 Thread Sam McCall via cfe-commits
Hi Tom, Sorry for missing this (too many email accounts).
And thank you for the fix!

On Fri, Nov 2, 2018 at 1:04 PM Tom Weaver  wrote:

> Hiya Sam,
>
> are you aware that r345961 caused a test failure on the following bot and
> build
>
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/21169
>
> is there any chance you could take a look please?
>
> thanks
> Tom
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54036: [fix][clang-tidy] fix for r345961 that introduced a test failure on Windows builds

2018-11-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thank you!

`{{.*}}not-exist` also seems fine, up to you.


Repository:
  rL LLVM

https://reviews.llvm.org/D54036



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


[clang-tools-extra] r345984 - [clang-tidy] Fixed code sample in a comment. NFC

2018-11-02 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Nov  2 08:29:37 2018
New Revision: 345984

URL: http://llvm.org/viewvc/llvm-project?rev=345984&view=rev
Log:
[clang-tidy] Fixed code sample in a comment. NFC

Modified:
clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.h

Modified: clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.h?rev=345984&r1=345983&r2=345984&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.h (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/IncludeInserter.h Fri Nov  2 
08:29:37 2018
@@ -25,16 +25,18 @@ namespace utils {
 /// \brief Produces fixes to insert specified includes to source files, if not
 /// yet present.
 ///
-/// ``IncludeInserter`` can be used by ``ClangTidyCheck`` in the following
-/// fashion:
+/// ``IncludeInserter`` can be used in clang-tidy checks in the following way:
 /// \code
+/// #include "../utils/IncludeInserter.h"
+/// #include "clang/Frontend/CompilerInstance.h"
+///
 /// class MyCheck : public ClangTidyCheck {
 ///  public:
 ///   void registerPPCallbacks(CompilerInstance& Compiler) override {
 /// Inserter = 
llvm::make_unique(&Compiler.getSourceManager(),
 ///   &Compiler.getLangOpts());
 /// Compiler.getPreprocessor().addPPCallbacks(
-/// Inserter->CreatePPCallback());
+/// Inserter->CreatePPCallbacks());
 ///   }
 ///
 ///   void registerMatchers(ast_matchers::MatchFinder* Finder) override { ... }
@@ -49,7 +51,7 @@ namespace utils {
 ///   }
 ///
 ///  private:
-///   std::unique_ptr Inserter;
+///   std::unique_ptr Inserter;
 /// };
 /// \endcode
 class IncludeInserter {


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


[PATCH] D54036: [fix][clang-tidy] fix for r345961 that introduced a test failure on Windows builds

2018-11-02 Thread Tom Weaver via Phabricator via cfe-commits
TWeaver added a comment.

I'm happy as is.

thanks for the review.


Repository:
  rL LLVM

https://reviews.llvm.org/D54036



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


[PATCH] D54010: [CodeGen] Fix a crash when updating a zeroinitialize designated initializer

2018-11-02 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D54010



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


[PATCH] D54036: [fix][clang-tidy] fix for r345961 that introduced a test failure on Windows builds

2018-11-02 Thread Tom Weaver via Phabricator via cfe-commits
TWeaver added a comment.

Oh, I don't have commit access, are you able to commit for me Sam?

Thanks


Repository:
  rL LLVM

https://reviews.llvm.org/D54036



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


r345985 - [analyzer][NFC] Fix some incorrect uses of -analyzer-config options

2018-11-02 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Fri Nov  2 08:48:10 2018
New Revision: 345985

URL: http://llvm.org/viewvc/llvm-project?rev=345985&view=rev
Log:
[analyzer][NFC] Fix some incorrect uses of -analyzer-config options

I'm in the process of refactoring AnalyzerOptions. The main motivation behind
here is to emit warnings if an invalid -analyzer-config option is given from
the command line, and be able to list them all.

In this patch, I found some flags that should've been used as checker options,
or have absolutely no mention of in AnalyzerOptions, or are nonexistent.

- NonLocalizedStringChecker now uses its "AggressiveReport" flag as a checker
option
- lib/StaticAnalyzer/Frontend/ModelInjector.cpp now accesses the "model-path"
option through a getter in AnalyzerOptions
- -analyzer-config path-diagnostics-alternate=false is not a thing, I removed 
it,
- lib/StaticAnalyzer/Checkers/AllocationDiagnostics.cpp and
lib/StaticAnalyzer/Checkers/AllocationDiagnostics.h are weird, they actually
only contain an option getter. I deleted them, and fixed RetainCountChecker
to get it's "leak-diagnostics-reference-allocation" option as a checker 
option,
- "region-store-small-struct-limit" has a proper getter now.

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

Removed:
cfe/trunk/lib/StaticAnalyzer/Checkers/AllocationDiagnostics.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/AllocationDiagnostics.h
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
cfe/trunk/test/Analysis/analyzer-config.c
cfe/trunk/test/Analysis/analyzer-config.cpp
cfe/trunk/test/Analysis/cstring-plist.c
cfe/trunk/test/Analysis/localization-aggressive.m

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h?rev=345985&r1=345984&r2=345985&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Fri Nov  2 
08:48:10 2018
@@ -328,6 +328,11 @@ private:
   /// \sa shouldElideConstructors
   Optional ElideConstructors;
 
+  /// \sa getModelPath
+  Optional ModelPath;
+
+  /// \sa getRegionStoreSmallStructLimit
+  Optional RegionStoreSmallStructLimit;
 
   /// A helper function that retrieves option for a given full-qualified
   /// checker name.
@@ -745,6 +750,21 @@ public:
   /// Starting with C++17 some elisions become mandatory, and in these cases
   /// the option will be ignored.
   bool shouldElideConstructors();
+
+  /// The largest number of fields a struct can have and still be
+  /// considered "small".
+  ///
+  /// This is currently used to decide whether or not it is worth "forcing" a
+  /// LazyCompoundVal on bind.
+  ///
+  /// This is controlled by 'region-store-small-struct-limit' option.
+  /// To disable all small-struct-dependent behavior, set the option to "0".
+  unsigned getRegionStoreSmallStructLimit();
+
+  /// The analyzer can inline an alternative implementation written in C at the
+  /// call site if the called function's body is not available. This is a path
+  /// where to look for those alternative implementations (called models)
+  StringRef getModelPath();
 };
 
 using AnalyzerOptionsRef = IntrusiveRefCntPtr;

Removed: cfe/trunk/lib/StaticAnalyzer/Checkers/AllocationDiagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/AllocationDiagnostics.cpp?rev=345984&view=auto
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/AllocationDiagnostics.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/AllocationDiagnostics.cpp (removed)
@@ -1,24 +0,0 @@
-//=- AllocationDiagnostics.cpp - Config options for allocation diags *- C++ 
-*-//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-//
-// Declares the configuration functions for leaks/allocation diagnostics.
-//
-//===--
-
-#include "AllocationDiagnostics.h"
-
-namespace clang {
-namespace ento {
-
-bool shouldIncludeAllocationSiteInLeakDiagnostics(AnalyzerOptions &AOpts) {
-  return AOpts.getBooleanOption("leak-diagnostics-refere

[PATCH] D53276: [analyzer][NFC] Fix some incorrect uses of -analyzer-config options

2018-11-02 Thread Umann Kristóf via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rC345985: [analyzer][NFC] Fix some incorrect uses of 
-analyzer-config options (authored by Szelethus, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53276?vs=171141&id=172373#toc

Repository:
  rC Clang

https://reviews.llvm.org/D53276

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/StaticAnalyzer/Checkers/AllocationDiagnostics.cpp
  lib/StaticAnalyzer/Checkers/AllocationDiagnostics.h
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
  lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
  lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/RegionStore.cpp
  lib/StaticAnalyzer/Frontend/ModelInjector.cpp
  test/Analysis/analyzer-config.c
  test/Analysis/analyzer-config.cpp
  test/Analysis/cstring-plist.c
  test/Analysis/localization-aggressive.m

Index: include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
===
--- include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -328,6 +328,11 @@
   /// \sa shouldElideConstructors
   Optional ElideConstructors;
 
+  /// \sa getModelPath
+  Optional ModelPath;
+
+  /// \sa getRegionStoreSmallStructLimit
+  Optional RegionStoreSmallStructLimit;
 
   /// A helper function that retrieves option for a given full-qualified
   /// checker name.
@@ -745,6 +750,21 @@
   /// Starting with C++17 some elisions become mandatory, and in these cases
   /// the option will be ignored.
   bool shouldElideConstructors();
+
+  /// The largest number of fields a struct can have and still be
+  /// considered "small".
+  ///
+  /// This is currently used to decide whether or not it is worth "forcing" a
+  /// LazyCompoundVal on bind.
+  ///
+  /// This is controlled by 'region-store-small-struct-limit' option.
+  /// To disable all small-struct-dependent behavior, set the option to "0".
+  unsigned getRegionStoreSmallStructLimit();
+
+  /// The analyzer can inline an alternative implementation written in C at the
+  /// call site if the called function's body is not available. This is a path
+  /// where to look for those alternative implementations (called models)
+  StringRef getModelPath();
 };
 
 using AnalyzerOptionsRef = IntrusiveRefCntPtr;
Index: test/Analysis/cstring-plist.c
===
--- test/Analysis/cstring-plist.c
+++ test/Analysis/cstring-plist.c
@@ -1,5 +1,8 @@
 // RUN: rm -f %t
-// RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=core,unix.Malloc,unix.cstring.NullArg -analyzer-disable-checker=alpha.unix.cstring.OutOfBounds -analyzer-output=plist -analyzer-config path-diagnostics-alternate=false -o %t %s
+// RUN: %clang_analyze_cc1 -fblocks \
+// RUN:   -analyzer-checker=core,unix.Malloc,unix.cstring.NullArg \
+// RUN:   -analyzer-disable-checker=alpha.unix.cstring.OutOfBounds \
+// RUN:   -analyzer-output=plist -o %t %s
 // RUN: FileCheck -input-file %t %s
 
 typedef __typeof(sizeof(int)) size_t;
Index: test/Analysis/analyzer-config.c
===
--- test/Analysis/analyzer-config.c
+++ test/Analysis/analyzer-config.c
@@ -26,7 +26,6 @@
 // CHECK-NEXT: inline-lambdas = true
 // CHECK-NEXT: ipa = dynamic-bifurcate
 // CHECK-NEXT: ipa-always-inline-size = 3
-// CHECK-NEXT: leak-diagnostics-reference-allocation = false
 // CHECK-NEXT: max-inlinable-size = 100
 // CHECK-NEXT: max-nodes = 225000
 // CHECK-NEXT: max-times-inline-large = 32
@@ -37,4 +36,4 @@
 // CHECK-NEXT: unroll-loops = false
 // CHECK-NEXT: widen-loops = false
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: num-entries = 25
+// CHECK-NEXT: num-entries = 24
Index: test/Analysis/analyzer-config.cpp
===
--- test/Analysis/analyzer-config.cpp
+++ test/Analysis/analyzer-config.cpp
@@ -41,7 +41,6 @@
 // CHECK-NEXT: inline-lambdas = true
 // CHECK-NEXT: ipa = dynamic-bifurcate
 // CHECK-NEXT: ipa-always-inline-size = 3
-// CHECK-NEXT: leak-diagnostics-reference-allocation = false
 // CHECK-NEXT: max-inlinable-size = 100
 // CHECK-NEXT: max-nodes = 225000
 // CHECK-NEXT: max-times-inline-large = 32
@@ -52,4 +51,4 @@
 // CHECK-NEXT: unroll-loops = false
 // CHECK-NEXT: widen-loops = false
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: num-entries = 32
+// CHECK-NEXT: num-entries = 31
Index: test/Analysis/localization-aggressive.m
===
--- test/Analysis/localization-aggressive.m
+++ test/Analysis/localization-aggressive.m
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 -fblocks -x objective-c-header -emit-pch -o %t.pch %S/Inputs/l

r345986 - [analyzer][NFC] Collect all -analyzer-config options in a .def file

2018-11-02 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Fri Nov  2 08:50:44 2018
New Revision: 345986

URL: http://llvm.org/viewvc/llvm-project?rev=345986&view=rev
Log:
[analyzer][NFC] Collect all -analyzer-config options in a .def file

I'm in the process of refactoring AnalyzerOptions. The main motivation behind
here is to emit warnings if an invalid -analyzer-config option is given from the
command line, and be able to list them all.

In this patch, I'm moving all analyzer options to a def file, and move 2 enums
to global namespace.

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

Added:
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp

Added: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def?rev=345986&view=auto
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def (added)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def Fri Nov  2 
08:50:44 2018
@@ -0,0 +1,467 @@
+//===-- AnalyzerOptions.def - Metadata about Static Analyses *- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This file defines the analyzer options avaible with -analyzer-config.
+//
+//  This file is in part intended for method generation. If it's not included
+//  for that purpose, the following function-like macros should be predefined,
+//  through which all registered options are accessible:
+//
+//* ANALYZER_OPTION: Register a new option.
+//* ANALYZER_OPTION_DEPENDS_ON_USER_MODE: Register a new option, default
+//  value depends on the "user-mode" option.
+//
+//  Options where a simple getter method is sufficient are registered with the
+//  following macros:
+//
+//* ANALYZER_OPTION_GEN_FN: Register a new option, and generate a getter
+//  method for it in AnalyzerOptions.
+//
+//* ANALYZER_OPTION_GEN_FN_DEPENDS_ON_USER_MODE: Same as above, but
+//  generates a getter function that depends on the "user-mode" option.
+//
+//  You can only include this file when both or none of the above two macros
+//  are defined!
+//  When they are defined, entries that do not generate functions  won't 
appear,
+//  and when they aren't, all entries are converted to ANALYZER_OPTION or to
+//  ANALYZER_OPTION_DEPENDS_ON_USER_MODE.
+//
+//===--===//
+
+#ifndef LLVM_ADT_STRINGREF_H
+#error This .def file is expected to be included in translation units where \
+"llvm/ADT/StringRef.h" is already included!
+#endif
+
+#ifdef ANALYZER_OPTION
+#ifndef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
+#error If you didn't include this file with the intent of generating methods, \
+define both 'ANALYZER_OPTION' and 'ANALYZER_OPTION_DEPENDS_ON_USER_MODE' 
macros!
+#endif
+#endif
+
+#ifndef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
+#ifdef ANALYZER_OPTION
+#error If you didn't include this file with the intent of generating methods, \
+define both 'ANALYZER_OPTION' and 'ANALYZER_OPTION_DEPENDS_ON_USER_MODE' 
macros!
+#endif
+#endif
+
+#ifdef ANALYZER_OPTION_GEN_FN
+#ifndef ANALYZER_OPTION_GEN_FN_DEPENDS_ON_USER_MODE
+#error If you include this file with the intent of generating functions, \
+define both 'ANALYZER_OPTION_GEN_FN' and \
+'ANALYZER_OPTION_GEN_FN_DEPENDS_ON_USER_MODE' macros!
+#endif
+#endif
+
+#ifdef ANALYZER_OPTION_GEN_FN_DEPENDS_ON_USER_MODE
+#ifndef ANALYZER_OPTION_GEN_FN
+#error If you include this file with the intent of generating functions, \
+define both 'ANALYZER_OPTION_GEN_FN' and \
+'ANALYZER_OPTION_GEN_FN_DEPENDS_ON_USER_MODE' macros!
+#endif
+#endif
+
+#ifndef ANALYZER_OPTION
+/// Create a new analyzer option, but dont generate a method for it in
+/// AnalyzerOptions.
+///
+///   TYPE - The type of the option object that will be stored in
+///  AnalyzerOptions. This file is expected to be icluded in 
translation
+///  units where AnalyzerOptions.h is included, so types from that
+///  header should be used.
+///   NAME - The name of the option object.
+///   CMDFLAG - The command line flag for the option.
+/// (-analyzer-config CMDFLAG=VALUE)
+///   DESC - Description of the flag.
+///   DEFAULT_VAL - The default value for CMDFLAG.
+#define ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, DEFAULT_VAL)
+#endif
+
+#ifndef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
+/// Create a new analyzer option, but dont generate a method for it in
+/// AnalyzerOptions. It's value depends on the opti

[PATCH] D53277: [analyzer][NFC] Collect all -analyzer-config options in a .def file

2018-11-02 Thread Umann Kristóf via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345986: [analyzer][NFC] Collect all -analyzer-config options 
in a .def file (authored by Szelethus, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53277?vs=170417&id=172375#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53277

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -56,17 +56,17 @@
 static std::unique_ptr generateWorkList(AnalyzerOptions &Opts,
   SubEngine &subengine) {
   switch (Opts.getExplorationStrategy()) {
-case AnalyzerOptions::ExplorationStrategyKind::DFS:
+case ExplorationStrategyKind::DFS:
   return WorkList::makeDFS();
-case AnalyzerOptions::ExplorationStrategyKind::BFS:
+case ExplorationStrategyKind::BFS:
   return WorkList::makeBFS();
-case AnalyzerOptions::ExplorationStrategyKind::BFSBlockDFSContents:
+case ExplorationStrategyKind::BFSBlockDFSContents:
   return WorkList::makeBFSBlockDFSContents();
-case AnalyzerOptions::ExplorationStrategyKind::UnexploredFirst:
+case ExplorationStrategyKind::UnexploredFirst:
   return WorkList::makeUnexploredFirst();
-case AnalyzerOptions::ExplorationStrategyKind::UnexploredFirstQueue:
+case ExplorationStrategyKind::UnexploredFirstQueue:
   return WorkList::makeUnexploredFirstPriorityQueue();
-case AnalyzerOptions::ExplorationStrategyKind::UnexploredFirstLocationQueue:
+case ExplorationStrategyKind::UnexploredFirstLocationQueue:
   return WorkList::makeUnexploredFirstPriorityLocationQueue();
   }
   llvm_unreachable("Unknown AnalyzerOptions::ExplorationStrategyKind");
Index: cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
@@ -49,91 +49,87 @@
   return Result;
 }
 
-AnalyzerOptions::UserModeKind AnalyzerOptions::getUserMode() {
+UserModeKind AnalyzerOptions::getUserMode() {
   if (!UserMode.hasValue()) {
-StringRef ModeStr = getOptionAsString("mode", "deep");
-UserMode = llvm::StringSwitch>(ModeStr)
-  .Case("shallow", UMK_Shallow)
-  .Case("deep", UMK_Deep)
-  .Default(None);
-assert(UserMode.getValue() && "User mode is invalid.");
+UserMode = getOptionAsString("mode", "deep");
   }
-  return UserMode.getValue();
+
+  auto K = llvm::StringSwitch>(*UserMode)
+.Case("shallow", UMK_Shallow)
+.Case("deep", UMK_Deep)
+.Default(None);
+  assert(UserMode.hasValue() && "User mode is invalid.");
+  return K.getValue();
 }
 
-AnalyzerOptions::ExplorationStrategyKind
+ExplorationStrategyKind
 AnalyzerOptions::getExplorationStrategy() {
   if (!ExplorationStrategy.hasValue()) {
-StringRef StratStr = getOptionAsString("exploration_strategy",
-   "unexplored_first_queue");
-ExplorationStrategy =
-llvm::StringSwitch>(StratStr)
-.Case("dfs", ExplorationStrategyKind::DFS)
-.Case("bfs", ExplorationStrategyKind::BFS)
-.Case("unexplored_first",
-  ExplorationStrategyKind::UnexploredFirst)
-.Case("unexplored_first_queue",
-  ExplorationStrategyKind::UnexploredFirstQueue)
-.Case("unexplored_first_location_queue",
-  ExplorationStrategyKind::UnexploredFirstLocationQueue)
-.Case("bfs_block_dfs_contents",
-  ExplorationStrategyKind::BFSBlockDFSContents)
-.Default(None);
-assert(ExplorationStrategy.hasValue() &&
-   "User mode is invalid.");
+ExplorationStrategy = getOptionAsString("exploration_strategy",
+"unexplored_first_queue");
   }
-  return ExplorationStrategy.getValue();
+  auto K =
+llvm::StringSwitch>(
+   *ExplorationStrategy)
+  .Case("dfs", ExplorationStrategyKind::DFS)
+  .Case("bfs", ExplorationStrategyKind::BFS)
+  .Case("unexplored_first",
+ExplorationStrategyKind::UnexploredFirst)
+  .Case("unexplored_first_queue",
+ExplorationStrategyKind::UnexploredFirstQueue)
+  .Case("unexplored_first_location_queue",
+ExplorationStrategyKind::UnexploredFirstLocationQueue)
+  .Case("bfs_block_dfs_contents",
+Explo

[PATCH] D52615: Handle -fsanitize-address-poison-class-member-array-new-cookie in the driver and propagate it to cc1

2018-11-02 Thread Filipe Cabecinhas via Phabricator via cfe-commits
filcab updated this revision to Diff 172376.
filcab added a comment.

Reworded with feedback from the review.


Repository:
  rC Clang

https://reviews.llvm.org/D52615

Files:
  docs/ClangCommandLineReference.rst
  docs/UsersManual.rst
  include/clang/Driver/Options.td
  include/clang/Driver/SanitizerArgs.h
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/address-sanitizer-and-array-cookie.cpp
  test/Driver/fsanitize.c

Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -208,6 +208,24 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE
 // CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE: -cc1{{.*}}address-use-after-scope
 
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-address-poison-custom-array-cookie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-POISON-CUSTOM-ARRAY-NEW-COOKIE
+// RUN: %clang_cl --target=x86_64-windows -fsanitize=address -fsanitize-address-poison-custom-array-cookie -### -- %s 2>&1 | FileCheck %s --check-prefix=CHECK-POISON-CUSTOM-ARRAY-NEW-COOKIE
+// CHECK-POISON-CUSTOM-ARRAY-NEW-COOKIE: -cc1{{.*}}-fsanitize-address-poison-custom-array-cookie
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fno-sanitize-address-poison-custom-array-cookie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-POISON-CUSTOM-ARRAY-NEW-COOKIE-OFF
+// RUN: %clang_cl --target=x86_64-windows -fsanitize=address -fno-sanitize-address-poison-custom-array-cookie -### -- %s 2>&1 | FileCheck %s --check-prefix=CHECK-POISON-CUSTOM-ARRAY-NEW-COOKIE-OFF
+// CHECK-POISON-CUSTOM-ARRAY-NEW-COOKIE-OFF-NOT: -cc1{{.*}}address-poison-custom-array-cookie
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fno-sanitize-address-poison-custom-array-cookie -fsanitize-address-poison-custom-array-cookie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-POISON-CUSTOM-ARRAY-NEW-COOKIE-BOTH
+// RUN: %clang_cl --target=x86_64-windows -fsanitize=address -fno-sanitize-address-poison-custom-array-cookie -fsanitize-address-poison-custom-array-cookie -### -- %s 2>&1 | FileCheck %s --check-prefix=CHECK-POISON-CUSTOM-ARRAY-NEW-COOKIE-BOTH
+// CHECK-POISON-CUSTOM-ARRAY-NEW-COOKIE-BOTH: -cc1{{.*}}-fsanitize-address-poison-custom-array-cookie
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-address-poison-custom-array-cookie -fno-sanitize-address-poison-custom-array-cookie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-POISON-CUSTOM-ARRAY-NEW-COOKIE-BOTH-OFF
+// CHECK-POISON-CUSTOM-ARRAY-NEW-COOKIE-BOTH-OFF-NOT: -cc1{{.*}}address-poison-custom-array-cookie
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-WITHOUT-POISON-CUSTOM-ARRAY-NEW-COOKIE
+// CHECK-ASAN-WITHOUT-POISON-CUSTOM-ARRAY-NEW-COOKIE-NOT: -cc1{{.*}}address-poison-custom-array-cookie
+
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-address-globals-dead-stripping %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-GLOBALS
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ASAN-GLOBALS
 // RUN: %clang_cl --target=x86_64-windows-msvc -fsanitize=address -fsanitize-address-globals-dead-stripping -### -- %s 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-GLOBALS
Index: test/CodeGen/address-sanitizer-and-array-cookie.cpp
===
--- test/CodeGen/address-sanitizer-and-array-cookie.cpp
+++ test/CodeGen/address-sanitizer-and-array-cookie.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-gnu-linux -emit-llvm -o - %s | FileCheck %s -check-prefix=PLAIN
 // RUN: %clang_cc1 -triple x86_64-gnu-linux -emit-llvm -o - -fsanitize=address %s | FileCheck %s -check-prefix=ASAN
-// RUN: %clang_cc1 -triple x86_64-gnu-linux -emit-llvm -o - -fsanitize=address -fsanitize-address-poison-class-member-array-new-cookie %s | FileCheck %s -check-prefix=ASAN-POISON-ALL-NEW-ARRAY
+// RUN: %clang_cc1 -triple x86_64-gnu-linux -emit-llvm -o - -fsanitize=address -fsanitize-address-poison-custom-array-cookie %s | FileCheck %s -check-prefix=ASAN-POISON-ALL-NEW-ARRAY
 
 typedef __typeof__(sizeof(0)) size_t;
 namespace std {
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -968,11 +968,11 @@
   Args.hasArg(OPT_fsanitize_cfi_icall_generalize_pointers);
   Opts.SanitizeStats = Args.hasArg(OPT_fsanitize_stats);
   if (Arg *A = Args.getLastArg(
-  OPT_fsanitize_address_poison_class_member_array_new_cookie,
-  OPT_fno_sanitize_address_poison_class_member_array_new_cookie)) {
-Opts.SanitizeAddressPo

r345989 - [analyzer] New flag to print all -analyzer-config options

2018-11-02 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Fri Nov  2 08:59:37 2018
New Revision: 345989

URL: http://llvm.org/viewvc/llvm-project?rev=345989&view=rev
Log:
[analyzer] New flag to print all -analyzer-config options

A new -cc1 flag is avaible for the said purpose: -analyzer-config-help

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

Added:
cfe/trunk/test/Analysis/analyzer-list-configs.c
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=345989&r1=345988&r2=345989&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Fri Nov  2 08:59:37 2018
@@ -129,6 +129,9 @@ def analyzer_disable_all_checks : Flag<[
 def analyzer_checker_help : Flag<["-"], "analyzer-checker-help">,
   HelpText<"Display the list of analyzer checkers that are available">;
 
+def analyzer_config_help : Flag<["-"], "analyzer-config-help">,
+  HelpText<"Display the list of -analyzer-config options">;
+
 def analyzer_list_enabled_checkers : Flag<["-"], 
"analyzer-list-enabled-checkers">,
   HelpText<"Display the list of enabled analyzer checkers">;
 

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h?rev=345989&r1=345988&r2=345989&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Fri Nov  2 
08:59:37 2018
@@ -175,6 +175,7 @@ public:
 
   unsigned ShowCheckerHelp : 1;
   unsigned ShowEnabledCheckerList : 1;
+  unsigned ShowConfigOptionsList : 1;
   unsigned AnalyzeAll : 1;
   unsigned AnalyzerDisplayProgress : 1;
   unsigned AnalyzeNestedBlocks : 1;

Modified: cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h?rev=345989&r1=345988&r2=345989&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h Fri Nov  
2 08:59:37 2018
@@ -55,6 +55,7 @@ private:
 void printCheckerHelp(raw_ostream &OS, ArrayRef plugins);
 void printEnabledCheckerList(raw_ostream &OS, ArrayRef plugins,
  const AnalyzerOptions &opts);
+void printAnalyzerConfigList(raw_ostream &OS);
 
 } // end GR namespace
 

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=345989&r1=345988&r2=345989&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Nov  2 08:59:37 2018
@@ -279,6 +279,7 @@ static bool ParseAnalyzerArgs(AnalyzerOp
   }
 
   Opts.ShowCheckerHelp = Args.hasArg(OPT_analyzer_checker_help);
+  Opts.ShowConfigOptionsList = Args.hasArg(OPT_analyzer_config_help);
   Opts.ShowEnabledCheckerList = 
Args.hasArg(OPT_analyzer_list_enabled_checkers);
   Opts.DisableAllChecks = Args.hasArg(OPT_analyzer_disable_all_checks);
 

Modified: cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp?rev=345989&r1=345988&r2=345989&view=diff
==
--- cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp (original)
+++ cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp Fri Nov  2 
08:59:37 2018
@@ -241,11 +241,19 @@ bool ExecuteCompilerInvocation(CompilerI
 ento::printCheckerHelp(llvm::outs(), Clang->getFrontendOpts().Plugins);
 return true;
   }
+
+  // Honor -analyzer-list-enabled-checkers.
   if (Clang->getAnalyzerOpts()->ShowEnabledCheckerList) {
 ento::printEnabledCheckerList(llvm::outs(),
   Clang->getFrontendOpts().Plugins,
   *Clang->getAnalyzerOpts());
   }
+
+  // Honor -analyzer-config-help.
+  if (Clang->getAnalyzerOpts()->ShowConfigOptionsList) {
+ento::printAnalyzerConfigList(llvm::outs());
+return true;
+  }
 #endif
 
   // If there were errors in processing 

[PATCH] D53296: [analyzer] New flag to print all -analyzer-config options

2018-11-02 Thread Umann Kristóf via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Szelethus marked an inline comment as done.
Closed by commit rC345989: [analyzer] New flag to print all -analyzer-config 
options (authored by Szelethus, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53296?vs=171611&id=172377#toc

Repository:
  rC Clang

https://reviews.llvm.org/D53296

Files:
  include/clang/Driver/CC1Options.td
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  include/clang/StaticAnalyzer/Frontend/FrontendActions.h
  lib/Frontend/CompilerInvocation.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
  test/Analysis/analyzer-list-configs.c

Index: include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
===
--- include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -175,6 +175,7 @@
 
   unsigned ShowCheckerHelp : 1;
   unsigned ShowEnabledCheckerList : 1;
+  unsigned ShowConfigOptionsList : 1;
   unsigned AnalyzeAll : 1;
   unsigned AnalyzerDisplayProgress : 1;
   unsigned AnalyzeNestedBlocks : 1;
Index: include/clang/StaticAnalyzer/Frontend/FrontendActions.h
===
--- include/clang/StaticAnalyzer/Frontend/FrontendActions.h
+++ include/clang/StaticAnalyzer/Frontend/FrontendActions.h
@@ -55,6 +55,7 @@
 void printCheckerHelp(raw_ostream &OS, ArrayRef plugins);
 void printEnabledCheckerList(raw_ostream &OS, ArrayRef plugins,
  const AnalyzerOptions &opts);
+void printAnalyzerConfigList(raw_ostream &OS);
 
 } // end GR namespace
 
Index: include/clang/Driver/CC1Options.td
===
--- include/clang/Driver/CC1Options.td
+++ include/clang/Driver/CC1Options.td
@@ -129,6 +129,9 @@
 def analyzer_checker_help : Flag<["-"], "analyzer-checker-help">,
   HelpText<"Display the list of analyzer checkers that are available">;
 
+def analyzer_config_help : Flag<["-"], "analyzer-config-help">,
+  HelpText<"Display the list of -analyzer-config options">;
+
 def analyzer_list_enabled_checkers : Flag<["-"], "analyzer-list-enabled-checkers">,
   HelpText<"Display the list of enabled analyzer checkers">;
 
Index: test/Analysis/analyzer-list-configs.c
===
--- test/Analysis/analyzer-list-configs.c
+++ test/Analysis/analyzer-list-configs.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -analyzer-config-help 2>&1 | FileCheck %s
+// CHECK: OVERVIEW: Clang Static Analyzer -analyzer-config Option List
+//
+// CHECK: USAGE: clang -cc1 [CLANG_OPTIONS] -analyzer-config 
+//
+// CHCEK:  clang -cc1 [CLANG_OPTIONS] -analyzer-config OPTION1=VALUE, -analyzer-config OPTION2=VALUE, ...
+//
+// CHECK:  clang [CLANG_OPTIONS] -Xclang -analyzer-config -Xclang
+//
+// CHECK:  clang [CLANG_OPTIONS] -Xclang -analyzer-config -Xclang OPTION1=VALUE, -Xclang -analyzer-config -Xclang OPTION2=VALUE, ...
+//
+//
+// CHECK: OPTIONS:
+//
+// CHECK: aggressive-binary-operation-simplification
+// CHECK:   (bool) Whether SValBuilder should rearrange
+// CHECK:   comparisons and additive operations of symbolic
+// CHECK:   expressions which consist of a sum of a
+// CHECK:   symbol and a concrete integer into the format
+// CHECK:   where symbols are on the left-hand side
+// CHECK:   and the integer is on the right. This is
+// CHECK:   only done if both symbols and both concrete
+// CHECK:   integers are signed, greater than or equal
+// CHECK:   to the quarter of the minimum value of the
+// CHECK:   type and less than or equal to the quarter
+// CHECK:   of the maximum value of that type. A + n
+// CHECK:B + m becomes A - B  m - n, where
+// CHECK:   A and B symbolic, n and m are integers.
+// CHECK:is any of '==', '!=', '<', '<=', '>',
+// CHECK:   '>=', '+' or '-'. The rearrangement also
+// CHECK:   happens with '-' instead of '+' on either
+// CHECK:   or both side and also if any or both integers
+// CHECK:   are missing. (default: false)
Index: lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
===
--- lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
+++ lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
@@ -22,6 +22,7 @@
 #include "clang/StaticAnalyzer/Frontend/FrontendActions.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/DynamicLibrary.h"
+#include "llvm/Support/FormattedStream.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -157,3 +158,74 @@

[PATCH] D53296: [analyzer] New flag to print all -analyzer-config options

2018-11-02 Thread Umann Kristóf via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345989: [analyzer] New flag to print all -analyzer-config 
options (authored by Szelethus, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53296?vs=171611&id=172378#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53296

Files:
  cfe/trunk/include/clang/Driver/CC1Options.td
  cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
  cfe/trunk/test/Analysis/analyzer-list-configs.c

Index: cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -241,11 +241,19 @@
 ento::printCheckerHelp(llvm::outs(), Clang->getFrontendOpts().Plugins);
 return true;
   }
+
+  // Honor -analyzer-list-enabled-checkers.
   if (Clang->getAnalyzerOpts()->ShowEnabledCheckerList) {
 ento::printEnabledCheckerList(llvm::outs(),
   Clang->getFrontendOpts().Plugins,
   *Clang->getAnalyzerOpts());
   }
+
+  // Honor -analyzer-config-help.
+  if (Clang->getAnalyzerOpts()->ShowConfigOptionsList) {
+ento::printAnalyzerConfigList(llvm::outs());
+return true;
+  }
 #endif
 
   // If there were errors in processing arguments, don't do anything else.
Index: cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
@@ -22,6 +22,7 @@
 #include "clang/StaticAnalyzer/Frontend/FrontendActions.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/DynamicLibrary.h"
+#include "llvm/Support/FormattedStream.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -157,3 +158,74 @@
   SmallVector checkerOpts = getCheckerOptList(opts);
   ClangCheckerRegistry(plugins).printList(out, checkerOpts);
 }
+
+void ento::printAnalyzerConfigList(raw_ostream &out) {
+  out << "OVERVIEW: Clang Static Analyzer -analyzer-config Option List\n\n";
+  out << "USAGE: clang -cc1 [CLANG_OPTIONS] -analyzer-config "
+"\n\n";
+  out << "   clang -cc1 [CLANG_OPTIONS] -analyzer-config OPTION1=VALUE, "
+  "-analyzer-config OPTION2=VALUE, ...\n\n";
+  out << "   clang [CLANG_OPTIONS] -Xclang -analyzer-config -Xclang"
+"\n\n";
+  out << "   clang [CLANG_OPTIONS] -Xclang -analyzer-config -Xclang "
+  "OPTION1=VALUE, -Xclang -analyzer-config -Xclang "
+  "OPTION2=VALUE, ...\n\n";
+  out << "OPTIONS:\n\n";
+
+  using OptionAndDescriptionTy = std::pair;
+  OptionAndDescriptionTy PrintableOptions[] = {
+#define ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, DEFAULT_VAL)\
+{  \
+  CMDFLAG, \
+  llvm::Twine(llvm::Twine() + "(" +\
+  (#TYPE == "StringRef" ? "string" : #TYPE ) + ") " DESC   \
+  " (default: " #DEFAULT_VAL ")").str()\
+},
+
+#define ANALYZER_OPTION_DEPENDS_ON_USER_MODE(TYPE, NAME, CMDFLAG, DESC,\
+ SHALLOW_VAL, DEEP_VAL)\
+{  \
+  CMDFLAG, \
+  llvm::Twine(llvm::Twine() + "(" +\
+  (#TYPE == "StringRef" ? "string" : #TYPE ) + ") " DESC   \
+  " (default: " #SHALLOW_VAL " in shallow mode, " #DEEP_VAL\
+  " in deep mode)").str()  \
+},
+#include "clang/StaticAnalyzer/Core/AnalyzerOptions.def"
+#undef ANALYZER_OPTION
+#undef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
+  };
+
+  llvm::sort(PrintableOptions, [](const OptionAndDescriptionTy &LHS,
+  const OptionAndDescriptionTy &RHS) {
+return LHS.first < RHS.first;
+  });
+
+  constexpr size_t MinLineWidth = 70;
+  constexpr size_t PadForOpt = 2;
+  constexpr size_t OptionWidth = 30;
+  constexpr size_t PadForDesc = PadForOpt + OptionWidth;
+  static_assert(MinLineWidth > PadForDesc, "MinLineWidth must be greate

r345990 - [analyzer] Put llvm.Conventions back in alpha

2018-11-02 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Fri Nov  2 09:02:10 2018
New Revision: 345990

URL: http://llvm.org/viewvc/llvm-project?rev=345990&view=rev
Log:
[analyzer] Put llvm.Conventions back in alpha

Interestingly, this many year old (when I last looked I remember 2010ish)
checker was committed without any tests, so I thought I'd implement them, but I
was shocked to see how I barely managed to get it working. The code is severely
outdated, I'm not even sure it has ever been used, so I'd propose to move it
back into alpha, and possibly even remove it.

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

Added:
cfe/trunk/test/Analysis/llvm-conventions.cpp
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp
cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
cfe/trunk/test/Analysis/diagnostics/explicit-suppression.cpp
cfe/trunk/test/Analysis/inner-pointer.cpp
cfe/trunk/test/Analysis/temporaries.cpp
cfe/trunk/www/analyzer/alpha_checks.html

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=345990&r1=345989&r2=345990&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Fri Nov  2 
09:02:10 2018
@@ -83,6 +83,7 @@ def LocalizabilityOptIn : Package<"local
 def MPI : Package<"mpi">, InPackage;
 
 def LLVM : Package<"llvm">;
+def LLVMAlpha : Package<"llvm">, InPackage, Hidden;
 
 // The APIModeling package is for checkers that model APIs and don't perform
 // any diagnostics. These checkers are always turned on; this package is
@@ -730,7 +731,7 @@ let ParentPackage = MPI in {
 
//===--===//
 
 def LLVMConventionsChecker : Checker<"Conventions">,
-  InPackage,
+  InPackage,
   HelpText<"Check code for LLVM codebase conventions">,
   DescFile<"LLVMConventionsChecker.cpp">;
 

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp?rev=345990&r1=345989&r2=345990&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp Fri Nov  2 
09:02:10 2018
@@ -32,8 +32,7 @@ static bool IsLLVMStringRef(QualType T)
   if (!RT)
 return false;
 
-  return StringRef(QualType(RT, 0).getAsString()) ==
-  "class StringRef";
+  return StringRef(QualType(RT, 0).getAsString()) == "class StringRef";
 }
 
 /// Check whether the declaration is semantically inside the top-level

Modified: cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h?rev=345990&r1=345989&r2=345990&view=diff
==
--- cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h (original)
+++ cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h Fri Nov  2 
09:02:10 2018
@@ -12,6 +12,13 @@ typedef __typeof__((char*)0-(char*)0) pt
 void *memmove(void *s1, const void *s2, size_t n);
 
 namespace std {
+  typedef size_t size_type;
+#if __cplusplus >= 201103L
+  using nullptr_t = decltype(nullptr);
+#endif
+}
+
+namespace std {
   struct input_iterator_tag { };
   struct output_iterator_tag { };
   struct forward_iterator_tag : public input_iterator_tag { };
@@ -517,6 +524,42 @@ namespace std {
 const T& front() const { return *begin(); }
   };
 
+  template 
+  class basic_string {
+  public:
+basic_string();
+basic_string(const CharT *s);
+
+~basic_string();
+void clear();
+
+basic_string &operator=(const basic_string &str);
+basic_string &operator+=(const basic_string &str);
+
+const CharT *c_str() const;
+const CharT *data() const;
+CharT *data();
+
+basic_string &append(size_type count, CharT ch);
+basic_string &assign(size_type count, CharT ch);
+basic_string &erase(size_type index, size_type count);
+basic_string &insert(size_type index, size_type count, CharT ch);
+basic_string &replace(size_type pos, size_type count, const basic_string 
&str);
+void pop_back();
+void push_back(CharT ch);
+void reserve(size_type new_cap);
+void resize(size_type count);
+void shrink_to_fit();
+void swap(basic_string &other);
+  };
+
+  typedef basic_string string;
+  typedef basic_string wstring;
+#if __cplusplus >= 201103L
+  typedef basic_string u16string;
+  typedef basic_string u32string;
+#endif
+
   class exception {
   public:

[PATCH] D53856: [analyzer] Put llvm.Conventions back in alpha

2018-11-02 Thread Umann Kristóf via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345990: [analyzer] Put llvm.Conventions back in alpha 
(authored by Szelethus, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53856?vs=172253&id=172379#toc

Repository:
  rC Clang

https://reviews.llvm.org/D53856

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
  cfe/trunk/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp
  cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
  cfe/trunk/test/Analysis/diagnostics/explicit-suppression.cpp
  cfe/trunk/test/Analysis/inner-pointer.cpp
  cfe/trunk/test/Analysis/llvm-conventions.cpp
  cfe/trunk/test/Analysis/temporaries.cpp
  cfe/trunk/www/analyzer/alpha_checks.html

Index: cfe/trunk/www/analyzer/alpha_checks.html
===
--- cfe/trunk/www/analyzer/alpha_checks.html
+++ cfe/trunk/www/analyzer/alpha_checks.html
@@ -27,6 +27,7 @@
 Clone Alpha Checkers
 Core Alpha Checkers
 C++ Alpha Checkers
+LLVM Checkers
 Variable Argument Alpha Checkers
 Dead Code Alpha Checkers
 OS X Alpha Checkers
@@ -583,6 +584,31 @@
 
 
 
+
+LLVM Checkers
+
+
+Name, DescriptionExample
+
+
+
+alpha.llvm.Conventions
+(C)
+Check code for LLVM codebase conventions:
+
+  A StringRef should not be bound to a temporary std::string
+  whose lifetime is shorter than the StringRef's.
+  Clang AST nodes should not have fields that can allocate memory.
+
+
+
+
+
+
+
+
+
+
 
 OS X Alpha Checkers
 
Index: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
===
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -83,6 +83,7 @@
 def MPI : Package<"mpi">, InPackage;
 
 def LLVM : Package<"llvm">;
+def LLVMAlpha : Package<"llvm">, InPackage, Hidden;
 
 // The APIModeling package is for checkers that model APIs and don't perform
 // any diagnostics. These checkers are always turned on; this package is
@@ -730,7 +731,7 @@
 //===--===//
 
 def LLVMConventionsChecker : Checker<"Conventions">,
-  InPackage,
+  InPackage,
   HelpText<"Check code for LLVM codebase conventions">,
   DescFile<"LLVMConventionsChecker.cpp">;
 
Index: cfe/trunk/test/Analysis/llvm-conventions.cpp
===
--- cfe/trunk/test/Analysis/llvm-conventions.cpp
+++ cfe/trunk/test/Analysis/llvm-conventions.cpp
@@ -0,0 +1,226 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.llvm.Conventions \
+// RUN:   -std=c++14 -verify  %s
+
+#include "Inputs/system-header-simulator-cxx.h"
+
+//===--===//
+// Forward declarations for StringRef tests.
+//===--===//
+
+using size_t = unsigned long;
+using size_type = size_t;
+
+namespace std {
+
+template 
+struct numeric_limits { const static bool is_signed; };
+
+} // end of namespace std
+
+namespace llvm {
+
+template 
+struct iterator_range;
+
+template 
+struct function_ref;
+
+struct hash_code;
+
+template 
+struct SmallVectorImpl;
+
+struct APInt;
+
+class StringRef {
+public:
+  static const size_t npos = ~size_t(0);
+  using iterator = const char *;
+  using const_iterator = const char *;
+  using size_type = size_t;
+
+  /*implicit*/ StringRef() = default;
+  StringRef(std::nullptr_t) = delete;
+  /*implicit*/ StringRef(const char *Str);
+  /*implicit*/ constexpr StringRef(const char *data, size_t length);
+  /*implicit*/ StringRef(const std::string &Str);
+
+  static StringRef withNullAsEmpty(const char *data);
+  iterator begin() const;
+  iterator end() const;
+  const unsigned char *bytes_begin() const;
+  const unsigned char *bytes_end() const;
+  iterator_range bytes() const;
+  const char *data() const;
+  bool empty() const;
+  size_t size() const;
+  char front() const;
+  char back() const;
+  template 
+  StringRef copy(Allocator &A) const;
+  bool equals(StringRef RHS) const;
+  bool equals_lower(StringRef RHS) const;
+  int compare(StringRef RHS) const;
+  int compare_lower(StringRef RHS) const;
+  int compare_numeric(StringRef RHS) const;
+  unsigned edit_distance(StringRef Other, bool AllowReplacements = true,
+ unsigned MaxEditDistance = 0) const;
+  std::string str() const;
+  char operator[](size_t Index) const;
+  template 
+  typename std::enable_if::value,
+  StringRef>::type &
+  operator=(T &&Str) = delete;
+  operator std::string() const;
+  bool startswith(StringRef Prefix) const;
+  bool startswith_lower(StringRef Prefix) const;
+  bool endswith(StringRef Suffix) const;
+  bool endswith_lower(StringRef Suffix) const;
+  size_t find(char C, size_t From = 0) const;
+  

[PATCH] D53856: [analyzer] Put llvm.Conventions back in alpha

2018-11-02 Thread Umann Kristóf via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC345990: [analyzer] Put llvm.Conventions back in alpha 
(authored by Szelethus, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53856?vs=172253&id=172380#toc

Repository:
  rC Clang

https://reviews.llvm.org/D53856

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp
  test/Analysis/Inputs/system-header-simulator-cxx.h
  test/Analysis/diagnostics/explicit-suppression.cpp
  test/Analysis/inner-pointer.cpp
  test/Analysis/llvm-conventions.cpp
  test/Analysis/temporaries.cpp
  www/analyzer/alpha_checks.html

Index: include/clang/StaticAnalyzer/Checkers/Checkers.td
===
--- include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -83,6 +83,7 @@
 def MPI : Package<"mpi">, InPackage;
 
 def LLVM : Package<"llvm">;
+def LLVMAlpha : Package<"llvm">, InPackage, Hidden;
 
 // The APIModeling package is for checkers that model APIs and don't perform
 // any diagnostics. These checkers are always turned on; this package is
@@ -730,7 +731,7 @@
 //===--===//
 
 def LLVMConventionsChecker : Checker<"Conventions">,
-  InPackage,
+  InPackage,
   HelpText<"Check code for LLVM codebase conventions">,
   DescFile<"LLVMConventionsChecker.cpp">;
 
Index: test/Analysis/inner-pointer.cpp
===
--- test/Analysis/inner-pointer.cpp
+++ test/Analysis/inner-pointer.cpp
@@ -1,43 +1,9 @@
-//RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.InnerPointer %s -analyzer-output=text -verify
+// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.InnerPointer \
+// RUN:   %s -analyzer-output=text -verify
 
+#include "Inputs/system-header-simulator-cxx.h"
 namespace std {
 
-typedef int size_type;
-
-template 
-class basic_string {
-public:
-  basic_string();
-  basic_string(const CharT *s);
-
-  ~basic_string();
-  void clear();
-
-  basic_string &operator=(const basic_string &str);
-  basic_string &operator+=(const basic_string &str);
-
-  const CharT *c_str() const;
-  const CharT *data() const;
-  CharT *data();
-
-  basic_string &append(size_type count, CharT ch);
-  basic_string &assign(size_type count, CharT ch);
-  basic_string &erase(size_type index, size_type count);
-  basic_string &insert(size_type index, size_type count, CharT ch);
-  basic_string &replace(size_type pos, size_type count, const basic_string &str);
-  void pop_back();
-  void push_back(CharT ch);
-  void reserve(size_type new_cap);
-  void resize(size_type count);
-  void shrink_to_fit();
-  void swap(basic_string &other);
-};
-
-typedef basic_string string;
-typedef basic_string wstring;
-typedef basic_string u16string;
-typedef basic_string u32string;
-
 template 
 void func_ref(T &a);
 
Index: test/Analysis/llvm-conventions.cpp
===
--- test/Analysis/llvm-conventions.cpp
+++ test/Analysis/llvm-conventions.cpp
@@ -0,0 +1,226 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.llvm.Conventions \
+// RUN:   -std=c++14 -verify  %s
+
+#include "Inputs/system-header-simulator-cxx.h"
+
+//===--===//
+// Forward declarations for StringRef tests.
+//===--===//
+
+using size_t = unsigned long;
+using size_type = size_t;
+
+namespace std {
+
+template 
+struct numeric_limits { const static bool is_signed; };
+
+} // end of namespace std
+
+namespace llvm {
+
+template 
+struct iterator_range;
+
+template 
+struct function_ref;
+
+struct hash_code;
+
+template 
+struct SmallVectorImpl;
+
+struct APInt;
+
+class StringRef {
+public:
+  static const size_t npos = ~size_t(0);
+  using iterator = const char *;
+  using const_iterator = const char *;
+  using size_type = size_t;
+
+  /*implicit*/ StringRef() = default;
+  StringRef(std::nullptr_t) = delete;
+  /*implicit*/ StringRef(const char *Str);
+  /*implicit*/ constexpr StringRef(const char *data, size_t length);
+  /*implicit*/ StringRef(const std::string &Str);
+
+  static StringRef withNullAsEmpty(const char *data);
+  iterator begin() const;
+  iterator end() const;
+  const unsigned char *bytes_begin() const;
+  const unsigned char *bytes_end() const;
+  iterator_range bytes() const;
+  const char *data() const;
+  bool empty() const;
+  size_t size() const;
+  char front() const;
+  char back() const;
+  template 
+  StringRef copy(Allocator &A) const;
+  bool equals(StringRef RHS) const;
+  bool equals_lower(StringRef RHS) const;
+  int compare(StringRef RHS) const;
+  int compare_lower(StringRef RHS) const;
+  int compare_numeric(StringRef RHS) const;
+  unsigned edit_distance(StringRef Other, bool

r345991 - [OPENMP][NVPTX]Use __kmpc_data_sharing_coalesced_push_stack function.

2018-11-02 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Nov  2 09:08:31 2018
New Revision: 345991

URL: http://llvm.org/viewvc/llvm-project?rev=345991&view=rev
Log:
[OPENMP][NVPTX]Use __kmpc_data_sharing_coalesced_push_stack function.

Coalesced memory access requires use of the new function
`__kmpc_data_sharing_coalesced_push_stack` instead of the
`__kmpc_data_sharing_push_stack`.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/test/OpenMP/declare_target_codegen_globalization.cpp
cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=345991&r1=345990&r2=345991&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Fri Nov  2 09:08:31 2018
@@ -84,9 +84,9 @@ enum OpenMPRTLFunctionNVPTX {
   OMPRTL_NVPTX__kmpc_data_sharing_init_stack,
   /// Call to void __kmpc_data_sharing_init_stack_spmd();
   OMPRTL_NVPTX__kmpc_data_sharing_init_stack_spmd,
-  /// Call to void* __kmpc_data_sharing_push_stack(size_t size,
+  /// Call to void* __kmpc_data_sharing_coalesced_push_stack(size_t size,
   /// int16_t UseSharedMemory);
-  OMPRTL_NVPTX__kmpc_data_sharing_push_stack,
+  OMPRTL_NVPTX__kmpc_data_sharing_coalesced_push_stack,
   /// Call to void __kmpc_data_sharing_pop_stack(void *a);
   OMPRTL_NVPTX__kmpc_data_sharing_pop_stack,
   /// Call to void __kmpc_begin_sharing_variables(void ***args,
@@ -1745,14 +1745,14 @@ CGOpenMPRuntimeNVPTX::createNVPTXRuntime
 CGM.CreateRuntimeFunction(FnTy, "__kmpc_data_sharing_init_stack_spmd");
 break;
   }
-  case OMPRTL_NVPTX__kmpc_data_sharing_push_stack: {
-// Build void *__kmpc_data_sharing_push_stack(size_t size,
+  case OMPRTL_NVPTX__kmpc_data_sharing_coalesced_push_stack: {
+// Build void *__kmpc_data_sharing_coalesced_push_stack(size_t size,
 // int16_t UseSharedMemory);
 llvm::Type *TypeParams[] = {CGM.SizeTy, CGM.Int16Ty};
 auto *FnTy =
 llvm::FunctionType::get(CGM.VoidPtrTy, TypeParams, /*isVarArg=*/false);
 RTLFn = CGM.CreateRuntimeFunction(
-FnTy, /*Name=*/"__kmpc_data_sharing_push_stack");
+FnTy, /*Name=*/"__kmpc_data_sharing_coalesced_push_stack");
 break;
   }
   case OMPRTL_NVPTX__kmpc_data_sharing_pop_stack: {
@@ -2105,10 +2105,10 @@ void CGOpenMPRuntimeNVPTX::emitGenericVa
   // the user, for now, default to global.
   llvm::Value *GlobalRecordSizeArg[] = {
   Size, CGF.Builder.getInt16(/*UseSharedMemory=*/0)};
-  llvm::Value *GlobalRecValue =
-  CGF.EmitRuntimeCall(createNVPTXRuntimeFunction(
-  OMPRTL_NVPTX__kmpc_data_sharing_push_stack),
-  GlobalRecordSizeArg);
+  llvm::Value *GlobalRecValue = CGF.EmitRuntimeCall(
+  createNVPTXRuntimeFunction(
+  OMPRTL_NVPTX__kmpc_data_sharing_coalesced_push_stack),
+  GlobalRecordSizeArg);
   GlobalRecCastAddr = Bld.CreatePointerBitCastOrAddrSpaceCast(
   GlobalRecValue, GlobalRecPtrTy);
   CGF.EmitBlock(ExitBB);
@@ -2182,10 +2182,10 @@ void CGOpenMPRuntimeNVPTX::emitGenericVa
   llvm::Value *GlobalRecordSizeArg[] = {
   llvm::ConstantInt::get(CGM.SizeTy, GlobalRecordSize),
   CGF.Builder.getInt16(/*UseSharedMemory=*/0)};
-  llvm::Value *GlobalRecValue =
-  CGF.EmitRuntimeCall(createNVPTXRuntimeFunction(
-  OMPRTL_NVPTX__kmpc_data_sharing_push_stack),
-  GlobalRecordSizeArg);
+  llvm::Value *GlobalRecValue = CGF.EmitRuntimeCall(
+  createNVPTXRuntimeFunction(
+  OMPRTL_NVPTX__kmpc_data_sharing_coalesced_push_stack),
+  GlobalRecordSizeArg);
   GlobalRecCastAddr = Bld.CreatePointerBitCastOrAddrSpaceCast(
   GlobalRecValue, GlobalRecPtrTy);
   I->getSecond().GlobalRecordAddr = GlobalRecValue;
@@ -2282,7 +2282,8 @@ void CGOpenMPRuntimeNVPTX::emitGenericVa
 llvm::Value *GlobalRecordSizeArg[] = {
 Size, CGF.Builder.getInt16(/*UseSharedMemory=*/0)};
 llvm::Value *GlobalRecValue = CGF.EmitRuntimeCall(
-createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_data_sharing_push_stack),
+createNVPTXRuntimeFunction(
+OMPRTL_NVPTX__kmpc_data_sharing_coalesced_push_stack),
 GlobalRecordSizeArg);
 llvm::Value *GlobalRecCastAddr = Bld.CreatePointerBitCastOrAddrSpaceCast(
 GlobalRecValue, CGF.ConvertTypeForMem(VD->getType())->getPointerTo());

Modified: cfe/trunk/test/OpenMP/declare_target_codegen_globalization.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_target_codegen_globalization.cpp?rev=345991&r1=345990&r2=345991&view=diff
==
--- cfe/trunk/test/OpenMP/declare

r345992 - [analyzer] Fix diagnostics/explicit-suppression.cpp

2018-11-02 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Fri Nov  2 09:23:37 2018
New Revision: 345992

URL: http://llvm.org/viewvc/llvm-project?rev=345992&view=rev
Log:
[analyzer] Fix diagnostics/explicit-suppression.cpp

*OI++ = *II++ is on line 670, not 668

Modified:
cfe/trunk/test/Analysis/diagnostics/explicit-suppression.cpp

Modified: cfe/trunk/test/Analysis/diagnostics/explicit-suppression.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/diagnostics/explicit-suppression.cpp?rev=345992&r1=345991&r2=345992&view=diff
==
--- cfe/trunk/test/Analysis/diagnostics/explicit-suppression.cpp (original)
+++ cfe/trunk/test/Analysis/diagnostics/explicit-suppression.cpp Fri Nov  2 
09:23:37 2018
@@ -19,6 +19,6 @@ class C {
 void testCopyNull(C *I, C *E) {
   std::copy(I, E, (C *)0);
 #ifndef SUPPRESSED
-  // expected-warning@../Inputs/system-header-simulator-cxx.h:668 {{Called C++ 
object pointer is null}}
+  // expected-warning@../Inputs/system-header-simulator-cxx.h:670 {{Called C++ 
object pointer is null}}
 #endif
 }


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


[PATCH] D52998: [benchmark] Disable exceptions in Microsoft STL

2018-11-02 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev accepted this revision.
kbobyrev added a comment.
This revision is now accepted and ready to land.

The patch is good to go!

Please add the commit reference to `utils/benchmark/README.LLVM` 
(https://github.com/google/benchmark/commit/a9b31c51b1ee7ec7b31438c647123c2cbac5d956)
 and the patch could be landed!


https://reviews.llvm.org/D52998



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


r345993 - Didn't -> didnt, because #errors complains about untermianted '

2018-11-02 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Fri Nov  2 09:32:15 2018
New Revision: 345993

URL: http://llvm.org/viewvc/llvm-project?rev=345993&view=rev
Log:
Didn't -> didnt, because #errors complains about untermianted '

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def?rev=345993&r1=345992&r2=345993&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def Fri Nov  2 
09:32:15 2018
@@ -41,14 +41,14 @@
 
 #ifdef ANALYZER_OPTION
 #ifndef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
-#error If you didn't include this file with the intent of generating methods, \
+#error If you didnt include this file with the intent of generating methods, \
 define both 'ANALYZER_OPTION' and 'ANALYZER_OPTION_DEPENDS_ON_USER_MODE' 
macros!
 #endif
 #endif
 
 #ifndef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
 #ifdef ANALYZER_OPTION
-#error If you didn't include this file with the intent of generating methods, \
+#error If you didnt include this file with the intent of generating methods, \
 define both 'ANALYZER_OPTION' and 'ANALYZER_OPTION_DEPENDS_ON_USER_MODE' 
macros!
 #endif
 #endif


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


[clang-tools-extra] r345995 - [fix][clang-tidy] fix for r345961 that introduced a test failure on Windows builds

2018-11-02 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Fri Nov  2 09:36:21 2018
New Revision: 345995

URL: http://llvm.org/viewvc/llvm-project?rev=345995&view=rev
Log:
[fix][clang-tidy] fix for r345961 that introduced a test failure on Windows 
builds

r345961 introduced a path check in
.\tools\clang\tools\extra\test\clang-tidy\clang-tidy-run-with-database.cpp.

r345961 added a check line for a path that only handled / on unix
machines and not \ on windows machines.

This patch handles both cases.

Patch by TWeaver.

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

Modified:
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-run-with-database.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-run-with-database.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/clang-tidy-run-with-database.cpp?rev=345995&r1=345994&r2=345995&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/clang-tidy-run-with-database.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/clang-tidy-run-with-database.cpp 
Fri Nov  2 09:36:21 2018
@@ -11,7 +11,7 @@
 
 // Regression test: shouldn't crash.
 // RUN: not clang-tidy --checks=-*,modernize-use-nullptr -p %T 
%T/compilation-database-test/b/not-exist -header-filter=.* 2>&1 | FileCheck %s 
-check-prefix=CHECK-NOT-EXIST
-// CHECK-NOT-EXIST: Error while processing {{.*}}/not-exist.
+// CHECK-NOT-EXIST: Error while processing {{.*[/\\]}}not-exist.
 // CHECK-NOT-EXIST: unable to handle compilation
 // CHECK-NOT-EXIST: Found compiler error
 


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


[PATCH] D54036: [fix][clang-tidy] fix for r345961 that introduced a test failure on Windows builds

2018-11-02 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth closed this revision.
JonasToth added a comment.

Thank you very much for the patch!
Committed in r345995.


Repository:
  rL LLVM

https://reviews.llvm.org/D54036



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


Re: r345971 - Reapply Logging: make os_log buffer size an integer constant expression.

2018-11-02 Thread Tim Northover via cfe-commits
On 2 Nov 2018, at 15:28, Sam McCall  wrote:
> In that case, I don't think it makes sense to think of the format string 
> parser as part of the analyzer - as the build deps suggest, it's now part of 
> AST and gets reused by analyzer. (Similar to how the analyzer uses other bits 
> of AST/clang). If there are parts only relevant to analyzer, it'd be nice to 
> move them out of the AST library, but I don't know to what extent that's 
> feasible.

The Scanf one could have been left there, but that seems even worse from a 
consistency point of view.

> So it does seem to me like all the uses of analyzer namespaces are suspect - 
> moving code from Analyzer to AST is a semantic difference (the layers aren't 
> *just* about making the linker happy, after all!)

But what it’s doing is still analysis. It seems like we’d just be making up 
another term for the sake of it if we changed it.

Cheers.

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


[PATCH] D53974: [clang-tidy] new check: bugprone-too-small-loop-variable

2018-11-02 Thread Tamás Zolnai via Phabricator via cfe-commits
ztamas added a comment.

Just to make it clear. I think this check is in a good shape now. I mean it 
catches usefull issues and also does not produce too many false positives, as I 
see.
So my intention here is to get it in as it is now (of course after I fixed 
things reviewers find) and later it can be improved in separate patches (e.g. 
reduce false positives even more, handle other use cases like while loop etc.). 
I think it would be better to have smaller patches than polishing this big one 
until it gets ~prefect.
In the test file I added some TODO comments. They were added as a documentation 
of future possibilities.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53974



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


r345997 - Remove the duplicated definition of size_t

2018-11-02 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Fri Nov  2 10:00:07 2018
New Revision: 345997

URL: http://llvm.org/viewvc/llvm-project?rev=345997&view=rev
Log:
Remove the duplicated definition of size_t

So hopefully windows won't complain.

Modified:
cfe/trunk/test/Analysis/llvm-conventions.cpp

Modified: cfe/trunk/test/Analysis/llvm-conventions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/llvm-conventions.cpp?rev=345997&r1=345996&r2=345997&view=diff
==
--- cfe/trunk/test/Analysis/llvm-conventions.cpp (original)
+++ cfe/trunk/test/Analysis/llvm-conventions.cpp Fri Nov  2 10:00:07 2018
@@ -7,7 +7,6 @@
 // Forward declarations for StringRef tests.
 
//===--===//
 
-using size_t = unsigned long;
 using size_type = size_t;
 
 namespace std {


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


[PATCH] D52615: Handle -fsanitize-address-poison-class-member-array-new-cookie in the driver and propagate it to cc1

2018-11-02 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D52615



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


Re: r345993 - Didn't -> didnt, because #errors complains about untermianted '

2018-11-02 Thread Aaron Ballman via cfe-commits
On Fri, Nov 2, 2018 at 12:34 PM Kristof Umann via cfe-commits
 wrote:
>
> Author: szelethus
> Date: Fri Nov  2 09:32:15 2018
> New Revision: 345993
>
> URL: http://llvm.org/viewvc/llvm-project?rev=345993&view=rev
> Log:
> Didn't -> didnt, because #errors complains about untermianted '

Why not quote the string instead of making it ungrammatical? e.g.,

#error "If you didn't include this file with the intent of generating
methods, define both 'ANALYZER_OPTION' " \
   "and 'ANALYZER_OPTION_DEPENDS_ON_USER_MODE' macros!"

~Aaron

>
> Modified:
> cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
>
> Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def?rev=345993&r1=345992&r2=345993&view=diff
> ==
> --- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def (original)
> +++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def Fri Nov  
> 2 09:32:15 2018
> @@ -41,14 +41,14 @@
>
>  #ifdef ANALYZER_OPTION
>  #ifndef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
> -#error If you didn't include this file with the intent of generating 
> methods, \
> +#error If you didnt include this file with the intent of generating methods, 
> \
>  define both 'ANALYZER_OPTION' and 'ANALYZER_OPTION_DEPENDS_ON_USER_MODE' 
> macros!
>  #endif
>  #endif
>
>  #ifndef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
>  #ifdef ANALYZER_OPTION
> -#error If you didn't include this file with the intent of generating 
> methods, \
> +#error If you didnt include this file with the intent of generating methods, 
> \
>  define both 'ANALYZER_OPTION' and 'ANALYZER_OPTION_DEPENDS_ON_USER_MODE' 
> macros!
>  #endif
>  #endif
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52998: [benchmark] Disable exceptions in Microsoft STL

2018-11-02 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews added a comment.

Thanks!


https://reviews.llvm.org/D52998



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


r346001 - Change -fsanitize-address-poison-class-member-array-new-cookie to -fsanitize-address-poison-custom-array-cookie

2018-11-02 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Fri Nov  2 10:29:04 2018
New Revision: 346001

URL: http://llvm.org/viewvc/llvm-project?rev=346001&view=rev
Log:
Change -fsanitize-address-poison-class-member-array-new-cookie to 
-fsanitize-address-poison-custom-array-cookie

Handle it in the driver and propagate it to cc1

Reviewers: rjmccall, kcc, rsmith

Subscribers: cfe-commits

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

Modified:
cfe/trunk/docs/ClangCommandLineReference.rst
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/SanitizerArgs.h
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/address-sanitizer-and-array-cookie.cpp
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/docs/ClangCommandLineReference.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=346001&r1=346000&r2=346001&view=diff
==
--- cfe/trunk/docs/ClangCommandLineReference.rst (original)
+++ cfe/trunk/docs/ClangCommandLineReference.rst Fri Nov  2 10:29:04 2018
@@ -800,9 +800,11 @@ Level of field padding for AddressSaniti
 
 Enable linker dead stripping of globals in AddressSanitizer
 
-.. option:: -fsanitize-address-poison-class-member-array-new-cookie, 
-fno-sanitize-address-poison-class-member-array-new-cookie
+.. option:: -fsanitize-address-poison-custom-array-cookie, 
-fno-sanitize-address-poison-custom-array-cookie
 
-Enable poisoning array cookies when using class member operator new\[\] in 
AddressSanitizer
+Enable "poisoning" array cookies when allocating arrays with a custom operator 
new\[\] in Address Sanitizer, preventing accesses to the cookies from user 
code. An array cookie is a small implementation-defined header added to certain 
array allocations to record metadata such as the length of the array. Accesses 
to array cookies from user code are technically allowed by the standard but are 
more likely to be the result of an out-of-bounds array access.
+
+An operator new\[\] is "custom" if it is not one of the allocation functions 
provided by the C++ standard library. Array cookies from non-custom allocation 
functions are always poisoned.
 
 .. option:: -fsanitize-address-use-after-scope, 
-fno-sanitize-address-use-after-scope
 

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=346001&r1=346000&r2=346001&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Fri Nov  2 10:29:04 2018
@@ -3000,8 +3000,8 @@ Execute ``clang-cl /?`` to see a list of
   -fno-debug-macroDo not emit macro debug information
   -fno-delayed-template-parsing
   Disable delayed template parsing
-  -fno-sanitize-address-poison-class-member-array-new-cookie
-  Disable poisoning array cookies when using class 
member operator new[] in AddressSanitizer
+  -fno-sanitize-address-poison-custom-array-cookie
+  Disable poisoning array cookies when using 
custom operator new[] in AddressSanitizer
   -fno-sanitize-address-use-after-scope
   Disable use-after-scope detection in 
AddressSanitizer
   -fno-sanitize-blacklist Don't use blacklist file for sanitizers
@@ -3037,8 +3037,8 @@ Execute ``clang-cl /?`` to see a list of
   Level of field padding for AddressSanitizer
   -fsanitize-address-globals-dead-stripping
   Enable linker dead stripping of globals in 
AddressSanitizer
-  -fsanitize-address-poison-class-member-array-new-cookie
-  Enable poisoning array cookies when using class 
member operator new[] in AddressSanitizer
+  -fsanitize-address-poison-custom-array-cookie
+  Enable poisoning array cookies when using custom 
operator new[] in AddressSanitizer
   -fsanitize-address-use-after-scope
   Enable use-after-scope detection in 
AddressSanitizer
   -fsanitize-blacklist=

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=346001&r1=346000&r2=346001&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Nov  2 10:29:04 2018
@@ -971,14 +971,14 @@ def fno_sanitize_address_use_after_scope
Group,
Flags<[CoreOption, Drive

[PATCH] D52615: Handle -fsanitize-address-poison-class-member-array-new-cookie in the driver and propagate it to cc1

2018-11-02 Thread Filipe Cabecinhas via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC346001: Change 
-fsanitize-address-poison-class-member-array-new-cookie to -fsanitize… 
(authored by filcab, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52615?vs=172376&id=172392#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52615

Files:
  docs/ClangCommandLineReference.rst
  docs/UsersManual.rst
  include/clang/Driver/Options.td
  include/clang/Driver/SanitizerArgs.h
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/address-sanitizer-and-array-cookie.cpp
  test/Driver/fsanitize.c

Index: docs/ClangCommandLineReference.rst
===
--- docs/ClangCommandLineReference.rst
+++ docs/ClangCommandLineReference.rst
@@ -800,9 +800,11 @@
 
 Enable linker dead stripping of globals in AddressSanitizer
 
-.. option:: -fsanitize-address-poison-class-member-array-new-cookie, -fno-sanitize-address-poison-class-member-array-new-cookie
+.. option:: -fsanitize-address-poison-custom-array-cookie, -fno-sanitize-address-poison-custom-array-cookie
 
-Enable poisoning array cookies when using class member operator new\[\] in AddressSanitizer
+Enable "poisoning" array cookies when allocating arrays with a custom operator new\[\] in Address Sanitizer, preventing accesses to the cookies from user code. An array cookie is a small implementation-defined header added to certain array allocations to record metadata such as the length of the array. Accesses to array cookies from user code are technically allowed by the standard but are more likely to be the result of an out-of-bounds array access.
+
+An operator new\[\] is "custom" if it is not one of the allocation functions provided by the C++ standard library. Array cookies from non-custom allocation functions are always poisoned.
 
 .. option:: -fsanitize-address-use-after-scope, -fno-sanitize-address-use-after-scope
 
Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -3000,8 +3000,8 @@
   -fno-debug-macroDo not emit macro debug information
   -fno-delayed-template-parsing
   Disable delayed template parsing
-  -fno-sanitize-address-poison-class-member-array-new-cookie
-  Disable poisoning array cookies when using class member operator new[] in AddressSanitizer
+  -fno-sanitize-address-poison-custom-array-cookie
+  Disable poisoning array cookies when using custom operator new[] in AddressSanitizer
   -fno-sanitize-address-use-after-scope
   Disable use-after-scope detection in AddressSanitizer
   -fno-sanitize-blacklist Don't use blacklist file for sanitizers
@@ -3037,8 +3037,8 @@
   Level of field padding for AddressSanitizer
   -fsanitize-address-globals-dead-stripping
   Enable linker dead stripping of globals in AddressSanitizer
-  -fsanitize-address-poison-class-member-array-new-cookie
-  Enable poisoning array cookies when using class member operator new[] in AddressSanitizer
+  -fsanitize-address-poison-custom-array-cookie
+  Enable poisoning array cookies when using custom operator new[] in AddressSanitizer
   -fsanitize-address-use-after-scope
   Enable use-after-scope detection in AddressSanitizer
   -fsanitize-blacklist=
Index: include/clang/Frontend/CodeGenOptions.def
===
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -174,7 +174,7 @@
 CODEGENOPT(SaveTempLabels, 1, 0) ///< Save temporary labels.
 CODEGENOPT(SanitizeAddressUseAfterScope , 1, 0) ///< Enable use-after-scope detection
 ///< in AddressSanitizer
-CODEGENOPT(SanitizeAddressPoisonClassMemberArrayNewCookie, 1,
+CODEGENOPT(SanitizeAddressPoisonCustomArrayCookie, 1,
0) ///< Enable poisoning operator new[] which is not a replaceable
   ///< global allocation function in AddressSanitizer
 CODEGENOPT(SanitizeAddressGlobalsDeadStripping, 1, 0) ///< Enable linker dead stripping
Index: include/clang/Driver/SanitizerArgs.h
===
--- include/clang/Driver/SanitizerArgs.h
+++ include/clang/Driver/SanitizerArgs.h
@@ -36,6 +36,7 @@
   int AsanFieldPadding = 0;
   bool SharedRuntime = false;
   bool AsanUseAfterScope = true;
+  bool AsanPoisonCustomArrayCookie = false;
   bool AsanGlobalsDeadStripping = false;
   bool LinkCXXRuntimes = false;
   bool NeedPIE = false;
Index: include/clang/Driver/

[PATCH] D52615: Handle -fsanitize-address-poison-class-member-array-new-cookie in the driver and propagate it to cc1

2018-11-02 Thread Filipe Cabecinhas via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL346001: Change 
-fsanitize-address-poison-class-member-array-new-cookie to -fsanitize… 
(authored by filcab, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D52615

Files:
  cfe/trunk/docs/ClangCommandLineReference.rst
  cfe/trunk/docs/UsersManual.rst
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Driver/SanitizerArgs.h
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/lib/Driver/SanitizerArgs.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGen/address-sanitizer-and-array-cookie.cpp
  cfe/trunk/test/Driver/fsanitize.c

Index: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
===
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
@@ -1916,7 +1916,7 @@
   // Handle the array cookie specially in ASan.
   if (CGM.getLangOpts().Sanitize.has(SanitizerKind::Address) && AS == 0 &&
   (expr->getOperatorNew()->isReplaceableGlobalAllocationFunction() ||
-   CGM.getCodeGenOpts().SanitizeAddressPoisonClassMemberArrayNewCookie)) {
+   CGM.getCodeGenOpts().SanitizeAddressPoisonCustomArrayCookie)) {
 // The store to the CookiePtr does not need to be instrumented.
 CGM.getSanitizerMetadata()->disableSanitizerForInstruction(SI);
 llvm::FunctionType *FTy =
Index: cfe/trunk/lib/Driver/SanitizerArgs.cpp
===
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp
@@ -724,6 +724,11 @@
 options::OPT_fsanitize_address_use_after_scope,
 options::OPT_fno_sanitize_address_use_after_scope, AsanUseAfterScope);
 
+AsanPoisonCustomArrayCookie = Args.hasFlag(
+options::OPT_fsanitize_address_poison_custom_array_cookie,
+options::OPT_fno_sanitize_address_poison_custom_array_cookie,
+AsanPoisonCustomArrayCookie);
+
 // As a workaround for a bug in gold 2.26 and earlier, dead stripping of
 // globals in ASan is disabled by default on ELF targets.
 // See https://sourceware.org/bugzilla/show_bug.cgi?id=19002
@@ -897,6 +902,9 @@
   if (AsanUseAfterScope)
 CmdArgs.push_back("-fsanitize-address-use-after-scope");
 
+  if (AsanPoisonCustomArrayCookie)
+CmdArgs.push_back("-fsanitize-address-poison-custom-array-cookie");
+
   if (AsanGlobalsDeadStripping)
 CmdArgs.push_back("-fsanitize-address-globals-dead-stripping");
 
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -969,11 +969,11 @@
   Args.hasArg(OPT_fsanitize_cfi_icall_generalize_pointers);
   Opts.SanitizeStats = Args.hasArg(OPT_fsanitize_stats);
   if (Arg *A = Args.getLastArg(
-  OPT_fsanitize_address_poison_class_member_array_new_cookie,
-  OPT_fno_sanitize_address_poison_class_member_array_new_cookie)) {
-Opts.SanitizeAddressPoisonClassMemberArrayNewCookie =
+  OPT_fsanitize_address_poison_custom_array_cookie,
+  OPT_fno_sanitize_address_poison_custom_array_cookie)) {
+Opts.SanitizeAddressPoisonCustomArrayCookie =
 A->getOption().getID() ==
-OPT_fsanitize_address_poison_class_member_array_new_cookie;
+OPT_fsanitize_address_poison_custom_array_cookie;
   }
   if (Arg *A = Args.getLastArg(OPT_fsanitize_address_use_after_scope,
OPT_fno_sanitize_address_use_after_scope)) {
Index: cfe/trunk/docs/UsersManual.rst
===
--- cfe/trunk/docs/UsersManual.rst
+++ cfe/trunk/docs/UsersManual.rst
@@ -3000,8 +3000,8 @@
   -fno-debug-macroDo not emit macro debug information
   -fno-delayed-template-parsing
   Disable delayed template parsing
-  -fno-sanitize-address-poison-class-member-array-new-cookie
-  Disable poisoning array cookies when using class member operator new[] in AddressSanitizer
+  -fno-sanitize-address-poison-custom-array-cookie
+  Disable poisoning array cookies when using custom operator new[] in AddressSanitizer
   -fno-sanitize-address-use-after-scope
   Disable use-after-scope detection in AddressSanitizer
   -fno-sanitize-blacklist Don't use blacklist file for sanitizers
@@ -3037,8 +3037,8 @@
   Level of field padding for AddressSanitizer
   -fsanitize-address-globals-dead-stripping
   Enable linker dead stripping of globals in AddressSanitizer
-  -fsanitize-address-poison-class-member-array-new-cookie
- 

[PATCH] D52615: Handle -fsanitize-address-poison-class-member-array-new-cookie in the driver and propagate it to cc1

2018-11-02 Thread Filipe Cabecinhas via Phabricator via cfe-commits
filcab added a comment.

Thanks for the review.
Unfortunately, I forgot to edit the commit message. Let's hope no one gets too 
confused (phab reviews will be up anyway, so should be easy to figure out).
Filipe


Repository:
  rL LLVM

https://reviews.llvm.org/D52615



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


r346004 - [CodeGen] Fix a crash when updating a designated initializer

2018-11-02 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Fri Nov  2 10:36:58 2018
New Revision: 346004

URL: http://llvm.org/viewvc/llvm-project?rev=346004&view=rev
Log:
[CodeGen] Fix a crash when updating a designated initializer

We need to handle the ConstantAggregateZero case here too.

rdar://45691981

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

Modified:
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/test/CodeGen/designated-initializers.c

Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=346004&r1=346003&r2=346004&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Fri Nov  2 10:36:58 2018
@@ -47,7 +47,7 @@ class ConstStructBuilder {
 public:
   static llvm::Constant *BuildStruct(ConstantEmitter &Emitter,
  ConstExprEmitter *ExprEmitter,
- llvm::ConstantStruct *Base,
+ llvm::Constant *Base,
  InitListExpr *Updater,
  QualType ValTy);
   static llvm::Constant *BuildStruct(ConstantEmitter &Emitter,
@@ -76,7 +76,7 @@ private:
   void ConvertStructToPacked();
 
   bool Build(InitListExpr *ILE);
-  bool Build(ConstExprEmitter *Emitter, llvm::ConstantStruct *Base,
+  bool Build(ConstExprEmitter *Emitter, llvm::Constant *Base,
  InitListExpr *Updater);
   bool Build(const APValue &Val, const RecordDecl *RD, bool IsPrimaryBase,
  const CXXRecordDecl *VTableClass, CharUnits BaseOffset);
@@ -566,7 +566,7 @@ llvm::Constant *ConstStructBuilder::Fina
 
 llvm::Constant *ConstStructBuilder::BuildStruct(ConstantEmitter &Emitter,
 ConstExprEmitter *ExprEmitter,
-llvm::ConstantStruct *Base,
+llvm::Constant *Base,
 InitListExpr *Updater,
 QualType ValTy) {
   ConstStructBuilder Builder(Emitter);
@@ -1027,8 +1027,8 @@ public:
 }
 
 if (destType->isRecordType())
-  return ConstStructBuilder::BuildStruct(Emitter, this,
- dyn_cast(Base), Updater, destType);
+  return ConstStructBuilder::BuildStruct(Emitter, this, Base, Updater,
+ destType);
 
 return nullptr;
   }
@@ -1103,7 +1103,7 @@ public:
 }  // end anonymous namespace.
 
 bool ConstStructBuilder::Build(ConstExprEmitter *ExprEmitter,
-   llvm::ConstantStruct *Base,
+   llvm::Constant *Base,
InitListExpr *Updater) {
   assert(Base && "base expression should not be empty");
 
@@ -,7 +,7 @@ bool ConstStructBuilder::Build(ConstExpr
   RecordDecl *RD = ExprType->getAs()->getDecl();
   const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(RD);
   const llvm::StructLayout *BaseLayout = CGM.getDataLayout().getStructLayout(
-   Base->getType());
+  cast(Base->getType()));
   unsigned FieldNo = -1;
   unsigned ElementNo = 0;
 
@@ -1132,7 +1132,7 @@ bool ConstStructBuilder::Build(ConstExpr
 if (Field->isUnnamedBitfield())
   continue;
 
-llvm::Constant *EltInit = Base->getOperand(ElementNo);
+llvm::Constant *EltInit = Base->getAggregateElement(ElementNo);
 
 // Bail out if the type of the ConstantStruct does not have the same layout
 // as the type of the InitListExpr.

Modified: cfe/trunk/test/CodeGen/designated-initializers.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/designated-initializers.c?rev=346004&r1=346003&r2=346004&view=diff
==
--- cfe/trunk/test/CodeGen/designated-initializers.c (original)
+++ cfe/trunk/test/CodeGen/designated-initializers.c Fri Nov  2 10:36:58 2018
@@ -142,6 +142,18 @@ union_16644_t union_16644_instance_4[2]
 // CHECK: @lab = global { [4 x i8], i32 } { [4 x i8] undef, i32 123 }
 struct leading_anon_bitfield { int : 32; int n; } lab = { .n = 123 };
 
+// rdar://45691981
+struct Base {
+  struct {
+int A;
+  };
+};
+struct Derived {
+  struct Base B;
+};
+struct Derived D = {{}, .B.A = 42};
+// CHECK: @D = global %struct.Derived { %struct.Base { %struct.anon.4 { i32 42 
} } }, align 4
+
 void test1(int argc, char **argv)
 {
   // CHECK: internal global %struct.foo { i8* null, i32 1024 }
@@ -149,7 +161,7 @@ void test1(int argc, char **argv)
 .b = 1024,
   };
 
-  // CHECK: bitcast %union.anon.4* %u2
+  // CHECK: bitcast %union.anon.5* %u2
   // CHECK: call void @llvm.memset
union { int i; float f; } u2 = { };
 


_

[PATCH] D54010: [CodeGen] Fix a crash when updating a zeroinitialize designated initializer

2018-11-02 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC346004: [CodeGen] Fix a crash when updating a designated 
initializer (authored by epilk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54010?vs=172306&id=172396#toc

Repository:
  rC Clang

https://reviews.llvm.org/D54010

Files:
  lib/CodeGen/CGExprConstant.cpp
  test/CodeGen/designated-initializers.c

Index: test/CodeGen/designated-initializers.c
===
--- test/CodeGen/designated-initializers.c
+++ test/CodeGen/designated-initializers.c
@@ -142,14 +142,26 @@
 // CHECK: @lab = global { [4 x i8], i32 } { [4 x i8] undef, i32 123 }
 struct leading_anon_bitfield { int : 32; int n; } lab = { .n = 123 };
 
+// rdar://45691981
+struct Base {
+  struct {
+int A;
+  };
+};
+struct Derived {
+  struct Base B;
+};
+struct Derived D = {{}, .B.A = 42};
+// CHECK: @D = global %struct.Derived { %struct.Base { %struct.anon.4 { i32 42 } } }, align 4
+
 void test1(int argc, char **argv)
 {
   // CHECK: internal global %struct.foo { i8* null, i32 1024 }
   static struct foo foo = {
 .b = 1024,
   };
 
-  // CHECK: bitcast %union.anon.4* %u2
+  // CHECK: bitcast %union.anon.5* %u2
   // CHECK: call void @llvm.memset
union { int i; float f; } u2 = { };
 
Index: lib/CodeGen/CGExprConstant.cpp
===
--- lib/CodeGen/CGExprConstant.cpp
+++ lib/CodeGen/CGExprConstant.cpp
@@ -47,7 +47,7 @@
 public:
   static llvm::Constant *BuildStruct(ConstantEmitter &Emitter,
  ConstExprEmitter *ExprEmitter,
- llvm::ConstantStruct *Base,
+ llvm::Constant *Base,
  InitListExpr *Updater,
  QualType ValTy);
   static llvm::Constant *BuildStruct(ConstantEmitter &Emitter,
@@ -76,7 +76,7 @@
   void ConvertStructToPacked();
 
   bool Build(InitListExpr *ILE);
-  bool Build(ConstExprEmitter *Emitter, llvm::ConstantStruct *Base,
+  bool Build(ConstExprEmitter *Emitter, llvm::Constant *Base,
  InitListExpr *Updater);
   bool Build(const APValue &Val, const RecordDecl *RD, bool IsPrimaryBase,
  const CXXRecordDecl *VTableClass, CharUnits BaseOffset);
@@ -566,7 +566,7 @@
 
 llvm::Constant *ConstStructBuilder::BuildStruct(ConstantEmitter &Emitter,
 ConstExprEmitter *ExprEmitter,
-llvm::ConstantStruct *Base,
+llvm::Constant *Base,
 InitListExpr *Updater,
 QualType ValTy) {
   ConstStructBuilder Builder(Emitter);
@@ -1027,8 +1027,8 @@
 }
 
 if (destType->isRecordType())
-  return ConstStructBuilder::BuildStruct(Emitter, this,
- dyn_cast(Base), Updater, destType);
+  return ConstStructBuilder::BuildStruct(Emitter, this, Base, Updater,
+ destType);
 
 return nullptr;
   }
@@ -1103,15 +1103,15 @@
 }  // end anonymous namespace.
 
 bool ConstStructBuilder::Build(ConstExprEmitter *ExprEmitter,
-   llvm::ConstantStruct *Base,
+   llvm::Constant *Base,
InitListExpr *Updater) {
   assert(Base && "base expression should not be empty");
 
   QualType ExprType = Updater->getType();
   RecordDecl *RD = ExprType->getAs()->getDecl();
   const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(RD);
   const llvm::StructLayout *BaseLayout = CGM.getDataLayout().getStructLayout(
-   Base->getType());
+  cast(Base->getType()));
   unsigned FieldNo = -1;
   unsigned ElementNo = 0;
 
@@ -1132,7 +1132,7 @@
 if (Field->isUnnamedBitfield())
   continue;
 
-llvm::Constant *EltInit = Base->getOperand(ElementNo);
+llvm::Constant *EltInit = Base->getAggregateElement(ElementNo);
 
 // Bail out if the type of the ConstantStruct does not have the same layout
 // as the type of the InitListExpr.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53974: [clang-tidy] new check: bugprone-too-small-loop-variable

2018-11-02 Thread Whisperity via Phabricator via cfe-commits
whisperity added inline comments.



Comment at: docs/clang-tidy/checks/bugprone-too-small-loop-variable.rst:18
+This for loop is an infinite loop because the short type can't represent all
+values in the [0..size] interval.
+

Format the interval as code (monospace): `[0 .. size]`



Comment at: docs/clang-tidy/checks/bugprone-too-small-loop-variable.rst:24
+
+int doSometinhg(const std::vector& items) {
+for (short i = 0; i < items.size(); ++i) {}

There is a typo in the function's name.



Comment at: test/clang-tidy/bugprone-too-small-loop-variable.cpp:116
+
+// TODO: handle those cases when the loop condition contains a floating point 
expression
+void voidDoubleForCond() {

(Misc: You might want to check out D52730 for floats later down the line.)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53974



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


[libunwind] r346022 - Creating release candidate rc2 from release_701 branch

2018-11-02 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Fri Nov  2 11:09:42 2018
New Revision: 346022

URL: http://llvm.org/viewvc/llvm-project?rev=346022&view=rev
Log:
Creating release candidate rc2 from release_701 branch

Added:
libunwind/tags/RELEASE_701/rc2/   (props changed)
  - copied from r346021, libunwind/branches/release_70/

Propchange: libunwind/tags/RELEASE_701/rc2/
--
svn:mergeinfo = /libunwind/trunk:339217


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


[PATCH] D53998: [COFF, ARM64] Change setjmp for AArch64 Windows to use Intrinsic.sponentry

2018-11-02 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang accepted this revision.
mgrang added a comment.
This revision is now accepted and ready to land.

Since this is the same as https://reviews.llvm.org/D53684, we can go ahead and 
close this.


Repository:
  rC Clang

https://reviews.llvm.org/D53998



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


r346024 - [COFF, ARM64] Change setjmp for AArch64 Windows to use Intrinsic.sponentry

2018-11-02 Thread Mandeep Singh Grang via cfe-commits
Author: mgrang
Date: Fri Nov  2 11:10:07 2018
New Revision: 346024

URL: http://llvm.org/viewvc/llvm-project?rev=346024&view=rev
Log:
[COFF, ARM64] Change setjmp for AArch64 Windows to use Intrinsic.sponentry

Summary: ARM64 setjmp expects sp on entry instead of framepointer.

Patch by: Yin Ma (yi...@codeaurora.org)

Reviewers: mgrang, eli.friedman, ssijaric, mstorsjo, rnk, compnerd

Reviewed By: mgrang

Subscribers: efriedma, javed.absar, kristof.beyls, chrib, cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/ms-setjmp.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=346024&r1=346023&r2=346024&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Nov  2 11:10:07 2018
@@ -711,8 +711,11 @@ static RValue EmitMSVCRTSetJmp(CodeGenFu
   } else {
 Name = SJKind == MSVCSetJmpKind::_setjmp ? "_setjmp" : "_setjmpex";
 Arg1Ty = CGF.Int8PtrTy;
-Arg1 = 
CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(Intrinsic::frameaddress),
-  llvm::ConstantInt::get(CGF.Int32Ty, 0));
+if (CGF.getTarget().getTriple().getArch() == llvm::Triple::aarch64) {
+  Arg1 = 
CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(Intrinsic::sponentry));
+} else
+  Arg1 = 
CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(Intrinsic::frameaddress),
+llvm::ConstantInt::get(CGF.Int32Ty, 0));
   }
 
   // Mark the call site and declaration with ReturnsTwice.

Modified: cfe/trunk/test/CodeGen/ms-setjmp.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-setjmp.c?rev=346024&r1=346023&r2=346024&view=diff
==
--- cfe/trunk/test/CodeGen/ms-setjmp.c (original)
+++ cfe/trunk/test/CodeGen/ms-setjmp.c Fri Nov  2 11:10:07 2018
@@ -25,7 +25,7 @@ int test_setjmp() {
   // X64-NEXT:  ret i32 %[[call]]
 
   // AARCH64-LABEL: define dso_local i32 @test_setjmp
-  // AARCH64:   %[[addr:.*]] = call i8* @llvm.frameaddress(i32 0)
+  // AARCH64:   %[[addr:.*]] = call i8* @llvm.sponentry()
   // AARCH64:   %[[call:.*]] = call i32 @_setjmpex(i8* getelementptr 
inbounds ([1 x i8], [1 x i8]* @jb, i32 0, i32 0), i8* %[[addr]])
   // AARCH64-NEXT:  ret i32 %[[call]]
 }
@@ -38,7 +38,7 @@ int test_setjmpex() {
   // X64-NEXT:  ret i32 %[[call]]
 
   // AARCH64-LABEL: define dso_local i32 @test_setjmpex
-  // AARCH64:   %[[addr:.*]] = call i8* @llvm.frameaddress(i32 0)
+  // AARCH64:   %[[addr:.*]] = call i8* @llvm.sponentry()
   // AARCH64:   %[[call:.*]] = call i32 @_setjmpex(i8* getelementptr 
inbounds ([1 x i8], [1 x i8]* @jb, i32 0, i32 0), i8* %[[addr]])
   // AARCH64-NEXT:  ret i32 %[[call]]
 }


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


[PATCH] D53830: [clang-tidy]: Abseil: new check 'abseil-upgrade-duration-conversions'

2018-11-02 Thread Alex Strelnikov via Phabricator via cfe-commits
astrelni updated this revision to Diff 172402.
astrelni added a comment.
Herald added a subscriber: mgrang.

Updated filtering of template instantiations to not use potentially costly 
hasDescendent matcher.


https://reviews.llvm.org/D53830

Files:
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp
  clang-tidy/abseil/UpgradeDurationConversionsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-upgrade-duration-conversions.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/abseil-upgrade-duration-conversions.cpp

Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -12,6 +12,7 @@
abseil-redundant-strcat-calls
abseil-string-find-startswith
abseil-str-cat-append
+   abseil-upgrade-duration-conversions
android-cloexec-accept
android-cloexec-accept4
android-cloexec-creat
Index: docs/clang-tidy/checks/abseil-upgrade-duration-conversions.rst
===
--- docs/clang-tidy/checks/abseil-upgrade-duration-conversions.rst
+++ docs/clang-tidy/checks/abseil-upgrade-duration-conversions.rst
@@ -0,0 +1,43 @@
+.. title:: clang-tidy - abseil-upgrade-duration-conversions
+
+abseil-upgrade-duration-conversions
+===
+
+Finds calls to ``absl::Duration`` arithmetic operators and factories whose
+argument needs an explicit cast to continue compiling after upcoming API
+changes.
+
+The operators ``*=``, ``/=``, ``*``, and ``/`` for ``absl::Duration`` currently
+accept an argument of class type that is convertible to an arithmetic type. Such
+a call currently converts the value to an ``int64_t``, even in a case such as
+``std::atomic`` that would result in lossy conversion.
+
+Additionally, the ``absl::Duration`` factory functions (``absl::Hours``,
+``absl::Minutes``, etc) currently accept an ``int64_t`` or a floating-point
+type. Similar to the arithmetic operators, calls with an argument of class type
+that is convertible to an arithmetic type go through the ``int64_t`` path.
+
+These operators and factories will be changed to only accept arithmetic types to
+prevent unintended behavior. After these changes are released, passing an
+argument of class type will no longer compile, even if the type is implicitly
+convertible to an arithmetic type.
+
+Here are example fixes created by this check:
+
+.. code-block:: c++
+
+  std::atomic a;
+  absl::Duration d = absl::Milliseconds(a);
+  d *= a;
+
+becomes
+
+.. code-block:: c++
+
+  std::atomic a;
+  absl::Duration d = absl::Milliseconds(static_cast(a));
+  d *= static_cast(a);
+
+Note that this check always adds a cast to ``int64_t`` in order to preserve the
+current behavior of user code. It is possible that this uncovers unintended
+behavior due to types implicitly convertible to a floating-point type.
Index: test/clang-tidy/abseil-upgrade-duration-conversions.cpp
===
--- test/clang-tidy/abseil-upgrade-duration-conversions.cpp
+++ test/clang-tidy/abseil-upgrade-duration-conversions.cpp
@@ -0,0 +1,451 @@
+// RUN: %check_clang_tidy %s abseil-upgrade-duration-conversions %t
+
+using int64_t = long long;
+
+// Partial implementation of relevant APIs from
+// https://github.com/abseil/abseil-cpp/blob/master/absl/time/time.h
+namespace absl {
+
+class Duration {
+public:
+  Duration &operator*=(int64_t r);
+  Duration &operator*=(float r);
+  Duration &operator*=(double r);
+  template  Duration &operator*=(T r);
+
+  Duration &operator/=(int64_t r);
+  Duration &operator/=(float r);
+  Duration &operator/=(double r);
+  template  Duration &operator/=(T r);
+};
+
+template  Duration operator*(Duration lhs, T rhs);
+template  Duration operator*(T lhs, Duration rhs);
+template  Duration operator/(Duration lhs, T rhs);
+
+constexpr Duration Nanoseconds(int64_t n);
+constexpr Duration Microseconds(int64_t n);
+constexpr Duration Milliseconds(int64_t n);
+constexpr Duration Seconds(int64_t n);
+constexpr Duration Minutes(int64_t n);
+constexpr Duration Hours(int64_t n);
+
+template  struct EnableIfFloatImpl {};
+template <> struct EnableIfFloatImpl { typedef int Type; };
+template <> struct EnableIfFloatImpl { typedef int Type; };
+template <> struct EnableIfFloatImpl { typedef int Type; };
+template  using EnableIfFloat = typename EnableIfFloatImpl::Type;
+
+template  = 0> Duration Nanoseconds(T n);
+template  = 0> Duration Microseconds(T n);
+template  = 0> Duration Milliseconds(T n);
+template  = 0> Duration Seconds(T n);
+template  = 0> Duration Minutes(T n);
+template  = 0> Duration Hours(T n);
+
+} // namespace absl
+
+template  struct ConvertibleTo {
+  operator T() const;
+};
+
+template 
+ConvertibleTo operator+(ConvertibleTo, ConvertibleTo);
+
+template 
+ConvertibleTo operator*(Conv

  1   2   >