[PATCH] D85582: [clang][Driver] Search lib32 on Linux/sparc64 with -m32

2020-08-08 Thread Rainer Orth via Phabricator via cfe-commits
ro created this revision.
ro added reviewers: echristo, MaskRay, phosek.
ro added a project: clang.
Herald added subscribers: fedor.sergeev, jyknight.
ro requested review of this revision.

When building current master on `sparc64-unknown-linux-gnu` (Debian 5.7.10), 
all 32-bit tests failed to link because the matching startup files and 
libraries weren't found.  As on Linux/x86_64 they live in `lib32` 
subdirectories.

This patch searches those directories as on x86 and ppc, allowing 32-bit links 
to succeed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85582

Files:
  clang/lib/Driver/ToolChains/Linux.cpp


Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -185,17 +185,18 @@
 return Triple.isArch32Bit() ? "lib" : "lib64";
   }
 
-  // It happens that only x86 and PPC use the 'lib32' variant of oslibdir, and
-  // using that variant while targeting other architectures causes problems
-  // because the libraries are laid out in shared system roots that can't cope
-  // with a 'lib32' library search path being considered. So we only enable
-  // them when we know we may need it.
+  // It happens that only x86, PPC, and SPARC use the 'lib32' variant of
+  // oslibdir, and using that variant while targeting other architectures
+  // causes problems because the libraries are laid out in shared system
+  // roots that can't cope with a 'lib32' library search path being
+  // considered. So we only enable them when we know we may need it.
   //
   // FIXME: This is a bit of a hack. We should really unify this code for
   // reasoning about oslibdir spellings with the lib dir spellings in the
   // GCCInstallationDetector, but that is a more significant refactoring.
   if (Triple.getArch() == llvm::Triple::x86 ||
-  Triple.getArch() == llvm::Triple::ppc)
+  Triple.getArch() == llvm::Triple::ppc ||
+  Triple.getArch() == llvm::Triple::sparc)
 return "lib32";
 
   if (Triple.getArch() == llvm::Triple::x86_64 &&


Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -185,17 +185,18 @@
 return Triple.isArch32Bit() ? "lib" : "lib64";
   }
 
-  // It happens that only x86 and PPC use the 'lib32' variant of oslibdir, and
-  // using that variant while targeting other architectures causes problems
-  // because the libraries are laid out in shared system roots that can't cope
-  // with a 'lib32' library search path being considered. So we only enable
-  // them when we know we may need it.
+  // It happens that only x86, PPC, and SPARC use the 'lib32' variant of
+  // oslibdir, and using that variant while targeting other architectures
+  // causes problems because the libraries are laid out in shared system
+  // roots that can't cope with a 'lib32' library search path being
+  // considered. So we only enable them when we know we may need it.
   //
   // FIXME: This is a bit of a hack. We should really unify this code for
   // reasoning about oslibdir spellings with the lib dir spellings in the
   // GCCInstallationDetector, but that is a more significant refactoring.
   if (Triple.getArch() == llvm::Triple::x86 ||
-  Triple.getArch() == llvm::Triple::ppc)
+  Triple.getArch() == llvm::Triple::ppc ||
+  Triple.getArch() == llvm::Triple::sparc)
 return "lib32";
 
   if (Triple.getArch() == llvm::Triple::x86_64 &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85582: [clang][Driver] Search lib32 on Linux/sparc64 with -m32

2020-08-08 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

Would it be possible to add a test case in `clang/test/Driver/linux-ld.c`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85582

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


[PATCH] D85528: [analyzer] Fix cast evaluation on scoped enums in ExprEngine

2020-08-08 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 284126.
steakhal marked 3 inline comments as done.
steakhal edited the summary of this revision.
steakhal added a comment.

- Using `dump`s instead of `reaching` in tests.
- Not requiring complete enums anymore //(unlike we did before the patch)//.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85528

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  clang/test/Analysis/z3-refute-enum-crash.cpp


Index: clang/test/Analysis/z3-refute-enum-crash.cpp
===
--- /dev/null
+++ clang/test/Analysis/z3-refute-enum-crash.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config crosscheck-with-z3=true -verify %s
+// REQUIRES: z3
+//
+// Requires z3 only for refutation. Works with both constraint managers.
+
+void clang_analyzer_dump(int);
+
+using sugar_t = unsigned char;
+
+// Enum types
+enum class ScopedSugared : sugar_t {};
+enum class ScopedPrimitive : unsigned char {};
+enum UnscopedSugared : sugar_t {};
+enum UnscopedPrimitive : unsigned char {};
+
+template 
+T conjure();
+
+void test_enum_types() {
+  int sym1 = static_cast(conjure()) & 0x0F;
+  int sym2 = static_cast(conjure()) & 0x0F;
+  int sym3 = static_cast(conjure()) & 0x0F;
+  int sym4 = static_cast(conjure()) & 0x0F;
+
+  if (sym1 && sym2 && sym3 && sym4) {
+// no-crash on these dumps
+clang_analyzer_dump(sym1); // expected-warning{{((unsigned char) (conj_}}
+clang_analyzer_dump(sym2); // expected-warning{{((unsigned char) (conj_}}
+clang_analyzer_dump(sym3); // expected-warning{{(conj_}}
+clang_analyzer_dump(sym4); // expected-warning{{(conj_}}
+  }
+}
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
@@ -95,11 +95,15 @@
   }
 
   bool haveSameType(QualType Ty1, QualType Ty2) {
+const bool BothHaveSameCanonicalTypes =
+Context.getCanonicalType(Ty1) == Context.getCanonicalType(Ty2);
+const bool BothHaveIntegralOrUnscopedEnumerationType =
+Ty1->isIntegralOrUnscopedEnumerationType() &&
+Ty2->isIntegralOrUnscopedEnumerationType();
 // FIXME: Remove the second disjunct when we support symbolic
 // truncation/extension.
-return (Context.getCanonicalType(Ty1) == Context.getCanonicalType(Ty2) ||
-(Ty1->isIntegralOrEnumerationType() &&
- Ty2->isIntegralOrEnumerationType()));
+return BothHaveSameCanonicalTypes ||
+   BothHaveIntegralOrUnscopedEnumerationType;
   }
 
   SVal evalCast(SVal val, QualType castTy, QualType originalType);


Index: clang/test/Analysis/z3-refute-enum-crash.cpp
===
--- /dev/null
+++ clang/test/Analysis/z3-refute-enum-crash.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config crosscheck-with-z3=true -verify %s
+// REQUIRES: z3
+//
+// Requires z3 only for refutation. Works with both constraint managers.
+
+void clang_analyzer_dump(int);
+
+using sugar_t = unsigned char;
+
+// Enum types
+enum class ScopedSugared : sugar_t {};
+enum class ScopedPrimitive : unsigned char {};
+enum UnscopedSugared : sugar_t {};
+enum UnscopedPrimitive : unsigned char {};
+
+template 
+T conjure();
+
+void test_enum_types() {
+  int sym1 = static_cast(conjure()) & 0x0F;
+  int sym2 = static_cast(conjure()) & 0x0F;
+  int sym3 = static_cast(conjure()) & 0x0F;
+  int sym4 = static_cast(conjure()) & 0x0F;
+
+  if (sym1 && sym2 && sym3 && sym4) {
+// no-crash on these dumps
+clang_analyzer_dump(sym1); // expected-warning{{((unsigned char) (conj_}}
+clang_analyzer_dump(sym2); // expected-warning{{((unsigned char) (conj_}}
+clang_analyzer_dump(sym3); // expected-warning{{(conj_}}
+clang_analyzer_dump(sym4); // expected-warning{{(conj_}}
+  }
+}
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
@@ -95,11 +95,15 @@
   }
 
   bool haveSameType(QualType Ty1, QualType Ty2) {
+const bool BothHaveSameCanonicalTypes =
+Context.getCanonicalType(Ty1) == Context.getCanonicalType(Ty2);
+const bool BothHaveIntegralOrUnscopedEnumerationType =
+Ty1->isIntegralOrUnscopedEnumerationType() &&
+Ty2->isIntegralOrUnscopedEnumerationType();
 // FIXME: Remove the second disjunct when we support symbolic
 // truncation/extension.
-return (Context.getCa

[PATCH] D85528: [analyzer] Fix cast evaluation on scoped enums in ExprEngine

2020-08-08 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D85528#2203325 , @NoQ wrote:

> Aha, ok, sounds like the right thing to do. Like, for Z3 it's actually the 
> wrong thing to do (you'd prefer to evaluate the cast perfectly by adding 
> `SymbolCast`) but for pure RangeConstraintManager this is the lesser of two 
> evils.

My primary objective is to fix all the crashes related to //Range CM + Z3 
refutation//.

> Because this patch changes the behavior of regular analysis (without Z3), i 
> expect tests to reflect that.

What do you expect exactly?

`REQUIRES: z3` is necessary for the refutation.
However, adding this requirement would not mean that this test will run if you 
have Z3 installed though.
You should add the extra `llvm-lit` param to enable such tests.
I don't want to repeat myself too much but D83677 
 describes all the details of this test infra 
fiasco.
I would appreciate some feedback there.

> Please add `ExprInspection`-based tests to test values produced by casts.

Ok, I fixed that - thanks.

> I don't understand why should the behavior be different for incomplete types. 
> Can you explain?

You should be right. Fixed that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85528

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


[PATCH] D85575: [ARM] Speed up arm-cortex-cpus.c test

2020-08-08 Thread Dave Green via Phabricator via cfe-commits
dmgreen accepted this revision.
dmgreen added a comment.
This revision is now accepted and ready to land.

Yeah, nice. Sounds good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85575

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


[PATCH] D85545: [Diagnostics] Diagnose missing comma in string array initialization

2020-08-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3003
+def warn_concatenated_literal_array_init : Warning<
+  "concatenated literal in a string array initialization - "
+  "possibly missing a comma">,

How about: `suspicious concatenation of string literals in an array 
initialization; did you mean to separate the elements with a comma?`



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:6147
+def note_concatenated_string_literal_silence :Note<
+  "place parentheses around string literal to silence warning">;
+

around string literal -> around the string literal



Comment at: clang/lib/Sema/SemaExpr.cpp:6916
+for (unsigned i = 0; i < numConcat; ++i)
+  if (SL->getStrTokenLoc(i).isMacroID()) {
+hasMacro = true;

xbolva00 wrote:
> Quuxplusone wrote:
> > I wonder if perhaps the warning should trigger only if the concatenated 
> > pieces appear one-per-line, i.e., whitespace-sensitive.
> > 
> > const char a[] = {
> > "a"
> > "b"
> > };
> > const char b[] = {
> > "b" "c"
> > };
> > 
> > It's at least arguable that `a` is a bug and `b` is intentional, based 
> > purely on how the whitespace appears. OTOH, whitespace is not preserved by 
> > clang-format, and it would suck for clang-formatting the code to cause the 
> > appearance (or disappearance) of diagnostics.
> Hard to tell, no strong opinion.
> 
> We can always decrease the "power" of warning based on external feedback.
I feel like it could go either way and really depends more on the number of 
initializers and other heuristic patterns than the whitespace. e.g., `{"a" "b", 
"c" "d"}` seems more likely to be correct than `{"a", "b" "c", "d"}` and it's 
sort of impossible to tell with `{"a" "b"}` what is intended, while `{"a", "b", 
"c", "d", "e" "f", "g", "h"}` is quite likely a bug.

I think the only scenario we should NOT warn on initially is when all the 
elements in the initializer are concatenated together because it seems 
plausible that would be done for ease of formatting. e.g., `{"a" "b"}`, `{"a" 
"b" "c" }`, etc.



Comment at: clang/test/Sema/string-concat.c:86
+};
\ No newline at end of file


Please add the newline to the end of the file.

Also, I'd like to see tests with other string literal types, like `L` or `u8` 
just to demonstrate that this isn't specific to narrow string literals.


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

https://reviews.llvm.org/D85545

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


[PATCH] D85536: [clang] Add a matcher for template template parameters.

2020-08-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85536

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


[PATCH] D85193: [clang] Do not use an invalid expression to update the initializer.

2020-08-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Should the `StructuredIndex` still be incremented even in the case of an error, 
as done around line 1589 and 1647? Do we need a similar change around line 2405?

I sort of wonder if the correct change is to make 
`UpdateStructuredListElement()` resilient to being passed a null `Expr *` and 
then removing the manual increments when the expression is an error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85193

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


[PATCH] D80514: [clang-tidy] modernize-use-trailing-return-type support for C++20 concepts and decltype

2020-08-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp:430
+  AT->getKeyword() == AutoTypeKeyword::Auto &&
+  !hasAnyNestedLocalQualifiers(F->getDeclaredReturnType()))
+return;

aaron.ballman wrote:
> bernhardmgruber wrote:
> > aaron.ballman wrote:
> > > Why do we need to check that there aren't any nested local qualifiers?
> > Because I would like the check to rewrite e.g. `const auto f();` into `auto 
> > f() -> const auto;`. If I omit the check for nested local qualifiers, then 
> > those kind of declarations would be skipped.
> I'm still wondering about this.
> Because I would like the check to rewrite e.g. const auto f(); into auto f() 
> -> const auto;. If I omit the check for nested local qualifiers, then those 
> kind of declarations would be skipped.

I don't think I understand why that's desirable though? What is it about the 
qualifier that makes it worthwhile to repeat the type like that?



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type.cpp:1
-// RUN: %check_clang_tidy -std=c++14,c++17 %s 
modernize-use-trailing-return-type %t -- -- -fdeclspec -fexceptions
+// RUN: %check_clang_tidy -std=c++14-or-later %s 
modernize-use-trailing-return-type %t -- -- -fdeclspec -fexceptions 
-DCOMMAND_LINE_INT=int
 // FIXME: Fix the checker to work in C++20 mode, it is performing a

bernhardmgruber wrote:
> aaron.ballman wrote:
> > The change to the language standard line makes me wonder if the fixme below 
> > it is now stale, or if the test will fail in C++20 mode.
> I just ran the tests again using `python .\check_clang_tidy.py -std=c++20 
> .\checkers\modernize-use-trailing-return-type.cpp 
> modernize-use-trailing-return-type aa -- -- -DCOMMAND_LINE_INT=int` and I did 
> not see mentioning of the use of an uninitialized variable. But I run on 
> Windows, maybe the issue just surfaces on another OS? Is there a way to 
> trigger the CI again?
> 
> I removed the FIXME in question in the hope the issue resolved itself.
> But I run on Windows, maybe the issue just surfaces on another OS? Is there a 
> way to trigger the CI again?

I also run on Windows so I can't easily test the behavior elsewhere for you. 
The CI will get triggered on new patch uploads, but I still don't always trust 
it. The bots are usually a more reliable source of CI truth but we have no way 
to speculatively trigger all the bots.


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

https://reviews.llvm.org/D80514

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


[PATCH] D85545: [Diagnostics] Diagnose missing comma in string array initialization

2020-08-08 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 284127.
xbolva00 added a comment.

Addressed review notes.


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

https://reviews.llvm.org/D85545

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/string-concat.c

Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6907,6 +6907,21 @@
 << DIE->getSourceRange();
   Diag(InitArgList[I]->getBeginLoc(), diag::note_designated_init_mixed)
 << InitArgList[I]->getSourceRange();
+} else if (const auto *SL = dyn_cast(InitArgList[I])) {
+  unsigned numConcat = SL->getNumConcatenated();
+  // Diagnose missing comma in string array initialization.
+  // Do not warn when all the elements in the initializer are concatenated together.
+  // Do not warn for macros too.
+  if (numConcat > 1 && E > 1 && !SL->getBeginLoc().isMacroID()) {
+SmallVector Hints;
+for (unsigned i = 0; i < numConcat - 1; ++i)
+  Hints.push_back(FixItHint::CreateInsertion(
+  PP.getLocForEndOfToken(SL->getStrTokenLoc(i)), ", "));
+
+Diag(SL->getStrTokenLoc(1), diag::warn_concatenated_literal_array_init)
+<< Hints;
+Diag(SL->getBeginLoc(), diag::note_concatenated_string_literal_silence);
+  }
 }
   }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2999,6 +2999,10 @@
 def warn_objc_string_literal_comparison : Warning<
   "direct comparison of a string literal has undefined behavior">,
   InGroup;
+def warn_concatenated_literal_array_init : Warning<
+  "suspicious concatenation of string literals in an array initialization; "
+  "did you mean to separate the elements with a comma?">,
+  InGroup>;
 def warn_concatenated_nsarray_literal : Warning<
   "concatenated NSString literal for an NSArray expression - "
   "possibly missing a comma">,
@@ -6139,6 +6143,9 @@
 def note_evaluate_comparison_first :Note<
   "place parentheses around comparison expression to evaluate it first">;
 
+def note_concatenated_string_literal_silence :Note<
+  "place parentheses around the string literal to silence warning">;
+
 def warn_addition_in_bitshift : Warning<
   "operator '%0' has lower precedence than '%1'; "
   "'%1' will be evaluated first">, InGroup;
Index: clang/test/Sema/string-concat.c
===
--- /dev/null
+++ clang/test/Sema/string-concat.c
@@ -0,0 +1,103 @@
+
+// RUN: %clang_cc1 -x c -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify %s
+
+const char *missing_comma[] = {
+"basic_filebuf",
+"basic_ios",
+"future",
+"optional",
+"packaged_task" // expected-note{{place parentheses around the string literal to silence warning}}
+"promise",  // expected-warning{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}} 
+"shared_future"
+};
+
+#ifndef __cplusplus
+typedef __WCHAR_TYPE__ wchar_t;
+#endif
+
+const wchar_t *missing_comma_wchar[] = {
+L"basic_filebuf",
+L"packaged_task" // expected-note{{place parentheses around the string literal to silence warning}}
+L"promise"  // expected-warning{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
+};
+
+const char *missing_comma_u8[] = {
+u8"basic_filebuf",
+u8"packaged_task" // expected-note{{place parentheses around the string literal to silence warning}}
+u8"promise"  // expected-warning{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
+};
+
+const char *missing_two_commas[] = {"basic_filebuf",
+   "basic_ios" // expected-note{{place parentheses around the string literal to silence warning}}
+   "future"// expected-warning{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
+   "optional",
+   "packaged_task"};
+
+const char *missing_comma_same_line[] = {"basic_filebuf", "basic_ios",
+   "future" "optional", // expected-note{{place parentheses around the string literal to silence warning}}
+   "packaged_task", "promise"}; // expected-warning@-1{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
+
+const char *missing_comma_different_lines[] = {"basic_filebuf", "basic_ios" // expected-note{{place par

[PATCH] D85545: [Diagnostics] Diagnose missing comma in string array initialization

2020-08-08 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 284128.

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

https://reviews.llvm.org/D85545

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/string-concat.c

Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6907,6 +6907,21 @@
 << DIE->getSourceRange();
   Diag(InitArgList[I]->getBeginLoc(), diag::note_designated_init_mixed)
 << InitArgList[I]->getSourceRange();
+} else if (const auto *SL = dyn_cast(InitArgList[I])) {
+  unsigned numConcat = SL->getNumConcatenated();
+  // Diagnose missing comma in string array initialization.
+  // Do not warn when all the elements in the initializer are concatenated together.
+  // Do not warn for macros too.
+  if (numConcat > 1 && E > 1 && !SL->getBeginLoc().isMacroID()) {
+SmallVector Hints;
+for (unsigned i = 0; i < numConcat - 1; ++i)
+  Hints.push_back(FixItHint::CreateInsertion(
+  PP.getLocForEndOfToken(SL->getStrTokenLoc(i)), ", "));
+
+Diag(SL->getStrTokenLoc(1), diag::warn_concatenated_literal_array_init)
+<< Hints;
+Diag(SL->getBeginLoc(), diag::note_concatenated_string_literal_silence);
+  }
 }
   }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2999,6 +2999,10 @@
 def warn_objc_string_literal_comparison : Warning<
   "direct comparison of a string literal has undefined behavior">,
   InGroup;
+def warn_concatenated_literal_array_init : Warning<
+  "suspicious concatenation of string literals in an array initialization; "
+  "did you mean to separate the elements with a comma?">,
+  InGroup>;
 def warn_concatenated_nsarray_literal : Warning<
   "concatenated NSString literal for an NSArray expression - "
   "possibly missing a comma">,
@@ -6139,6 +6143,9 @@
 def note_evaluate_comparison_first :Note<
   "place parentheses around comparison expression to evaluate it first">;
 
+def note_concatenated_string_literal_silence :Note<
+  "place parentheses around the string literal to silence warning">;
+
 def warn_addition_in_bitshift : Warning<
   "operator '%0' has lower precedence than '%1'; "
   "'%1' will be evaluated first">, InGroup;
Index: clang/test/Sema/string-concat.c
===
--- /dev/null
+++ clang/test/Sema/string-concat.c
@@ -0,0 +1,102 @@
+
+// RUN: %clang_cc1 -x c -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify %s
+
+const char *missing_comma[] = {
+"basic_filebuf",
+"basic_ios",
+"future",
+"optional",
+"packaged_task" // expected-note{{place parentheses around the string literal to silence warning}}
+"promise",  // expected-warning{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}} 
+"shared_future"
+};
+
+#ifndef __cplusplus
+typedef __WCHAR_TYPE__ wchar_t;
+#endif
+
+const wchar_t *missing_comma_wchar[] = {
+L"basic_filebuf",
+L"packaged_task" // expected-note{{place parentheses around the string literal to silence warning}}
+L"promise"  // expected-warning{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
+};
+
+const char *missing_comma_u8[] = {
+u8"basic_filebuf",
+u8"packaged_task" // expected-note{{place parentheses around the string literal to silence warning}}
+u8"promise"  // expected-warning{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
+};
+
+const char *missing_two_commas[] = {"basic_filebuf",
+   "basic_ios" // expected-note{{place parentheses around the string literal to silence warning}}
+   "future"// expected-warning{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
+   "optional",
+   "packaged_task"};
+
+const char *missing_comma_same_line[] = {"basic_filebuf", "basic_ios",
+   "future" "optional", // expected-note{{place parentheses around the string literal to silence warning}}
+   "packaged_task", "promise"}; // expected-warning@-1{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
+
+const char *missing_comma_different_lines[] = {"basic_filebuf", "basic_ios" // expected-note{{place parentheses around the string literal to silence warnin

[PATCH] D85545: [Diagnostics] Diagnose missing comma in string array initialization

2020-08-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from a nit, but you should give other reviewers a chance to comment 
if they have additional feedback.




Comment at: clang/lib/Sema/SemaExpr.cpp:6911
+} else if (const auto *SL = dyn_cast(InitArgList[I])) {
+  unsigned numConcat = SL->getNumConcatenated();
+  // Diagnose missing comma in string array initialization.

`numConcat` -> `NumConcat`


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

https://reviews.llvm.org/D85545

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


[PATCH] D80514: [clang-tidy] modernize-use-trailing-return-type support for C++20 concepts and decltype

2020-08-08 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type.cpp:1
-// RUN: %check_clang_tidy -std=c++14,c++17 %s 
modernize-use-trailing-return-type %t -- -- -fdeclspec -fexceptions
+// RUN: %check_clang_tidy -std=c++14-or-later %s 
modernize-use-trailing-return-type %t -- -- -fdeclspec -fexceptions 
-DCOMMAND_LINE_INT=int
 // FIXME: Fix the checker to work in C++20 mode, it is performing a

aaron.ballman wrote:
> bernhardmgruber wrote:
> > aaron.ballman wrote:
> > > The change to the language standard line makes me wonder if the fixme 
> > > below it is now stale, or if the test will fail in C++20 mode.
> > I just ran the tests again using `python .\check_clang_tidy.py -std=c++20 
> > .\checkers\modernize-use-trailing-return-type.cpp 
> > modernize-use-trailing-return-type aa -- -- -DCOMMAND_LINE_INT=int` and I 
> > did not see mentioning of the use of an uninitialized variable. But I run 
> > on Windows, maybe the issue just surfaces on another OS? Is there a way to 
> > trigger the CI again?
> > 
> > I removed the FIXME in question in the hope the issue resolved itself.
> > But I run on Windows, maybe the issue just surfaces on another OS? Is there 
> > a way to trigger the CI again?
> 
> I also run on Windows so I can't easily test the behavior elsewhere for you. 
> The CI will get triggered on new patch uploads, but I still don't always 
> trust it. The bots are usually a more reliable source of CI truth but we have 
> no way to speculatively trigger all the bots.
I can run it for you with asan/msan.


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

https://reviews.llvm.org/D80514

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


[PATCH] D84068: AMDGPU/clang: Search resource directory for device libraries

2020-08-08 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D84068#2159391 , @tra wrote:

> Could you walk me through how you see this working in practice?
>
> IIUIC, the idea is to have bitcode files located somewhere within clang 
> installation.

Yes

> If that's the case, will we ship those bitcode libraries with clang, or do 
> they come from ROCm packages?

The rocm package will install symlinks into the clang resource directory. The 
rocm provided clang package should depend on the bitcode package

> If we ship them with clang, who/where/how builds them?
> If they come from ROCm packages, how would those packages add stuff into 
> *clang* install directory? Resource dir is a rather awkward location if 
> contents may be expected to change routinely.

Symlinks. I've been building the device libraries as part of 
LLVM_EXTERNAL_PROJECTS, and think this should be the preferred way to build and 
package the libraries. This is how compiler-rt is packaged on linux 
distributions. The compiler-rt binaries are a separate package symlinked into 
the resource directory locations. I'm not sure what you mean exactly by change 
routinely, the libraries should be an implementation detail invisible to users, 
not something they should be directly relying on. Only clang actually knows how 
to use them correctly and every other user is buggy

> What if I have multiple ROCm versions installed? Which one should provide the 
> bitcode in the resource dir?

These should be treated as an integral part of clang, and not something to mix 
and match. Each rocm version should have its own copy of the device libraries. 
It only happens to work most of the time if you mismatch these, and this isn't 
a guaranteed property.

> As long as explicitly specified `--hip-device-lib-path` can still point to 
> the right path, it's probably OK, but it all adds some confusion about who 
> controls which parts of the HIP compilation and how it all is supposed to 
> work in cases that deviate from the default assumptions.

Long term I would rather get rid of --hip-device-lib-path, and only use the 
standard -resource_dir flags

> It would help if the requirements would be documented somewhere.

Documentation would be good, but the problem I always have is deciding where 
"somewhere" is


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

https://reviews.llvm.org/D84068

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


[PATCH] D80514: [clang-tidy] modernize-use-trailing-return-type support for C++20 concepts and decltype

2020-08-08 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type.cpp:1
-// RUN: %check_clang_tidy -std=c++14,c++17 %s 
modernize-use-trailing-return-type %t -- -- -fdeclspec -fexceptions
+// RUN: %check_clang_tidy -std=c++14-or-later %s 
modernize-use-trailing-return-type %t -- -- -fdeclspec -fexceptions 
-DCOMMAND_LINE_INT=int
 // FIXME: Fix the checker to work in C++20 mode, it is performing a

riccibruno wrote:
> aaron.ballman wrote:
> > bernhardmgruber wrote:
> > > aaron.ballman wrote:
> > > > The change to the language standard line makes me wonder if the fixme 
> > > > below it is now stale, or if the test will fail in C++20 mode.
> > > I just ran the tests again using `python .\check_clang_tidy.py -std=c++20 
> > > .\checkers\modernize-use-trailing-return-type.cpp 
> > > modernize-use-trailing-return-type aa -- -- -DCOMMAND_LINE_INT=int` and I 
> > > did not see mentioning of the use of an uninitialized variable. But I run 
> > > on Windows, maybe the issue just surfaces on another OS? Is there a way 
> > > to trigger the CI again?
> > > 
> > > I removed the FIXME in question in the hope the issue resolved itself.
> > > But I run on Windows, maybe the issue just surfaces on another OS? Is 
> > > there a way to trigger the CI again?
> > 
> > I also run on Windows so I can't easily test the behavior elsewhere for 
> > you. The CI will get triggered on new patch uploads, but I still don't 
> > always trust it. The bots are usually a more reliable source of CI truth 
> > but we have no way to speculatively trigger all the bots.
> I can run it for you with asan/msan.
No warning with either asan or msan on x86-64 linux with clang 10.


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

https://reviews.llvm.org/D80514

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


[PATCH] D79219: [CMake] Simplify CMake handling for zlib

2020-08-08 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 284106.

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

https://reviews.llvm.org/D79219

Files:
  clang/test/CMakeLists.txt
  clang/test/lit.site.cfg.py.in
  compiler-rt/test/lit.common.configured.in
  lld/test/CMakeLists.txt
  lld/test/lit.site.cfg.py.in
  lldb/cmake/modules/LLDBStandalone.cmake
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  llvm/cmake/config-ix.cmake
  llvm/cmake/modules/LLVMConfig.cmake.in
  llvm/include/llvm/Config/config.h.cmake
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/CRC.cpp
  llvm/lib/Support/Compression.cpp
  llvm/test/CMakeLists.txt
  llvm/test/lit.site.cfg.py.in
  llvm/unittests/Support/CompressionTest.cpp
  llvm/utils/gn/secondary/clang/test/BUILD.gn
  llvm/utils/gn/secondary/compiler-rt/test/BUILD.gn
  llvm/utils/gn/secondary/lld/test/BUILD.gn
  llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
  llvm/utils/gn/secondary/llvm/test/BUILD.gn

Index: llvm/utils/gn/secondary/llvm/test/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/test/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/test/BUILD.gn
@@ -174,9 +174,9 @@
   }
 
   if (llvm_enable_zlib) {
-extra_values += [ "HAVE_LIBZ=1" ]
+extra_values += [ "LLVM_ENABLE_ZLIB=1" ]
   } else {
-extra_values += [ "HAVE_LIBZ=0" ]  # Must be 0.
+extra_values += [ "LLVM_ENABLE_ZLIB=0" ]  # Must be 0.
   }
 }
 
Index: llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
@@ -295,20 +295,10 @@
 values += [ "LLVM_ENABLE_DIA_SDK=" ]
   }
 
-  # FIXME: Once https://reviews.llvm.org/D79219 is in, remove the two
-  # redundant HAVE_ variables.
   if (llvm_enable_zlib) {
-values += [
-  "HAVE_LIBZ=1",
-  "HAVE_ZLIB_H=1",
-  "LLVM_ENABLE_ZLIB=1",
-]
+values += [ "LLVM_ENABLE_ZLIB=1" ]
   } else {
-values += [
-  "HAVE_LIBZ=",
-  "HAVE_ZLIB_H=",
-  "LLVM_ENABLE_ZLIB=",
-]
+values += [ "LLVM_ENABLE_ZLIB=" ]
   }
 
   if (llvm_enable_libxml2) {
Index: llvm/utils/gn/secondary/lld/test/BUILD.gn
===
--- llvm/utils/gn/secondary/lld/test/BUILD.gn
+++ llvm/utils/gn/secondary/lld/test/BUILD.gn
@@ -49,9 +49,9 @@
   }
 
   if (llvm_enable_zlib) {
-extra_values += [ "HAVE_LIBZ=1" ]
+extra_values += [ "LLVM_ENABLE_ZLIB=1" ]
   } else {
-extra_values += [ "HAVE_LIBZ=0" ]  # Must be 0.
+extra_values += [ "LLVM_ENABLE_ZLIB=0" ]  # Must be 0.
   }
 
   if (current_cpu == "x64" || current_cpu == "arm64" ||
Index: llvm/utils/gn/secondary/compiler-rt/test/BUILD.gn
===
--- llvm/utils/gn/secondary/compiler-rt/test/BUILD.gn
+++ llvm/utils/gn/secondary/compiler-rt/test/BUILD.gn
@@ -86,8 +86,8 @@
   }
 
   if (llvm_enable_zlib) {
-values += [ "HAVE_LIBZ=1" ]
+values += [ "LLVM_ENABLE_ZLIB=1" ]
   } else {
-values += [ "HAVE_LIBZ=0" ]
+values += [ "LLVM_ENABLE_ZLIB=0" ]
   }
 }
Index: llvm/utils/gn/secondary/clang/test/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/test/BUILD.gn
+++ llvm/utils/gn/secondary/clang/test/BUILD.gn
@@ -79,9 +79,9 @@
   }
 
   if (llvm_enable_zlib) {
-extra_values += [ "HAVE_LIBZ=1" ]
+extra_values += [ "LLVM_ENABLE_ZLIB=1" ]
   } else {
-extra_values += [ "HAVE_LIBZ=0" ]  # Must be 0.
+extra_values += [ "LLVM_ENABLE_ZLIB=0" ]  # Must be 0.
   }
 
   if (host_cpu == "x64") {
Index: llvm/unittests/Support/CompressionTest.cpp
===
--- llvm/unittests/Support/CompressionTest.cpp
+++ llvm/unittests/Support/CompressionTest.cpp
@@ -21,7 +21,7 @@
 
 namespace {
 
-#if LLVM_ENABLE_ZLIB == 1 && HAVE_LIBZ
+#if LLVM_ENABLE_ZLIB
 
 void TestZlibCompression(StringRef Input, int Level) {
   SmallString<32> Compressed;
Index: llvm/test/lit.site.cfg.py.in
===
--- llvm/test/lit.site.cfg.py.in
+++ llvm/test/lit.site.cfg.py.in
@@ -33,7 +33,7 @@
 config.host_ldflags = '@HOST_LDFLAGS@'
 config.llvm_use_intel_jitevents = @LLVM_USE_INTEL_JITEVENTS@
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
-config.have_zlib = @HAVE_LIBZ@
+config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.have_libxar = @HAVE_LIBXAR@
 config.have_dia_sdk = @LLVM_ENABLE_DIA_SDK@
 config.enable_ffi = @LLVM_ENABLE_FFI@
Index: llvm/test/CMakeLists.txt
===
--- llvm/test/CMakeLists.txt
+++ llvm/test/CMakeLists.txt
@@ -1,12 +1,12 @@
 llvm_canonicalize_cmake_booleans(
   BUILD_SHARED_LIBS
   HAVE_LIBXAR
-

[PATCH] D79219: [CMake] Simplify CMake handling for zlib

2020-08-08 Thread Xun Li via Phabricator via cfe-commits
lxfind added a comment.

In D79219#2201415 , @phosek wrote:

> In D79219#2201109 , @lxfind wrote:
>
>> @phosek, Under this change, now when I build LLVM (with a basic config 
>> `cmake -G Ninja --LLVM_ENABLE_PROJECTS=clang ../llvm`), in file 
>> `build_dir/lib/cmake/llvm/LLVMExports.cmake`, I see this:
>>
>>   set_target_properties(LLVMSupport PROPERTIES
>> INTERFACE_LINK_LIBRARIES "curses;m;ZLIB::ZLIB;LLVMDemangle"
>>
>> This seems broken to me. Can you take a look?
>
> This is correct. That target is provided by `find_package(ZLIB)`. In 
> LLVMConfig.cmake, we invoke `find_package(ZLIB)` when zlib support is 
> enabled. If you're using `LLVMExports.cmake`, you'll need to invoke 
> `find_package(ZLIB)` yourself.

@phosek, Thanks for the reply. I am not too familiar with this. Could you 
please elaborate more on why setting it to `ZLIB::ZLIB` here is more modern? 
And how one is expected to deal with `ZLIB::ZLIB` that shows up in 
LLVMExports.cmake` (in the modern way)? Should one string pattern matching for 
`ZLIB::ZLIB` and invoke `find_package(ZLIB)` again? (previously one could 
simply concatenate `-l` with the library name in there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79219

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


[PATCH] D85545: [Diagnostics] Diagnose missing comma in string array initialization

2020-08-08 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

LGTM; nothing further from me!


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

https://reviews.llvm.org/D85545

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


[PATCH] D84600: [Analyzer] Support note tags for smart ptr checker

2020-08-08 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp:33
 
+// Static global pointer to NullDereferenceBugType.
+static const BugType *NullDereferenceBugTypePtr;

xazax.hun wrote:
> I find this comment redundant as well. It just repeats what is already 
> evident from the code.
removed



Comment at: clang/test/Analysis/smart-ptr-text-output.cpp:63
+void derefOnReleasedNullRawPtr() {
+  std::unique_ptr P;
+  A *AP = P.release(); // expected-note {{'AP' initialized to a null pointer 
value}}

NoQ wrote:
> Unlike the next line, this line deserves a note that `P` holds a null value.
Added a FIXEM to add note "Default constructed smart pointer 'P' is null"



Comment at: clang/test/Analysis/smart-ptr-text-output.cpp:65
+  A *AP = P.release(); // expected-note {{'AP' initialized to a null pointer 
value}}
+  //TODO add note "Smart pointer 'P' is released and set to null"
+  AP->foo(); // expected-warning {{Called C++ object pointer is null 
[core.CallAndMessage]}}

NoQ wrote:
> Such note is unnecessary. We don't care what happens to `P` after it's 
> released; we only care about its old value.
Removed this.



Comment at: clang/test/Analysis/smart-ptr-text-output.cpp:79
+
+// TODO: Enabale this test when "std::swap" is modeled seperately.
+void derefOnStdSwappedNullPtr() {

NoQ wrote:
> Instead of commenting out tests, i recommend testing the incorrect behavior 
> (with a FIXME comment telling us why it's incorrect). This way we'll be 
> notified when the test is fixed, accidentally or intentionally, and also 
> generally that's more testing for everybody.
I have commented out this since right now `std::swap` is using 
`unique_ptr.swap`.
So note tag for std::swap is added in header file  
`system-header-simulator-cxx.h`
eg:
`system-header-simulator-cxx.h Line 978: Swapped null smart pointer 'PNull' 
with smart pointer 'P'`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84600

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


[PATCH] D84600: [Analyzer] Support note tags for smart ptr checker

2020-08-08 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar updated this revision to Diff 284137.
vrnithinkumar marked 4 inline comments as done.
vrnithinkumar added a comment.

- Review comment changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84600

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  clang/lib/StaticAnalyzer/Checkers/SmartPtr.h
  clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/test/Analysis/smart-ptr-text-output.cpp
  clang/test/Analysis/smart-ptr.cpp

Index: clang/test/Analysis/smart-ptr.cpp
===
--- clang/test/Analysis/smart-ptr.cpp
+++ clang/test/Analysis/smart-ptr.cpp
@@ -12,7 +12,7 @@
   std::unique_ptr Q = std::move(P);
   if (Q)
 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
-  *Q.get() = 1; // no-warning
+  *Q.get() = 1; // no-warning
   if (P)
 clang_analyzer_warnIfReached(); // no-warning
   // TODO: Report a null dereference (instead).
@@ -50,37 +50,38 @@
 
 void derefAfterDefaultCtr() {
   std::unique_ptr P;
-  P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+  P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
 }
 
 void derefAfterCtrWithNull() {
   std::unique_ptr P(nullptr);
-  *P; // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+  *P; // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
 }
 
-void derefAfterCtrWithNullReturnMethod() {
-  std::unique_ptr P(return_null());
-  P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+void derefAfterCtrWithNullVariable() {
+  A *InnerPtr = nullptr;
+  std::unique_ptr P(InnerPtr);
+  P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
 }
 
 void derefAfterRelease() {
   std::unique_ptr P(new A());
   P.release();
   clang_analyzer_numTimesReached(); // expected-warning {{1}}
-  P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+  P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
 }
 
 void derefAfterReset() {
   std::unique_ptr P(new A());
   P.reset();
   clang_analyzer_numTimesReached(); // expected-warning {{1}}
-  P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+  P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
 }
 
 void derefAfterResetWithNull() {
   std::unique_ptr P(new A());
   P.reset(nullptr);
-  P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+  P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
 }
 
 void derefAfterResetWithNonNull() {
@@ -102,6 +103,12 @@
   AP->foo(); // expected-warning {{Called C++ object pointer is null [core.CallAndMessage]}}
 }
 
+void derefOnReleasedValidRawPtr() {
+  std::unique_ptr P(new A());
+  A *AP = P.release();
+  AP->foo(); // No warning.
+}
+
 void pass_smart_ptr_by_ref(std::unique_ptr &a);
 void pass_smart_ptr_by_const_ref(const std::unique_ptr &a);
 void pass_smart_ptr_by_rvalue_ref(std::unique_ptr &&a);
@@ -118,7 +125,7 @@
   {
 std::unique_ptr P;
 pass_smart_ptr_by_const_ref(P);
-P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
   }
   {
 std::unique_ptr P;
@@ -128,7 +135,7 @@
   {
 std::unique_ptr P;
 pass_smart_ptr_by_const_rvalue_ref(std::move(P));
-P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
   }
   {
 std::unique_ptr P;
@@ -138,7 +145,7 @@
   {
 std::unique_ptr P;
 pass_smart_ptr_by_const_ptr(&P);
-P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+P->foo(); // expected-warning {{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}
   }
 }
 
@@ -162,7 +169,7 @@
   {
 StructWithSmartPtr S;
 pass_struct_with_smart_ptr_by_const_ref(S);
-S.P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+S.P->foo(); // expected-warning {{Dereference of null smart pointer 'S.P' [alpha.cplusplus.SmartPtr]}}
   }
   {
 StructWithSmartPtr S;
@@ -172,7 +179,7 @@
   {
 StructWithSmartPtr S;
 pass_struct_with_smart_ptr_by_const_rvalue_ref(std::move(S));
-S.P->foo(); // expected-warning {{D

[PATCH] D85545: [Diagnostics] Diagnose missing comma in string array initialization

2020-08-08 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 284136.
xbolva00 added a comment.

Fixed nit


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

https://reviews.llvm.org/D85545

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/string-concat.c

Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -6907,6 +6907,21 @@
 << DIE->getSourceRange();
   Diag(InitArgList[I]->getBeginLoc(), diag::note_designated_init_mixed)
 << InitArgList[I]->getSourceRange();
+} else if (const auto *SL = dyn_cast(InitArgList[I])) {
+  unsigned NumConcat = SL->getNumConcatenated();
+  // Diagnose missing comma in string array initialization.
+  // Do not warn when all the elements in the initializer are concatenated together.
+  // Do not warn for macros too.
+  if (NumConcat > 1 && E > 1 && !SL->getBeginLoc().isMacroID()) {
+SmallVector Hints;
+for (unsigned i = 0; i < NumConcat - 1; ++i)
+  Hints.push_back(FixItHint::CreateInsertion(
+  PP.getLocForEndOfToken(SL->getStrTokenLoc(i)), ", "));
+
+Diag(SL->getStrTokenLoc(1), diag::warn_concatenated_literal_array_init)
+<< Hints;
+Diag(SL->getBeginLoc(), diag::note_concatenated_string_literal_silence);
+  }
 }
   }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2999,6 +2999,10 @@
 def warn_objc_string_literal_comparison : Warning<
   "direct comparison of a string literal has undefined behavior">,
   InGroup;
+def warn_concatenated_literal_array_init : Warning<
+  "suspicious concatenation of string literals in an array initialization; "
+  "did you mean to separate the elements with a comma?">,
+  InGroup>;
 def warn_concatenated_nsarray_literal : Warning<
   "concatenated NSString literal for an NSArray expression - "
   "possibly missing a comma">,
@@ -6139,6 +6143,9 @@
 def note_evaluate_comparison_first :Note<
   "place parentheses around comparison expression to evaluate it first">;
 
+def note_concatenated_string_literal_silence :Note<
+  "place parentheses around the string literal to silence warning">;
+
 def warn_addition_in_bitshift : Warning<
   "operator '%0' has lower precedence than '%1'; "
   "'%1' will be evaluated first">, InGroup;
Index: clang/test/Sema/string-concat.c
===
--- /dev/null
+++ clang/test/Sema/string-concat.c
@@ -0,0 +1,102 @@
+
+// RUN: %clang_cc1 -x c -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify %s
+
+const char *missing_comma[] = {
+"basic_filebuf",
+"basic_ios",
+"future",
+"optional",
+"packaged_task" // expected-note{{place parentheses around the string literal to silence warning}}
+"promise",  // expected-warning{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}} 
+"shared_future"
+};
+
+#ifndef __cplusplus
+typedef __WCHAR_TYPE__ wchar_t;
+#endif
+
+const wchar_t *missing_comma_wchar[] = {
+L"basic_filebuf",
+L"packaged_task" // expected-note{{place parentheses around the string literal to silence warning}}
+L"promise"  // expected-warning{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
+};
+
+const char *missing_comma_u8[] = {
+u8"basic_filebuf",
+u8"packaged_task" // expected-note{{place parentheses around the string literal to silence warning}}
+u8"promise"  // expected-warning{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
+};
+
+const char *missing_two_commas[] = {"basic_filebuf",
+   "basic_ios" // expected-note{{place parentheses around the string literal to silence warning}}
+   "future"// expected-warning{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
+   "optional",
+   "packaged_task"};
+
+const char *missing_comma_same_line[] = {"basic_filebuf", "basic_ios",
+   "future" "optional", // expected-note{{place parentheses around the string literal to silence warning}}
+   "packaged_task", "promise"}; // expected-warning@-1{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
+
+const char *missing_comma_different_lines[] = {"basic_filebuf", "basic_ios" // expected-note{{place parentheses aroun

[PATCH] D85545: [Diagnostics] Diagnose missing comma in string array initialization

2020-08-08 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Thank you all for code review


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

https://reviews.llvm.org/D85545

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


[clang] dc096a6 - [Diagnostics] Diagnose missing comma in string array initialization

2020-08-08 Thread Dávid Bolvanský via cfe-commits

Author: Dávid Bolvanský
Date: 2020-08-08T19:24:30+02:00
New Revision: dc096a66cb519532121fb0fbedb13265bd4b29ec

URL: 
https://github.com/llvm/llvm-project/commit/dc096a66cb519532121fb0fbedb13265bd4b29ec
DIFF: 
https://github.com/llvm/llvm-project/commit/dc096a66cb519532121fb0fbedb13265bd4b29ec.diff

LOG: [Diagnostics] Diagnose missing comma in string array initialization

Motivation (from PR37674):

const char *ss[] = {
  "foo", "bar",
  "baz", "qux"  // <-- Missing comma!
  "abc", "xyz"
  };

This kind of bug was recently also found in LLVM codebase (see PR47030).

Solves PR47038, PR37674

Reviewed By: aaron.ballman

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

Added: 
clang/test/Sema/string-concat.c

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaExpr.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 659f1d6df39e..7fe9396dbfc3 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3002,6 +3002,10 @@ def err_missing_atsign_prefix : Error<
 def warn_objc_string_literal_comparison : Warning<
   "direct comparison of a string literal has undefined behavior">,
   InGroup;
+def warn_concatenated_literal_array_init : Warning<
+  "suspicious concatenation of string literals in an array initialization; "
+  "did you mean to separate the elements with a comma?">,
+  InGroup>;
 def warn_concatenated_nsarray_literal : Warning<
   "concatenated NSString literal for an NSArray expression - "
   "possibly missing a comma">,
@@ -6142,6 +6146,9 @@ def warn_overloaded_shift_in_comparison :Warning<
 def note_evaluate_comparison_first :Note<
   "place parentheses around comparison expression to evaluate it first">;
 
+def note_concatenated_string_literal_silence :Note<
+  "place parentheses around the string literal to silence warning">;
+
 def warn_addition_in_bitshift : Warning<
   "operator '%0' has lower precedence than '%1'; "
   "'%1' will be evaluated first">, InGroup;

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 28da268e637f..e86c5b919698 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -6906,6 +6906,21 @@ Sema::ActOnInitList(SourceLocation LBraceLoc, 
MultiExprArg InitArgList,
 << DIE->getSourceRange();
   Diag(InitArgList[I]->getBeginLoc(), diag::note_designated_init_mixed)
 << InitArgList[I]->getSourceRange();
+} else if (const auto *SL = dyn_cast(InitArgList[I])) {
+  unsigned NumConcat = SL->getNumConcatenated();
+  // Diagnose missing comma in string array initialization.
+  // Do not warn when all the elements in the initializer are concatenated 
together.
+  // Do not warn for macros too.
+  if (NumConcat > 1 && E > 1 && !SL->getBeginLoc().isMacroID()) {
+SmallVector Hints;
+for (unsigned i = 0; i < NumConcat - 1; ++i)
+  Hints.push_back(FixItHint::CreateInsertion(
+  PP.getLocForEndOfToken(SL->getStrTokenLoc(i)), ", "));
+
+Diag(SL->getStrTokenLoc(1), diag::warn_concatenated_literal_array_init)
+<< Hints;
+Diag(SL->getBeginLoc(), 
diag::note_concatenated_string_literal_silence);
+  }
 }
   }
 

diff  --git a/clang/test/Sema/string-concat.c b/clang/test/Sema/string-concat.c
new file mode 100644
index ..bf8369b079c8
--- /dev/null
+++ b/clang/test/Sema/string-concat.c
@@ -0,0 +1,102 @@
+
+// RUN: %clang_cc1 -x c -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify %s
+
+const char *missing_comma[] = {
+"basic_filebuf",
+"basic_ios",
+"future",
+"optional",
+"packaged_task" // expected-note{{place parentheses around the string 
literal to silence warning}}
+"promise",  // expected-warning{{suspicious concatenation of string 
literals in an array initialization; did you mean to separate the elements with 
a comma?}} 
+"shared_future"
+};
+
+#ifndef __cplusplus
+typedef __WCHAR_TYPE__ wchar_t;
+#endif
+
+const wchar_t *missing_comma_wchar[] = {
+L"basic_filebuf",
+L"packaged_task" // expected-note{{place parentheses around the string 
literal to silence warning}}
+L"promise"  // expected-warning{{suspicious concatenation of string 
literals in an array initialization; did you mean to separate the elements with 
a comma?}}
+};
+
+const char *missing_comma_u8[] = {
+u8"basic_filebuf",
+u8"packaged_task" // expected-note{{place parentheses around the string 
literal to silence warning}}
+u8"promise"  // expected-warning{{suspicious concatenation of string 
literals in an array initialization; did you mean to separate the elements with 
a comma?}}
+};
+
+const char *missing_two_commas[] = {"basic_filebuf",
+   "basic_ios" // expecte

[PATCH] D85545: [Diagnostics] Diagnose missing comma in string array initialization

2020-08-08 Thread Dávid Bolvanský via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdc096a66cb51: [Diagnostics] Diagnose missing comma in string 
array initialization (authored by xbolva00).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85545

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/string-concat.c

Index: clang/test/Sema/string-concat.c
===
--- /dev/null
+++ clang/test/Sema/string-concat.c
@@ -0,0 +1,102 @@
+
+// RUN: %clang_cc1 -x c -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify %s
+
+const char *missing_comma[] = {
+"basic_filebuf",
+"basic_ios",
+"future",
+"optional",
+"packaged_task" // expected-note{{place parentheses around the string literal to silence warning}}
+"promise",  // expected-warning{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}} 
+"shared_future"
+};
+
+#ifndef __cplusplus
+typedef __WCHAR_TYPE__ wchar_t;
+#endif
+
+const wchar_t *missing_comma_wchar[] = {
+L"basic_filebuf",
+L"packaged_task" // expected-note{{place parentheses around the string literal to silence warning}}
+L"promise"  // expected-warning{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
+};
+
+const char *missing_comma_u8[] = {
+u8"basic_filebuf",
+u8"packaged_task" // expected-note{{place parentheses around the string literal to silence warning}}
+u8"promise"  // expected-warning{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
+};
+
+const char *missing_two_commas[] = {"basic_filebuf",
+   "basic_ios" // expected-note{{place parentheses around the string literal to silence warning}}
+   "future"// expected-warning{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
+   "optional",
+   "packaged_task"};
+
+const char *missing_comma_same_line[] = {"basic_filebuf", "basic_ios",
+   "future" "optional", // expected-note{{place parentheses around the string literal to silence warning}}
+   "packaged_task", "promise"}; // expected-warning@-1{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
+
+const char *missing_comma_different_lines[] = {"basic_filebuf", "basic_ios" // expected-note{{place parentheses around the string literal to silence warning}}
+   "future", "optional",// expected-warning{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
+   "packaged_task", "promise"};
+
+const char *missing_comma_same_line_all_literals[] = {"basic_filebuf", "future" "optional", "packaged_task"}; // expected-note{{place parentheses around the string literal to silence warning}}
+   // expected-warning@-1{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
+
+char missing_comma_inner[][4] = {
+"a",
+"b" // expected-note{{place parentheses around the string literal to silence warning}}
+"c" // expected-warning{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
+};
+
+
+#define ONE(x) x
+#define TWO "foo"
+const char *macro_test[] = { ONE("foo") "bar", 
+ TWO "bar", 
+ "foo" TWO // expected-note{{place parentheses around the string literal to silence warning}}
+   };  // expected-warning@-1{{suspicious concatenation of string literals in an array initialization; did you mean to separate the elements with a comma?}}
+
+// Do not warn for macros.
+
+#define BASIC_IOS "basic_ios"
+#define FUTURE "future"
+const char *macro_test2[] = {"basic_filebuf", BASIC_IOS
+FUTURE, "optional",
+   "packaged_task", "promise"};
+
+#define FOO(xx) xx "_normal", \
+xx "_movable",
+
+const char *macro_test3[] = {"basic_filebuf",
+   "basic_ios",
+   FOO("future")
+   "optional",
+   "packaged_task"};
+
+#define BAR(name) #name "_normal"
+
+const char *macro_test4[] = {"basic_filebuf",
+   "basic_ios",
+   BAR(fut

[PATCH] D84600: [Analyzer] Support note tags for smart ptr checker

2020-08-08 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar added a comment.

In D84600#2203604 , @Szelethus wrote:

> Layering violations are a running theme in the analyzer -- CheckerRegistry 
> and the entire MallocChecker fiasco 
>  are two glaring examples. 
> Luckily, this isn't a severe case so I wouldn't worry about it much.
>
> I've been following your patches, but them mentors answer way ahead of me and 
> are very thorough :^) Best of luck with the finale!

Thanks for sharing checker dependency talk.
Also fo suggesting to separate checker and modeling from beginning.  :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84600

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


[PATCH] D84600: [Analyzer] Support note tags for smart ptr checker

2020-08-08 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar added inline comments.



Comment at: clang/test/Analysis/smart-ptr-text-output.cpp:79
+
+// TODO: Enabale this test when "std::swap" is modeled seperately.
+void derefOnStdSwappedNullPtr() {

vrnithinkumar wrote:
> NoQ wrote:
> > Instead of commenting out tests, i recommend testing the incorrect behavior 
> > (with a FIXME comment telling us why it's incorrect). This way we'll be 
> > notified when the test is fixed, accidentally or intentionally, and also 
> > generally that's more testing for everybody.
> I have commented out this since right now `std::swap` is using 
> `unique_ptr.swap`.
> So note tag for std::swap is added in header file  
> `system-header-simulator-cxx.h`
> eg:
> `system-header-simulator-cxx.h Line 978: Swapped null smart pointer 'PNull' 
> with smart pointer 'P'`
- Is it okay to add a expected-note on `system-header-simulator-cxx.h`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84600

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


[clang] 0fef780 - [Clang] Avoid whitespace in fixit note

2020-08-08 Thread Dávid Bolvanský via cfe-commits

Author: Dávid Bolvanský
Date: 2020-08-08T19:34:07+02:00
New Revision: 0fef780aa70b48551ae6df373955b5e4f5130fa4

URL: 
https://github.com/llvm/llvm-project/commit/0fef780aa70b48551ae6df373955b5e4f5130fa4
DIFF: 
https://github.com/llvm/llvm-project/commit/0fef780aa70b48551ae6df373955b5e4f5130fa4.diff

LOG: [Clang] Avoid whitespace in fixit note

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index e86c5b919698..7560dc996b15 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -6915,7 +6915,7 @@ Sema::ActOnInitList(SourceLocation LBraceLoc, 
MultiExprArg InitArgList,
 SmallVector Hints;
 for (unsigned i = 0; i < NumConcat - 1; ++i)
   Hints.push_back(FixItHint::CreateInsertion(
-  PP.getLocForEndOfToken(SL->getStrTokenLoc(i)), ", "));
+  PP.getLocForEndOfToken(SL->getStrTokenLoc(i)), ","));
 
 Diag(SL->getStrTokenLoc(1), diag::warn_concatenated_literal_array_init)
 << Hints;



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


[clang] 6cd2355 - [Clang] Fixed buildboit failure; bot defaults to older C++ standard

2020-08-08 Thread Dávid Bolvanský via cfe-commits

Author: Dávid Bolvanský
Date: 2020-08-08T19:37:50+02:00
New Revision: 6cd23558d3a9fbe8bc73e96d4df4e52c8261d1b5

URL: 
https://github.com/llvm/llvm-project/commit/6cd23558d3a9fbe8bc73e96d4df4e52c8261d1b5
DIFF: 
https://github.com/llvm/llvm-project/commit/6cd23558d3a9fbe8bc73e96d4df4e52c8261d1b5.diff

LOG: [Clang] Fixed buildboit failure; bot defaults to older C++ standard

Added: 


Modified: 
clang/test/Sema/string-concat.c

Removed: 




diff  --git a/clang/test/Sema/string-concat.c b/clang/test/Sema/string-concat.c
index bf8369b079c8..8f087e37d953 100644
--- a/clang/test/Sema/string-concat.c
+++ b/clang/test/Sema/string-concat.c
@@ -22,11 +22,13 @@ const wchar_t *missing_comma_wchar[] = {
 L"promise"  // expected-warning{{suspicious concatenation of string 
literals in an array initialization; did you mean to separate the elements with 
a comma?}}
 };
 
+#if __cplusplus >= 201103L
 const char *missing_comma_u8[] = {
 u8"basic_filebuf",
 u8"packaged_task" // expected-note{{place parentheses around the string 
literal to silence warning}}
 u8"promise"  // expected-warning{{suspicious concatenation of string 
literals in an array initialization; did you mean to separate the elements with 
a comma?}}
 };
+#endif
 
 const char *missing_two_commas[] = {"basic_filebuf",
"basic_ios" // expected-note{{place parentheses around 
the string literal to silence warning}}



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


[clang] cd5ab56 - Change the default target CPU for OpenBSD/i386 to i586

2020-08-08 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2020-08-08T13:49:45-04:00
New Revision: cd5ab56bc406c3f9a6f593f98c63dafb53547ab1

URL: 
https://github.com/llvm/llvm-project/commit/cd5ab56bc406c3f9a6f593f98c63dafb53547ab1
DIFF: 
https://github.com/llvm/llvm-project/commit/cd5ab56bc406c3f9a6f593f98c63dafb53547ab1.diff

LOG: Change the default target CPU for OpenBSD/i386 to i586

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/X86.cpp
clang/test/Driver/openbsd.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index c49aaadc42ae..94a53f9d9e46 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -94,13 +94,13 @@ std::string x86::getX86TargetCPU(const ArgList &Args,
 return "x86-64";
 
   switch (Triple.getOS()) {
-  case llvm::Triple::FreeBSD:
-return "i686";
   case llvm::Triple::NetBSD:
-  case llvm::Triple::OpenBSD:
 return "i486";
   case llvm::Triple::Haiku:
+  case llvm::Triple::OpenBSD:
 return "i586";
+  case llvm::Triple::FreeBSD:
+return "i686";
   default:
 // Fallback to p4.
 return "pentium4";

diff  --git a/clang/test/Driver/openbsd.c b/clang/test/Driver/openbsd.c
index 51a5b4380f45..e17d05dc76da 100644
--- a/clang/test/Driver/openbsd.c
+++ b/clang/test/Driver/openbsd.c
@@ -14,6 +14,11 @@
 // CHECK-PG: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
 // CHECK-PG: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" 
"-dynamic-linker" "{{.*}}ld.so" "-nopie" "-o" "a.out" "{{.*}}gcrt0.o" 
"{{.*}}crtbegin.o" "{{.*}}.o" "-lcompiler_rt" "-lpthread_p" "-lc_p" 
"-lcompiler_rt" "{{.*}}crtend.o"
 
+// Check CPU type for i386
+// RUN: %clang -target i386-unknown-openbsd -### -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-i386-CPU %s
+// CHECK-i386-CPU: "-target-cpu" "i586"
+
 // Check CPU type for MIPS64
 // RUN: %clang -target mips64-unknown-openbsd -### -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-MIPS64-CPU %s



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


[clang] 090f9d5 - Fix MSVC "not all control paths return a value" warning. NFC.

2020-08-08 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-08-08T19:12:11+01:00
New Revision: 090f9d5a55338ee815f5a6ef7aaa1ed712f65e05

URL: 
https://github.com/llvm/llvm-project/commit/090f9d5a55338ee815f5a6ef7aaa1ed712f65e05
DIFF: 
https://github.com/llvm/llvm-project/commit/090f9d5a55338ee815f5a6ef7aaa1ed712f65e05.diff

LOG: Fix MSVC "not all control paths return a value" warning. NFC.

Added: 


Modified: 
clang/lib/Tooling/Syntax/BuildTree.cpp

Removed: 




diff  --git a/clang/lib/Tooling/Syntax/BuildTree.cpp 
b/clang/lib/Tooling/Syntax/BuildTree.cpp
index 21ac6b8bda62..4e76b3825b6f 100644
--- a/clang/lib/Tooling/Syntax/BuildTree.cpp
+++ b/clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -769,6 +769,7 @@ class BuildTreeVisitor : public 
RecursiveASTVisitor {
   llvm::report_fatal_error("We don't yet support the __super specifier",
true);
 }
+llvm_unreachable("Unhandled NestedNameSpecifier::SpecifierKind enum");
   }
 
   // FIXME: Fix `NestedNameSpecifierLoc::getLocalSourceRange` for the



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


[PATCH] D85545: [Diagnostics] Diagnose missing comma in string array initialization

2020-08-08 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

And we caught one more bug in LLVM repo (in libcxx)

  const char* TestCaseSetOne[] = {"", "s", "bac",
  "bacasf"
  "lkajseravea",
  "adsfkajdsfjkas;lnc441324513,34535r34525234",
  "b*c",
  "ba?sf"
  "lka*ea",
  "adsf*kas;lnc441[0-9]1r34525234"};

https://github.com/llvm/llvm-project/blob/daacf57032450079b44b8a7f9b976700d3bc38f8/libcxx/test/libcxx/fuzzing/fuzzer_test.h#L20


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85545

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


[clang] 4eb4ebf - Hook up OpenBSD 64-bit PowerPC support

2020-08-08 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2020-08-08T17:51:19-04:00
New Revision: 4eb4ebf76a6e26b0632968dd299d1dc6ad07e694

URL: 
https://github.com/llvm/llvm-project/commit/4eb4ebf76a6e26b0632968dd299d1dc6ad07e694
DIFF: 
https://github.com/llvm/llvm-project/commit/4eb4ebf76a6e26b0632968dd299d1dc6ad07e694.diff

LOG: Hook up OpenBSD 64-bit PowerPC support

Added: 


Modified: 
clang/lib/Basic/Targets.cpp
clang/lib/Basic/Targets/OSTargets.h
clang/lib/Basic/Targets/PPC.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/ppc-abi.c
clang/test/Preprocessor/init-ppc64.c
clang/test/Preprocessor/init.c

Removed: 




diff  --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 6bbcafa27dfe..bd3c2d66f958 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -346,6 +346,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
   return new FreeBSDTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
+case llvm::Triple::OpenBSD:
+  return new OpenBSDTargetInfo(Triple, Opts);
 case llvm::Triple::AIX:
   return new AIXPPC64TargetInfo(Triple, Opts);
 default:
@@ -358,6 +360,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
   return new LinuxTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
+case llvm::Triple::OpenBSD:
+  return new OpenBSDTargetInfo(Triple, Opts);
 default:
   return new PPC64TargetInfo(Triple, Opts);
 }

diff  --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 7b3acc335a35..cc726a92a7ca 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -476,6 +476,8 @@ class LLVM_LIBRARY_VISIBILITY OpenBSDTargetInfo : public 
OSTargetInfo {
 case llvm::Triple::mips64:
 case llvm::Triple::mips64el:
 case llvm::Triple::ppc:
+case llvm::Triple::ppc64:
+case llvm::Triple::ppc64le:
 case llvm::Triple::sparcv9:
   this->MCountName = "_mcount";
   break;

diff  --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index da4d37bbdcfc..88523279a6ee 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -418,7 +418,7 @@ class LLVM_LIBRARY_VISIBILITY PPC64TargetInfo : public 
PPCTargetInfo {
   ABI = "elfv1";
 }
 
-if (Triple.isOSFreeBSD() || Triple.isMusl()) {
+if (Triple.isOSFreeBSD() || Triple.isOSOpenBSD() || Triple.isMusl()) {
   LongDoubleWidth = LongDoubleAlign = 64;
   LongDoubleFormat = &llvm::APFloat::IEEEdouble();
 }

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 68e4eb0eedda..b4a8ce8e95ce 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1883,7 +1883,8 @@ void Clang::AddPPCTargetArgs(const ArgList &Args,
   if (T.isOSBinFormatELF()) {
 switch (getToolChain().getArch()) {
 case llvm::Triple::ppc64: {
-  if (T.isMusl() || (T.isOSFreeBSD() && T.getOSMajorVersion() >= 13))
+  if ((T.isOSFreeBSD() && T.getOSMajorVersion() >= 13) ||
+  T.isOSOpenBSD() || T.isMusl()
 ABIName = "elfv2";
   else
 ABIName = "elfv1";

diff  --git a/clang/test/Driver/ppc-abi.c b/clang/test/Driver/ppc-abi.c
index 2b5cc463e7c3..9415b4c020ab 100644
--- a/clang/test/Driver/ppc-abi.c
+++ b/clang/test/Driver/ppc-abi.c
@@ -20,6 +20,7 @@
 // RUN: %clang -target powerpc64-unknown-freebsd12 %s -### 2>&1 | FileCheck 
--check-prefix=CHECK-ELFv1 %s
 // RUN: %clang -target powerpc64-unknown-freebsd13 %s -### 2>&1 | FileCheck 
--check-prefix=CHECK-ELFv2-BE %s
 // RUN: %clang -target powerpc64-unknown-freebsd14 %s -### 2>&1 | FileCheck 
--check-prefix=CHECK-ELFv2-BE %s
+// RUN: %clang -target powerpc64-unknown-openbsd %s -### 2>&1 | FileCheck 
--check-prefix=CHECK-ELFv2-BE-PIE %
 // RUN: %clang -target powerpc64-linux-musl %s -### 2>&1 | FileCheck 
--check-prefix=CHECK-ELFv2-BE-PIE %s
 
 // CHECK-ELFv1: "-mrelocation-model" "static"

diff  --git a/clang/test/Preprocessor/init-ppc64.c 
b/clang/test/Preprocessor/init-ppc64.c
index 48d35c95aa57..3550af3b680b 100644
--- a/clang/test/Preprocessor/init-ppc64.c
+++ b/clang/test/Preprocessor/init-ppc64.c
@@ -1062,6 +1062,7 @@
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-freebsd11 
-target-abi elfv1 -xc /dev/null | FileCheck --check-prefix=PPC64-ELFv1 %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-freebsd12 
-target-abi elfv1 -xc /dev/null | FileCheck --check-prefix=PPC64-ELFv1 %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-freebsd13 
-target-abi elfv2 -xc /dev/null | FileCheck --check-prefix=PPC64-ELFv2 %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-openbsd 
-target-abi elfv2 -xc /dev/nul

[clang] 430db35 - fix typo

2020-08-08 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2020-08-08T17:58:13-04:00
New Revision: 430db35bf21505015c618e292e98793e2ed49169

URL: 
https://github.com/llvm/llvm-project/commit/430db35bf21505015c618e292e98793e2ed49169
DIFF: 
https://github.com/llvm/llvm-project/commit/430db35bf21505015c618e292e98793e2ed49169.diff

LOG: fix typo

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index b4a8ce8e95ce..d35d7d808084 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1884,7 +1884,7 @@ void Clang::AddPPCTargetArgs(const ArgList &Args,
 switch (getToolChain().getArch()) {
 case llvm::Triple::ppc64: {
   if ((T.isOSFreeBSD() && T.getOSMajorVersion() >= 13) ||
-  T.isOSOpenBSD() || T.isMusl()
+  T.isOSOpenBSD() || T.isMusl())
 ABIName = "elfv2";
   else
 ABIName = "elfv1";



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


[clang] f4aba9d - Backout a test that is dependent on an uncommited diff. Fix another.

2020-08-08 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2020-08-08T18:39:43-04:00
New Revision: f4aba9d76c61cc4c87b45e4edb57b1968eb7194c

URL: 
https://github.com/llvm/llvm-project/commit/f4aba9d76c61cc4c87b45e4edb57b1968eb7194c
DIFF: 
https://github.com/llvm/llvm-project/commit/f4aba9d76c61cc4c87b45e4edb57b1968eb7194c.diff

LOG: Backout a test that is dependent on an uncommited diff. Fix another.

Added: 


Modified: 
clang/test/Driver/ppc-abi.c
clang/test/Preprocessor/init.c

Removed: 




diff  --git a/clang/test/Driver/ppc-abi.c b/clang/test/Driver/ppc-abi.c
index 9415b4c020ab..491f9336a5c3 100644
--- a/clang/test/Driver/ppc-abi.c
+++ b/clang/test/Driver/ppc-abi.c
@@ -20,7 +20,7 @@
 // RUN: %clang -target powerpc64-unknown-freebsd12 %s -### 2>&1 | FileCheck 
--check-prefix=CHECK-ELFv1 %s
 // RUN: %clang -target powerpc64-unknown-freebsd13 %s -### 2>&1 | FileCheck 
--check-prefix=CHECK-ELFv2-BE %s
 // RUN: %clang -target powerpc64-unknown-freebsd14 %s -### 2>&1 | FileCheck 
--check-prefix=CHECK-ELFv2-BE %s
-// RUN: %clang -target powerpc64-unknown-openbsd %s -### 2>&1 | FileCheck 
--check-prefix=CHECK-ELFv2-BE-PIE %
+// RUN: %clang -target powerpc64-unknown-openbsd %s -### 2>&1 | FileCheck 
--check-prefix=CHECK-ELFv2-BE-PIE %s
 // RUN: %clang -target powerpc64-linux-musl %s -### 2>&1 | FileCheck 
--check-prefix=CHECK-ELFv2-BE-PIE %s
 
 // CHECK-ELFv1: "-mrelocation-model" "static"

diff  --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index 9e085a8f9fe8..d6f3225bd04b 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -7321,8 +7321,6 @@
 // RUN: %clang_cc1 -E -dM -ffreestanding 
-triple=arm-unknown-openbsd6.1-gnueabi < /dev/null | FileCheck 
-match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=i386-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
-// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-openbsd6.1 
< /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
-// RUN: %clang_cc1 -E -dM -ffreestanding 
-triple=powerpc64le-unknown-openbsd6.1 < /dev/null | FileCheck 
-match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64el-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s



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


[PATCH] D85590: [clang][HeaderInsert] Do not treat defines with values as header guards

2020-08-08 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: hokein.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
kadircet requested review of this revision.

This was resulting in inserting headers at bogus locations, see
https://github.com/ycm-core/YouCompleteMe/issues/3736 for an example.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85590

Files:
  clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
  clang/unittests/Tooling/HeaderIncludesTest.cpp


Index: clang/unittests/Tooling/HeaderIncludesTest.cpp
===
--- clang/unittests/Tooling/HeaderIncludesTest.cpp
+++ clang/unittests/Tooling/HeaderIncludesTest.cpp
@@ -529,6 +529,18 @@
   EXPECT_EQ(Expected, remove(Code, "\"b.h\""));
 }
 
+TEST_F(HeaderIncludesTest, FakeHeaderGuardIfnDef) {
+  std::string Code = "#ifndef A_H\n"
+ "#define A_H 1\n"
+ "#endif";
+  std::string Expected = "#include \"b.h\"\n"
+ "#ifndef A_H\n"
+ "#define A_H 1\n"
+ "#endif";
+
+  EXPECT_EQ(Expected, insert(Code, "\"b.h\""));
+}
+
 } // namespace
 } // namespace tooling
 } // namespace clang
Index: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
===
--- clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -100,7 +100,8 @@
   [](const SourceManager &SM, Lexer &Lex, Token Tok) -> unsigned {
 if (checkAndConsumeDirectiveWithName(Lex, "ifndef", Tok)) {
   skipComments(Lex, Tok);
-  if (checkAndConsumeDirectiveWithName(Lex, "define", Tok))
+  if (checkAndConsumeDirectiveWithName(Lex, "define", Tok) &&
+  Tok.isAtStartOfLine())
 return SM.getFileOffset(Tok.getLocation());
 }
 return 0;


Index: clang/unittests/Tooling/HeaderIncludesTest.cpp
===
--- clang/unittests/Tooling/HeaderIncludesTest.cpp
+++ clang/unittests/Tooling/HeaderIncludesTest.cpp
@@ -529,6 +529,18 @@
   EXPECT_EQ(Expected, remove(Code, "\"b.h\""));
 }
 
+TEST_F(HeaderIncludesTest, FakeHeaderGuardIfnDef) {
+  std::string Code = "#ifndef A_H\n"
+ "#define A_H 1\n"
+ "#endif";
+  std::string Expected = "#include \"b.h\"\n"
+ "#ifndef A_H\n"
+ "#define A_H 1\n"
+ "#endif";
+
+  EXPECT_EQ(Expected, insert(Code, "\"b.h\""));
+}
+
 } // namespace
 } // namespace tooling
 } // namespace clang
Index: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
===
--- clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -100,7 +100,8 @@
   [](const SourceManager &SM, Lexer &Lex, Token Tok) -> unsigned {
 if (checkAndConsumeDirectiveWithName(Lex, "ifndef", Tok)) {
   skipComments(Lex, Tok);
-  if (checkAndConsumeDirectiveWithName(Lex, "define", Tok))
+  if (checkAndConsumeDirectiveWithName(Lex, "define", Tok) &&
+  Tok.isAtStartOfLine())
 return SM.getFileOffset(Tok.getLocation());
 }
 return 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a4d78d2 - Revert "[CMake] Simplify CMake handling for zlib"

2020-08-08 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2020-08-08T17:08:23-07:00
New Revision: a4d78d23c53451ccefe0df0adfff9a1ac3077f10

URL: 
https://github.com/llvm/llvm-project/commit/a4d78d23c53451ccefe0df0adfff9a1ac3077f10
DIFF: 
https://github.com/llvm/llvm-project/commit/a4d78d23c53451ccefe0df0adfff9a1ac3077f10.diff

LOG: Revert "[CMake] Simplify CMake handling for zlib"

This reverts commit ccbc1485b55ff4acd21bcfafbf7aec4ed0fd818d which
is still failing on the Windows MLIR bots.

Added: 


Modified: 
clang/test/CMakeLists.txt
clang/test/lit.site.cfg.py.in
compiler-rt/test/lit.common.configured.in
lld/test/CMakeLists.txt
lld/test/lit.site.cfg.py.in
lldb/cmake/modules/LLDBStandalone.cmake
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
llvm/cmake/config-ix.cmake
llvm/cmake/modules/LLVMConfig.cmake.in
llvm/include/llvm/Config/config.h.cmake
llvm/lib/Support/CMakeLists.txt
llvm/lib/Support/CRC.cpp
llvm/lib/Support/Compression.cpp
llvm/test/CMakeLists.txt
llvm/test/lit.site.cfg.py.in
llvm/unittests/Support/CompressionTest.cpp
llvm/utils/gn/secondary/clang/test/BUILD.gn
llvm/utils/gn/secondary/compiler-rt/test/BUILD.gn
llvm/utils/gn/secondary/lld/test/BUILD.gn
llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
llvm/utils/gn/secondary/llvm/test/BUILD.gn

Removed: 




diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 334a90498d0d..38bbc5be90d5 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -9,6 +9,15 @@ endif ()
 
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR 
${LLVM_RUNTIME_OUTPUT_INTDIR})
 
+if(CLANG_BUILT_STANDALONE)
+  # Set HAVE_LIBZ according to recorded LLVM_ENABLE_ZLIB value. This
+  # value is forced to 0 if zlib was not found, so it is fine to use it
+  # instead of HAVE_LIBZ (not recorded).
+  if(LLVM_ENABLE_ZLIB)
+set(HAVE_LIBZ 1)
+  endif()
+endif()
+
 llvm_canonicalize_cmake_booleans(
   CLANG_BUILD_EXAMPLES
   CLANG_ENABLE_ARCMT
@@ -16,7 +25,7 @@ llvm_canonicalize_cmake_booleans(
   CLANG_SPAWN_CC1
   ENABLE_BACKTRACES
   ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER
-  LLVM_ENABLE_ZLIB
+  HAVE_LIBZ
   LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
   LLVM_ENABLE_PLUGINS
   LLVM_ENABLE_THREADS)

diff  --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index 286ea06d798c..d9b5b2f2592e 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -16,7 +16,7 @@ config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.host_cxx = "@CMAKE_CXX_COMPILER@"
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
-config.have_zlib = @LLVM_ENABLE_ZLIB@
+config.have_zlib = @HAVE_LIBZ@
 config.clang_arcmt = @CLANG_ENABLE_ARCMT@
 config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@"
 config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@

diff  --git a/compiler-rt/test/lit.common.configured.in 
b/compiler-rt/test/lit.common.configured.in
index 000bf9b98470..1f746c067b84 100644
--- a/compiler-rt/test/lit.common.configured.in
+++ b/compiler-rt/test/lit.common.configured.in
@@ -57,7 +57,7 @@ elif config.android:
 else:
   set_default("target_suffix", "-%s" % config.target_arch)
 
-set_default("have_zlib", "@LLVM_ENABLE_ZLIB@")
+set_default("have_zlib", "@HAVE_LIBZ@")
 set_default("libcxx_used", "@LLVM_LIBCXX_USED@")
 
 # LLVM tools dir can be passed in lit parameters, so try to

diff  --git a/lld/test/CMakeLists.txt b/lld/test/CMakeLists.txt
index 52e6118ba876..74b29f5d65b8 100644
--- a/lld/test/CMakeLists.txt
+++ b/lld/test/CMakeLists.txt
@@ -4,8 +4,17 @@ set(LLVM_BUILD_MODE "%(build_mode)s")
 set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/%(build_config)s")
 set(LLVM_LIBS_DIR 
"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/%(build_config)s")
 
+if(LLD_BUILT_STANDALONE)
+  # Set HAVE_LIBZ according to recorded LLVM_ENABLE_ZLIB value. This
+  # value is forced to 0 if zlib was not found, so it is fine to use it
+  # instead of HAVE_LIBZ (not recorded).
+  if(LLVM_ENABLE_ZLIB)
+set(HAVE_LIBZ 1)
+  endif()
+endif()
+
 llvm_canonicalize_cmake_booleans(
-  LLVM_ENABLE_ZLIB
+  HAVE_LIBZ
   LLVM_LIBXML2_ENABLED
   )
 

diff  --git a/lld/test/lit.site.cfg.py.in b/lld/test/lit.site.cfg.py.in
index 3d4c51f4ab64..4aa2fcda73bb 100644
--- a/lld/test/lit.site.cfg.py.in
+++ b/lld/test/lit.site.cfg.py.in
@@ -14,7 +14,7 @@ config.lld_libs_dir = "@LLVM_LIBRARY_OUTPUT_INTDIR@"
 config.lld_tools_dir = "@LLVM_RUNTIME_OUTPUT_INTDIR@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.python_executable = "@Python3_EXECUTABLE@"
-config.have_zlib = @LLVM_ENABLE_ZLIB@
+config.have_zlib = @HAVE_LIBZ@
 config.sizeof_void_p = @CMAKE_SIZEOF_VOID_P@
 
 # Support substitution of the tools and libs dirs with user parameters. This is

diff  --git a/lldb/cmake/

[PATCH] D85596: [Docs] Link to --print-supported-cpus option

2020-08-08 Thread Travis Finkenauer via Phabricator via cfe-commits
tmfink created this revision.
tmfink added reviewers: nickdesaulniers, ziangwan.
tmfink added a project: clang.
tmfink requested review of this revision.

Adds link and avoids rendering two dashes as non-ascii "en dash" in HTML output.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85596

Files:
  clang/docs/CommandGuide/clang.rst


Index: clang/docs/CommandGuide/clang.rst
===
--- clang/docs/CommandGuide/clang.rst
+++ clang/docs/CommandGuide/clang.rst
@@ -343,7 +343,7 @@
 
 .. option:: -mcpu=?, -mtune=?
 
-  Aliases of --print-supported-cpus
+  Aliases of :option:`--print-supported-cpus`
 
 .. option:: -march=
 


Index: clang/docs/CommandGuide/clang.rst
===
--- clang/docs/CommandGuide/clang.rst
+++ clang/docs/CommandGuide/clang.rst
@@ -343,7 +343,7 @@
 
 .. option:: -mcpu=?, -mtune=?
 
-  Aliases of --print-supported-cpus
+  Aliases of :option:`--print-supported-cpus`
 
 .. option:: -march=
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits