[PATCH] D32489: [compiler-rt] [test] Build sanitizer/xray tests only if COMPILER_RT_BUILD_* is on

2017-04-26 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL301387: [test] Build sanitizer/xray tests only if 
COMPILER_RT_BUILD_* is on (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D32489?vs=96564&id=96678#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32489

Files:
  compiler-rt/trunk/test/CMakeLists.txt


Index: compiler-rt/trunk/test/CMakeLists.txt
===
--- compiler-rt/trunk/test/CMakeLists.txt
+++ compiler-rt/trunk/test/CMakeLists.txt
@@ -41,47 +41,49 @@
   if(COMPILER_RT_BUILD_BUILTINS)
 add_subdirectory(builtins)
   endif()
-  if(COMPILER_RT_HAS_ASAN)
-add_subdirectory(asan)
-  endif()
-  if(COMPILER_RT_HAS_DFSAN)
-add_subdirectory(dfsan)
-  endif()
-  if (COMPILER_RT_HAS_INTERCEPTION)
-add_subdirectory(interception)
-  endif()
-  if(COMPILER_RT_HAS_LSAN)
-add_subdirectory(lsan)
-  endif()
-  if(COMPILER_RT_HAS_MSAN)
-add_subdirectory(msan)
-  endif()
-  if(COMPILER_RT_HAS_PROFILE)
-add_subdirectory(profile)
-  endif()
-  if(COMPILER_RT_HAS_SANITIZER_COMMON)
-add_subdirectory(sanitizer_common)
-  endif()
-  if(COMPILER_RT_HAS_TSAN)
-add_subdirectory(tsan)
-  endif()
-  if(COMPILER_RT_HAS_UBSAN)
-add_subdirectory(ubsan)
-  endif()
-  # CFI tests require diagnostic mode, which is implemented in UBSan.
-  if(COMPILER_RT_HAS_UBSAN)
-add_subdirectory(cfi)
-  endif()
-  if(COMPILER_RT_HAS_SAFESTACK)
-add_subdirectory(safestack)
-  endif()
-  if(COMPILER_RT_HAS_ESAN)
-add_subdirectory(esan)
-  endif()
-  if(COMPILER_RT_HAS_SCUDO)
-add_subdirectory(scudo)
+  if(COMPILER_RT_BUILD_SANITIZERS)
+if(COMPILER_RT_HAS_ASAN)
+  add_subdirectory(asan)
+endif()
+if(COMPILER_RT_HAS_DFSAN)
+  add_subdirectory(dfsan)
+endif()
+if (COMPILER_RT_HAS_INTERCEPTION)
+  add_subdirectory(interception)
+endif()
+if(COMPILER_RT_HAS_LSAN)
+  add_subdirectory(lsan)
+endif()
+if(COMPILER_RT_HAS_MSAN)
+  add_subdirectory(msan)
+endif()
+if(COMPILER_RT_HAS_PROFILE)
+  add_subdirectory(profile)
+endif()
+if(COMPILER_RT_HAS_SANITIZER_COMMON)
+  add_subdirectory(sanitizer_common)
+endif()
+if(COMPILER_RT_HAS_TSAN)
+  add_subdirectory(tsan)
+endif()
+if(COMPILER_RT_HAS_UBSAN)
+  add_subdirectory(ubsan)
+endif()
+# CFI tests require diagnostic mode, which is implemented in UBSan.
+if(COMPILER_RT_HAS_UBSAN)
+  add_subdirectory(cfi)
+endif()
+if(COMPILER_RT_HAS_SAFESTACK)
+  add_subdirectory(safestack)
+endif()
+if(COMPILER_RT_HAS_ESAN)
+  add_subdirectory(esan)
+endif()
+if(COMPILER_RT_HAS_SCUDO)
+  add_subdirectory(scudo)
+endif()
   endif()
-  if(COMPILER_RT_HAS_XRAY)
+  if(COMPILER_RT_BUILD_XRAY AND COMPILER_RT_HAS_XRAY)
 add_subdirectory(xray)
   endif()
 endif()


Index: compiler-rt/trunk/test/CMakeLists.txt
===
--- compiler-rt/trunk/test/CMakeLists.txt
+++ compiler-rt/trunk/test/CMakeLists.txt
@@ -41,47 +41,49 @@
   if(COMPILER_RT_BUILD_BUILTINS)
 add_subdirectory(builtins)
   endif()
-  if(COMPILER_RT_HAS_ASAN)
-add_subdirectory(asan)
-  endif()
-  if(COMPILER_RT_HAS_DFSAN)
-add_subdirectory(dfsan)
-  endif()
-  if (COMPILER_RT_HAS_INTERCEPTION)
-add_subdirectory(interception)
-  endif()
-  if(COMPILER_RT_HAS_LSAN)
-add_subdirectory(lsan)
-  endif()
-  if(COMPILER_RT_HAS_MSAN)
-add_subdirectory(msan)
-  endif()
-  if(COMPILER_RT_HAS_PROFILE)
-add_subdirectory(profile)
-  endif()
-  if(COMPILER_RT_HAS_SANITIZER_COMMON)
-add_subdirectory(sanitizer_common)
-  endif()
-  if(COMPILER_RT_HAS_TSAN)
-add_subdirectory(tsan)
-  endif()
-  if(COMPILER_RT_HAS_UBSAN)
-add_subdirectory(ubsan)
-  endif()
-  # CFI tests require diagnostic mode, which is implemented in UBSan.
-  if(COMPILER_RT_HAS_UBSAN)
-add_subdirectory(cfi)
-  endif()
-  if(COMPILER_RT_HAS_SAFESTACK)
-add_subdirectory(safestack)
-  endif()
-  if(COMPILER_RT_HAS_ESAN)
-add_subdirectory(esan)
-  endif()
-  if(COMPILER_RT_HAS_SCUDO)
-add_subdirectory(scudo)
+  if(COMPILER_RT_BUILD_SANITIZERS)
+if(COMPILER_RT_HAS_ASAN)
+  add_subdirectory(asan)
+endif()
+if(COMPILER_RT_HAS_DFSAN)
+  add_subdirectory(dfsan)
+endif()
+if (COMPILER_RT_HAS_INTERCEPTION)
+  add_subdirectory(interception)
+endif()
+if(COMPILER_RT_HAS_LSAN)
+  add_subdirectory(lsan)
+endif()
+if(COMPILER_RT_HAS_MSAN)
+  add_subdirectory(msan)
+endif()
+if(COMPILER_RT_HAS_PROFILE)
+  add_subdirectory(profile)
+endif()
+if(COMPILER_RT_HAS_SANITIZER_COMMON)
+  add_subdirectory(sanitizer_common)
+endif()
+if(COMPILER_RT_HAS_TSAN)
+  add_subdirectory(tsan)
+endif()
+if(COMPILER_RT_HAS_UBSAN)
+  add_subdirectory(ubsan)
+endif()
+# CFI tests require diagnosti

[PATCH] D31975: [Analyzer] Iterator Checkers

2017-04-26 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

Thank you for your help.

Actually, I did neither merge the patches nor the checkers. Based on the 
experiences in the prototype I created a totally new checker. Incremental 
development sounds good, but I did a lot of experimenting in this particular 
checker, which means I added things then removed them, I changed things then 
changed them back etc.

I can try to separate that small part (simple_good and simple_bad tests pass), 
but cutting the patch in 12+ parts is overkill. For example, separation of 
insert and emplace is pointless because they affect iterators exactly the same 
way. But I woul also merge them with erase, the patches remain small enough. I 
think 5 parts are more than enough, because review will take weeks, so 
uploading them incrementally one-by-one will take at least half a year.


https://reviews.llvm.org/D31975



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


[PATCH] D32389: [libclang] Expose some target information via the C API.

2017-04-26 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

It looks good, I have a couple of comments:




Comment at: clang/include/clang-c/Index.h:1573
+CINDEX_LINKAGE void
+clang_TargetInfo_dispose(CXTargetInfo info);
+

Please capitalize `Info` here and in the other parameter lists.



Comment at: clang/include/clang-c/Index.h:1584
+/**
+ * \brief Get the pointer width of the target.
+ *

You could mention that the function returns the width in bits.



Comment at: clang/test/Index/target-info.c:4
+// CHECK: PointerWidth: 32
+// RUN: c-index-test -test-print-target-info %s 
--target=x86_64-unknown-linux-gnu | FileCheck --check-prefix=CHECK-1 %s
+// CHECK-1: TargetTriple: x86_64-unknown-linux-gnu

NIT: Please put both RUN lines at the top of the file.



Comment at: clang/tools/libclang/CIndex.cpp:4035
+  CXTranslationUnit CTUnit = TargetInfo->TranslationUnit;
+  assert(!isNotUsableTU(CTUnit));
+

Please add a message to the `assert`  (e.g. `&& "message"`).



Comment at: clang/tools/libclang/CIndex.cpp:4048
+  CXTranslationUnit CTUnit = TargetInfo->TranslationUnit;
+  assert(!isNotUsableTU(CTUnit));
+

Please add an assertion message here as well.


Repository:
  rL LLVM

https://reviews.llvm.org/D32389



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


[PATCH] D32531: clang-format: [JS] prevent wraps before class members.

2017-04-26 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
Herald added a subscriber: klimek.

In JavaScript/TypeScript, class member definitions that use modifiers can be 
subject to Automatic Semicolon Insertion (ASI). For example, "class X { get \n 
foo }" defines a property called "get" and a property called "foo", both with 
no type annotation. This change prevents wrapping after the modifier keywords 
(visibility modifiers, static, get and set) to prevent accidental ASI.


https://reviews.llvm.org/D32531

Files:
  lib/Format/FormatToken.h
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -318,6 +318,25 @@
"};");
 }
 
+TEST_F(FormatTestJS, GettersSettersVisibilityKeywords) {
+  // Don't break after "protected"
+  verifyFormat("class X {\n"
+   "  protected get getter():\n"
+   "  number {\n"
+   "return 1;\n"
+   "  }\n"
+   "}",
+   getGoogleJSStyleWithColumns(12));
+  // Don't break after "get"
+  verifyFormat("class X {\n"
+   "  protected get someReallyLongGetterName():\n"
+   "  number {\n"
+   "return 1;\n"
+   "  }\n"
+   "}",
+   getGoogleJSStyleWithColumns(40));
+}
+
 TEST_F(FormatTestJS, SpacesInContainerLiterals) {
   verifyFormat("var arr = [1, 2, 3];");
   verifyFormat("f({a: 1, b: 2, c: 3});");
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2543,7 +2543,11 @@
 if (NonComment &&
 NonComment->isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
 tok::kw_throw, Keywords.kw_interface,
-Keywords.kw_type))
+Keywords.kw_type, tok::kw_static, tok::kw_public,
+tok::kw_private, tok::kw_protected,
+Keywords.kw_abstract,
+Keywords.kw_get,
+Keywords.kw_set))
   return false; // Otherwise a semicolon is inserted.
 if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace))
   return false;
Index: lib/Format/FormatToken.h
===
--- lib/Format/FormatToken.h
+++ lib/Format/FormatToken.h
@@ -617,10 +617,12 @@
 kw_finally = &IdentTable.get("finally");
 kw_from = &IdentTable.get("from");
 kw_function = &IdentTable.get("function");
+kw_get = &IdentTable.get("get");
 kw_import = &IdentTable.get("import");
 kw_is = &IdentTable.get("is");
 kw_let = &IdentTable.get("let");
 kw_module = &IdentTable.get("module");
+kw_set = &IdentTable.get("set");
 kw_type = &IdentTable.get("type");
 kw_var = &IdentTable.get("var");
 kw_yield = &IdentTable.get("yield");
@@ -675,10 +677,12 @@
   IdentifierInfo *kw_finally;
   IdentifierInfo *kw_from;
   IdentifierInfo *kw_function;
+  IdentifierInfo *kw_get;
   IdentifierInfo *kw_import;
   IdentifierInfo *kw_is;
   IdentifierInfo *kw_let;
   IdentifierInfo *kw_module;
+  IdentifierInfo *kw_set;
   IdentifierInfo *kw_type;
   IdentifierInfo *kw_var;
   IdentifierInfo *kw_yield;


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -318,6 +318,25 @@
"};");
 }
 
+TEST_F(FormatTestJS, GettersSettersVisibilityKeywords) {
+  // Don't break after "protected"
+  verifyFormat("class X {\n"
+   "  protected get getter():\n"
+   "  number {\n"
+   "return 1;\n"
+   "  }\n"
+   "}",
+   getGoogleJSStyleWithColumns(12));
+  // Don't break after "get"
+  verifyFormat("class X {\n"
+   "  protected get someReallyLongGetterName():\n"
+   "  number {\n"
+   "return 1;\n"
+   "  }\n"
+   "}",
+   getGoogleJSStyleWithColumns(40));
+}
+
 TEST_F(FormatTestJS, SpacesInContainerLiterals) {
   verifyFormat("var arr = [1, 2, 3];");
   verifyFormat("f({a: 1, b: 2, c: 3});");
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2543,7 +2543,11 @@
 if (NonComment &&
 NonComment->isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
 tok::kw_throw, Keywords.kw_interface,
-Keywords.kw_type))
+Keywords.kw_type, tok::kw_static, tok::kw_public,
+tok::kw_private, 

[PATCH] D32532: clang-format: [JS/Java] ignore Objective-C constructs in JS & Java.

2017-04-26 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
Herald added a subscriber: klimek.

Java and JavaScript support annotations and decorators, respectively, that use 
a leading "@" token. clang-format currently detects this as an Objective-C 
construct and applies special formatting, for example no whitespace around "=" 
operators. This change disables the distinction for Java and JavaScript, which 
leads to normal formatting of single line annotated and initialized properties.

Before:

  class X {
@foo() bar=false;
  }

After:

  class X {
@foo() bar = false;
  }


https://reviews.llvm.org/D32532

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1220,6 +1220,9 @@
"}");
   verifyFormat("class X {}\n"
"class Y {}");
+  verifyFormat("class X {\n"
+   "  @property() private isReply = false;\n"
+   "}\n");
 }
 
 TEST_F(FormatTestJS, TypeAliases) {
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1120,7 +1120,11 @@
 Current.Type = TT_FunctionAnnotationRParen;
   }
 }
-} else if (Current.is(tok::at) && Current.Next) {
+} else if (Current.is(tok::at) && Current.Next &&
+   Style.Language != FormatStyle::LK_JavaScript &&
+   Style.Language != FormatStyle::LK_Java) {
+  // In Java & JavaScript, "@..." is a decorator or annotation. In ObjC, it
+  // marks declarations and properties that need special formatting.
   switch (Current.Next->Tok.getObjCKeywordID()) {
   case tok::objc_interface:
   case tok::objc_implementation:


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1220,6 +1220,9 @@
"}");
   verifyFormat("class X {}\n"
"class Y {}");
+  verifyFormat("class X {\n"
+   "  @property() private isReply = false;\n"
+   "}\n");
 }
 
 TEST_F(FormatTestJS, TypeAliases) {
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1120,7 +1120,11 @@
 Current.Type = TT_FunctionAnnotationRParen;
   }
 }
-} else if (Current.is(tok::at) && Current.Next) {
+} else if (Current.is(tok::at) && Current.Next &&
+   Style.Language != FormatStyle::LK_JavaScript &&
+   Style.Language != FormatStyle::LK_Java) {
+  // In Java & JavaScript, "@..." is a decorator or annotation. In ObjC, it
+  // marks declarations and properties that need special formatting.
   switch (Current.Next->Tok.getObjCKeywordID()) {
   case tok::objc_interface:
   case tok::objc_implementation:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32531: clang-format: [JS] prevent wraps before class members.

2017-04-26 Thread Martin Probst via Phabricator via cfe-commits
mprobst updated this revision to Diff 96712.
mprobst added a comment.

- formatting


https://reviews.llvm.org/D32531

Files:
  lib/Format/FormatToken.h
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -318,6 +318,25 @@
"};");
 }
 
+TEST_F(FormatTestJS, GettersSettersVisibilityKeywords) {
+  // Don't break after "protected"
+  verifyFormat("class X {\n"
+   "  protected get getter():\n"
+   "  number {\n"
+   "return 1;\n"
+   "  }\n"
+   "}",
+   getGoogleJSStyleWithColumns(12));
+  // Don't break after "get"
+  verifyFormat("class X {\n"
+   "  protected get someReallyLongGetterName():\n"
+   "  number {\n"
+   "return 1;\n"
+   "  }\n"
+   "}",
+   getGoogleJSStyleWithColumns(40));
+}
+
 TEST_F(FormatTestJS, SpacesInContainerLiterals) {
   verifyFormat("var arr = [1, 2, 3];");
   verifyFormat("f({a: 1, b: 2, c: 3});");
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2541,9 +2541,11 @@
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 const FormatToken *NonComment = Right.getPreviousNonComment();
 if (NonComment &&
-NonComment->isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
-tok::kw_throw, Keywords.kw_interface,
-Keywords.kw_type))
+NonComment->isOneOf(
+tok::kw_return, tok::kw_continue, tok::kw_break, tok::kw_throw,
+Keywords.kw_interface, Keywords.kw_type, tok::kw_static,
+tok::kw_public, tok::kw_private, tok::kw_protected,
+Keywords.kw_abstract, Keywords.kw_get, Keywords.kw_set))
   return false; // Otherwise a semicolon is inserted.
 if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace))
   return false;
Index: lib/Format/FormatToken.h
===
--- lib/Format/FormatToken.h
+++ lib/Format/FormatToken.h
@@ -617,10 +617,12 @@
 kw_finally = &IdentTable.get("finally");
 kw_from = &IdentTable.get("from");
 kw_function = &IdentTable.get("function");
+kw_get = &IdentTable.get("get");
 kw_import = &IdentTable.get("import");
 kw_is = &IdentTable.get("is");
 kw_let = &IdentTable.get("let");
 kw_module = &IdentTable.get("module");
+kw_set = &IdentTable.get("set");
 kw_type = &IdentTable.get("type");
 kw_var = &IdentTable.get("var");
 kw_yield = &IdentTable.get("yield");
@@ -675,10 +677,12 @@
   IdentifierInfo *kw_finally;
   IdentifierInfo *kw_from;
   IdentifierInfo *kw_function;
+  IdentifierInfo *kw_get;
   IdentifierInfo *kw_import;
   IdentifierInfo *kw_is;
   IdentifierInfo *kw_let;
   IdentifierInfo *kw_module;
+  IdentifierInfo *kw_set;
   IdentifierInfo *kw_type;
   IdentifierInfo *kw_var;
   IdentifierInfo *kw_yield;


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -318,6 +318,25 @@
"};");
 }
 
+TEST_F(FormatTestJS, GettersSettersVisibilityKeywords) {
+  // Don't break after "protected"
+  verifyFormat("class X {\n"
+   "  protected get getter():\n"
+   "  number {\n"
+   "return 1;\n"
+   "  }\n"
+   "}",
+   getGoogleJSStyleWithColumns(12));
+  // Don't break after "get"
+  verifyFormat("class X {\n"
+   "  protected get someReallyLongGetterName():\n"
+   "  number {\n"
+   "return 1;\n"
+   "  }\n"
+   "}",
+   getGoogleJSStyleWithColumns(40));
+}
+
 TEST_F(FormatTestJS, SpacesInContainerLiterals) {
   verifyFormat("var arr = [1, 2, 3];");
   verifyFormat("f({a: 1, b: 2, c: 3});");
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2541,9 +2541,11 @@
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 const FormatToken *NonComment = Right.getPreviousNonComment();
 if (NonComment &&
-NonComment->isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
-tok::kw_throw, Keywords.kw_interface,
-Keywords.kw_type))
+NonComment->isOneOf(
+tok::kw_return, tok::kw_continue, tok::kw_break, tok::kw_throw,
+Keywords.kw_interface, Keywords.kw_type, tok::kw_static,
+tok::kw_public, tok::

[PATCH] D32532: clang-format: [JS/Java] ignore Objective-C constructs in JS & Java.

2017-04-26 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good.


https://reviews.llvm.org/D32532



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


[PATCH] D32531: clang-format: [JS] prevent wraps before class members.

2017-04-26 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good.


https://reviews.llvm.org/D32531



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


r301397 - clang-format: [JS] prevent wraps before class members.

2017-04-26 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Wed Apr 26 07:34:15 2017
New Revision: 301397

URL: http://llvm.org/viewvc/llvm-project?rev=301397&view=rev
Log:
clang-format: [JS] prevent wraps before class members.

Summary: In JavaScript/TypeScript, class member definitions that use modifiers 
can be subject to Automatic Semicolon Insertion (ASI). For example, "class X { 
get \n foo }" defines a property called "get" and a property called "foo", both 
with no type annotation. This change prevents wrapping after the modifier 
keywords (visibility modifiers, static, get and set) to prevent accidental ASI.

Reviewers: djasper, bkramer

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/FormatToken.h
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/FormatToken.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=301397&r1=301396&r2=301397&view=diff
==
--- cfe/trunk/lib/Format/FormatToken.h (original)
+++ cfe/trunk/lib/Format/FormatToken.h Wed Apr 26 07:34:15 2017
@@ -617,10 +617,12 @@ struct AdditionalKeywords {
 kw_finally = &IdentTable.get("finally");
 kw_from = &IdentTable.get("from");
 kw_function = &IdentTable.get("function");
+kw_get = &IdentTable.get("get");
 kw_import = &IdentTable.get("import");
 kw_is = &IdentTable.get("is");
 kw_let = &IdentTable.get("let");
 kw_module = &IdentTable.get("module");
+kw_set = &IdentTable.get("set");
 kw_type = &IdentTable.get("type");
 kw_var = &IdentTable.get("var");
 kw_yield = &IdentTable.get("yield");
@@ -675,10 +677,12 @@ struct AdditionalKeywords {
   IdentifierInfo *kw_finally;
   IdentifierInfo *kw_from;
   IdentifierInfo *kw_function;
+  IdentifierInfo *kw_get;
   IdentifierInfo *kw_import;
   IdentifierInfo *kw_is;
   IdentifierInfo *kw_let;
   IdentifierInfo *kw_module;
+  IdentifierInfo *kw_set;
   IdentifierInfo *kw_type;
   IdentifierInfo *kw_var;
   IdentifierInfo *kw_yield;

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=301397&r1=301396&r2=301397&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Apr 26 07:34:15 2017
@@ -2543,7 +2543,11 @@ bool TokenAnnotator::canBreakBefore(cons
 if (NonComment &&
 NonComment->isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
 tok::kw_throw, Keywords.kw_interface,
-Keywords.kw_type))
+Keywords.kw_type, tok::kw_static, tok::kw_public,
+tok::kw_private, tok::kw_protected,
+Keywords.kw_abstract,
+Keywords.kw_get,
+Keywords.kw_set))
   return false; // Otherwise a semicolon is inserted.
 if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace))
   return false;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=301397&r1=301396&r2=301397&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Wed Apr 26 07:34:15 2017
@@ -318,6 +318,25 @@ TEST_F(FormatTestJS, MethodsInObjectLite
"};");
 }
 
+TEST_F(FormatTestJS, GettersSettersVisibilityKeywords) {
+  // Don't break after "protected"
+  verifyFormat("class X {\n"
+   "  protected get getter():\n"
+   "  number {\n"
+   "return 1;\n"
+   "  }\n"
+   "}",
+   getGoogleJSStyleWithColumns(12));
+  // Don't break after "get"
+  verifyFormat("class X {\n"
+   "  protected get someReallyLongGetterName():\n"
+   "  number {\n"
+   "return 1;\n"
+   "  }\n"
+   "}",
+   getGoogleJSStyleWithColumns(40));
+}
+
 TEST_F(FormatTestJS, SpacesInContainerLiterals) {
   verifyFormat("var arr = [1, 2, 3];");
   verifyFormat("f({a: 1, b: 2, c: 3});");


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


r301398 - formatting

2017-04-26 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Wed Apr 26 07:34:18 2017
New Revision: 301398

URL: http://llvm.org/viewvc/llvm-project?rev=301398&view=rev
Log:
formatting

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=301398&r1=301397&r2=301398&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Apr 26 07:34:18 2017
@@ -2541,13 +2541,11 @@ bool TokenAnnotator::canBreakBefore(cons
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 const FormatToken *NonComment = Right.getPreviousNonComment();
 if (NonComment &&
-NonComment->isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
-tok::kw_throw, Keywords.kw_interface,
-Keywords.kw_type, tok::kw_static, tok::kw_public,
-tok::kw_private, tok::kw_protected,
-Keywords.kw_abstract,
-Keywords.kw_get,
-Keywords.kw_set))
+NonComment->isOneOf(
+tok::kw_return, tok::kw_continue, tok::kw_break, tok::kw_throw,
+Keywords.kw_interface, Keywords.kw_type, tok::kw_static,
+tok::kw_public, tok::kw_private, tok::kw_protected,
+Keywords.kw_abstract, Keywords.kw_get, Keywords.kw_set))
   return false; // Otherwise a semicolon is inserted.
 if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace))
   return false;


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


[PATCH] D32531: clang-format: [JS] prevent wraps before class members.

2017-04-26 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL301397: clang-format: [JS] prevent wraps before class 
members. (authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D32531?vs=96712&id=96719#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32531

Files:
  cfe/trunk/lib/Format/FormatToken.h
  cfe/trunk/lib/Format/TokenAnnotator.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -2543,7 +2543,11 @@
 if (NonComment &&
 NonComment->isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
 tok::kw_throw, Keywords.kw_interface,
-Keywords.kw_type))
+Keywords.kw_type, tok::kw_static, tok::kw_public,
+tok::kw_private, tok::kw_protected,
+Keywords.kw_abstract,
+Keywords.kw_get,
+Keywords.kw_set))
   return false; // Otherwise a semicolon is inserted.
 if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace))
   return false;
Index: cfe/trunk/lib/Format/FormatToken.h
===
--- cfe/trunk/lib/Format/FormatToken.h
+++ cfe/trunk/lib/Format/FormatToken.h
@@ -617,10 +617,12 @@
 kw_finally = &IdentTable.get("finally");
 kw_from = &IdentTable.get("from");
 kw_function = &IdentTable.get("function");
+kw_get = &IdentTable.get("get");
 kw_import = &IdentTable.get("import");
 kw_is = &IdentTable.get("is");
 kw_let = &IdentTable.get("let");
 kw_module = &IdentTable.get("module");
+kw_set = &IdentTable.get("set");
 kw_type = &IdentTable.get("type");
 kw_var = &IdentTable.get("var");
 kw_yield = &IdentTable.get("yield");
@@ -675,10 +677,12 @@
   IdentifierInfo *kw_finally;
   IdentifierInfo *kw_from;
   IdentifierInfo *kw_function;
+  IdentifierInfo *kw_get;
   IdentifierInfo *kw_import;
   IdentifierInfo *kw_is;
   IdentifierInfo *kw_let;
   IdentifierInfo *kw_module;
+  IdentifierInfo *kw_set;
   IdentifierInfo *kw_type;
   IdentifierInfo *kw_var;
   IdentifierInfo *kw_yield;
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -318,6 +318,25 @@
"};");
 }
 
+TEST_F(FormatTestJS, GettersSettersVisibilityKeywords) {
+  // Don't break after "protected"
+  verifyFormat("class X {\n"
+   "  protected get getter():\n"
+   "  number {\n"
+   "return 1;\n"
+   "  }\n"
+   "}",
+   getGoogleJSStyleWithColumns(12));
+  // Don't break after "get"
+  verifyFormat("class X {\n"
+   "  protected get someReallyLongGetterName():\n"
+   "  number {\n"
+   "return 1;\n"
+   "  }\n"
+   "}",
+   getGoogleJSStyleWithColumns(40));
+}
+
 TEST_F(FormatTestJS, SpacesInContainerLiterals) {
   verifyFormat("var arr = [1, 2, 3];");
   verifyFormat("f({a: 1, b: 2, c: 3});");


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -2543,7 +2543,11 @@
 if (NonComment &&
 NonComment->isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
 tok::kw_throw, Keywords.kw_interface,
-Keywords.kw_type))
+Keywords.kw_type, tok::kw_static, tok::kw_public,
+tok::kw_private, tok::kw_protected,
+Keywords.kw_abstract,
+Keywords.kw_get,
+Keywords.kw_set))
   return false; // Otherwise a semicolon is inserted.
 if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace))
   return false;
Index: cfe/trunk/lib/Format/FormatToken.h
===
--- cfe/trunk/lib/Format/FormatToken.h
+++ cfe/trunk/lib/Format/FormatToken.h
@@ -617,10 +617,12 @@
 kw_finally = &IdentTable.get("finally");
 kw_from = &IdentTable.get("from");
 kw_function = &IdentTable.get("function");
+kw_get = &IdentTable.get("get");
 kw_import = &IdentTable.get("import");
 kw_is = &IdentTable.get("is");
 kw_let = &IdentTable.get("let");
 kw_module = &IdentTable.get("module");
+kw_set = &IdentTable.get("set");
 kw_type = &IdentTable.get("type");
 kw_var = &IdentTable.get("var");
 kw_yield = &IdentTable.get("yield");
@@ -675,10 +

r301399 - clang-format: [JS/Java] ignore Objective-C constructs in JS & Java.

2017-04-26 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Wed Apr 26 07:36:49 2017
New Revision: 301399

URL: http://llvm.org/viewvc/llvm-project?rev=301399&view=rev
Log:
clang-format: [JS/Java] ignore Objective-C constructs in JS & Java.

Summary:
Java and JavaScript support annotations and decorators, respectively, that use 
a leading "@" token. clang-format currently detects this as an Objective-C 
construct and applies special formatting, for example no whitespace around "=" 
operators. This change disables the distinction for Java and JavaScript, which 
leads to normal formatting of single line annotated and initialized properties.

Before:
class X {
  @foo() bar=false;
}

After:
class X {
  @foo() bar = false;
}

Reviewers: djasper, bkramer

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=301399&r1=301398&r2=301399&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Apr 26 07:36:49 2017
@@ -1120,7 +1120,11 @@ private:
 Current.Type = TT_FunctionAnnotationRParen;
   }
 }
-} else if (Current.is(tok::at) && Current.Next) {
+} else if (Current.is(tok::at) && Current.Next &&
+   Style.Language != FormatStyle::LK_JavaScript &&
+   Style.Language != FormatStyle::LK_Java) {
+  // In Java & JavaScript, "@..." is a decorator or annotation. In ObjC, it
+  // marks declarations and properties that need special formatting.
   switch (Current.Next->Tok.getObjCKeywordID()) {
   case tok::objc_interface:
   case tok::objc_implementation:

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=301399&r1=301398&r2=301399&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Wed Apr 26 07:36:49 2017
@@ -1239,6 +1239,9 @@ TEST_F(FormatTestJS, MetadataAnnotations
"}");
   verifyFormat("class X {}\n"
"class Y {}");
+  verifyFormat("class X {\n"
+   "  @property() private isReply = false;\n"
+   "}\n");
 }
 
 TEST_F(FormatTestJS, TypeAliases) {


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


[PATCH] D32532: clang-format: [JS/Java] ignore Objective-C constructs in JS & Java.

2017-04-26 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL301399: clang-format: [JS/Java] ignore Objective-C 
constructs in JS & Java. (authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D32532?vs=96710&id=96720#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32532

Files:
  cfe/trunk/lib/Format/TokenAnnotator.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -1120,7 +1120,11 @@
 Current.Type = TT_FunctionAnnotationRParen;
   }
 }
-} else if (Current.is(tok::at) && Current.Next) {
+} else if (Current.is(tok::at) && Current.Next &&
+   Style.Language != FormatStyle::LK_JavaScript &&
+   Style.Language != FormatStyle::LK_Java) {
+  // In Java & JavaScript, "@..." is a decorator or annotation. In ObjC, it
+  // marks declarations and properties that need special formatting.
   switch (Current.Next->Tok.getObjCKeywordID()) {
   case tok::objc_interface:
   case tok::objc_implementation:
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1239,6 +1239,9 @@
"}");
   verifyFormat("class X {}\n"
"class Y {}");
+  verifyFormat("class X {\n"
+   "  @property() private isReply = false;\n"
+   "}\n");
 }
 
 TEST_F(FormatTestJS, TypeAliases) {


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -1120,7 +1120,11 @@
 Current.Type = TT_FunctionAnnotationRParen;
   }
 }
-} else if (Current.is(tok::at) && Current.Next) {
+} else if (Current.is(tok::at) && Current.Next &&
+   Style.Language != FormatStyle::LK_JavaScript &&
+   Style.Language != FormatStyle::LK_Java) {
+  // In Java & JavaScript, "@..." is a decorator or annotation. In ObjC, it
+  // marks declarations and properties that need special formatting.
   switch (Current.Next->Tok.getObjCKeywordID()) {
   case tok::objc_interface:
   case tok::objc_implementation:
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1239,6 +1239,9 @@
"}");
   verifyFormat("class X {}\n"
"class Y {}");
+  verifyFormat("class X {\n"
+   "  @property() private isReply = false;\n"
+   "}\n");
 }
 
 TEST_F(FormatTestJS, TypeAliases) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r301400 - [AST] Look through attribute type locs when searching for function type

2017-04-26 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Apr 26 07:46:27 2017
New Revision: 301400

URL: http://llvm.org/viewvc/llvm-project?rev=301400&view=rev
Log:
[AST] Look through attribute type locs when searching for function type
loc

Prior to this commit -Wdocumentation crashed when checking the @returns command
for declarations whose function/block pointer type included an attribute like
_Nullable.

rdar://31818195

Modified:
cfe/trunk/lib/AST/Comment.cpp
cfe/trunk/test/Sema/warn-documentation.m

Modified: cfe/trunk/lib/AST/Comment.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Comment.cpp?rev=301400&r1=301399&r2=301400&view=diff
==
--- cfe/trunk/lib/AST/Comment.cpp (original)
+++ cfe/trunk/lib/AST/Comment.cpp Wed Apr 26 07:46:27 2017
@@ -116,6 +116,9 @@ bool ParagraphComment::isWhitespaceNoCac
 static TypeLoc lookThroughTypedefOrTypeAliasLocs(TypeLoc &SrcTL) {
   TypeLoc TL = SrcTL.IgnoreParens();
 
+  // Look through attribute types.
+  if (AttributedTypeLoc AttributeTL = TL.getAs())
+return AttributeTL.getModifiedLoc();
   // Look through qualified types.
   if (QualifiedTypeLoc QualifiedTL = TL.getAs())
 return QualifiedTL.getUnqualifiedLoc();

Modified: cfe/trunk/test/Sema/warn-documentation.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-documentation.m?rev=301400&r1=301399&r2=301400&view=diff
==
--- cfe/trunk/test/Sema/warn-documentation.m (original)
+++ cfe/trunk/test/Sema/warn-documentation.m Wed Apr 26 07:46:27 2017
@@ -254,7 +254,7 @@ struct HasFields {
  * \param p not here.
  * \returns integer.
  */
-void (^blockPointerVariableThatLeadsNowhere)();
+void (^_Nullable blockPointerVariableThatLeadsNowhere)();
 
 @interface CheckFunctionBlockPointerVars {
   /**


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


r301402 - -Wdocumentation should not check the @returns command for Objective-C

2017-04-26 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Apr 26 08:09:28 2017
New Revision: 301402

URL: http://llvm.org/viewvc/llvm-project?rev=301402&view=rev
Log:
-Wdocumentation should not check the @returns command for Objective-C
function/block pointer properties

The commit r300981 allowed @param/@return commands for function/block
pointer property declarations. This meant that -Wdocumentation started warning
about @return that was used to document properties whose function/block type
returned void. However, prior to that commit, we allowed @return for all
property declarations, because it can be used to document the value that's
returned by the property getter. This commit restores the previous behaviour:
now the @return command can be used to document all properties without warnings.

rdar://24978538

Modified:
cfe/trunk/lib/AST/CommentSema.cpp
cfe/trunk/test/Sema/warn-documentation.m

Modified: cfe/trunk/lib/AST/CommentSema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentSema.cpp?rev=301402&r1=301401&r2=301402&view=diff
==
--- cfe/trunk/lib/AST/CommentSema.cpp (original)
+++ cfe/trunk/lib/AST/CommentSema.cpp Wed Apr 26 08:09:28 2017
@@ -584,6 +584,10 @@ void Sema::checkReturnsCommand(const Blo
 
   assert(ThisDeclInfo && "should not call this check on a bare comment");
 
+  // We allow the return command for all @properties because it can be used
+  // to document the value that the property getter returns.
+  if (isObjCPropertyDecl())
+return;
   if (isFunctionDecl() || isFunctionOrBlockPointerVarLikeDecl()) {
 if (ThisDeclInfo->ReturnType->isVoidType()) {
   unsigned DiagKind;
@@ -610,8 +614,6 @@ void Sema::checkReturnsCommand(const Blo
 }
 return;
   }
-  else if (isObjCPropertyDecl())
-return;
 
   Diag(Command->getLocation(),
diag::warn_doc_returns_not_attached_to_a_function_decl)

Modified: cfe/trunk/test/Sema/warn-documentation.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-documentation.m?rev=301402&r1=301401&r2=301402&view=diff
==
--- cfe/trunk/test/Sema/warn-documentation.m (original)
+++ cfe/trunk/test/Sema/warn-documentation.m Wed Apr 26 08:09:28 2017
@@ -290,4 +290,12 @@ void (^_Nullable blockPointerVariableTha
  */
 @property int (^blockPointerProperty)(int i);
 
+/**
+ * blockReturnsNothing
+ *
+ * \returns Nothing, but can allow this as this pattern is used to document the
+ * value that the property getter returns.
+ */
+@property void (^blockReturnsNothing)();
+
 @end


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


[PATCH] D32333: [clang-tidy] Update IdentifierNamingCheck to remove extra leading/trailing underscores

2017-04-26 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

  LG with a nit.




Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:378
+  StringRef Mid = StringRef(Fixed).trim("_");
+  if (Mid.size() == 0)
+Mid = "_";

Mid.empty()


https://reviews.llvm.org/D32333



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


[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

2017-04-26 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 96727.
xazax.hun marked 5 inline comments as done.
xazax.hun added a comment.

- Updates according to review comments
- Improvements to the python scripts


https://reviews.llvm.org/D30691

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Mangle.h
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/ItaniumMangle.cpp
  lib/Basic/SourceManager.cpp
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/CMakeLists.txt
  lib/StaticAnalyzer/Core/CallEvent.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  test/Analysis/Inputs/ctu-chain.cpp
  test/Analysis/Inputs/ctu-other.cpp
  test/Analysis/Inputs/externalFnMap.txt
  test/Analysis/ctu-main.cpp
  test/Analysis/func-mapping-test.cpp
  test/CMakeLists.txt
  test/lit.cfg
  tools/CMakeLists.txt
  tools/clang-func-mapping/CMakeLists.txt
  tools/clang-func-mapping/ClangFnMapGen.cpp
  tools/ctu-analysis/ctu-analyze.py
  tools/ctu-analysis/ctu-build.py
  tools/scan-build-py/libscanbuild/runner.py

Index: tools/scan-build-py/libscanbuild/runner.py
===
--- tools/scan-build-py/libscanbuild/runner.py
+++ tools/scan-build-py/libscanbuild/runner.py
@@ -162,7 +162,8 @@
 
 def target():
 """ Creates output file name for reports. """
-if opts['output_format'] in {'plist', 'plist-html'}:
+if opts['output_format'] in {'plist', 'plist-html',
+ 'plist-multi-file'}:
 (handle, name) = tempfile.mkstemp(prefix='report-',
   suffix='.plist',
   dir=opts['output_dir'])
Index: tools/ctu-analysis/ctu-build.py
===
--- /dev/null
+++ tools/ctu-analysis/ctu-build.py
@@ -0,0 +1,239 @@
+#!/usr/bin/env python
+
+import argparse
+import json
+import glob
+import logging
+import multiprocessing
+import os
+import re
+import signal
+import subprocess
+import shlex
+import shutil
+import tempfile
+
+SOURCE_PATTERN = re.compile('.*\.(C|c|cc|cpp|cxx|ii|m|mm)$', re.IGNORECASE)
+TIMEOUT = 86400
+EXTERNAL_FUNCTION_MAP_FILENAME = 'externalFnMap.txt'
+TEMP_EXTERNAL_FNMAP_FOLDER = 'tmpExternalFnMaps'
+
+
+def get_args():
+parser = argparse.ArgumentParser(
+description='Executes 1st pass of CTU analysis where we preprocess '
+'all files in the compilation database and generate '
+'AST dumps and other necessary information from those '
+'to be used later by the 2nd pass of '
+'Cross Translation Unit analysis',
+formatter_class=argparse.ArgumentDefaultsHelpFormatter)
+parser.add_argument('-b', required=True, dest='buildlog',
+metavar='build.json',
+help='JSON Compilation Database to be used')
+parser.add_argument('-p', metavar='preanalyze-dir', dest='ctuindir',
+help='Target directory for preanalyzation data',
+default='.ctu')
+parser.add_argument('-j', metavar='threads', dest='threads', type=int,
+help='Number of threads to be used',
+default=int(multiprocessing.cpu_count() * 1.0))
+parser.add_argument('-v', dest='verbose', action='store_true',
+help='Verbose output')
+parser.add_argument('--clang-path', metavar='clang-path',
+dest='clang_path',
+help='Set path to directory of clang binaries used '
+ '(default taken from CLANG_PATH envvar)',
+default=os.environ.get('CLANG_PATH'))
+mainargs = parser.parse_args()
+
+if mainargs.verbose:
+logging.getLogger().setLevel(logging.INFO)
+
+if mainargs.clang_path is None:
+clang_path = ''
+else:
+clang_path = os.path.abspath(mainargs.clang_path)
+logging.info('CTU uses clang dir: ' +
+ (clang_path if clang_path != '' else ''))
+
+return mainargs, clang_path
+
+
+def process_buildlog(buildlog_filename, src_2_dir, src_2_cmd, src_order,
+ cmd_2_src, cmd_order):
+with open(buildlog_filename, 'r') as buildlog_file:
+buildlog = json.load(buildlog_file)
+for step in buildlog:
+if SOURCE_PATTERN.match(step['file']):
+if step['file'] not in src_2_dir:
+src_2_dir[step['file']] = step['directory']
+src_2_cmd[step['file']] = step['command']
+src_order.append(step['file'])
+if step['command'] not in cmd_2_src:
+cmd_2_src[step['

[PATCH] D32436: [clang-tidy] Support detecting for-range loop in inefficient-vector-operation check.

2017-04-26 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Cool! A few nits.




Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:56
+ast_matchers::internal::Matcher supportedContainerTypesMatcher() {
+  const auto types = cxxRecordDecl(hasAnyName(
+  "::std::vector", "::std::set", "::std::unordered_set", "::std::map",

I'd just inline the expression and remove the local variable, since it doesn't 
seem to bring any benefits.



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:103
+  // Matchers for the loop whose body has only 1 push_back calling statement.
+  const auto HasInterestedLoopBody = hasBody(anyOf(
+  compoundStmt(statementCountIs(1), has(PushBackCall)), PushBackCall));

s/Interested/Interesting/



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:129
+  cxxForRangeStmt(
+  hasRangeInit(declRefExpr(supportedContainerTypesMatcher())),
+  HasInterestedLoopBody, InInterestedCompoundStmt)

It might be valuable to support more complex expressions here, though it would 
require more involved fixes, e.g.

  for (const auto& e : *source)
v.push_back(e);

->

  v.reserve(source->size());
  for (const auto& e : *source)
v.push_back(e);

or even like this:

  for (const auto& e : *some(complex)->container().expression())
v.push_back(e);

->

  const auto& source_container = *some(complex)->container().expression();
  v.reserve(source_container.size());
  for (const auto& e : source_container)
v.push_back(e);

Maybe leave a FIXME for this?



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:152
+
+  const Stmt * LoopStmt = nullptr;
+  if (ForLoop)

const Stmt *LoopStmt = ForLoop ? ForLoop : RangeLoop;



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:185
+// `for (range-declarator: range-expression)`.
+llvm::StringRef RangeInitExpName = clang::Lexer::getSourceText(
+CharSourceRange::getTokenRange(

No need to qualify `StringRef` and `Lexer`. Here and a couple of other 
instances in this function.



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:198
+Context->getLangOpts());
+ReserveStmt = (VectorVarName + ".reserve(" + LoopEndSource + ");\n").str();
+  }

Does the check handle destination vector not being empty before the push_back 
loop? We'd need to reserve `destination.size() + source.size()` items in this 
case.

If this is not handled yet, please add a FIXME.


https://reviews.llvm.org/D32436



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


[PATCH] D30295: [analyzer] clarify undef shift result when shift count is negative or exceeds the bit width

2017-04-26 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

I only found two nits otherwise looks good to me.




Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h:46
 
+bool exprComparesTo(SVal LHSVal, BinaryOperatorKind ComparisonOp, SVal RHSVal,
+ProgramStateRef State);

Right now the name of this function is exprComparesTo, but none of its 
arguments are expressions. You should either rename it to svalComparesTo, or 
use expr as its arguments. 



Comment at: lib/StaticAnalyzer/Core/CheckerHelpers.cpp:116
+return false;
+  ConstraintManager &CM = State->getConstraintManager();
+  ProgramStateRef StTrue, StFalse;

Any reason why do you get the constraint manager and not using 
ProgramState::assume?


Repository:
  rL LLVM

https://reviews.llvm.org/D30295



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


[PATCH] D32436: [clang-tidy] Support detecting for-range loop in inefficient-vector-operation check.

2017-04-26 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 96738.
hokein marked 6 inline comments as done.
hokein added a comment.

Address review comments.


https://reviews.llvm.org/D32436

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

Index: test/clang-tidy/performance-inefficient-vector-operation.cpp
===
--- test/clang-tidy/performance-inefficient-vector-operation.cpp
+++ test/clang-tidy/performance-inefficient-vector-operation.cpp
@@ -1,9 +1,27 @@
-// RUN: %check_clang_tidy %s performance-inefficient-vector-operation %t -- -format-style=llvm --
+// RUN: %check_clang_tidy %s performance-inefficient-vector-operation %t -- -format-style=llvm -- --std=c++11
 
 namespace std {
 
 typedef int size_t;
 
+template class initializer_list {
+public:
+  using value_type = E;
+  using reference = E&;
+  using const_reference = const E&;
+  using size_type = size_t;
+  using iterator = const E*;
+  using const_iterator = const E*;
+  initializer_list();
+  size_t size() const; // number of elements
+  const E* begin() const; // first element
+  const E* end() const; // one past the last element
+};
+
+// initializer list range access
+template const E* begin(initializer_list il);
+template const E* end(initializer_list il);
+
 template 
 class vector {
  public:
@@ -23,9 +41,24 @@
   size_t size();
   const_reference operator[] (size_type) const;
   reference operator[] (size_type);
+
+  const_iterator begin() const;
+  const_iterator end() const;
 };
 } // namespace std
 
+class Foo {
+ public:
+  explicit Foo(int);
+};
+
+class Bar {
+ public:
+  Bar(int);
+};
+
+int Op(int);
+
 void f(std::vector& t) {
   {
 std::vector v;
@@ -85,7 +118,38 @@
   v.push_back(t[i]);
 } // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
   }
-
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(t.size());
+for (const auto &e : t) {
+  v.push_back(e);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
+}
+  }
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(t.size());
+for (const auto &e : t) {
+  v.push_back(Op(e));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
+}
+  }
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(t.size());
+for (const auto &e : t) {
+  v.push_back(Foo(e));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
+}
+  }
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(t.size());
+for (const auto &e : t) {
+  v.push_back(e);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
+}
+  }
   //  Non-fixed Cases 
   {
 std::vector v;
@@ -181,4 +245,21 @@
   v.push_back(t[i]);
 }
   }
+  {
+std::vector v;
+// initializer_list should not trigger the check.
+for (int e : {1, 2, 3, 4, 5}) {
+  v.push_back(e);
+}
+  }
+  {
+std::vector v;
+std::vector* v2 = &t;
+// We only support detecting the range init expression which references
+// container directly.
+// Complex range init expressions like `*v2` is not supported.
+for (const auto &e : *v2) {
+  v.push_back(e);
+}
+  }
 }
Index: docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
===
--- docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
+++ docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
@@ -3,11 +3,13 @@
 performance-inefficient-vector-operation
 
 
-Finds possible inefficient `std::vector` operations (e.g. `push_back`) that may
-cause unnecessary memory reallocations.
+Finds possible inefficient ``std::vector`` operations (e.g. ``push_back``) that
+may cause unnecessary memory reallocations.
 
-Currently, the check only detects a typical counter-based for loop with a single
-statement in it, see below:
+Currently, the check only detects following kinds of loops with a single
+statement body:
+
+* Counter-based for loops start with 0:
 
 .. code-block:: c++
 
@@ -18,3 +20,30 @@
 // memory reallocations in v. This can be avoid by inserting a 'reserve(n)'
 // statment before the for statment.
   }
+
+
+* For-range loops like ``for (range-declaration : range_expression)``, the type
+  of ``range_expression`` can be ``std::vector``, ``std::array``,
+  ``std::dequeue``, ``std::set``, ``std::unordered_set``, ``std::map``,
+  ``std::unordered_set``:
+
+.. code-block:: c++
+
+  std::vector data;
+  std::vector v;
+
+  for (auto element : data) {
+v.push_back(element);
+// This will trigger the warning since the 'push_back' may cause multiple
+// memory reallocations in v. This can be avoid by 

[PATCH] D32436: [clang-tidy] Support detecting for-range loop in inefficient-vector-operation check.

2017-04-26 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Thanks for the comments!




Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:129
+  cxxForRangeStmt(
+  hasRangeInit(declRefExpr(supportedContainerTypesMatcher())),
+  HasInterestedLoopBody, InInterestedCompoundStmt)

alexfh wrote:
> It might be valuable to support more complex expressions here, though it 
> would require more involved fixes, e.g.
> 
>   for (const auto& e : *source)
> v.push_back(e);
> 
> ->
> 
>   v.reserve(source->size());
>   for (const auto& e : *source)
> v.push_back(e);
> 
> or even like this:
> 
>   for (const auto& e : *some(complex)->container().expression())
> v.push_back(e);
> 
> ->
> 
>   const auto& source_container = *some(complex)->container().expression();
>   v.reserve(source_container.size());
>   for (const auto& e : source_container)
> v.push_back(e);
> 
> Maybe leave a FIXME for this?
Nice brainstorm, added a FIXME.



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:152
+
+  const Stmt * LoopStmt = nullptr;
+  if (ForLoop)

alexfh wrote:
> const Stmt *LoopStmt = ForLoop ? ForLoop : RangeLoop;
We can't do it because `ForLoop` and `RangeLoop` are different types.



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:198
+Context->getLangOpts());
+ReserveStmt = (VectorVarName + ".reserve(" + LoopEndSource + ");\n").str();
+  }

alexfh wrote:
> Does the check handle destination vector not being empty before the push_back 
> loop? We'd need to reserve `destination.size() + source.size()` items in this 
> case.
> 
> If this is not handled yet, please add a FIXME.
This case should not happen, because we only find the push_back loop before 
which there are no usages (defined as DeclRefExpr that refers to vector`v`) of 
the vector `v`.


https://reviews.llvm.org/D32436



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


r301409 - -Wunguarded-availability should support if (@available) checks in top-level

2017-04-26 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Apr 26 09:20:02 2017
New Revision: 301409

URL: http://llvm.org/viewvc/llvm-project?rev=301409&view=rev
Log:
-Wunguarded-availability should support if (@available) checks in top-level
blocks and lambdas

Prior to this commit Clang emitted the old "partial availability" warning for
expressions that referred to declarations that were not yet introduced in
blocks and lambdas that were not in a function/method. This commit ensures that
top-level blocks and lambdas use the new unguarded availability checks.

rdar://31835952

Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaObjC/unguarded-availability.m

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=301409&r1=301408&r2=301409&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Apr 26 09:20:02 2017
@@ -7220,6 +7220,8 @@ void Sema::DiagnoseUnguardedAvailability
 Body = FD->getBody();
   } else if (auto *MD = dyn_cast(D))
 Body = MD->getBody();
+  else if (auto *BD = dyn_cast(D))
+Body = BD->getBody();
 
   assert(Body && "Need a body here!");
 

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=301409&r1=301408&r2=301409&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Apr 26 09:20:02 2017
@@ -171,9 +171,14 @@ DiagnoseAvailabilityOfDecl(Sema &S, Name
   if (AvailabilityResult Result =
   S.ShouldDiagnoseAvailabilityOfDecl(D, &Message)) {
 
-if (Result == AR_NotYetIntroduced && S.getCurFunctionOrMethodDecl()) {
-  S.getEnclosingFunction()->HasPotentialAvailabilityViolations = true;
-  return;
+if (Result == AR_NotYetIntroduced) {
+  if (S.getCurFunctionOrMethodDecl()) {
+S.getEnclosingFunction()->HasPotentialAvailabilityViolations = true;
+return;
+  } else if (S.getCurBlock() || S.getCurLambda()) {
+S.getCurFunction()->HasPotentialAvailabilityViolations = true;
+return;
+  }
 }
 
 const ObjCPropertyDecl *ObjCPDecl = nullptr;
@@ -12498,6 +12503,9 @@ ExprResult Sema::ActOnBlockStmtExpr(Sour
 
   BSI->TheDecl->setBody(cast(Body));
 
+  if (Body && getCurFunction()->HasPotentialAvailabilityViolations)
+DiagnoseUnguardedAvailabilityViolations(BSI->TheDecl);
+
   // Try to apply the named return value optimization. We have to check again
   // if we can do this, though, because blocks keep return statements around
   // to deduce an implicit return type.

Modified: cfe/trunk/test/SemaObjC/unguarded-availability.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/unguarded-availability.m?rev=301409&r1=301408&r2=301409&view=diff
==
--- cfe/trunk/test/SemaObjC/unguarded-availability.m (original)
+++ cfe/trunk/test/SemaObjC/unguarded-availability.m Wed Apr 26 09:20:02 2017
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-apple-macosx-10.9 -Wunguarded-availability 
-fblocks -fsyntax-only -verify %s
-// RUN: %clang_cc1 -xobjective-c++ -DOBJCPP -triple x86_64-apple-macosx-10.9 
-Wunguarded-availability -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -xobjective-c++ -std=c++11 -DOBJCPP -triple 
x86_64-apple-macosx-10.9 -Wunguarded-availability -fblocks -fsyntax-only 
-verify %s
 
 #define AVAILABLE_10_0  __attribute__((availability(macos, introduced = 10.0)))
 #define AVAILABLE_10_11 __attribute__((availability(macos, introduced = 
10.11)))
@@ -8,9 +8,9 @@
 int func_10_11() AVAILABLE_10_11; // expected-note 4 {{'func_10_11' has been 
explicitly marked partial here}}
 
 #ifdef OBJCPP
-// expected-note@+2 {{marked partial here}}
+// expected-note@+2 2 {{marked partial here}}
 #endif
-int func_10_12() AVAILABLE_10_12; // expected-note 5 {{'func_10_12' has been 
explicitly marked partial here}}
+int func_10_12() AVAILABLE_10_12; // expected-note 6 {{'func_10_12' has been 
explicitly marked partial here}}
 
 int func_10_0() AVAILABLE_10_0;
 
@@ -129,6 +129,12 @@ void test_params(int_10_12 x); // expect
 
 void test_params2(int_10_12 x) AVAILABLE_10_12; // no warn
 
+void (^topLevelBlockDecl)() = ^ {
+  func_10_12(); // expected-warning{{'func_10_12' is only available on macOS 
10.12 or newer}} expected-note{{@available}}
+  if (@available(macos 10.12, *))
+func_10_12();
+};
+
 #ifdef OBJCPP
 
 int f(char) AVAILABLE_10_12;
@@ -176,4 +182,10 @@ int instantiate_availability() {
 with_availability_attr(); // 
expected-warning{{'with_availability_attr' is only available on macOS 
10.11 or newer}} expected-warning{{'int_10_12' is only available on macOS 10.12 
or newer}} expected-note 2 {{enclose}}
 }
 

Re: r289018 - [Headers] Enable #include_next on Darwin

2017-04-26 Thread Aaron Ballman via cfe-commits
On Tue, Apr 25, 2017 at 5:46 PM, Bruno Cardoso Lopes
 wrote:
> On Tue, Apr 25, 2017 at 2:34 PM, Aaron Ballman  wrote:
>> On Tue, Apr 25, 2017 at 5:33 PM, Bruno Cardoso Lopes
>>  wrote:
>>> On Tue, Apr 25, 2017 at 6:29 AM, Aaron Ballman  
>>> wrote:
 On Wed, Dec 7, 2016 at 9:13 PM, Bruno Cardoso Lopes via cfe-commits
  wrote:
> Author: bruno
> Date: Wed Dec  7 20:13:56 2016
> New Revision: 289018
>
> URL: http://llvm.org/viewvc/llvm-project?rev=289018&view=rev
> Log:
> [Headers] Enable #include_next on Darwin
>
> Allows darwin targets to provide additional definitions and
> implementation specifc values for float.h
>
> rdar://problem/21961491
>
> Added:
> cfe/trunk/test/Headers/Inputs/usr/
> cfe/trunk/test/Headers/Inputs/usr/include/
> cfe/trunk/test/Headers/Inputs/usr/include/float.h
> cfe/trunk/test/Headers/float-darwin.c
> Modified:
> cfe/trunk/lib/Headers/float.h

 This commit appears to have caused a regression:
 https://bugs.llvm.org//show_bug.cgi?id=31504

 I am running into this on a Snow Leopard system as well, where the
 Integration tests are now failing because float.h cannot be found by
 the system #include_next.
>>>
>>> What's actually happening here is that Snow Leopard (or any < 10.7)
>>> used to ship a /usr/include/float.h, which has by itself another
>>> include_next (which is the one failing), see:
>>>
>>> --
>>> /* This file exists soley to keep Metrowerks' compilers happy.  The version
>>>used by GCC can be found in /usr/lib/gcc, although it's
>>>not very informative.  */
>>>
>>> #ifndef _FLOAT_H_
>>>
>>> #if defined(__GNUC__)
>>> #include_next 
>>> --
>>>
>>> We don't have any reliable way to check for the SDK version at this
>>> level, the current macros we have tell a history about deployment
>>> target, but that won't always solve the issue here. Can you try this
>>> workaround below and let me know if works?
>>>
>>> --
>>> #if (defined(__APPLE__) || (defined(__MINGW32__) || defined(_MSC_VER))) && \
>>>__STDC_HOSTED__ && __has_include_next()
>>>
>>> #ifdef __APPLE__
>>> #define _FLOAT_H_ // Avoid #include_next'ing float.h content on MacOSX < 
>>> 10.7
>>> #endif
>>>
>>> #  include_next 
>>> --
>>>
 I was thinking of modifying lib/Headers/float.h to use the SDK version as 
 mentioned in the bug report, but I share the reporter's question: why was 
 this change needed in the first place? I couldn't find a review for the 
 commit, and don't have access to the rdar link.
>>>
>>> We need it to have flexibility to implement additional stuff for
>>> float.h on future SDKs. There was no good reason for not upstreaming
>>> it. I never got to the point of dealing with this specific issue
>>> though, thanks for pinging.
>>
>> What good timing. I was about to post this as a possible fix:
>>
>> Index: lib/Headers/float.h
>> ===
>> --- lib/Headers/float.h (revision 135915)
>> +++ lib/Headers/float.h (working copy)
>> @@ -31 +31 @@
>> - * Also fall back on Darwin to allow additional definitions and
>> + * Also fall back on Darwin 10.7 or later to allow additional definitions 
>> and
>> @@ -34 +34,4 @@
>> -#if (defined(__APPLE__) || (defined(__MINGW32__) || defined(_MSC_VER))) && \
>> +#if ((defined(__APPLE__) &&
>>  \
>> +  defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) &&
>>  \
>> +  __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1070) ||
>>  \
>> + (defined(__MINGW32__) || defined(_MSC_VER))) &&
>>  \
>>
>> Would this be an improvement over your suggestion?
>
> This would be fine for most cases I believe, but if you're trying to
> deploy to a target >= 1070 while using Snow Leopard you would still
> get the error.

Okay, that makes sense to me. Thank you! I've tested your patch and it
does work for us on both 10.6 and 10.12.

~Aaron

>
>> ~Aaron
>>
>>>
>>> --
>>> Bruno Cardoso Lopes
>>> http://www.brunocardoso.cc
>
>
>
> --
> Bruno Cardoso Lopes
> http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r301410 - [OPENMP] Move handling of threadprivate vars from the stack, NFC.

2017-04-26 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Apr 26 09:24:21 2017
New Revision: 301410

URL: http://llvm.org/viewvc/llvm-project?rev=301410&view=rev
Log:
[OPENMP] Move handling of threadprivate vars from the stack, NFC.

Threadprivate variables do no need to be handled in the Stack of all
directives, moving it out for better performance and memory.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=301410&r1=301409&r2=301410&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Apr 26 09:24:21 2017
@@ -118,6 +118,7 @@ private:
   typedef SmallVector StackTy;
 
   /// \brief Stack of used declaration and their data-sharing attributes.
+  DeclSAMapTy Threadprivates;
   StackTy Stack;
   /// \brief true, if check for DSA must be from parent directive, false, if
   /// from current directive.
@@ -134,7 +135,7 @@ private:
   bool isOpenMPLocal(VarDecl *D, StackTy::reverse_iterator Iter);
 
 public:
-  explicit DSAStackTy(Sema &S) : Stack(1), SemaRef(S) {}
+  explicit DSAStackTy(Sema &S) : SemaRef(S) {}
 
   bool isClauseParsingMode() const { return ClauseKindMode != OMPC_unknown; }
   void setClauseParsingMode(OpenMPClauseKind K) { ClauseKindMode = K; }
@@ -149,7 +150,7 @@ public:
   }
 
   void pop() {
-assert(Stack.size() > 1 && "Data-sharing attributes stack is empty!");
+assert(!Stack.empty() && "Data-sharing attributes stack is empty!");
 Stack.pop_back();
   }
 
@@ -229,11 +230,11 @@ public:
 
   /// \brief Returns currently analyzed directive.
   OpenMPDirectiveKind getCurrentDirective() const {
-return Stack.back().Directive;
+return Stack.empty() ? OMPD_unknown : Stack.back().Directive;
   }
   /// \brief Returns parent directive.
   OpenMPDirectiveKind getParentDirective() const {
-if (Stack.size() > 2)
+if (Stack.size() > 1)
   return Stack[Stack.size() - 2].Directive;
 return OMPD_unknown;
   }
@@ -250,10 +251,10 @@ public:
   }
 
   DefaultDataSharingAttributes getDefaultDSA() const {
-return Stack.back().DefaultAttr;
+return Stack.empty() ? DSA_unspecified : Stack.back().DefaultAttr;
   }
   SourceLocation getDefaultDSALocation() const {
-return Stack.back().DefaultAttrLoc;
+return Stack.empty() ? SourceLocation() : Stack.back().DefaultAttrLoc;
   }
 
   /// \brief Checks if the specified variable is a threadprivate.
@@ -270,13 +271,13 @@ public:
   /// \brief Returns true, if parent region is ordered (has associated
   /// 'ordered' clause), false - otherwise.
   bool isParentOrderedRegion() const {
-if (Stack.size() > 2)
+if (Stack.size() > 1)
   return Stack[Stack.size() - 2].OrderedRegion.getInt();
 return false;
   }
   /// \brief Returns optional parameter for the ordered region.
   Expr *getParentOrderedRegionParam() const {
-if (Stack.size() > 2)
+if (Stack.size() > 1)
   return Stack[Stack.size() - 2].OrderedRegion.getPointer();
 return nullptr;
   }
@@ -287,28 +288,32 @@ public:
   /// \brief Returns true, if parent region is nowait (has associated
   /// 'nowait' clause), false - otherwise.
   bool isParentNowaitRegion() const {
-if (Stack.size() > 2)
+if (Stack.size() > 1)
   return Stack[Stack.size() - 2].NowaitRegion;
 return false;
   }
   /// \brief Marks parent region as cancel region.
   void setParentCancelRegion(bool Cancel = true) {
-if (Stack.size() > 2)
+if (Stack.size() > 1)
   Stack[Stack.size() - 2].CancelRegion =
   Stack[Stack.size() - 2].CancelRegion || Cancel;
   }
   /// \brief Return true if current region has inner cancel construct.
-  bool isCancelRegion() const { return Stack.back().CancelRegion; }
+  bool isCancelRegion() const {
+return Stack.empty() ? false : Stack.back().CancelRegion;
+  }
 
   /// \brief Set collapse value for the region.
   void setAssociatedLoops(unsigned Val) { Stack.back().AssociatedLoops = Val; }
   /// \brief Return collapse value for region.
-  unsigned getAssociatedLoops() const { return Stack.back().AssociatedLoops; }
+  unsigned getAssociatedLoops() const {
+return Stack.empty() ? 0 : Stack.back().AssociatedLoops;
+  }
 
   /// \brief Marks current target region as one with closely nested teams
   /// region.
   void setParentTeamsRegionLoc(SourceLocation TeamsRegionLoc) {
-if (Stack.size() > 2)
+if (Stack.size() > 1)
   Stack[Stack.size() - 2].InnerTeamsRegionLoc = TeamsRegionLoc;
   }
   /// \brief Returns true, if current region has closely nested teams region.
@@ -317,14 +322,18 @@ public:
   }
   /// \brief Returns location of the nested teams region (if any).
   SourceLocation getInnerTeamsRegionLoc() const {
-if (Stack.size() > 1)
-  return Stack.back().InnerTeamsRegionLoc;
-return SourceLocation();
+return Stack.empty() ? SourceLocation() : Stac

r301416 - [OPENMP] Fix handling of OpenMP code during template instantiation.

2017-04-26 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Apr 26 10:06:24 2017
New Revision: 301416

URL: http://llvm.org/viewvc/llvm-project?rev=301416&view=rev
Log:
[OPENMP] Fix handling of OpenMP code during template instantiation.

If some function template is instantiated during handling of OpenMP
code, currently it may cause crash of compiler because of trying of
capturing variables in non-capturing function scopes. Patch fixes this
bug.

Added:
cfe/trunk/test/OpenMP/capturing_in_templates.cpp
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=301416&r1=301415&r2=301416&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Apr 26 10:06:24 2017
@@ -8327,6 +8327,12 @@ private:
   /// Returns OpenMP nesting level for current directive.
   unsigned getOpenMPNestingLevel() const;
 
+  /// Push new OpenMP function region for non-capturing function.
+  void pushOpenMPFunctionRegion();
+
+  /// Pop OpenMP function region for non-capturing function.
+  void popOpenMPFunctionRegion(const sema::FunctionScopeInfo *OldFSI);
+
   /// Checks if a type or a declaration is disabled due to the owning extension
   /// being disabled, and emits diagnostic messages if it is disabled.
   /// \param D type or declaration to be checked.

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=301416&r1=301415&r2=301416&view=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Wed Apr 26 10:06:24 2017
@@ -1161,10 +1161,14 @@ void Sema::PushFunctionScope() {
 // memory for a new scope.
 FunctionScopes.back()->Clear();
 FunctionScopes.push_back(FunctionScopes.back());
+if (LangOpts.OpenMP)
+  pushOpenMPFunctionRegion();
 return;
   }
 
   FunctionScopes.push_back(new FunctionScopeInfo(getDiagnostics()));
+  if (LangOpts.OpenMP)
+pushOpenMPFunctionRegion();
 }
 
 void Sema::PushBlockScope(Scope *BlockScope, BlockDecl *Block) {
@@ -1192,6 +1196,9 @@ void Sema::PopFunctionScopeInfo(const An
   FunctionScopeInfo *Scope = FunctionScopes.pop_back_val();
   assert(!FunctionScopes.empty() && "mismatched push/pop!");
 
+  if (LangOpts.OpenMP)
+popOpenMPFunctionRegion(Scope);
+
   // Issue any analysis-based warnings.
   if (WP && D)
 AnalysisWarnings.IssueWarnings(*WP, Scope, D, blkExpr);

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=301416&r1=301415&r2=301416&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Apr 26 10:06:24 2017
@@ -119,7 +119,8 @@ private:
 
   /// \brief Stack of used declaration and their data-sharing attributes.
   DeclSAMapTy Threadprivates;
-  StackTy Stack;
+  const FunctionScopeInfo *CurrentNonCapturingFunctionScope = nullptr;
+  SmallVector, 4> Stack;
   /// \brief true, if check for DSA must be from parent directive, false, if
   /// from current directive.
   OpenMPClauseKind ClauseKindMode = OMPC_unknown;
@@ -134,6 +135,12 @@ private:
   /// \brief Checks if the variable is a local for OpenMP region.
   bool isOpenMPLocal(VarDecl *D, StackTy::reverse_iterator Iter);
 
+  bool isStackEmpty() const {
+return Stack.empty() ||
+   Stack.back().second != CurrentNonCapturingFunctionScope ||
+   Stack.back().first.empty();
+  }
+
 public:
   explicit DSAStackTy(Sema &S) : SemaRef(S) {}
 
@@ -145,13 +152,38 @@ public:
 
   void push(OpenMPDirectiveKind DKind, const DeclarationNameInfo &DirName,
 Scope *CurScope, SourceLocation Loc) {
-Stack.push_back(SharingMapTy(DKind, DirName, CurScope, Loc));
-Stack.back().DefaultAttrLoc = Loc;
+if (Stack.empty() ||
+Stack.back().second != CurrentNonCapturingFunctionScope)
+  Stack.emplace_back(StackTy(), CurrentNonCapturingFunctionScope);
+Stack.back().first.emplace_back(DKind, DirName, CurScope, Loc);
+Stack.back().first.back().DefaultAttrLoc = Loc;
   }
 
   void pop() {
-assert(!Stack.empty() && "Data-sharing attributes stack is empty!");
-Stack.pop_back();
+assert(!Stack.back().first.empty() &&
+   "Data-sharing attributes stack is empty!");
+Stack.back().first.pop_back();
+  }
+
+  /// Start new OpenMP region stack in new non-capturing function.
+  void pushFunction() {
+const FunctionScopeInfo *CurFnScope = SemaRef.getCurFunction();
+assert(!isa(CurFnScope));
+CurrentNonCapturingFunctionScope = CurFnScope;
+  }
+  /// Pop region stack for non-capturing function.
+  void popFuncti

[PATCH] D32439: Fix for incorrect source position of dependent c'tor initializer (bug:26195)

2017-04-26 Thread Serge Preis via Phabricator via cfe-commits
Serge_Preis updated this revision to Diff 96752.
Serge_Preis added a comment.

- Minor improvement to the fix: ensure that Type is of expected kind.
- Added test for various situations causing problems with source poisition in 
current implementation


https://reviews.llvm.org/D32439

Files:
  lib/Sema/SemaDeclCXX.cpp
  test/Misc/ctor-init-source-loc.cpp

Index: test/Misc/ctor-init-source-loc.cpp
===
--- test/Misc/ctor-init-source-loc.cpp
+++ test/Misc/ctor-init-source-loc.cpp
@@ -0,0 +1,117 @@
+// RUN: c-index-test -test-load-source all %s | FileCheck %s
+template
+struct Derived:  MyBase::InnerIterator
+{
+Derived() : MyBase::InnerIterator() {}
+// CHECK:  TypeRef=MyBase:2:19 Extent=[5:17 - 5:23]
+};
+
+template
+struct Derived2:  MyBase::Deeper::InnerIterator
+{
+Derived2() : MyBase::Deeper::InnerIterator() {}
+// CHECK:  TypeRef=MyBase:9:19 Extent=[12:18 - 12:24]
+};
+
+template
+struct Templ;
+
+template
+struct Derived3:  Templ::InnerIterator
+{
+Derived3() : Templ::InnerIterator() {}
+// CHECK: TemplateRef=Templ:17:8 Extent=[22:18 - 22:23]
+// CHECK: TypeRef=MyBase:19:19 Extent=[22:24 - 22:30]
+};
+
+
+struct Outer {
+template 
+struct Inner {
+typedef Q Parm;
+};
+};
+
+template
+struct Derived4:  Outer::Inner::Parm
+{
+Derived4() : Outer::Inner::Parm() {}
+// CHECK: TypeRef=struct Outer:28:8 Extent=[38:18 - 38:23]
+// CHECK: TemplateRef=Inner:30:12 Extent=[38:25 - 38:30]
+// CHECK: TypeRef=Q:35:19 Extent=[38:31 - 38:32]
+};
+
+template
+struct Derived5:  Outer::Inner::Parm::InnerIterator
+{
+Derived5() : Outer::Inner::Parm::InnerIterator() {}
+// CHECK: TypeRef=struct Outer:28:8 Extent=[47:18 - 47:23]
+// CHECK: TemplateRef=Inner:30:12 Extent=[47:25 - 47:30]
+// CHECK: TypeRef=Q:44:19 Extent=[47:31 - 47:32]
+};
+
+template
+struct Derived6:  Outer::Inner
+{
+Derived6() : Outer::Inner() {}
+// CHECK: TypeRef=struct Outer:28:8 Extent=[56:18 - 56:23]
+// CHECK: TemplateRef=Inner:30:12 Extent=[56:25 - 56:30]
+// CHECK: TypeRef=Q:53:19 Extent=[56:31 - 56:32]
+};
+
+struct Base {};
+
+struct Derived7:  Outer::Inner::Parm
+{
+Derived7() : Outer::Inner::Parm() {}
+// CHECK: TypeRef=struct Outer:28:8 Extent=[66:18 - 66:23]
+// CHECK: TemplateRef=Inner:30:12 Extent=[66:25 - 66:30]
+// CHECK: TypeRef=struct Base:62:8 Extent=[66:31 - 66:35]
+};
+
+struct Derived8:  Outer::Inner
+{
+Derived8() : Outer::Inner() {}
+// CHECK: TypeRef=struct Outer:28:8 Extent=[74:18 - 74:23]
+// CHECK: TemplateRef=Inner:30:12 Extent=[74:25 - 74:30]
+// CHECK: TypeRef=struct Base:62:8 Extent=[74:31 - 74:35]
+};
+
+namespace Namespace {
+template struct Templ;
+
+struct Outer {
+template 
+struct Inner {
+typedef Q Parm;
+};
+};
+}
+
+template
+struct Derived9:  Namespace::Templ::InnerIterator
+{
+Derived9() : Namespace::Templ::InnerIterator() {}
+// CHECK: NamespaceRef=Namespace:80:11 Extent=[94:18 - 94:27]
+// CHECK: TemplateRef=Templ:81:33 Extent=[94:29 - 94:34]
+// CHECK: TypeRef=MyBase:91:19 Extent=[94:35 - 94:41]
+};
+
+template
+struct Derived10:  Namespace::Templ
+{
+Derived10() : Namespace::Templ() {}
+// CHECK: NamespaceRef=Namespace:80:11 Extent=[103:19 - 103:28]
+// CHECK: TemplateRef=Templ:81:33 Extent=[103:30 - 103:35]
+// CHECK: TypeRef=MyBase:100:19 Extent=[103:36 - 103:42]
+};
+
+template
+struct Derived11:  Namespace::Outer::Inner::Parm
+{
+Derived11() : Namespace::Outer::Inner::Parm() {}
+// CHECK: NamespaceRef=Namespace:80:11 Extent=[112:19 - 112:28]
+// CHECK: TypeRef=struct Namespace::Outer:83:12 Extent=[112:30 - 112:35]
+// CHECK: TemplateRef=Inner:85:16 Extent=[112:37 - 112:42]
+// CHECK: TypeRef=MyBase:109:19 Extent=[112:43 - 112:49]
+};
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -3767,6 +3767,14 @@
   if (BaseType.isNull())
 return true;
 
+  TInfo = Context.CreateTypeSourceInfo(BaseType);
+  DependentNameTypeLoc TL = TInfo->getTypeLoc().castAs();
+  if (!TL.isNull()) {
+TL.setNameLoc(IdLoc);
+TL.setElaboratedKeywordLoc(SourceLocation());
+TL.setQualifierLoc(SS.getWithLocInContext(Context));
+  }
+
   R.clear();
   R.setLookupName(MemberOrBase);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r301417 - [OPENMP] Fix failing test.

2017-04-26 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Apr 26 10:30:36 2017
New Revision: 301417

URL: http://llvm.org/viewvc/llvm-project?rev=301417&view=rev
Log:
[OPENMP] Fix failing test.

Modified:
cfe/trunk/test/OpenMP/capturing_in_templates.cpp

Modified: cfe/trunk/test/OpenMP/capturing_in_templates.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/capturing_in_templates.cpp?rev=301417&r1=301416&r2=301417&view=diff
==
--- cfe/trunk/test/OpenMP/capturing_in_templates.cpp (original)
+++ cfe/trunk/test/OpenMP/capturing_in_templates.cpp Wed Apr 26 10:30:36 2017
@@ -15,7 +15,7 @@ pair make_pair(T1 &&t1, T2 &&t2)
 
 // CHECK-LABEL: @main
 int main(int argc, char **argv) {
-// CHECK: call i32 @__tgt_target(i32 -1, i8* [[OFFLOAD:@[^.]+]].region_id, i32 
0, i8** null, i8** null, i64* null, i32* null)
+// CHECK: call i32 @__tgt_target(i32 -1, i8* @{{.+}}.region_id, i32 0, i8** 
null, i8** null, i64* null, i32* null)
 #pragma omp target
  {
 for (int i = 0; i < 64; ++i) {
@@ -27,5 +27,4 @@ int main(int argc, char **argv) {
   return 0;
 }
 
-// CHECK: define internal void [[OFFLOAD]](
 // CHECK: call {{.+}} @{{.*}}make_pair


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


[PATCH] D32519: [Sema] Avoid using a null type pointer (fixes PR32750)

2017-04-26 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added inline comments.



Comment at: test/SemaCXX/MicrosoftExtensions.cpp:516
+template struct A {};
+template struct B : A > { A::C::D d; }; // expected-error 
{{missing 'typename' prior to dependent type name 'A::C::D'}}
+}

nikola wrote:
> nitpick: you don't need the space between angle brackets since you set the 
> standard to C++14, I'm not sure what the convention here is but you don't 
> need more than C++11...
Thanks for taking a look! I'll fix this up before committing.


https://reviews.llvm.org/D32519



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


r301420 - [Sema] Avoid using a null type pointer (fixes PR32750)

2017-04-26 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Wed Apr 26 10:40:21 2017
New Revision: 301420

URL: http://llvm.org/viewvc/llvm-project?rev=301420&view=rev
Log:
[Sema] Avoid using a null type pointer (fixes PR32750)

isMicrosoftMissingTypename() uses a Type pointer without first checking
that it's non-null. PR32750 reports a case where the pointer is in fact
null. This patch adds in a defensive check and a regression test.

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

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=301420&r1=301419&r2=301420&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Apr 26 10:40:21 2017
@@ -615,7 +615,7 @@ bool Sema::isMicrosoftMissingTypename(co
 
 CXXRecordDecl *RD = cast(CurContext);
 for (const auto &Base : RD->bases())
-  if (Context.hasSameUnqualifiedType(QualType(Ty, 1), Base.getType()))
+  if (Ty && Context.hasSameUnqualifiedType(QualType(Ty, 1), 
Base.getType()))
 return true;
 return S->isFunctionPrototypeScope();
   }

Modified: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=301420&r1=301419&r2=301420&view=diff
==
--- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp Wed Apr 26 10:40:21 2017
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -std=c++98 %s -triple i686-pc-win32 -fsyntax-only 
-Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-extensions 
-fexceptions -fcxx-exceptions -DTEST1
 // RUN: %clang_cc1 -std=c++11 %s -triple i686-pc-win32 -fsyntax-only 
-Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-extensions 
-fexceptions -fcxx-exceptions -DTEST1
 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft 
-Wc++11-extensions -Wno-long-long -verify -fexceptions -fcxx-exceptions -DTEST2
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 
-fms-compatibility -verify -DTEST3
 
 #if TEST1
 
@@ -508,6 +509,13 @@ int S::fn() { return 0; } // expected-wa
 // Check that __unaligned is not recognized if MS extensions are not enabled
 typedef char __unaligned *aligned_type; // expected-error {{expected ';' after 
top level declarator}}
 
+#elif TEST3
+
+namespace PR32750 {
+template struct A {};
+template struct B : A> { A::C::D d; }; // expected-error 
{{missing 'typename' prior to dependent type name 'A::C::D'}}
+}
+
 #else
 
 #error Unknown test mode


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


[PATCH] D32519: [Sema] Avoid using a null type pointer (fixes PR32750)

2017-04-26 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL301420: [Sema] Avoid using a null type pointer (fixes 
PR32750) (authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D32519?vs=96668&id=96757#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32519

Files:
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp


Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -615,7 +615,7 @@
 
 CXXRecordDecl *RD = cast(CurContext);
 for (const auto &Base : RD->bases())
-  if (Context.hasSameUnqualifiedType(QualType(Ty, 1), Base.getType()))
+  if (Ty && Context.hasSameUnqualifiedType(QualType(Ty, 1), 
Base.getType()))
 return true;
 return S->isFunctionPrototypeScope();
   }
Index: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
===
--- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
+++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -std=c++98 %s -triple i686-pc-win32 -fsyntax-only 
-Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-extensions 
-fexceptions -fcxx-exceptions -DTEST1
 // RUN: %clang_cc1 -std=c++11 %s -triple i686-pc-win32 -fsyntax-only 
-Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-extensions 
-fexceptions -fcxx-exceptions -DTEST1
 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft 
-Wc++11-extensions -Wno-long-long -verify -fexceptions -fcxx-exceptions -DTEST2
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 
-fms-compatibility -verify -DTEST3
 
 #if TEST1
 
@@ -508,6 +509,13 @@
 // Check that __unaligned is not recognized if MS extensions are not enabled
 typedef char __unaligned *aligned_type; // expected-error {{expected ';' after 
top level declarator}}
 
+#elif TEST3
+
+namespace PR32750 {
+template struct A {};
+template struct B : A> { A::C::D d; }; // expected-error 
{{missing 'typename' prior to dependent type name 'A::C::D'}}
+}
+
 #else
 
 #error Unknown test mode


Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -615,7 +615,7 @@
 
 CXXRecordDecl *RD = cast(CurContext);
 for (const auto &Base : RD->bases())
-  if (Context.hasSameUnqualifiedType(QualType(Ty, 1), Base.getType()))
+  if (Ty && Context.hasSameUnqualifiedType(QualType(Ty, 1), Base.getType()))
 return true;
 return S->isFunctionPrototypeScope();
   }
Index: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
===
--- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
+++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -std=c++98 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-extensions -fexceptions -fcxx-exceptions -DTEST1
 // RUN: %clang_cc1 -std=c++11 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-extensions -fexceptions -fcxx-exceptions -DTEST1
 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fexceptions -fcxx-exceptions -DTEST2
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 -fms-compatibility -verify -DTEST3
 
 #if TEST1
 
@@ -508,6 +509,13 @@
 // Check that __unaligned is not recognized if MS extensions are not enabled
 typedef char __unaligned *aligned_type; // expected-error {{expected ';' after top level declarator}}
 
+#elif TEST3
+
+namespace PR32750 {
+template struct A {};
+template struct B : A> { A::C::D d; }; // expected-error {{missing 'typename' prior to dependent type name 'A::C::D'}}
+}
+
 #else
 
 #error Unknown test mode
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32543: [X86] Clang option -fuse-init-array has no effect when generating for MCU target

2017-04-26 Thread Andrei via Phabricator via cfe-commits
AndreiGrischenko created this revision.

Our runtime for MCU X86 target supports .init_array section for globals that 
should be dynamically initialized.
But default Clang generates .ctors section and even if it has option 
-fuse-init-array, the option has no effect if set explicitly in a command-line.
The problem is in lack of -fuse-array-init option initialization in CodeGen

void
X86LinuxNaClTargetObjectFile::Initialize(MCContext &Ctx,

 const TargetMachine &TM) {
  TargetLoweringObjectFileELF::Initialize(Ctx, TM);
  InitializeELF(TM.Options.UseInitArray);

}


https://reviews.llvm.org/D32543

Files:
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/tools/clang/test/CodeGen/init_array_sectionMCU.c


Index: llvm/tools/clang/test/CodeGen/init_array_sectionMCU.c
===
--- llvm/tools/clang/test/CodeGen/init_array_sectionMCU.c
+++ llvm/tools/clang/test/CodeGen/init_array_sectionMCU.c
@@ -0,0 +1,18 @@
+// REQUIRES: x86-registered-target
+
+// RUN: %clang_cc1 -triple i586-intel-elfiamcu -S -o - < %s | FileCheck %s 
--check-prefix=CTORS
+// RUN: %clang_cc1 -triple i586-intel-elfiamcu -S -fuse-init-array -o - < %s | 
FileCheck %s --check-prefix=INIT_ARR
+// RUN: %clang_cc1 -triple i586-intel-elfiamcu -S -fno-use-init-array -o - < 
%s | FileCheck %s --check-prefix=CTORS
+
+
+int a = 1;
+
+void __attribute__((constructor)) foo()
+{
+a = 0;
+}
+
+// INIT_ARR: .init_array
+// CTORS-NOT: .init_array
+// CTORS: .ctors
+// CTORS-NOT: .init_array
Index: llvm/lib/Target/X86/X86TargetMachine.cpp
===
--- llvm/lib/Target/X86/X86TargetMachine.cpp
+++ llvm/lib/Target/X86/X86TargetMachine.cpp
@@ -56,7 +56,7 @@

   if (TT.isOSFreeBSD())
 return make_unique();  
-  if (TT.isOSLinux() || TT.isOSNaCl()) 
+  if (TT.isOSLinux() || TT.isOSNaCl() || TT.isOSIAMCU())   
 return make_unique();
   if (TT.isOSFuchsia())
 return make_unique();  


Index: llvm/tools/clang/test/CodeGen/init_array_sectionMCU.c
===
--- llvm/tools/clang/test/CodeGen/init_array_sectionMCU.c
+++ llvm/tools/clang/test/CodeGen/init_array_sectionMCU.c
@@ -0,0 +1,18 @@
+// REQUIRES: x86-registered-target
+
+// RUN: %clang_cc1 -triple i586-intel-elfiamcu -S -o - < %s | FileCheck %s --check-prefix=CTORS
+// RUN: %clang_cc1 -triple i586-intel-elfiamcu -S -fuse-init-array -o - < %s | FileCheck %s --check-prefix=INIT_ARR
+// RUN: %clang_cc1 -triple i586-intel-elfiamcu -S -fno-use-init-array -o - < %s | FileCheck %s --check-prefix=CTORS
+
+
+int a = 1;
+
+void __attribute__((constructor)) foo()
+{
+a = 0;
+}
+
+// INIT_ARR: .init_array
+// CTORS-NOT: .init_array
+// CTORS: .ctors
+// CTORS-NOT: .init_array
Index: llvm/lib/Target/X86/X86TargetMachine.cpp
===
--- llvm/lib/Target/X86/X86TargetMachine.cpp
+++ llvm/lib/Target/X86/X86TargetMachine.cpp
@@ -56,7 +56,7 @@

   if (TT.isOSFreeBSD())
 return make_unique();  
-  if (TT.isOSLinux() || TT.isOSNaCl()) 
+  if (TT.isOSLinux() || TT.isOSNaCl() || TT.isOSIAMCU())   
 return make_unique();
   if (TT.isOSFuchsia())
 return make_unique();  
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32333: [clang-tidy] Update IdentifierNamingCheck to remove extra leading/trailing underscores

2017-04-26 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes updated this revision to Diff 96762.
jtbandes added a comment.

Fixed nit


https://reviews.llvm.org/D32333

Files:
  clang-tidy/readability/IdentifierNamingCheck.cpp
  test/clang-tidy/readability-identifier-naming.cpp


Index: test/clang-tidy/readability-identifier-naming.cpp
===
--- test/clang-tidy/readability-identifier-naming.cpp
+++ test/clang-tidy/readability-identifier-naming.cpp
@@ -175,6 +175,9 @@
   int member2 = 2;
 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private 
member 'member2'
 // CHECK-FIXES: {{^}}  int __member2 = 2;{{$}}
+  int _memberWithExtraUnderscores_ = 42;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private 
member '_memberWithExtraUnderscores_'
+// CHECK-FIXES: {{^}}  int __memberWithExtraUnderscores = 42;{{$}}
 
 private:
 int private_member = 3;
Index: clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -262,6 +262,11 @@
   else
 Matches = false;
 
+  // Ensure the name doesn't have any extra underscores beyond those specified
+  // in the prefix and suffix.
+  if (Name.startswith("_") || Name.endswith("_"))
+Matches = false;
+
   if (Style.Case && !Matchers[static_cast(*Style.Case)].match(Name))
 Matches = false;
 
@@ -367,10 +372,12 @@
 static std::string
 fixupWithStyle(StringRef Name,
const IdentifierNamingCheck::NamingStyle &Style) {
-  return Style.Prefix +
- fixupWithCase(Name, Style.Case.getValueOr(
- IdentifierNamingCheck::CaseType::CT_AnyCase)) 
+
- Style.Suffix;
+  const std::string Fixed = fixupWithCase(
+  Name, 
Style.Case.getValueOr(IdentifierNamingCheck::CaseType::CT_AnyCase));
+  StringRef Mid = StringRef(Fixed).trim("_");
+  if (Mid.empty())
+Mid = "_";
+  return (Style.Prefix + Mid + Style.Suffix).str();
 }
 
 static StyleKind findStyleKind(


Index: test/clang-tidy/readability-identifier-naming.cpp
===
--- test/clang-tidy/readability-identifier-naming.cpp
+++ test/clang-tidy/readability-identifier-naming.cpp
@@ -175,6 +175,9 @@
   int member2 = 2;
 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private member 'member2'
 // CHECK-FIXES: {{^}}  int __member2 = 2;{{$}}
+  int _memberWithExtraUnderscores_ = 42;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private member '_memberWithExtraUnderscores_'
+// CHECK-FIXES: {{^}}  int __memberWithExtraUnderscores = 42;{{$}}
 
 private:
 int private_member = 3;
Index: clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -262,6 +262,11 @@
   else
 Matches = false;
 
+  // Ensure the name doesn't have any extra underscores beyond those specified
+  // in the prefix and suffix.
+  if (Name.startswith("_") || Name.endswith("_"))
+Matches = false;
+
   if (Style.Case && !Matchers[static_cast(*Style.Case)].match(Name))
 Matches = false;
 
@@ -367,10 +372,12 @@
 static std::string
 fixupWithStyle(StringRef Name,
const IdentifierNamingCheck::NamingStyle &Style) {
-  return Style.Prefix +
- fixupWithCase(Name, Style.Case.getValueOr(
- IdentifierNamingCheck::CaseType::CT_AnyCase)) +
- Style.Suffix;
+  const std::string Fixed = fixupWithCase(
+  Name, Style.Case.getValueOr(IdentifierNamingCheck::CaseType::CT_AnyCase));
+  StringRef Mid = StringRef(Fixed).trim("_");
+  if (Mid.empty())
+Mid = "_";
+  return (Style.Prefix + Mid + Style.Suffix).str();
 }
 
 static StyleKind findStyleKind(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r301427 - Update to LLVM's use of WeakTrackingVH; NFC

2017-04-26 Thread Sanjoy Das via cfe-commits
Author: sanjoy
Date: Wed Apr 26 11:22:36 2017
New Revision: 301427

URL: http://llvm.org/viewvc/llvm-project?rev=301427&view=rev
Log:
Update to LLVM's use of WeakTrackingVH; NFC

Summary: Depends on D32266

Reviewers: davide, dblaikie

Subscribers: mcrosier, llvm-commits

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

Modified:
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=301427&r1=301426&r2=301427&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Wed Apr 26 11:22:36 2017
@@ -571,9 +571,10 @@ CodeGenFunction::GenerateCXXGlobalInitFu
   FinishFunction();
 }
 
-void CodeGenFunction::GenerateCXXGlobalDtorsFunc(llvm::Function *Fn,
-  const std::vector >
-&DtorsAndObjects) {
+void CodeGenFunction::GenerateCXXGlobalDtorsFunc(
+llvm::Function *Fn,
+const std::vector>
+&DtorsAndObjects) {
   {
 auto NL = ApplyDebugLocation::CreateEmpty(*this);
 StartFunction(GlobalDecl(), getContext().VoidTy, Fn,

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=301427&r1=301426&r2=301427&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Wed Apr 26 11:22:36 2017
@@ -886,7 +886,7 @@ protected:
 
   /// Cached reference to the class for constant strings. This value has type
   /// int * but is actually an Obj-C class pointer.
-  llvm::WeakVH ConstantStringClassRef;
+  llvm::WeakTrackingVH ConstantStringClassRef;
 
   /// \brief The LLVM type corresponding to NSConstantString.
   llvm::StructType *NSConstantStringType = nullptr;

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=301427&r1=301426&r2=301427&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Wed Apr 26 11:22:36 2017
@@ -3470,9 +3470,10 @@ public:
 
   /// GenerateCXXGlobalDtorsFunc - Generates code for destroying global
   /// variables.
-  void GenerateCXXGlobalDtorsFunc(llvm::Function *Fn,
-  const std::vector > &DtorsAndObjects);
+  void GenerateCXXGlobalDtorsFunc(
+  llvm::Function *Fn,
+  const std::vector>
+  &DtorsAndObjects);
 
   void GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn,
 const VarDecl *D,

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=301427&r1=301426&r2=301427&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Apr 26 11:22:36 2017
@@ -1150,7 +1150,7 @@ void CodeGenModule::addCompilerUsedGloba
 }
 
 static void emitUsed(CodeGenModule &CGM, StringRef Name,
- std::vector &List) {
+ std::vector &List) {
   // Don't create llvm.used if there is no need.
   if (List.empty())
 return;

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=301427&r1=301426&r2=301427&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Wed Apr 26 11:22:36 2017
@@ -349,8 +349,8 @@ private:
   /// List of global values which are required to be present in the object 
file;
   /// bitcast to i8*. This is used for forcing visibility of symbols which may
   /// otherwise be optimized out.
-  std::vector LLVMUsed;
-  std::vector LLVMCompilerUsed;
+  std::vector LLVMUsed;
+  std::vector LLVMCompilerUsed;
 
   /// Store the list of global constructors and their respective priorities to
   /// be emitted when the translation unit is complete.
@@ -421,7 +421,7 @@ private:
   SmallVector PrioritizedCXXGlobalInits;
 
   /// Global destructor functions and arguments that need to run on 
termination.
-  std::vector > CXXGlobalDtors;
+  std::vector> 
CXXGlobalDtors;
 
   /// \brief The complete set of modules that has been imported.
   llvm::SetVector ImportedModules;
@@ -438,7 +438,7 @@ private:
 
   /// Cached reference to the class for constant strings. This value has type
   /// int * 

[PATCH] D32333: [clang-tidy] Update IdentifierNamingCheck to remove extra leading/trailing underscores

2017-04-26 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes marked an inline comment as done.
jtbandes added a comment.

Done, thanks for the review!

What is the procedure for merging patches in? I'm sure I don't have permissions 
to do it myself.


https://reviews.llvm.org/D32333



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


[PATCH] D32333: [clang-tidy] Update IdentifierNamingCheck to remove extra leading/trailing underscores

2017-04-26 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D32333#738266, @jtbandes wrote:

> Done, thanks for the review!
>
> What is the procedure for merging patches in? I'm sure I don't have 
> permissions to do it myself.


I'll commit the patch for you.

Thank you for working on this!


https://reviews.llvm.org/D32333



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


r301430 - Revert "Update to LLVM's use of WeakTrackingVH; NFC"

2017-04-26 Thread Sanjoy Das via cfe-commits
Author: sanjoy
Date: Wed Apr 26 11:37:51 2017
New Revision: 301430

URL: http://llvm.org/viewvc/llvm-project?rev=301430&view=rev
Log:
Revert "Update to LLVM's use of WeakTrackingVH; NFC"

This reverts commit r301427.

Modified:
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=301430&r1=301429&r2=301430&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Wed Apr 26 11:37:51 2017
@@ -571,10 +571,9 @@ CodeGenFunction::GenerateCXXGlobalInitFu
   FinishFunction();
 }
 
-void CodeGenFunction::GenerateCXXGlobalDtorsFunc(
-llvm::Function *Fn,
-const std::vector>
-&DtorsAndObjects) {
+void CodeGenFunction::GenerateCXXGlobalDtorsFunc(llvm::Function *Fn,
+  const std::vector >
+&DtorsAndObjects) {
   {
 auto NL = ApplyDebugLocation::CreateEmpty(*this);
 StartFunction(GlobalDecl(), getContext().VoidTy, Fn,

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=301430&r1=301429&r2=301430&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Wed Apr 26 11:37:51 2017
@@ -886,7 +886,7 @@ protected:
 
   /// Cached reference to the class for constant strings. This value has type
   /// int * but is actually an Obj-C class pointer.
-  llvm::WeakTrackingVH ConstantStringClassRef;
+  llvm::WeakVH ConstantStringClassRef;
 
   /// \brief The LLVM type corresponding to NSConstantString.
   llvm::StructType *NSConstantStringType = nullptr;

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=301430&r1=301429&r2=301430&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Wed Apr 26 11:37:51 2017
@@ -3470,10 +3470,9 @@ public:
 
   /// GenerateCXXGlobalDtorsFunc - Generates code for destroying global
   /// variables.
-  void GenerateCXXGlobalDtorsFunc(
-  llvm::Function *Fn,
-  const std::vector>
-  &DtorsAndObjects);
+  void GenerateCXXGlobalDtorsFunc(llvm::Function *Fn,
+  const std::vector > &DtorsAndObjects);
 
   void GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn,
 const VarDecl *D,

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=301430&r1=301429&r2=301430&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Apr 26 11:37:51 2017
@@ -1150,7 +1150,7 @@ void CodeGenModule::addCompilerUsedGloba
 }
 
 static void emitUsed(CodeGenModule &CGM, StringRef Name,
- std::vector &List) {
+ std::vector &List) {
   // Don't create llvm.used if there is no need.
   if (List.empty())
 return;

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=301430&r1=301429&r2=301430&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Wed Apr 26 11:37:51 2017
@@ -349,8 +349,8 @@ private:
   /// List of global values which are required to be present in the object 
file;
   /// bitcast to i8*. This is used for forcing visibility of symbols which may
   /// otherwise be optimized out.
-  std::vector LLVMUsed;
-  std::vector LLVMCompilerUsed;
+  std::vector LLVMUsed;
+  std::vector LLVMCompilerUsed;
 
   /// Store the list of global constructors and their respective priorities to
   /// be emitted when the translation unit is complete.
@@ -421,7 +421,7 @@ private:
   SmallVector PrioritizedCXXGlobalInits;
 
   /// Global destructor functions and arguments that need to run on 
termination.
-  std::vector> 
CXXGlobalDtors;
+  std::vector > CXXGlobalDtors;
 
   /// \brief The complete set of modules that has been imported.
   llvm::SetVector ImportedModules;
@@ -438,7 +438,7 @@ private:
 
   /// Cached reference to the class for constant strings. This value has type
   /// int * but is actually an Obj-C class pointer.
-  llvm::WeakTrackingVH CFConstantStringClassRef;
+  llvm::WeakVH CFCon

[PATCH] D32436: [clang-tidy] Support detecting for-range loop in inefficient-vector-operation check.

2017-04-26 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG




Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:152
+
+  const Stmt * LoopStmt = nullptr;
+  if (ForLoop)

hokein wrote:
> alexfh wrote:
> > const Stmt *LoopStmt = ForLoop ? ForLoop : RangeLoop;
> We can't do it because `ForLoop` and `RangeLoop` are different types.
Yup, static_cast would be more ugly. This could still be shortened a bit:

  const Stmt *LoopStmt = ForLoop;
  if (!LoopStmt)
LoopStmt = RangeLoop;

Not that it makes too much difference though. Up to you.



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:153
+
+  const Stmt * LoopStmt = nullptr;
+  if (ForLoop)

nit: Please remove the extra space after the asterisk.


https://reviews.llvm.org/D32436



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


[clang-tools-extra] r301431 - [clang-tidy] Update IdentifierNamingCheck to remove extra leading/trailing underscores

2017-04-26 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Apr 26 11:39:11 2017
New Revision: 301431

URL: http://llvm.org/viewvc/llvm-project?rev=301431&view=rev
Log:
[clang-tidy] Update IdentifierNamingCheck to remove extra leading/trailing 
underscores

Summary:
The goal of this change is to fix the following suboptimal replacements 
currently suggested by clang-tidy:
```
// with MemberPrefix == "_"
int __foo;  // accepted without complaint
```
```
// with MemberPrefix == "m_"
int _foo;
^~
m__foo
```

I fixed this by
- updating `matchesStyle()` to reject names which have a leading underscore 
after a prefix has already been stripped, or a trailing underscore if a suffix 
has already been stripped;
- updating `fixupWithStyle()` to strip leading & trailing underscores before 
adding the user-defined prefix and suffix.

The replacements are now:
```
// MemberPrefix == "_"
int __foo;
^~
_foo
```
```
// MemberPrefix == "m_"
int _foo;
^
m_foo
```

Future improvements might elect to add .clang-tidy flags to improve what is 
being stripped. For instance, stripping `m_` could allow `m_foo` to be 
automatically replaced with `_foo`.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: cfe-commits

Patch by Jacob Bandes-Storch!

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

Modified:
clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp?rev=301431&r1=301430&r2=301431&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp 
Wed Apr 26 11:39:11 2017
@@ -262,6 +262,11 @@ static bool matchesStyle(StringRef Name,
   else
 Matches = false;
 
+  // Ensure the name doesn't have any extra underscores beyond those specified
+  // in the prefix and suffix.
+  if (Name.startswith("_") || Name.endswith("_"))
+Matches = false;
+
   if (Style.Case && !Matchers[static_cast(*Style.Case)].match(Name))
 Matches = false;
 
@@ -367,10 +372,12 @@ static std::string fixupWithCase(StringR
 static std::string
 fixupWithStyle(StringRef Name,
const IdentifierNamingCheck::NamingStyle &Style) {
-  return Style.Prefix +
- fixupWithCase(Name, Style.Case.getValueOr(
- IdentifierNamingCheck::CaseType::CT_AnyCase)) 
+
- Style.Suffix;
+  const std::string Fixed = fixupWithCase(
+  Name, 
Style.Case.getValueOr(IdentifierNamingCheck::CaseType::CT_AnyCase));
+  StringRef Mid = StringRef(Fixed).trim("_");
+  if (Mid.empty())
+Mid = "_";
+  return (Style.Prefix + Mid + Style.Suffix).str();
 }
 
 static StyleKind findStyleKind(

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp?rev=301431&r1=301430&r2=301431&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp 
Wed Apr 26 11:39:11 2017
@@ -175,6 +175,9 @@ private:
   int member2 = 2;
 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private 
member 'member2'
 // CHECK-FIXES: {{^}}  int __member2 = 2;{{$}}
+  int _memberWithExtraUnderscores_ = 42;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private 
member '_memberWithExtraUnderscores_'
+// CHECK-FIXES: {{^}}  int __memberWithExtraUnderscores = 42;{{$}}
 
 private:
 int private_member = 3;


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


[PATCH] D32333: [clang-tidy] Update IdentifierNamingCheck to remove extra leading/trailing underscores

2017-04-26 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL301431: [clang-tidy] Update IdentifierNamingCheck to remove 
extra leading/trailing… (authored by alexfh).

Changed prior to commit:
  https://reviews.llvm.org/D32333?vs=96762&id=96771#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32333

Files:
  clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp


Index: clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp
@@ -175,6 +175,9 @@
   int member2 = 2;
 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private 
member 'member2'
 // CHECK-FIXES: {{^}}  int __member2 = 2;{{$}}
+  int _memberWithExtraUnderscores_ = 42;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private 
member '_memberWithExtraUnderscores_'
+// CHECK-FIXES: {{^}}  int __memberWithExtraUnderscores = 42;{{$}}
 
 private:
 int private_member = 3;
Index: clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -262,6 +262,11 @@
   else
 Matches = false;
 
+  // Ensure the name doesn't have any extra underscores beyond those specified
+  // in the prefix and suffix.
+  if (Name.startswith("_") || Name.endswith("_"))
+Matches = false;
+
   if (Style.Case && !Matchers[static_cast(*Style.Case)].match(Name))
 Matches = false;
 
@@ -367,10 +372,12 @@
 static std::string
 fixupWithStyle(StringRef Name,
const IdentifierNamingCheck::NamingStyle &Style) {
-  return Style.Prefix +
- fixupWithCase(Name, Style.Case.getValueOr(
- IdentifierNamingCheck::CaseType::CT_AnyCase)) 
+
- Style.Suffix;
+  const std::string Fixed = fixupWithCase(
+  Name, 
Style.Case.getValueOr(IdentifierNamingCheck::CaseType::CT_AnyCase));
+  StringRef Mid = StringRef(Fixed).trim("_");
+  if (Mid.empty())
+Mid = "_";
+  return (Style.Prefix + Mid + Style.Suffix).str();
 }
 
 static StyleKind findStyleKind(


Index: clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp
@@ -175,6 +175,9 @@
   int member2 = 2;
 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private member 'member2'
 // CHECK-FIXES: {{^}}  int __member2 = 2;{{$}}
+  int _memberWithExtraUnderscores_ = 42;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private member '_memberWithExtraUnderscores_'
+// CHECK-FIXES: {{^}}  int __memberWithExtraUnderscores = 42;{{$}}
 
 private:
 int private_member = 3;
Index: clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -262,6 +262,11 @@
   else
 Matches = false;
 
+  // Ensure the name doesn't have any extra underscores beyond those specified
+  // in the prefix and suffix.
+  if (Name.startswith("_") || Name.endswith("_"))
+Matches = false;
+
   if (Style.Case && !Matchers[static_cast(*Style.Case)].match(Name))
 Matches = false;
 
@@ -367,10 +372,12 @@
 static std::string
 fixupWithStyle(StringRef Name,
const IdentifierNamingCheck::NamingStyle &Style) {
-  return Style.Prefix +
- fixupWithCase(Name, Style.Case.getValueOr(
- IdentifierNamingCheck::CaseType::CT_AnyCase)) +
- Style.Suffix;
+  const std::string Fixed = fixupWithCase(
+  Name, Style.Case.getValueOr(IdentifierNamingCheck::CaseType::CT_AnyCase));
+  StringRef Mid = StringRef(Fixed).trim("_");
+  if (Mid.empty())
+Mid = "_";
+  return (Style.Prefix + Mid + Style.Suffix).str();
 }
 
 static StyleKind findStyleKind(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32436: [clang-tidy] Support detecting for-range loop in inefficient-vector-operation check.

2017-04-26 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 96775.
hokein marked 2 inline comments as done.
hokein added a comment.

Address remaining nits.


https://reviews.llvm.org/D32436

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

Index: test/clang-tidy/performance-inefficient-vector-operation.cpp
===
--- test/clang-tidy/performance-inefficient-vector-operation.cpp
+++ test/clang-tidy/performance-inefficient-vector-operation.cpp
@@ -1,9 +1,27 @@
-// RUN: %check_clang_tidy %s performance-inefficient-vector-operation %t -- -format-style=llvm --
+// RUN: %check_clang_tidy %s performance-inefficient-vector-operation %t -- -format-style=llvm -- --std=c++11
 
 namespace std {
 
 typedef int size_t;
 
+template class initializer_list {
+public:
+  using value_type = E;
+  using reference = E&;
+  using const_reference = const E&;
+  using size_type = size_t;
+  using iterator = const E*;
+  using const_iterator = const E*;
+  initializer_list();
+  size_t size() const; // number of elements
+  const E* begin() const; // first element
+  const E* end() const; // one past the last element
+};
+
+// initializer list range access
+template const E* begin(initializer_list il);
+template const E* end(initializer_list il);
+
 template 
 class vector {
  public:
@@ -23,9 +41,24 @@
   size_t size();
   const_reference operator[] (size_type) const;
   reference operator[] (size_type);
+
+  const_iterator begin() const;
+  const_iterator end() const;
 };
 } // namespace std
 
+class Foo {
+ public:
+  explicit Foo(int);
+};
+
+class Bar {
+ public:
+  Bar(int);
+};
+
+int Op(int);
+
 void f(std::vector& t) {
   {
 std::vector v;
@@ -85,7 +118,38 @@
   v.push_back(t[i]);
 } // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
   }
-
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(t.size());
+for (const auto &e : t) {
+  v.push_back(e);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
+}
+  }
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(t.size());
+for (const auto &e : t) {
+  v.push_back(Op(e));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
+}
+  }
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(t.size());
+for (const auto &e : t) {
+  v.push_back(Foo(e));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
+}
+  }
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(t.size());
+for (const auto &e : t) {
+  v.push_back(e);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
+}
+  }
   //  Non-fixed Cases 
   {
 std::vector v;
@@ -181,4 +245,21 @@
   v.push_back(t[i]);
 }
   }
+  {
+std::vector v;
+// initializer_list should not trigger the check.
+for (int e : {1, 2, 3, 4, 5}) {
+  v.push_back(e);
+}
+  }
+  {
+std::vector v;
+std::vector* v2 = &t;
+// We only support detecting the range init expression which references
+// container directly.
+// Complex range init expressions like `*v2` is not supported.
+for (const auto &e : *v2) {
+  v.push_back(e);
+}
+  }
 }
Index: docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
===
--- docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
+++ docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
@@ -3,11 +3,13 @@
 performance-inefficient-vector-operation
 
 
-Finds possible inefficient `std::vector` operations (e.g. `push_back`) that may
-cause unnecessary memory reallocations.
+Finds possible inefficient ``std::vector`` operations (e.g. ``push_back``) that
+may cause unnecessary memory reallocations.
 
-Currently, the check only detects a typical counter-based for loop with a single
-statement in it, see below:
+Currently, the check only detects following kinds of loops with a single
+statement body:
+
+* Counter-based for loops start with 0:
 
 .. code-block:: c++
 
@@ -18,3 +20,30 @@
 // memory reallocations in v. This can be avoid by inserting a 'reserve(n)'
 // statment before the for statment.
   }
+
+
+* For-range loops like ``for (range-declaration : range_expression)``, the type
+  of ``range_expression`` can be ``std::vector``, ``std::array``,
+  ``std::dequeue``, ``std::set``, ``std::unordered_set``, ``std::map``,
+  ``std::unordered_set``:
+
+.. code-block:: c++
+
+  std::vector data;
+  std::vector v;
+
+  for (auto element : data) {
+v.push_back(element);
+// This will trigger the warning since the 'push_back' may cause multiple
+// memory reallocations in v. This can be avoid by i

[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

2017-04-26 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added inline comments.



Comment at: lib/AST/ASTContext.cpp:1481
+  assert(!FD->hasBody() && "FD has a definition in current translation unit!");
+  if (!FD->getType()->getAs())
+return nullptr; // Cannot even mangle that.

xazax.hun wrote:
> a.sidorin wrote:
> > This needs a FIXME because currently many functions cannot be analyzed 
> > because of it.
> What do you mean here?
This comment was about  `if (!FD->getType()->getAs()) return 
nullptr`. While testing, we have found that many C and C-style functions are 
FunctionNoProtoTypes, so they cannot be mangled, but they still have a body in 
another TU. There definitely should be a way to fix this.


https://reviews.llvm.org/D30691



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


[PATCH] D32475: [clang-format] Don’t propagate AvoidBinPacking into argument subexpressions

2017-04-26 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes added a reviewer: bkramer.
jtbandes added a comment.

Not exactly sure who is the right person for this.


https://reviews.llvm.org/D32475



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


[PATCH] D31777: [ASTImporter] Move structural equivalence context to its own file. NFCI

2017-04-26 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin accepted this revision.
a.sidorin added a comment.

Refactoring changes are always appreciated. I only have a minor naming nit.




Comment at: include/clang/AST/ASTStructuralEquivalence.h:33
+  /// AST contexts for which we are checking structural equivalence.
+  ASTContext &C1, &C2;
+

FromCtx, ToCtx?


https://reviews.llvm.org/D31777



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


[PATCH] D32475: [clang-format] Don’t propagate AvoidBinPacking into argument subexpressions

2017-04-26 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

What happens if the function call where this happens actually does not have 
multiple parameters but one parameter with many operands, e.g. changing your 
test case to:

  arg3 + is + quite + long + so + it
  + f(arguments << of << its << subexpressions << lengthy << as << they
<< may << or__ << may)




Comment at: lib/Format/ContinuationIndenter.cpp:923
+// Don't propagate AvoidBinPacking into subexpressions of arg/param lists.
+if (Current.FakeLParens.size() > 0 &&
+Current.FakeLParens.back() > prec::Comma) {

I think you cannot get here if .size() is 0 as this is iterating over the 
elements.



Comment at: lib/Format/ContinuationIndenter.cpp:924
+if (Current.FakeLParens.size() > 0 &&
+Current.FakeLParens.back() > prec::Comma) {
+  NewParenState.AvoidBinPacking = false;

LLVM coding style doesn't use braces for single-statement-ifs



Comment at: unittests/Format/FormatTest.cpp:2596
+  FormatStyle Style = getLLVMStyle();
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;

Is this important?



Comment at: unittests/Format/FormatTest.cpp:2597
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;
+  Style.BinPackArguments = false;

Does this bug only happen when breaking before operators? If not can you add a 
test case with None?



Comment at: unittests/Format/FormatTest.cpp:2599
+  Style.BinPackArguments = false;
+  Style.BinPackParameters = false;
+  verifyFormat(StringRef(R"(

This is not tested/changed at all, I think.



Comment at: unittests/Format/FormatTest.cpp:2600
+  Style.BinPackParameters = false;
+  verifyFormat(StringRef(R"(
+someFunction(

Don't use raw strings to be more consistent with the rest. If we want, we 
should eventually convert all of the tests in one go.

Also, try to come up with a small reduced test case. Here you are actually 
testing much more than you want to test. Also, you set the ColumnLimit of Style 
in order to force earlier linebreaks.


https://reviews.llvm.org/D32475



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


[clang-tools-extra] r301440 - [clang-tidy] Support detecting for-range loop in inefficient-vector-operation check.

2017-04-26 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed Apr 26 13:13:05 2017
New Revision: 301440

URL: http://llvm.org/viewvc/llvm-project?rev=301440&view=rev
Log:
[clang-tidy] Support detecting for-range loop in inefficient-vector-operation 
check.

Summary:
Also add an option "VectorLikeClasses" allowing user specify customized
vectors.

Reviewers: alexfh, aaron.ballman

Reviewed By: alexfh

Subscribers: Eugene.Zelenko, cfe-commits

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

Modified:

clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.cpp

clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/performance-inefficient-vector-operation.rst

clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-vector-operation.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.cpp?rev=301440&r1=301439&r2=301440&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.cpp
 Wed Apr 26 13:13:05 2017
@@ -12,6 +12,7 @@
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Lex/Lexer.h"
 #include "../utils/DeclRefExprUtils.h"
+#include "../utils/OptionsUtils.h"
 
 using namespace clang::ast_matchers;
 
@@ -33,7 +34,7 @@ namespace {
 // \endcode
 //
 // The matcher names are bound to following parts of the AST:
-//   - LoopName: The entire for loop (as ForStmt).
+//   - LoopCounterName: The entire for loop (as ForStmt).
 //   - LoopParentName: The body of function f (as CompoundStmt).
 //   - VectorVarDeclName: 'v' in  (as VarDecl).
 //   - VectorVarDeclStmatName: The entire 'std::vector v;' statement (as
@@ -46,14 +47,34 @@ static const char LoopParentName[] = "lo
 static const char VectorVarDeclName[] = "vector_var_decl";
 static const char VectorVarDeclStmtName[] = "vector_var_decl_stmt";
 static const char PushBackCallName[] = "push_back_call";
-
 static const char LoopInitVarName[] = "loop_init_var";
 static const char LoopEndExprName[] = "loop_end_expr";
 
+static const char RangeLoopName[] = "for_range_loop";
+
+ast_matchers::internal::Matcher supportedContainerTypesMatcher() {
+  return hasType(cxxRecordDecl(hasAnyName(
+  "::std::vector", "::std::set", "::std::unordered_set", "::std::map",
+  "::std::unordered_map", "::std::array", "::std::dequeue")));
+}
+
 } // namespace
 
+InefficientVectorOperationCheck::InefficientVectorOperationCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  VectorLikeClasses(utils::options::parseStringList(
+  Options.get("VectorLikeClasses", "::std::vector"))) {}
+
+void InefficientVectorOperationCheck::storeOptions(
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "VectorLikeClasses",
+utils::options::serializeStringList(VectorLikeClasses));
+}
+
 void InefficientVectorOperationCheck::registerMatchers(MatchFinder *Finder) {
-  const auto VectorDecl = cxxRecordDecl(hasName("::std::vector"));
+  const auto VectorDecl = cxxRecordDecl(hasAnyName(SmallVector(
+  VectorLikeClasses.begin(), VectorLikeClasses.end(;
   const auto VectorDefaultConstructorCall = cxxConstructExpr(
   hasType(VectorDecl),
   hasDeclaration(cxxConstructorDecl(isDefaultConstructor(;
@@ -77,6 +98,12 @@ void InefficientVectorOperationCheck::re
   const auto RefersToLoopVar = ignoringParenImpCasts(
   declRefExpr(to(varDecl(equalsBoundNode(LoopInitVarName);
 
+  // Matchers for the loop whose body has only 1 push_back calling statement.
+  const auto HasInterestingLoopBody = hasBody(anyOf(
+  compoundStmt(statementCountIs(1), has(PushBackCall)), PushBackCall));
+  const auto InInterestingCompoundStmt =
+  hasParent(compoundStmt(has(VectorVarDefStmt)).bind(LoopParentName));
+
   // Match counter-based for loops:
   //  for (int i = 0; i < n; ++i) { v.push_back(...); }
   //
@@ -90,11 +117,20 @@ void InefficientVectorOperationCheck::re
  .bind(LoopEndExprName,
   hasIncrement(unaryOperator(hasOperatorName("++"),
  hasUnaryOperand(RefersToLoopVar))),
-  hasBody(anyOf(compoundStmt(statementCountIs(1), has(PushBackCall)),
-PushBackCall)),
-  hasParent(compoundStmt(has(VectorVarDefStmt)).bind(LoopParentName)))
+  HasInterestingLoopBody, InInterestingCompoundStmt)
   .bind(LoopCounterName),
   this);
+
+  // Match for-range loops:
+  //   for (const auto& E : data) { v.push_back(...); }
+  //
+  // FIXME: Support more complex range-expressions.
+  Finder->addMatcher(
+  cxx

[PATCH] D32436: [clang-tidy] Support detecting for-range loop in inefficient-vector-operation check.

2017-04-26 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL301440: [clang-tidy] Support detecting for-range loop in 
inefficient-vector-operation… (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D32436?vs=96775&id=96793#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32436

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

Index: clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-vector-operation.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-vector-operation.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-vector-operation.cpp
@@ -1,9 +1,27 @@
-// RUN: %check_clang_tidy %s performance-inefficient-vector-operation %t -- -format-style=llvm --
+// RUN: %check_clang_tidy %s performance-inefficient-vector-operation %t -- -format-style=llvm -- --std=c++11
 
 namespace std {
 
 typedef int size_t;
 
+template class initializer_list {
+public:
+  using value_type = E;
+  using reference = E&;
+  using const_reference = const E&;
+  using size_type = size_t;
+  using iterator = const E*;
+  using const_iterator = const E*;
+  initializer_list();
+  size_t size() const; // number of elements
+  const E* begin() const; // first element
+  const E* end() const; // one past the last element
+};
+
+// initializer list range access
+template const E* begin(initializer_list il);
+template const E* end(initializer_list il);
+
 template 
 class vector {
  public:
@@ -23,9 +41,24 @@
   size_t size();
   const_reference operator[] (size_type) const;
   reference operator[] (size_type);
+
+  const_iterator begin() const;
+  const_iterator end() const;
 };
 } // namespace std
 
+class Foo {
+ public:
+  explicit Foo(int);
+};
+
+class Bar {
+ public:
+  Bar(int);
+};
+
+int Op(int);
+
 void f(std::vector& t) {
   {
 std::vector v;
@@ -85,7 +118,38 @@
   v.push_back(t[i]);
 } // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
   }
-
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(t.size());
+for (const auto &e : t) {
+  v.push_back(e);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
+}
+  }
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(t.size());
+for (const auto &e : t) {
+  v.push_back(Op(e));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
+}
+  }
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(t.size());
+for (const auto &e : t) {
+  v.push_back(Foo(e));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
+}
+  }
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(t.size());
+for (const auto &e : t) {
+  v.push_back(e);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
+}
+  }
   //  Non-fixed Cases 
   {
 std::vector v;
@@ -181,4 +245,21 @@
   v.push_back(t[i]);
 }
   }
+  {
+std::vector v;
+// initializer_list should not trigger the check.
+for (int e : {1, 2, 3, 4, 5}) {
+  v.push_back(e);
+}
+  }
+  {
+std::vector v;
+std::vector* v2 = &t;
+// We only support detecting the range init expression which references
+// container directly.
+// Complex range init expressions like `*v2` is not supported.
+for (const auto &e : *v2) {
+  v.push_back(e);
+}
+  }
 }
Index: clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.h
+++ clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.h
@@ -23,10 +23,13 @@
 /// http://clang.llvm.org/extra/clang-tidy/checks/performance-inefficient-vector-operation.html
 class InefficientVectorOperationCheck : public ClangTidyCheck {
 public:
-  InefficientVectorOperationCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  InefficientVectorOperationCheck(StringRef Name, ClangTidyContext *Context);
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+
+private:
+  const std::vector VectorLikeClasses;
 };
 
 } // namespace performance
Index: clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/performance/

[PATCH] D31588: Fix PR25627: Certain constant local variables must be usable as template arguments (without being odr-used)

2017-04-26 Thread Richard Smith via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Parse/ParseTemplate.cpp:1203-1204
+  {
+EnterExpressionEvaluationContext EnterConstantEvaluated(
+Actions, Sema::ExpressionEvaluationContext::ConstantEvaluated);
+if (isCXXTypeId(TypeIdAsTemplateArgument)) {

Please add a comment here, something like:

isCXXTypeId might look up and annotate an identifier as an id-expression during 
disambiguation, so enter the appropriate context for a constant expression 
template argument before trying to disambiguate.



Comment at: lib/Parse/ParseTemplate.cpp:1214-1243
+} else {
+  // If we disambiguated as an expression that we identified as potentially
+  // not being odr-used (consistent with a template argument context), and
+  // annotated our token as that expression, then remove it from the
+  // MaybeODRUsedExprs so that it doesn't trigger a false error, since it
+  // would otherwise have been removed when completing processing of a
+  // constant expression.

... we shouldn't need to do any of this: instead, keep your 
`ExprEvaluationContext` alive through the call to `ParseConstantExpression`, 
and tell it to not create its own context in this case.



Comment at: lib/Parse/ParseTemplate.cpp:1234-1237
+// it for later since we can be certain that this expression would
+// eventually have been removed during ActOnConstantExpression called
+// from ParseConstantExpression when parsing the non-type template
+// argument below.  Eitherway, the appropriate checking for an

This doesn't seem right. If the template parameter is of reference type, the 
named entity should be considered to be odr-used. And likewise just because we 
stopped disambiguation after finding an id-expression that names a non-type, 
that does not imply that the overall template argument is the entity named by 
that id-expression. (Eg, consider `X`, where `F` is a functor whose 
`operator()` returns `this` -- that template argument should be considered to 
odr-use `F`.) But...


Repository:
  rL LLVM

https://reviews.llvm.org/D31588



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


[PATCH] D32342: Changed llvm/CMakeLists.txt and added relative path to llvm doxygen

2017-04-26 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev accepted this revision.
v.g.vassilev added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D32342



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


[PATCH] D32550: Supress all uses of LLVM_END_WITH_NULL

2017-04-26 Thread serge via Phabricator via cfe-commits
serge-sans-paille created this revision.

Variadic templates are type safer, easier to use and don't require the extra 
sentinel.


https://reviews.llvm.org/D32550

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCUDANV.cpp
  lib/CodeGen/CGCleanup.cpp
  lib/CodeGen/CGException.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGObjCGNU.cpp
  lib/CodeGen/CGObjCMac.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
  lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
  lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  lib/StaticAnalyzer/Checkers/SelectorExtras.h

Index: lib/StaticAnalyzer/Checkers/SelectorExtras.h
===
--- lib/StaticAnalyzer/Checkers/SelectorExtras.h
+++ lib/StaticAnalyzer/Checkers/SelectorExtras.h
@@ -11,48 +11,26 @@
 #define LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_SELECTOREXTRAS_H
 
 #include "clang/AST/ASTContext.h"
-#include 
 
 namespace clang {
 namespace ento {
 
-static inline Selector getKeywordSelectorImpl(ASTContext &Ctx,
-  const char *First,
-  va_list argp) {
-  SmallVector II;
-  II.push_back(&Ctx.Idents.get(First));
-
-  while (const char *s = va_arg(argp, const char *))
-II.push_back(&Ctx.Idents.get(s));
+template 
+static inline Selector getKeywordSelector(ASTContext &Ctx,
+  IdentifierInfos *... IIs) {
+  static_assert(sizeof...(IdentifierInfos),
+"keyword selectors must have at least one argument");
+  SmallVector II{{&Ctx.Idents.get(IIs)...}};
 
   return Ctx.Selectors.getSelector(II.size(), &II[0]);
 }
 
-static inline Selector getKeywordSelector(ASTContext &Ctx, va_list argp) {
-  const char *First = va_arg(argp, const char *);
-  assert(First && "keyword selectors must have at least one argument");
-  return getKeywordSelectorImpl(Ctx, First, argp);
-}
-
-LLVM_END_WITH_NULL
-static inline Selector getKeywordSelector(ASTContext &Ctx,
-  const char *First, ...) {
-  va_list argp;
-  va_start(argp, First);
-  Selector result = getKeywordSelectorImpl(Ctx, First, argp);
-  va_end(argp);
-  return result;
-}
-
-LLVM_END_WITH_NULL
+template 
 static inline void lazyInitKeywordSelector(Selector &Sel, ASTContext &Ctx,
-   const char *First, ...) {
+   IdentifierInfos *... IIs) {
   if (!Sel.isNull())
 return;
-  va_list argp;
-  va_start(argp, First);
-  Sel = getKeywordSelectorImpl(Ctx, First, argp);
-  va_end(argp);
+  Sel = getKeywordSelector(Ctx, IIs...);
 }
 
 static inline void lazyInitNullarySelector(Selector &Sel, ASTContext &Ctx,
Index: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
@@ -703,31 +703,30 @@
 ObjCMethodSummaries[ObjCSummaryKey(ClsII, S)]  = Summ;
   }
 
+  template 
   void addMethodSummary(IdentifierInfo *ClsII, ObjCMethodSummariesTy &Summaries,
-const RetainSummary *Summ, va_list argp) {
-Selector S = getKeywordSelector(Ctx, argp);
+const RetainSummary *Summ, Keywords *... Kws) {
+Selector S = getKeywordSelector(Ctx, Kws...);
 Summaries[ObjCSummaryKey(ClsII, S)] = Summ;
   }
 
-  void addInstMethSummary(const char* Cls, const RetainSummary * Summ, ...) {
-va_list argp;
-va_start(argp, Summ);
-addMethodSummary(&Ctx.Idents.get(Cls), ObjCMethodSummaries, Summ, argp);
-va_end(argp);
-  }
-
-  void addClsMethSummary(const char* Cls, const RetainSummary * Summ, ...) {
-va_list argp;
-va_start(argp, Summ);
-addMethodSummary(&Ctx.Idents.get(Cls),ObjCClassMethodSummaries, Summ, argp);
-va_end(argp);
-  }
-
-  void addClsMethSummary(IdentifierInfo *II, const RetainSummary * Summ, ...) {
-va_list argp;
-va_start(argp, Summ);
-addMethodSummary(II, ObjCClassMethodSummaries, Summ, argp);
-va_end(argp);
+  template 
+  void addInstMethSummary(const char *Cls, const RetainSummary *Summ,
+  Keywords *... Kws) {
+addMethodSummary(&Ctx.Idents.get(Cls), ObjCMethodSummaries, Summ, Kws...);
+  }
+
+  template 
+  void addClsMethSummary(const char *Cls, const RetainSummary *Summ,
+ Keywords *... Kws) {
+addMethodSummary(&Ctx.Idents.get(Cls), ObjCClassMethodSummaries, Summ,
+ Kws...);
+  }
+
+  template 
+  void addClsMethSummary(IdentifierInfo *II, const RetainSummary *Summ,
+ Keywords *... Kws) {
+addMethodSummary(II, ObjCClas

[PATCH] D32475: [clang-format] Don’t propagate AvoidBinPacking into argument subexpressions

2017-04-26 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes added a comment.

Thanks for the feedback, I'll work on making those changes.

In https://reviews.llvm.org/D32475#738425, @djasper wrote:

> What happens if the function call where this happens actually does not have 
> multiple parameters but one parameter with many operands, e.g. changing your 
> test case to:
>
>   arg3 + is + quite + long + so + it
>   + f(arguments << of << its << subexpressions << lengthy << as << they
> << may << or__ << may)


I don't think this is relevant to what I am trying to fix. The issue being 
fixed is specifically with multiple arguments: I don't want 
BinPackArguments=false to affect bin-packing of an individual argument. For 
completeness, though, I can include a test case with one argument.




Comment at: lib/Format/ContinuationIndenter.cpp:923
+// Don't propagate AvoidBinPacking into subexpressions of arg/param lists.
+if (Current.FakeLParens.size() > 0 &&
+Current.FakeLParens.back() > prec::Comma) {

djasper wrote:
> I think you cannot get here if .size() is 0 as this is iterating over the 
> elements.
Good point, thanks.



Comment at: unittests/Format/FormatTest.cpp:2596
+  FormatStyle Style = getLLVMStyle();
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;

djasper wrote:
> Is this important?
Not really. I can remove it.


https://reviews.llvm.org/D32475



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


[PATCH] D32475: [clang-format] Don’t propagate AvoidBinPacking into argument subexpressions

2017-04-26 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes added inline comments.



Comment at: lib/Format/ContinuationIndenter.cpp:923
+// Don't propagate AvoidBinPacking into subexpressions of arg/param lists.
+if (Current.FakeLParens.size() > 0 &&
+Current.FakeLParens.back() > prec::Comma) {

jtbandes wrote:
> djasper wrote:
> > I think you cannot get here if .size() is 0 as this is iterating over the 
> > elements.
> Good point, thanks.
Actually, I can probably just use `*I > prec::Comma`.


https://reviews.llvm.org/D32475



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


r301442 - Refactor frontend InputKind to prepare for treating module maps as a distinct kind of input.

2017-04-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Apr 26 13:57:40 2017
New Revision: 301442

URL: http://llvm.org/viewvc/llvm-project?rev=301442&view=rev
Log:
Refactor frontend InputKind to prepare for treating module maps as a distinct 
kind of input.

No functionality change intended.

Modified:
cfe/trunk/include/clang/Frontend/FrontendOptions.h
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/FrontendAction.cpp
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Frontend/FrontendOptions.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
cfe/trunk/unittests/Frontend/CodeGenActionTest.cpp
cfe/trunk/unittests/Frontend/FrontendActionTest.cpp

Modified: cfe/trunk/include/clang/Frontend/FrontendOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendOptions.h?rev=301442&r1=301441&r2=301442&view=diff
==
--- cfe/trunk/include/clang/Frontend/FrontendOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendOptions.h Wed Apr 26 13:57:40 2017
@@ -62,25 +62,63 @@ namespace frontend {
   };
 }
 
-enum InputKind {
-  IK_None,
-  IK_Asm,
-  IK_C,
-  IK_CXX,
-  IK_ObjC,
-  IK_ObjCXX,
-  IK_PreprocessedC,
-  IK_PreprocessedCXX,
-  IK_PreprocessedObjC,
-  IK_PreprocessedObjCXX,
-  IK_OpenCL,
-  IK_CUDA,
-  IK_PreprocessedCuda,
-  IK_RenderScript,
-  IK_AST,
-  IK_LLVM_IR
-};
+/// The kind of a file that we've been handed as an input.
+class InputKind {
+private:
+  unsigned Lang : 4;
+  unsigned Fmt : 3;
+  unsigned Preprocessed : 1;
+
+public:
+  /// The language for the input, used to select and validate the language
+  /// standard and possible actions.
+  enum Language {
+Unknown,
+
+/// Assembly: we accept this only so that we can preprocess it.
+Asm,
+
+/// LLVM IR: we accept this so that we can run the optimizer on it,
+/// and compile it to assembly or object code.
+LLVM_IR,
+
+///@{ Languages that the frontend can parse and compile.
+C,
+CXX,
+ObjC,
+ObjCXX,
+OpenCL,
+CUDA,
+RenderScript,
+///@}
+  };
+
+  /// The input file format.
+  enum Format {
+Source,
+ModuleMap,
+Precompiled
+  };
 
+  constexpr InputKind(Language L = Unknown, bool PP = false)
+  : Lang(L), Fmt(Source), Preprocessed(PP) {}
+  constexpr InputKind(Language L, Format F, bool PP = false)
+  : Lang(L), Fmt(F), Preprocessed(PP) {}
+
+  Language getLanguage() const { return static_cast(Lang); }
+  Format getFormat() const { return static_cast(Fmt); }
+  bool isPreprocessed() const { return Preprocessed; }
+
+  /// Is the input kind fully-unknown?
+  bool isUnknown() const { return Lang == Unknown && Fmt == Source; }
+
+  /// Is the language of the input some dialect of Objective-C?
+  bool isObjectiveC() const { return Lang == ObjC || Lang == ObjCXX; }
+
+  InputKind getPreprocessed() const {
+return InputKind(getLanguage(), getFormat(), true);
+  }
+};
 
 /// \brief An input file for the front end.
 class FrontendInputFile {
@@ -96,7 +134,7 @@ class FrontendInputFile {
   bool IsSystem;
 
 public:
-  FrontendInputFile() : Buffer(nullptr), Kind(IK_None), IsSystem(false) { }
+  FrontendInputFile() : Buffer(nullptr), Kind(), IsSystem(false) { }
   FrontendInputFile(StringRef File, InputKind Kind, bool IsSystem = false)
 : File(File.str()), Buffer(nullptr), Kind(Kind), IsSystem(IsSystem) { }
   FrontendInputFile(llvm::MemoryBuffer *buffer, InputKind Kind,
@@ -109,13 +147,7 @@ public:
   bool isEmpty() const { return File.empty() && Buffer == nullptr; }
   bool isFile() const { return !isBuffer(); }
   bool isBuffer() const { return Buffer != nullptr; }
-  bool isPreprocessed() const {
-return Kind == IK_PreprocessedC ||
-   Kind == IK_PreprocessedCXX ||
-   Kind == IK_PreprocessedObjC ||
-   Kind == IK_PreprocessedObjCXX ||
-   Kind == IK_PreprocessedCuda;
-  }
+  bool isPreprocessed() const { return Kind.isPreprocessed(); }
 
   StringRef getFile() const {
 assert(isFile());
@@ -299,10 +331,10 @@ public:
   {}
 
   /// getInputKindForExtension - Return the appropriate input kind for a file
-  /// extension. For example, "c" would return IK_C.
+  /// extension. For example, "c" would return InputKind::C.
   ///
-  /// \return The input kind for the extension, or IK_None if the extension is
-  /// not recognized.
+  /// \return The input kind for the extension, or InputKind::Unknown if the
+  /// extension is not recognized.
   static InputKind getInputKindForExtension(StringRef Extension);
 };
 

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=301442&r1=301441&r2=301442&view=diff
=

[PATCH] D32401: [Devirtualization] insert placement new barrier with -O0

2017-04-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D32401#735127, @Prazek wrote:

> In https://reviews.llvm.org/D32401#734921, @rjmccall wrote:
>
> > I continue to be really uncomfortable with the entire design of this 
> > optimization, which appears to miscompile code by default, but as long as 
> > nobody's suggesting that we actually turn it on by default, I guess it can 
> > be your little research-compiler playground.  It might be better to 
> > downgrade it to a -cc1 option, though.
> >
> > This specific change is fine by me.
>
>
> Can you tell me a little more about what part of the design you dislike? Is 
> it about missing optimizations by introducing the barriers, cost of inserting 
> the barriers or the fact that we have to be cautious to not break anything?


The latter.  The optimization design seems to rely on anticipating every case 
that should disable the optimization, hence this patch adding special-case 
logic to the frontend, and the 3 other patches you've got out for review adding 
special-case logic to different parts of the frontend, all on top of a ton of 
special-case logic in yet more parts of the frontend from when you implemented 
the optimization in the first place.  There is an additive problem here where 
suddenly the design of this specific optimizaton becomes an affirmative burden 
to basically all the code in the frontend and, presumably, the middle-end and 
beyond, as opposed to just defaulting to correct behavior.  There is zero 
chance that this latest collection of changes is actually fixing all of the 
problems; it's just papering over the next round of testing.

I'm very sympathetic, because I know this is an important optimization, but 
it's not clear to me that it's actually reasonable to implement in LLVM.

John.


https://reviews.llvm.org/D32401



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


r301449 - PPCallbacks::MacroUndefined, change signature and add test.

2017-04-26 Thread Frederich Munch via cfe-commits
Author: marsupial
Date: Wed Apr 26 14:47:31 2017
New Revision: 301449

URL: http://llvm.org/viewvc/llvm-project?rev=301449&view=rev
Log:
PPCallbacks::MacroUndefined, change signature and add test.

Summary:
The PPCallbacks::MacroUndefined callback is currently insufficient for clients 
that need to track the MacroDirectives.
This patch adds an additional argument to PPCallbacks::MacroUndefined that is 
the undef MacroDirective.

Reviewers: bruno, manmanren

Reviewed By: bruno

Subscribers: nemanjai, cfe-commits

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

Modified:
cfe/trunk/include/clang/Lex/PPCallbacks.h
cfe/trunk/include/clang/Lex/PreprocessingRecord.h
cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/lib/Lex/PreprocessingRecord.cpp
cfe/trunk/tools/libclang/Indexing.cpp
cfe/trunk/unittests/Basic/SourceManagerTest.cpp

Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPCallbacks.h?rev=301449&r1=301448&r2=301449&view=diff
==
--- cfe/trunk/include/clang/Lex/PPCallbacks.h (original)
+++ cfe/trunk/include/clang/Lex/PPCallbacks.h Wed Apr 26 14:47:31 2017
@@ -247,10 +247,14 @@ public:
   }
 
   /// \brief Hook called whenever a macro \#undef is seen.
+  /// \param Token The active Token
+  /// \param MD A MacroDefinition for the named macro.
+  /// \param Undef New MacroDirective if the macro was defined, null otherwise.
   ///
   /// MD is released immediately following this callback.
   virtual void MacroUndefined(const Token &MacroNameTok,
-  const MacroDefinition &MD) {
+  const MacroDefinition &MD,
+  const MacroDirective *Undef) {
   }
   
   /// \brief Hook called whenever the 'defined' operator is seen.
@@ -439,15 +443,17 @@ public:
 Second->MacroExpands(MacroNameTok, MD, Range, Args);
   }
 
-  void MacroDefined(const Token &MacroNameTok, const MacroDirective *MD) 
override {
+  void MacroDefined(const Token &MacroNameTok,
+const MacroDirective *MD) override {
 First->MacroDefined(MacroNameTok, MD);
 Second->MacroDefined(MacroNameTok, MD);
   }
 
   void MacroUndefined(const Token &MacroNameTok,
-  const MacroDefinition &MD) override {
-First->MacroUndefined(MacroNameTok, MD);
-Second->MacroUndefined(MacroNameTok, MD);
+  const MacroDefinition &MD,
+  const MacroDirective *Undef) override {
+First->MacroUndefined(MacroNameTok, MD, Undef);
+Second->MacroUndefined(MacroNameTok, MD, Undef);
   }
 
   void Defined(const Token &MacroNameTok, const MacroDefinition &MD,

Modified: cfe/trunk/include/clang/Lex/PreprocessingRecord.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessingRecord.h?rev=301449&r1=301448&r2=301449&view=diff
==
--- cfe/trunk/include/clang/Lex/PreprocessingRecord.h (original)
+++ cfe/trunk/include/clang/Lex/PreprocessingRecord.h Wed Apr 26 14:47:31 2017
@@ -488,7 +488,8 @@ namespace clang {
 void MacroExpands(const Token &Id, const MacroDefinition &MD,
   SourceRange Range, const MacroArgs *Args) override;
 void MacroDefined(const Token &Id, const MacroDirective *MD) override;
-void MacroUndefined(const Token &Id, const MacroDefinition &MD) override;
+void MacroUndefined(const Token &Id, const MacroDefinition &MD,
+const MacroDirective *Undef) override;
 void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
 StringRef FileName, bool IsAngled,
 CharSourceRange FilenameRange,

Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=301449&r1=301448&r2=301449&view=diff
==
--- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)
+++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Wed Apr 26 14:47:31 2017
@@ -172,7 +172,8 @@ public:
 
   /// MacroUndefined - This hook is called whenever a macro #undef is seen.
   void MacroUndefined(const Token &MacroNameTok,
-  const MacroDefinition &MD) override;
+  const MacroDefinition &MD,
+  const MacroDirective *Undef) override;
 };
 }  // end anonymous namespace
 
@@ -389,7 +390,8 @@ void PrintPPOutputPPCallbacks::MacroDefi
 }
 
 void PrintPPOutputPPCallbacks::MacroUndefined(const Token &MacroNameTok,
-  const MacroDefinition &MD) {
+  const MacroDefinition &M

[PATCH] D29923: PPCallbacks::MacroUndefined, change signature and add test.

2017-04-26 Thread Frederich Munch via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL301449: PPCallbacks::MacroUndefined, change signature and 
add test. (authored by marsupial).

Changed prior to commit:
  https://reviews.llvm.org/D29923?vs=91627&id=96808#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29923

Files:
  cfe/trunk/include/clang/Lex/PPCallbacks.h
  cfe/trunk/include/clang/Lex/PreprocessingRecord.h
  cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
  cfe/trunk/lib/Lex/PPDirectives.cpp
  cfe/trunk/lib/Lex/PreprocessingRecord.cpp
  cfe/trunk/tools/libclang/Indexing.cpp
  cfe/trunk/unittests/Basic/SourceManagerTest.cpp

Index: cfe/trunk/include/clang/Lex/PreprocessingRecord.h
===
--- cfe/trunk/include/clang/Lex/PreprocessingRecord.h
+++ cfe/trunk/include/clang/Lex/PreprocessingRecord.h
@@ -488,7 +488,8 @@
 void MacroExpands(const Token &Id, const MacroDefinition &MD,
   SourceRange Range, const MacroArgs *Args) override;
 void MacroDefined(const Token &Id, const MacroDirective *MD) override;
-void MacroUndefined(const Token &Id, const MacroDefinition &MD) override;
+void MacroUndefined(const Token &Id, const MacroDefinition &MD,
+const MacroDirective *Undef) override;
 void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
 StringRef FileName, bool IsAngled,
 CharSourceRange FilenameRange,
Index: cfe/trunk/include/clang/Lex/PPCallbacks.h
===
--- cfe/trunk/include/clang/Lex/PPCallbacks.h
+++ cfe/trunk/include/clang/Lex/PPCallbacks.h
@@ -247,10 +247,14 @@
   }
 
   /// \brief Hook called whenever a macro \#undef is seen.
+  /// \param Token The active Token
+  /// \param MD A MacroDefinition for the named macro.
+  /// \param Undef New MacroDirective if the macro was defined, null otherwise.
   ///
   /// MD is released immediately following this callback.
   virtual void MacroUndefined(const Token &MacroNameTok,
-  const MacroDefinition &MD) {
+  const MacroDefinition &MD,
+  const MacroDirective *Undef) {
   }
   
   /// \brief Hook called whenever the 'defined' operator is seen.
@@ -439,15 +443,17 @@
 Second->MacroExpands(MacroNameTok, MD, Range, Args);
   }
 
-  void MacroDefined(const Token &MacroNameTok, const MacroDirective *MD) override {
+  void MacroDefined(const Token &MacroNameTok,
+const MacroDirective *MD) override {
 First->MacroDefined(MacroNameTok, MD);
 Second->MacroDefined(MacroNameTok, MD);
   }
 
   void MacroUndefined(const Token &MacroNameTok,
-  const MacroDefinition &MD) override {
-First->MacroUndefined(MacroNameTok, MD);
-Second->MacroUndefined(MacroNameTok, MD);
+  const MacroDefinition &MD,
+  const MacroDirective *Undef) override {
+First->MacroUndefined(MacroNameTok, MD, Undef);
+Second->MacroUndefined(MacroNameTok, MD, Undef);
   }
 
   void Defined(const Token &MacroNameTok, const MacroDefinition &MD,
Index: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
===
--- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
+++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -172,7 +172,8 @@
 
   /// MacroUndefined - This hook is called whenever a macro #undef is seen.
   void MacroUndefined(const Token &MacroNameTok,
-  const MacroDefinition &MD) override;
+  const MacroDefinition &MD,
+  const MacroDirective *Undef) override;
 };
 }  // end anonymous namespace
 
@@ -389,7 +390,8 @@
 }
 
 void PrintPPOutputPPCallbacks::MacroUndefined(const Token &MacroNameTok,
-  const MacroDefinition &MD) {
+  const MacroDefinition &MD,
+  const MacroDirective *Undef) {
   // Only print out macro definitions in -dD mode.
   if (!DumpDefines) return;
 
Index: cfe/trunk/lib/Lex/PreprocessingRecord.cpp
===
--- cfe/trunk/lib/Lex/PreprocessingRecord.cpp
+++ cfe/trunk/lib/Lex/PreprocessingRecord.cpp
@@ -422,7 +422,8 @@
 }
 
 void PreprocessingRecord::MacroUndefined(const Token &Id,
- const MacroDefinition &MD) {
+ const MacroDefinition &MD,
+ const MacroDirective *Undef) {
   MD.forAllDefinitions([&](MacroInfo *MI) { MacroDefinitions.erase(MI); });
 }
 
Index: cfe/trunk/lib/Lex/PPDirectives.cpp
===
--- cfe/trunk/lib/Lex/PPDirecti

[PATCH] D32401: [Devirtualization] insert placement new barrier with -O0

2017-04-26 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

I tend to agree with @rjmccall on the principle. Howerever:

> The optimization design seems to rely on anticipating every case that should 
> disable the optimization, hence this patch adding special-case logic to the 
> frontend, and the 3 other patch

I believe this is patch is *removing* a special case logic that was wrong.

I agree that the whole system should be "safe". But I'm not sure it is unsafe 
as it is designed: if we are already issuing an error when merging two modules 
that have different settings IIUC.


https://reviews.llvm.org/D32401



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


[PATCH] D32475: [clang-format] Don’t propagate AvoidBinPacking into argument subexpressions

2017-04-26 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

My point is though that even with only one argument, the BinPackArguments 
setting might lead to this bug. If not, that's good :).


https://reviews.llvm.org/D32475



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


[PATCH] D32475: [clang-format] Don’t propagate AvoidBinPacking into argument subexpressions

2017-04-26 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes added inline comments.



Comment at: unittests/Format/FormatTest.cpp:2597
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;
+  Style.BinPackArguments = false;

djasper wrote:
> Does this bug only happen when breaking before operators? If not can you add 
> a test case with None?
Yeah it is only when breaking before operators, because the condition which 
causes `mustBreak` to be true includes `Current.CanBreakBefore`.



Comment at: unittests/Format/FormatTest.cpp:2599
+  Style.BinPackArguments = false;
+  Style.BinPackParameters = false;
+  verifyFormat(StringRef(R"(

djasper wrote:
> This is not tested/changed at all, I think.
That's a good point. I had this because my test code is a function call at the 
top level, which is treated as a signature rather than a call. I will wrap it 
in another block and remove the BinPackParameters setting.


https://reviews.llvm.org/D32475



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


r301453 - [Modules] Fix a crash-on-invalid with overloaded functions

2017-04-26 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Apr 26 15:13:45 2017
New Revision: 301453

URL: http://llvm.org/viewvc/llvm-project?rev=301453&view=rev
Log:
[Modules] Fix a crash-on-invalid with overloaded functions

Do not add an overload if the function doesn't have a prototype; this
can happen if, for instance, a misplaced/malformed call site is
considered like a declaration for recovery purposes.

rdar://problem/31306325

Added:
cfe/trunk/test/Modules/Inputs/malformed-overload/
cfe/trunk/test/Modules/Inputs/malformed-overload/X.h
cfe/trunk/test/Modules/Inputs/malformed-overload/module.modulemap
cfe/trunk/test/Modules/malformed-overload.m
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=301453&r1=301452&r2=301453&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Apr 26 15:13:45 2017
@@ -11426,6 +11426,10 @@ static void AddOverloadedCallCandidate(S
   assert(!KnownValid && "Explicit template arguments?");
   return;
 }
+// Prevent ill-formed function decls to be added as overload candidates.
+if (!dyn_cast(Func->getType()->getAs()))
+  return;
+
 S.AddOverloadCandidate(Func, FoundDecl, Args, CandidateSet,
/*SuppressUsedConversions=*/false,
PartialOverloading);

Added: cfe/trunk/test/Modules/Inputs/malformed-overload/X.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/malformed-overload/X.h?rev=301453&view=auto
==
--- cfe/trunk/test/Modules/Inputs/malformed-overload/X.h (added)
+++ cfe/trunk/test/Modules/Inputs/malformed-overload/X.h Wed Apr 26 15:13:45 
2017
@@ -0,0 +1,2 @@
+@class NSString;
+extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 
1, 2))) __attribute__((not_tail_called));

Added: cfe/trunk/test/Modules/Inputs/malformed-overload/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/malformed-overload/module.modulemap?rev=301453&view=auto
==
--- cfe/trunk/test/Modules/Inputs/malformed-overload/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/malformed-overload/module.modulemap Wed Apr 
26 15:13:45 2017
@@ -0,0 +1,4 @@
+module X {
+  header "X.h"
+  export *
+}

Added: cfe/trunk/test/Modules/malformed-overload.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/malformed-overload.m?rev=301453&view=auto
==
--- cfe/trunk/test/Modules/malformed-overload.m (added)
+++ cfe/trunk/test/Modules/malformed-overload.m Wed Apr 26 15:13:45 2017
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -I%S/Inputs/malformed-overload -fmodules 
-fimplicit-module-maps -fmodules-cache-path=tmp -verify %s
+NSLog(@"%@", path); // expected-error {{expected parameter declarator}} 
expected-error {{expected ')'}} expected-warning {{type specifier missing}} 
expected-warning {{incompatible redeclaration}} expected-note {{to match this 
'('}} expected-note {{'NSLog' is a builtin with type}}
+#import "X.h"
+
+@class NSString;
+void f(NSString *a) {
+ NSLog(@"* failed to get URL for %@", a);
+}


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


Re: r301449 - PPCallbacks::MacroUndefined, change signature and add test.

2017-04-26 Thread Hans Wennborg via cfe-commits
The bots are red, e.g.
http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/4342

On Wed, Apr 26, 2017 at 12:47 PM, Frederich Munch via cfe-commits
 wrote:
> Author: marsupial
> Date: Wed Apr 26 14:47:31 2017
> New Revision: 301449
>
> URL: http://llvm.org/viewvc/llvm-project?rev=301449&view=rev
> Log:
> PPCallbacks::MacroUndefined, change signature and add test.
>
> Summary:
> The PPCallbacks::MacroUndefined callback is currently insufficient for 
> clients that need to track the MacroDirectives.
> This patch adds an additional argument to PPCallbacks::MacroUndefined that is 
> the undef MacroDirective.
>
> Reviewers: bruno, manmanren
>
> Reviewed By: bruno
>
> Subscribers: nemanjai, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D29923
>
> Modified:
> cfe/trunk/include/clang/Lex/PPCallbacks.h
> cfe/trunk/include/clang/Lex/PreprocessingRecord.h
> cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
> cfe/trunk/lib/Lex/PPDirectives.cpp
> cfe/trunk/lib/Lex/PreprocessingRecord.cpp
> cfe/trunk/tools/libclang/Indexing.cpp
> cfe/trunk/unittests/Basic/SourceManagerTest.cpp
>
> Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPCallbacks.h?rev=301449&r1=301448&r2=301449&view=diff
> ==
> --- cfe/trunk/include/clang/Lex/PPCallbacks.h (original)
> +++ cfe/trunk/include/clang/Lex/PPCallbacks.h Wed Apr 26 14:47:31 2017
> @@ -247,10 +247,14 @@ public:
>}
>
>/// \brief Hook called whenever a macro \#undef is seen.
> +  /// \param Token The active Token
> +  /// \param MD A MacroDefinition for the named macro.
> +  /// \param Undef New MacroDirective if the macro was defined, null 
> otherwise.
>///
>/// MD is released immediately following this callback.
>virtual void MacroUndefined(const Token &MacroNameTok,
> -  const MacroDefinition &MD) {
> +  const MacroDefinition &MD,
> +  const MacroDirective *Undef) {
>}
>
>/// \brief Hook called whenever the 'defined' operator is seen.
> @@ -439,15 +443,17 @@ public:
>  Second->MacroExpands(MacroNameTok, MD, Range, Args);
>}
>
> -  void MacroDefined(const Token &MacroNameTok, const MacroDirective *MD) 
> override {
> +  void MacroDefined(const Token &MacroNameTok,
> +const MacroDirective *MD) override {
>  First->MacroDefined(MacroNameTok, MD);
>  Second->MacroDefined(MacroNameTok, MD);
>}
>
>void MacroUndefined(const Token &MacroNameTok,
> -  const MacroDefinition &MD) override {
> -First->MacroUndefined(MacroNameTok, MD);
> -Second->MacroUndefined(MacroNameTok, MD);
> +  const MacroDefinition &MD,
> +  const MacroDirective *Undef) override {
> +First->MacroUndefined(MacroNameTok, MD, Undef);
> +Second->MacroUndefined(MacroNameTok, MD, Undef);
>}
>
>void Defined(const Token &MacroNameTok, const MacroDefinition &MD,
>
> Modified: cfe/trunk/include/clang/Lex/PreprocessingRecord.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessingRecord.h?rev=301449&r1=301448&r2=301449&view=diff
> ==
> --- cfe/trunk/include/clang/Lex/PreprocessingRecord.h (original)
> +++ cfe/trunk/include/clang/Lex/PreprocessingRecord.h Wed Apr 26 14:47:31 2017
> @@ -488,7 +488,8 @@ namespace clang {
>  void MacroExpands(const Token &Id, const MacroDefinition &MD,
>SourceRange Range, const MacroArgs *Args) override;
>  void MacroDefined(const Token &Id, const MacroDirective *MD) override;
> -void MacroUndefined(const Token &Id, const MacroDefinition &MD) override;
> +void MacroUndefined(const Token &Id, const MacroDefinition &MD,
> +const MacroDirective *Undef) override;
>  void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
>  StringRef FileName, bool IsAngled,
>  CharSourceRange FilenameRange,
>
> Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=301449&r1=301448&r2=301449&view=diff
> ==
> --- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)
> +++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Wed Apr 26 14:47:31 
> 2017
> @@ -172,7 +172,8 @@ public:
>
>/// MacroUndefined - This hook is called whenever a macro #undef is seen.
>void MacroUndefined(const Token &MacroNameTok,
> -  const MacroDefinition &MD) override;
> +  const MacroDefinition &MD,
> +  

[PATCH] D32543: [X86] Clang option -fuse-init-array has no effect when generating for MCU target

2017-04-26 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

Do you need a front-end test? Since the changes are in the backend, I think 
it's better to add the test to the backend (using llc).


https://reviews.llvm.org/D32543



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


[PATCH] D32475: [clang-format] Don’t propagate AvoidBinPacking into argument subexpressions

2017-04-26 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes updated this revision to Diff 96815.
jtbandes marked 6 inline comments as done.
jtbandes added a comment.

Updates from review


https://reviews.llvm.org/D32475

Files:
  lib/Format/ContinuationIndenter.cpp
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -2591,6 +2591,60 @@
Style);
 }
 
+TEST_F(FormatTest, AllowBinPackingInsideArguments) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;
+  Style.BinPackArguments = false;
+  Style.ColumnLimit = 40;
+  verifyFormat("void test() {\n"
+   "  someFunction(\n"
+   "  this + argument + is + quite\n"
+   "  + long + so + it + gets + wrapped\n"
+   "  + but + remains + bin - packed);\n"
+   "}",
+   Style);
+  verifyFormat("void test() {\n"
+   "  someFunction(arg1,\n"
+   "   this + argument + is\n"
+   "   + quite + long + so\n"
+   "   + it + gets + wrapped\n"
+   "   + but + remains + bin\n"
+   "   - packed,\n"
+   "   arg3);\n"
+   "}",
+   Style);
+  verifyFormat("void test() {\n"
+   "  someFunction(\n"
+   "  arg1,\n"
+   "  this + argument + has\n"
+   "  + anotherFunc(nested,\n"
+   "calls + whose\n"
+   "+ arguments\n"
+   "+ are + also\n"
+   "+ wrapped,\n"
+   "in + addition)\n"
+   "  + to + being + bin - packed,\n"
+   "  arg3);\n"
+   "}",
+   Style);
+
+  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
+  verifyFormat("void test() {\n"
+   "  someFunction(\n"
+   "  arg1,\n"
+   "  this + argument + has +\n"
+   "  anotherFunc(nested,\n"
+   "  calls + whose +\n"
+   "  arguments +\n"
+   "  are + also +\n"
+   "  wrapped,\n"
+   "  in + addition) +\n"
+   "  to + being + bin - packed,\n"
+   "  arg3);\n"
+   "}",
+   Style);
+}
+
 TEST_F(FormatTest, ConstructorInitializers) {
   verifyFormat("Constructor() : Initializer(FitsOnTheLine) {}");
   verifyFormat("Constructor() : Inttializer(FitsOnTheLine) {}",
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -920,6 +920,10 @@
 NewParenState.NoLineBreak =
 NewParenState.NoLineBreak || State.Stack.back().NoLineBreakInOperand;
 
+// Don't propagate AvoidBinPacking into subexpressions of arg/param lists.
+if (*I > prec::Comma)
+  NewParenState.AvoidBinPacking = false;
+
 // Indent from 'LastSpace' unless these are fake parentheses encapsulating
 // a builder type call after 'return' or, if the alignment after opening
 // brackets is disabled.


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -2591,6 +2591,60 @@
Style);
 }
 
+TEST_F(FormatTest, AllowBinPackingInsideArguments) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;
+  Style.BinPackArguments = false;
+  Style.ColumnLimit = 40;
+  verifyFormat("void test() {\n"
+   "  someFunction(\n"
+   "  this + argument + is + quite\n"
+   "  + long + so + it + gets + wrapped\n"
+   "  + but + remains + bin - packed);\n"
+   "}",
+   Style);
+  verifyFormat("void test() {\n"
+   "  someFunction(arg1,\n"
+   "   this + argument + is\n"
+   "   + quite + long + so\n"
+   "   + it + gets + wrapped\n"
+   "   + but + remains + bin\n"
+   "   - packed,\n"
+   "   arg3);\n"
+   "}",
+   Style);
+  verifyFormat("void test() {\n"
+   "  someFunction(\n"
+   "  arg1,\n"
+   "  this + argument + has\n"
+   "  + ano

Re: r301449 - PPCallbacks::MacroUndefined, change signature and add test.

2017-04-26 Thread Evgenii Stepanov via cfe-commits
Please change the signature of all overriding definitions as well.

/code/llvm/tools/clang/lib/CodeGen/MacroPPCallbacks.h:114:50: error:
non-virtual member function marked 'override' hides virtual member
function
  const MacroDefinition &MD) override;
 ^
/code/llvm/tools/clang/include/clang/Lex/PPCallbacks.h:255:16: note:
hidden overloaded virtual function
'clang::PPCallbacks::MacroUndefined' declared here: different number
of parameters (3 vs 2)
  virtual void MacroUndefined(const Token &MacroNameTok,

On Wed, Apr 26, 2017 at 12:47 PM, Frederich Munch via cfe-commits
 wrote:
> Author: marsupial
> Date: Wed Apr 26 14:47:31 2017
> New Revision: 301449
>
> URL: http://llvm.org/viewvc/llvm-project?rev=301449&view=rev
> Log:
> PPCallbacks::MacroUndefined, change signature and add test.
>
> Summary:
> The PPCallbacks::MacroUndefined callback is currently insufficient for 
> clients that need to track the MacroDirectives.
> This patch adds an additional argument to PPCallbacks::MacroUndefined that is 
> the undef MacroDirective.
>
> Reviewers: bruno, manmanren
>
> Reviewed By: bruno
>
> Subscribers: nemanjai, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D29923
>
> Modified:
> cfe/trunk/include/clang/Lex/PPCallbacks.h
> cfe/trunk/include/clang/Lex/PreprocessingRecord.h
> cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
> cfe/trunk/lib/Lex/PPDirectives.cpp
> cfe/trunk/lib/Lex/PreprocessingRecord.cpp
> cfe/trunk/tools/libclang/Indexing.cpp
> cfe/trunk/unittests/Basic/SourceManagerTest.cpp
>
> Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPCallbacks.h?rev=301449&r1=301448&r2=301449&view=diff
> ==
> --- cfe/trunk/include/clang/Lex/PPCallbacks.h (original)
> +++ cfe/trunk/include/clang/Lex/PPCallbacks.h Wed Apr 26 14:47:31 2017
> @@ -247,10 +247,14 @@ public:
>}
>
>/// \brief Hook called whenever a macro \#undef is seen.
> +  /// \param Token The active Token
> +  /// \param MD A MacroDefinition for the named macro.
> +  /// \param Undef New MacroDirective if the macro was defined, null 
> otherwise.
>///
>/// MD is released immediately following this callback.
>virtual void MacroUndefined(const Token &MacroNameTok,
> -  const MacroDefinition &MD) {
> +  const MacroDefinition &MD,
> +  const MacroDirective *Undef) {
>}
>
>/// \brief Hook called whenever the 'defined' operator is seen.
> @@ -439,15 +443,17 @@ public:
>  Second->MacroExpands(MacroNameTok, MD, Range, Args);
>}
>
> -  void MacroDefined(const Token &MacroNameTok, const MacroDirective *MD) 
> override {
> +  void MacroDefined(const Token &MacroNameTok,
> +const MacroDirective *MD) override {
>  First->MacroDefined(MacroNameTok, MD);
>  Second->MacroDefined(MacroNameTok, MD);
>}
>
>void MacroUndefined(const Token &MacroNameTok,
> -  const MacroDefinition &MD) override {
> -First->MacroUndefined(MacroNameTok, MD);
> -Second->MacroUndefined(MacroNameTok, MD);
> +  const MacroDefinition &MD,
> +  const MacroDirective *Undef) override {
> +First->MacroUndefined(MacroNameTok, MD, Undef);
> +Second->MacroUndefined(MacroNameTok, MD, Undef);
>}
>
>void Defined(const Token &MacroNameTok, const MacroDefinition &MD,
>
> Modified: cfe/trunk/include/clang/Lex/PreprocessingRecord.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessingRecord.h?rev=301449&r1=301448&r2=301449&view=diff
> ==
> --- cfe/trunk/include/clang/Lex/PreprocessingRecord.h (original)
> +++ cfe/trunk/include/clang/Lex/PreprocessingRecord.h Wed Apr 26 14:47:31 2017
> @@ -488,7 +488,8 @@ namespace clang {
>  void MacroExpands(const Token &Id, const MacroDefinition &MD,
>SourceRange Range, const MacroArgs *Args) override;
>  void MacroDefined(const Token &Id, const MacroDirective *MD) override;
> -void MacroUndefined(const Token &Id, const MacroDefinition &MD) override;
> +void MacroUndefined(const Token &Id, const MacroDefinition &MD,
> +const MacroDirective *Undef) override;
>  void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
>  StringRef FileName, bool IsAngled,
>  CharSourceRange FilenameRange,
>
> Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=301449&r1=301448&r2=301449&view=diff
> ==

[PATCH] D32372: Arrays of unknown bound in constant expressions

2017-04-26 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

The change in direction from diagnosing the lvalue-to-rvalue conversion to 
diagnosing the pointer arithmetic seems fine to me (and is likely a better 
approach overall), but this means we should now treat a designator referring to 
element 0 of an array of unknown / runtime bound as being valid. We have 
minimal support for this already for `__builtin_object_size` evaluation, which 
you should be able to generalize to support arbitrary designators ending with 
such a value.




Comment at: lib/AST/ExprConstant.cpp:2957
+  else
+return CompleteObject();
+}

This path fails without producing a diagnostic (a default-constructed 
`CompleteObject()` is an error return). I think we should instead treat this as 
a valid `CompleteObject` with a type that simply can't be further decomposed.



Comment at: lib/AST/ExprConstant.cpp:5559-5567
+  // If we're dealing with an array of non-constant bound, the expression is
+  // not a constant expression. Use the Designator's most derived type field,
+  // since we may cover addition with a flexible array member.
+  if (!Info.checkingPotentialConstantExpression() && Result.Designator.Invalid
+   && !Result.Designator.MostDerivedType.isNull()
+   && Info.Ctx.getAsArrayType(Result.Designator.MostDerivedType))
+CCEDiag(PExp, diag::note_constexpr_array_unknown_bound_arithmetic)

I think this should be handled in `SubobjectDesignator::adjustIndex` instead; 
there are other ways to get to the pointer arithmetic logic (such as array 
indexing and the implicit indexing we do in some builtins).



Comment at: lib/AST/ExprConstant.cpp:5679-5680
+Result.addArray(Info, E, CAT);
+  else
+Result.Designator.setInvalid();
+}

We should never set a designator invalid without issuing a diagnostic. If you 
want to defer the diagnostic until pointer arithmetic happens, you need to be 
able to represent that situation in a valid designator. Perhaps generalizing 
the existing support for `isMostDerivedAnUnsizedArray` would be a path forward.


https://reviews.llvm.org/D32372



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


[clang-tools-extra] r301468 - Fix API breaks

2017-04-26 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Wed Apr 26 15:58:03 2017
New Revision: 301468

URL: http://llvm.org/viewvc/llvm-project?rev=301468&view=rev
Log:
Fix API breaks

Modified:
clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp
clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h

Modified: clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp?rev=301468&r1=301467&r2=301468&view=diff
==
--- clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp (original)
+++ clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.cpp Wed Apr 26 15:58:03 
2017
@@ -324,7 +324,8 @@ PPCallbacksTracker::MacroDefined(const c
 // Hook called whenever a macro #undef is seen.
 void PPCallbacksTracker::MacroUndefined(
 const clang::Token &MacroNameTok,
-const clang::MacroDefinition &MacroDefinition) {
+const clang::MacroDefinition &MacroDefinition,
+const clang::MacroDirective *Undef) {
   beginCallback("MacroUndefined");
   appendArgument("MacroNameTok", MacroNameTok);
   appendArgument("MacroDefinition", MacroDefinition);

Modified: clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h?rev=301468&r1=301467&r2=301468&view=diff
==
--- clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h (original)
+++ clang-tools-extra/trunk/pp-trace/PPCallbacksTracker.h Wed Apr 26 15:58:03 
2017
@@ -140,7 +140,8 @@ public:
   void MacroDefined(const clang::Token &MacroNameTok,
 const clang::MacroDirective *MD) override;
   void MacroUndefined(const clang::Token &MacroNameTok,
-  const clang::MacroDefinition &MD) override;
+  const clang::MacroDefinition &MD,
+  const clang::MacroDirective *Undef) override;
   void Defined(const clang::Token &MacroNameTok,
const clang::MacroDefinition &MD,
clang::SourceRange Range) override;


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


r301470 - Fix API breaks

2017-04-26 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Wed Apr 26 15:58:21 2017
New Revision: 301470

URL: http://llvm.org/viewvc/llvm-project?rev=301470&view=rev
Log:
Fix API breaks

Modified:
cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp
cfe/trunk/lib/CodeGen/MacroPPCallbacks.h

Modified: cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp?rev=301470&r1=301469&r2=301470&view=diff
==
--- cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp (original)
+++ cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp Wed Apr 26 15:58:21 2017
@@ -198,7 +198,8 @@ void MacroPPCallbacks::MacroDefined(cons
 }
 
 void MacroPPCallbacks::MacroUndefined(const Token &MacroNameTok,
-  const MacroDefinition &MD) {
+  const MacroDefinition &MD,
+  const MacroDirective *Undef) {
   IdentifierInfo *Id = MacroNameTok.getIdentifierInfo();
   SourceLocation location = getCorrectLocation(MacroNameTok.getLocation());
   Gen->getCGDebugInfo()->CreateMacro(getCurrentScope(),

Modified: cfe/trunk/lib/CodeGen/MacroPPCallbacks.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MacroPPCallbacks.h?rev=301470&r1=301469&r2=301470&view=diff
==
--- cfe/trunk/lib/CodeGen/MacroPPCallbacks.h (original)
+++ cfe/trunk/lib/CodeGen/MacroPPCallbacks.h Wed Apr 26 15:58:21 2017
@@ -110,8 +110,8 @@ public:
   /// Hook called whenever a macro \#undef is seen.
   ///
   /// MD is released immediately following this callback.
-  void MacroUndefined(const Token &MacroNameTok,
-  const MacroDefinition &MD) override;
+  void MacroUndefined(const Token &MacroNameTok, const MacroDefinition &MD,
+  const MacroDirective *Undef) override;
 };
 
 } // end namespace clang


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


r301469 - Revert "PPCallbacks::MacroUndefined, change signature and add test."

2017-04-26 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Wed Apr 26 15:58:19 2017
New Revision: 301469

URL: http://llvm.org/viewvc/llvm-project?rev=301469&view=rev
Log:
Revert "PPCallbacks::MacroUndefined, change signature and add test."

This reverts commit r301449. It breaks the build with:

  MacroPPCallbacks.h:114:50: error: non-virtual member function marked 
'override' hides virtual member function

Modified:
cfe/trunk/include/clang/Lex/PPCallbacks.h
cfe/trunk/include/clang/Lex/PreprocessingRecord.h
cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/lib/Lex/PreprocessingRecord.cpp
cfe/trunk/tools/libclang/Indexing.cpp
cfe/trunk/unittests/Basic/SourceManagerTest.cpp

Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPCallbacks.h?rev=301469&r1=301468&r2=301469&view=diff
==
--- cfe/trunk/include/clang/Lex/PPCallbacks.h (original)
+++ cfe/trunk/include/clang/Lex/PPCallbacks.h Wed Apr 26 15:58:19 2017
@@ -247,14 +247,10 @@ public:
   }
 
   /// \brief Hook called whenever a macro \#undef is seen.
-  /// \param Token The active Token
-  /// \param MD A MacroDefinition for the named macro.
-  /// \param Undef New MacroDirective if the macro was defined, null otherwise.
   ///
   /// MD is released immediately following this callback.
   virtual void MacroUndefined(const Token &MacroNameTok,
-  const MacroDefinition &MD,
-  const MacroDirective *Undef) {
+  const MacroDefinition &MD) {
   }
   
   /// \brief Hook called whenever the 'defined' operator is seen.
@@ -443,17 +439,15 @@ public:
 Second->MacroExpands(MacroNameTok, MD, Range, Args);
   }
 
-  void MacroDefined(const Token &MacroNameTok,
-const MacroDirective *MD) override {
+  void MacroDefined(const Token &MacroNameTok, const MacroDirective *MD) 
override {
 First->MacroDefined(MacroNameTok, MD);
 Second->MacroDefined(MacroNameTok, MD);
   }
 
   void MacroUndefined(const Token &MacroNameTok,
-  const MacroDefinition &MD,
-  const MacroDirective *Undef) override {
-First->MacroUndefined(MacroNameTok, MD, Undef);
-Second->MacroUndefined(MacroNameTok, MD, Undef);
+  const MacroDefinition &MD) override {
+First->MacroUndefined(MacroNameTok, MD);
+Second->MacroUndefined(MacroNameTok, MD);
   }
 
   void Defined(const Token &MacroNameTok, const MacroDefinition &MD,

Modified: cfe/trunk/include/clang/Lex/PreprocessingRecord.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessingRecord.h?rev=301469&r1=301468&r2=301469&view=diff
==
--- cfe/trunk/include/clang/Lex/PreprocessingRecord.h (original)
+++ cfe/trunk/include/clang/Lex/PreprocessingRecord.h Wed Apr 26 15:58:19 2017
@@ -488,8 +488,7 @@ namespace clang {
 void MacroExpands(const Token &Id, const MacroDefinition &MD,
   SourceRange Range, const MacroArgs *Args) override;
 void MacroDefined(const Token &Id, const MacroDirective *MD) override;
-void MacroUndefined(const Token &Id, const MacroDefinition &MD,
-const MacroDirective *Undef) override;
+void MacroUndefined(const Token &Id, const MacroDefinition &MD) override;
 void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
 StringRef FileName, bool IsAngled,
 CharSourceRange FilenameRange,

Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=301469&r1=301468&r2=301469&view=diff
==
--- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)
+++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Wed Apr 26 15:58:19 2017
@@ -172,8 +172,7 @@ public:
 
   /// MacroUndefined - This hook is called whenever a macro #undef is seen.
   void MacroUndefined(const Token &MacroNameTok,
-  const MacroDefinition &MD,
-  const MacroDirective *Undef) override;
+  const MacroDefinition &MD) override;
 };
 }  // end anonymous namespace
 
@@ -390,8 +389,7 @@ void PrintPPOutputPPCallbacks::MacroDefi
 }
 
 void PrintPPOutputPPCallbacks::MacroUndefined(const Token &MacroNameTok,
-  const MacroDefinition &MD,
-  const MacroDirective *Undef) {
+  const MacroDefinition &MD) {
   // Only print out macro definitions in -dD mode.
   if (!DumpDefines) return;
 

Modified: cfe/trunk/lib/Lex/PPDire

Re: r301449 - PPCallbacks::MacroUndefined, change signature and add test.

2017-04-26 Thread Vedant Kumar via cfe-commits
Hi Frederich,

I had to revert this to unblock myself (r301469).

best,
vedant

> On Apr 26, 2017, at 1:51 PM, Evgenii Stepanov via cfe-commits 
>  wrote:
> 
> Please change the signature of all overriding definitions as well.
> 
> /code/llvm/tools/clang/lib/CodeGen/MacroPPCallbacks.h:114:50: error:
> non-virtual member function marked 'override' hides virtual member
> function
>  const MacroDefinition &MD) override;
> ^
> /code/llvm/tools/clang/include/clang/Lex/PPCallbacks.h:255:16: note:
> hidden overloaded virtual function
> 'clang::PPCallbacks::MacroUndefined' declared here: different number
> of parameters (3 vs 2)
>  virtual void MacroUndefined(const Token &MacroNameTok,
> 
> On Wed, Apr 26, 2017 at 12:47 PM, Frederich Munch via cfe-commits
>  wrote:
>> Author: marsupial
>> Date: Wed Apr 26 14:47:31 2017
>> New Revision: 301449
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=301449&view=rev
>> Log:
>> PPCallbacks::MacroUndefined, change signature and add test.
>> 
>> Summary:
>> The PPCallbacks::MacroUndefined callback is currently insufficient for 
>> clients that need to track the MacroDirectives.
>> This patch adds an additional argument to PPCallbacks::MacroUndefined that 
>> is the undef MacroDirective.
>> 
>> Reviewers: bruno, manmanren
>> 
>> Reviewed By: bruno
>> 
>> Subscribers: nemanjai, cfe-commits
>> 
>> Differential Revision: https://reviews.llvm.org/D29923
>> 
>> Modified:
>>cfe/trunk/include/clang/Lex/PPCallbacks.h
>>cfe/trunk/include/clang/Lex/PreprocessingRecord.h
>>cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
>>cfe/trunk/lib/Lex/PPDirectives.cpp
>>cfe/trunk/lib/Lex/PreprocessingRecord.cpp
>>cfe/trunk/tools/libclang/Indexing.cpp
>>cfe/trunk/unittests/Basic/SourceManagerTest.cpp
>> 
>> Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPCallbacks.h?rev=301449&r1=301448&r2=301449&view=diff
>> ==
>> --- cfe/trunk/include/clang/Lex/PPCallbacks.h (original)
>> +++ cfe/trunk/include/clang/Lex/PPCallbacks.h Wed Apr 26 14:47:31 2017
>> @@ -247,10 +247,14 @@ public:
>>   }
>> 
>>   /// \brief Hook called whenever a macro \#undef is seen.
>> +  /// \param Token The active Token
>> +  /// \param MD A MacroDefinition for the named macro.
>> +  /// \param Undef New MacroDirective if the macro was defined, null 
>> otherwise.
>>   ///
>>   /// MD is released immediately following this callback.
>>   virtual void MacroUndefined(const Token &MacroNameTok,
>> -  const MacroDefinition &MD) {
>> +  const MacroDefinition &MD,
>> +  const MacroDirective *Undef) {
>>   }
>> 
>>   /// \brief Hook called whenever the 'defined' operator is seen.
>> @@ -439,15 +443,17 @@ public:
>> Second->MacroExpands(MacroNameTok, MD, Range, Args);
>>   }
>> 
>> -  void MacroDefined(const Token &MacroNameTok, const MacroDirective *MD) 
>> override {
>> +  void MacroDefined(const Token &MacroNameTok,
>> +const MacroDirective *MD) override {
>> First->MacroDefined(MacroNameTok, MD);
>> Second->MacroDefined(MacroNameTok, MD);
>>   }
>> 
>>   void MacroUndefined(const Token &MacroNameTok,
>> -  const MacroDefinition &MD) override {
>> -First->MacroUndefined(MacroNameTok, MD);
>> -Second->MacroUndefined(MacroNameTok, MD);
>> +  const MacroDefinition &MD,
>> +  const MacroDirective *Undef) override {
>> +First->MacroUndefined(MacroNameTok, MD, Undef);
>> +Second->MacroUndefined(MacroNameTok, MD, Undef);
>>   }
>> 
>>   void Defined(const Token &MacroNameTok, const MacroDefinition &MD,
>> 
>> Modified: cfe/trunk/include/clang/Lex/PreprocessingRecord.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessingRecord.h?rev=301449&r1=301448&r2=301449&view=diff
>> ==
>> --- cfe/trunk/include/clang/Lex/PreprocessingRecord.h (original)
>> +++ cfe/trunk/include/clang/Lex/PreprocessingRecord.h Wed Apr 26 14:47:31 
>> 2017
>> @@ -488,7 +488,8 @@ namespace clang {
>> void MacroExpands(const Token &Id, const MacroDefinition &MD,
>>   SourceRange Range, const MacroArgs *Args) override;
>> void MacroDefined(const Token &Id, const MacroDirective *MD) override;
>> -void MacroUndefined(const Token &Id, const MacroDefinition &MD) 
>> override;
>> +void MacroUndefined(const Token &Id, const MacroDefinition &MD,
>> +const MacroDirective *Undef) override;
>> void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
>> StringRef FileName, bool IsAngled,
>> CharSourceRan

Re: r301470 - Fix API breaks

2017-04-26 Thread Vedant Kumar via cfe-commits
Hi David,

It looks like this conflicts with my revert. I will revert my revert, since 
this seems like it fixes things.

vedant

> On Apr 26, 2017, at 1:58 PM, David Blaikie via cfe-commits 
>  wrote:
> 
> Author: dblaikie
> Date: Wed Apr 26 15:58:21 2017
> New Revision: 301470
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=301470&view=rev
> Log:
> Fix API breaks
> 
> Modified:
>cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp
>cfe/trunk/lib/CodeGen/MacroPPCallbacks.h
> 
> Modified: cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp?rev=301470&r1=301469&r2=301470&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp (original)
> +++ cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp Wed Apr 26 15:58:21 2017
> @@ -198,7 +198,8 @@ void MacroPPCallbacks::MacroDefined(cons
> }
> 
> void MacroPPCallbacks::MacroUndefined(const Token &MacroNameTok,
> -  const MacroDefinition &MD) {
> +  const MacroDefinition &MD,
> +  const MacroDirective *Undef) {
>   IdentifierInfo *Id = MacroNameTok.getIdentifierInfo();
>   SourceLocation location = getCorrectLocation(MacroNameTok.getLocation());
>   Gen->getCGDebugInfo()->CreateMacro(getCurrentScope(),
> 
> Modified: cfe/trunk/lib/CodeGen/MacroPPCallbacks.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MacroPPCallbacks.h?rev=301470&r1=301469&r2=301470&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/MacroPPCallbacks.h (original)
> +++ cfe/trunk/lib/CodeGen/MacroPPCallbacks.h Wed Apr 26 15:58:21 2017
> @@ -110,8 +110,8 @@ public:
>   /// Hook called whenever a macro \#undef is seen.
>   ///
>   /// MD is released immediately following this callback.
> -  void MacroUndefined(const Token &MacroNameTok,
> -  const MacroDefinition &MD) override;
> +  void MacroUndefined(const Token &MacroNameTok, const MacroDefinition &MD,
> +  const MacroDirective *Undef) override;
> };
> 
> } // end namespace clang
> 
> 
> ___
> 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


Re: r301470 - Fix API breaks

2017-04-26 Thread David Blaikie via cfe-commits
Sorry about that - thought I synced up moments before the commit.

Stuff like this is generally easier to fix forward, imho. Though the fact
that this wouldn't've compiled without the changes does provide some
misgivings about the quality of the patch (but I've certainly committed
some things as shots from the hip that broke the build & were still good to
fix forward)


On Wed, Apr 26, 2017 at 2:14 PM Vedant Kumar  wrote:

> Hi David,
>
> It looks like this conflicts with my revert. I will revert my revert,
> since this seems like it fixes things.
>
> vedant
>
> > On Apr 26, 2017, at 1:58 PM, David Blaikie via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >
> > Author: dblaikie
> > Date: Wed Apr 26 15:58:21 2017
> > New Revision: 301470
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=301470&view=rev
> > Log:
> > Fix API breaks
> >
> > Modified:
> >cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp
> >cfe/trunk/lib/CodeGen/MacroPPCallbacks.h
> >
> > Modified: cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp?rev=301470&r1=301469&r2=301470&view=diff
> >
> ==
> > --- cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp (original)
> > +++ cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp Wed Apr 26 15:58:21 2017
> > @@ -198,7 +198,8 @@ void MacroPPCallbacks::MacroDefined(cons
> > }
> >
> > void MacroPPCallbacks::MacroUndefined(const Token &MacroNameTok,
> > -  const MacroDefinition &MD) {
> > +  const MacroDefinition &MD,
> > +  const MacroDirective *Undef) {
> >   IdentifierInfo *Id = MacroNameTok.getIdentifierInfo();
> >   SourceLocation location =
> getCorrectLocation(MacroNameTok.getLocation());
> >   Gen->getCGDebugInfo()->CreateMacro(getCurrentScope(),
> >
> > Modified: cfe/trunk/lib/CodeGen/MacroPPCallbacks.h
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MacroPPCallbacks.h?rev=301470&r1=301469&r2=301470&view=diff
> >
> ==
> > --- cfe/trunk/lib/CodeGen/MacroPPCallbacks.h (original)
> > +++ cfe/trunk/lib/CodeGen/MacroPPCallbacks.h Wed Apr 26 15:58:21 2017
> > @@ -110,8 +110,8 @@ public:
> >   /// Hook called whenever a macro \#undef is seen.
> >   ///
> >   /// MD is released immediately following this callback.
> > -  void MacroUndefined(const Token &MacroNameTok,
> > -  const MacroDefinition &MD) override;
> > +  void MacroUndefined(const Token &MacroNameTok, const MacroDefinition
> &MD,
> > +  const MacroDirective *Undef) override;
> > };
> >
> > } // end namespace clang
> >
> >
> > ___
> > 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


r301472 - Revert "Revert "PPCallbacks::MacroUndefined, change signature and add test.""

2017-04-26 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Wed Apr 26 16:05:44 2017
New Revision: 301472

URL: http://llvm.org/viewvc/llvm-project?rev=301472&view=rev
Log:
Revert "Revert "PPCallbacks::MacroUndefined, change signature and add test.""

This reverts commit r301469. It isn't needed with r301470, which fixes
the API break introduced in the original commit.

Modified:
cfe/trunk/include/clang/Lex/PPCallbacks.h
cfe/trunk/include/clang/Lex/PreprocessingRecord.h
cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/lib/Lex/PreprocessingRecord.cpp
cfe/trunk/tools/libclang/Indexing.cpp
cfe/trunk/unittests/Basic/SourceManagerTest.cpp

Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPCallbacks.h?rev=301472&r1=301471&r2=301472&view=diff
==
--- cfe/trunk/include/clang/Lex/PPCallbacks.h (original)
+++ cfe/trunk/include/clang/Lex/PPCallbacks.h Wed Apr 26 16:05:44 2017
@@ -247,10 +247,14 @@ public:
   }
 
   /// \brief Hook called whenever a macro \#undef is seen.
+  /// \param Token The active Token
+  /// \param MD A MacroDefinition for the named macro.
+  /// \param Undef New MacroDirective if the macro was defined, null otherwise.
   ///
   /// MD is released immediately following this callback.
   virtual void MacroUndefined(const Token &MacroNameTok,
-  const MacroDefinition &MD) {
+  const MacroDefinition &MD,
+  const MacroDirective *Undef) {
   }
   
   /// \brief Hook called whenever the 'defined' operator is seen.
@@ -439,15 +443,17 @@ public:
 Second->MacroExpands(MacroNameTok, MD, Range, Args);
   }
 
-  void MacroDefined(const Token &MacroNameTok, const MacroDirective *MD) 
override {
+  void MacroDefined(const Token &MacroNameTok,
+const MacroDirective *MD) override {
 First->MacroDefined(MacroNameTok, MD);
 Second->MacroDefined(MacroNameTok, MD);
   }
 
   void MacroUndefined(const Token &MacroNameTok,
-  const MacroDefinition &MD) override {
-First->MacroUndefined(MacroNameTok, MD);
-Second->MacroUndefined(MacroNameTok, MD);
+  const MacroDefinition &MD,
+  const MacroDirective *Undef) override {
+First->MacroUndefined(MacroNameTok, MD, Undef);
+Second->MacroUndefined(MacroNameTok, MD, Undef);
   }
 
   void Defined(const Token &MacroNameTok, const MacroDefinition &MD,

Modified: cfe/trunk/include/clang/Lex/PreprocessingRecord.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessingRecord.h?rev=301472&r1=301471&r2=301472&view=diff
==
--- cfe/trunk/include/clang/Lex/PreprocessingRecord.h (original)
+++ cfe/trunk/include/clang/Lex/PreprocessingRecord.h Wed Apr 26 16:05:44 2017
@@ -488,7 +488,8 @@ namespace clang {
 void MacroExpands(const Token &Id, const MacroDefinition &MD,
   SourceRange Range, const MacroArgs *Args) override;
 void MacroDefined(const Token &Id, const MacroDirective *MD) override;
-void MacroUndefined(const Token &Id, const MacroDefinition &MD) override;
+void MacroUndefined(const Token &Id, const MacroDefinition &MD,
+const MacroDirective *Undef) override;
 void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
 StringRef FileName, bool IsAngled,
 CharSourceRange FilenameRange,

Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=301472&r1=301471&r2=301472&view=diff
==
--- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)
+++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Wed Apr 26 16:05:44 2017
@@ -172,7 +172,8 @@ public:
 
   /// MacroUndefined - This hook is called whenever a macro #undef is seen.
   void MacroUndefined(const Token &MacroNameTok,
-  const MacroDefinition &MD) override;
+  const MacroDefinition &MD,
+  const MacroDirective *Undef) override;
 };
 }  // end anonymous namespace
 
@@ -389,7 +390,8 @@ void PrintPPOutputPPCallbacks::MacroDefi
 }
 
 void PrintPPOutputPPCallbacks::MacroUndefined(const Token &MacroNameTok,
-  const MacroDefinition &MD) {
+  const MacroDefinition &MD,
+  const MacroDirective *Undef) {
   // Only print out macro definitions in -dD mode.
   if (!DumpDefines) return;
 

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/

Re: r301449 - PPCallbacks::MacroUndefined, change signature and add test.

2017-04-26 Thread Vedant Kumar via cfe-commits
And I reverted my revert in r301472. See the thread re: r301470.

Sorry for the noise,
vedant

> On Apr 26, 2017, at 2:12 PM, Vedant Kumar via cfe-commits 
>  wrote:
> 
> Hi Frederich,
> 
> I had to revert this to unblock myself (r301469).
> 
> best,
> vedant
> 
>> On Apr 26, 2017, at 1:51 PM, Evgenii Stepanov via cfe-commits 
>>  wrote:
>> 
>> Please change the signature of all overriding definitions as well.
>> 
>> /code/llvm/tools/clang/lib/CodeGen/MacroPPCallbacks.h:114:50: error:
>> non-virtual member function marked 'override' hides virtual member
>> function
>> const MacroDefinition &MD) override;
>>^
>> /code/llvm/tools/clang/include/clang/Lex/PPCallbacks.h:255:16: note:
>> hidden overloaded virtual function
>> 'clang::PPCallbacks::MacroUndefined' declared here: different number
>> of parameters (3 vs 2)
>> virtual void MacroUndefined(const Token &MacroNameTok,
>> 
>> On Wed, Apr 26, 2017 at 12:47 PM, Frederich Munch via cfe-commits
>>  wrote:
>>> Author: marsupial
>>> Date: Wed Apr 26 14:47:31 2017
>>> New Revision: 301449
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=301449&view=rev
>>> Log:
>>> PPCallbacks::MacroUndefined, change signature and add test.
>>> 
>>> Summary:
>>> The PPCallbacks::MacroUndefined callback is currently insufficient for 
>>> clients that need to track the MacroDirectives.
>>> This patch adds an additional argument to PPCallbacks::MacroUndefined that 
>>> is the undef MacroDirective.
>>> 
>>> Reviewers: bruno, manmanren
>>> 
>>> Reviewed By: bruno
>>> 
>>> Subscribers: nemanjai, cfe-commits
>>> 
>>> Differential Revision: https://reviews.llvm.org/D29923
>>> 
>>> Modified:
>>>   cfe/trunk/include/clang/Lex/PPCallbacks.h
>>>   cfe/trunk/include/clang/Lex/PreprocessingRecord.h
>>>   cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
>>>   cfe/trunk/lib/Lex/PPDirectives.cpp
>>>   cfe/trunk/lib/Lex/PreprocessingRecord.cpp
>>>   cfe/trunk/tools/libclang/Indexing.cpp
>>>   cfe/trunk/unittests/Basic/SourceManagerTest.cpp
>>> 
>>> Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPCallbacks.h?rev=301449&r1=301448&r2=301449&view=diff
>>> ==
>>> --- cfe/trunk/include/clang/Lex/PPCallbacks.h (original)
>>> +++ cfe/trunk/include/clang/Lex/PPCallbacks.h Wed Apr 26 14:47:31 2017
>>> @@ -247,10 +247,14 @@ public:
>>>  }
>>> 
>>>  /// \brief Hook called whenever a macro \#undef is seen.
>>> +  /// \param Token The active Token
>>> +  /// \param MD A MacroDefinition for the named macro.
>>> +  /// \param Undef New MacroDirective if the macro was defined, null 
>>> otherwise.
>>>  ///
>>>  /// MD is released immediately following this callback.
>>>  virtual void MacroUndefined(const Token &MacroNameTok,
>>> -  const MacroDefinition &MD) {
>>> +  const MacroDefinition &MD,
>>> +  const MacroDirective *Undef) {
>>>  }
>>> 
>>>  /// \brief Hook called whenever the 'defined' operator is seen.
>>> @@ -439,15 +443,17 @@ public:
>>>Second->MacroExpands(MacroNameTok, MD, Range, Args);
>>>  }
>>> 
>>> -  void MacroDefined(const Token &MacroNameTok, const MacroDirective *MD) 
>>> override {
>>> +  void MacroDefined(const Token &MacroNameTok,
>>> +const MacroDirective *MD) override {
>>>First->MacroDefined(MacroNameTok, MD);
>>>Second->MacroDefined(MacroNameTok, MD);
>>>  }
>>> 
>>>  void MacroUndefined(const Token &MacroNameTok,
>>> -  const MacroDefinition &MD) override {
>>> -First->MacroUndefined(MacroNameTok, MD);
>>> -Second->MacroUndefined(MacroNameTok, MD);
>>> +  const MacroDefinition &MD,
>>> +  const MacroDirective *Undef) override {
>>> +First->MacroUndefined(MacroNameTok, MD, Undef);
>>> +Second->MacroUndefined(MacroNameTok, MD, Undef);
>>>  }
>>> 
>>>  void Defined(const Token &MacroNameTok, const MacroDefinition &MD,
>>> 
>>> Modified: cfe/trunk/include/clang/Lex/PreprocessingRecord.h
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessingRecord.h?rev=301449&r1=301448&r2=301449&view=diff
>>> ==
>>> --- cfe/trunk/include/clang/Lex/PreprocessingRecord.h (original)
>>> +++ cfe/trunk/include/clang/Lex/PreprocessingRecord.h Wed Apr 26 14:47:31 
>>> 2017
>>> @@ -488,7 +488,8 @@ namespace clang {
>>>void MacroExpands(const Token &Id, const MacroDefinition &MD,
>>>  SourceRange Range, const MacroArgs *Args) override;
>>>void MacroDefined(const Token &Id, const MacroDirective *MD) override;
>>> -void MacroUndefined(const Token &Id, const MacroDefinition &MD) 
>>> override;
>>> +void MacroUndefined(const Token &Id, const MacroDefiniti

Re: r301470 - Fix API breaks

2017-04-26 Thread Vedant Kumar via cfe-commits

> On Apr 26, 2017, at 2:16 PM, David Blaikie  wrote:
> 
> Sorry about that - thought I synced up moments before the commit.

No worries, it's an innocent race.


> Stuff like this is generally easier to fix forward, imho. Though the fact 
> that this wouldn't've compiled without the changes does provide some 
> misgivings about the quality of the patch (but I've certainly committed some 
> things as shots from the hip that broke the build & were still good to fix 
> forward)

Understood. I guess I thought it was safer to revert in this case, because 
testing didn't include.. building clang? But it was a simple enough fix, I'll 
go with that next time.

Reverted my revert in r301472.

vedant

> 
> 
> On Wed, Apr 26, 2017 at 2:14 PM Vedant Kumar  wrote:
> Hi David,
> 
> It looks like this conflicts with my revert. I will revert my revert, since 
> this seems like it fixes things.
> 
> vedant
> 
> > On Apr 26, 2017, at 1:58 PM, David Blaikie via cfe-commits 
> >  wrote:
> >
> > Author: dblaikie
> > Date: Wed Apr 26 15:58:21 2017
> > New Revision: 301470
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=301470&view=rev
> > Log:
> > Fix API breaks
> >
> > Modified:
> >cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp
> >cfe/trunk/lib/CodeGen/MacroPPCallbacks.h
> >
> > Modified: cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp
> > URL: 
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp?rev=301470&r1=301469&r2=301470&view=diff
> > ==
> > --- cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp (original)
> > +++ cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp Wed Apr 26 15:58:21 2017
> > @@ -198,7 +198,8 @@ void MacroPPCallbacks::MacroDefined(cons
> > }
> >
> > void MacroPPCallbacks::MacroUndefined(const Token &MacroNameTok,
> > -  const MacroDefinition &MD) {
> > +  const MacroDefinition &MD,
> > +  const MacroDirective *Undef) {
> >   IdentifierInfo *Id = MacroNameTok.getIdentifierInfo();
> >   SourceLocation location = getCorrectLocation(MacroNameTok.getLocation());
> >   Gen->getCGDebugInfo()->CreateMacro(getCurrentScope(),
> >
> > Modified: cfe/trunk/lib/CodeGen/MacroPPCallbacks.h
> > URL: 
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MacroPPCallbacks.h?rev=301470&r1=301469&r2=301470&view=diff
> > ==
> > --- cfe/trunk/lib/CodeGen/MacroPPCallbacks.h (original)
> > +++ cfe/trunk/lib/CodeGen/MacroPPCallbacks.h Wed Apr 26 15:58:21 2017
> > @@ -110,8 +110,8 @@ public:
> >   /// Hook called whenever a macro \#undef is seen.
> >   ///
> >   /// MD is released immediately following this callback.
> > -  void MacroUndefined(const Token &MacroNameTok,
> > -  const MacroDefinition &MD) override;
> > +  void MacroUndefined(const Token &MacroNameTok, const MacroDefinition &MD,
> > +  const MacroDirective *Undef) override;
> > };
> >
> > } // end namespace clang
> >
> >
> > ___
> > 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


Re: r301470 - Fix API breaks

2017-04-26 Thread David Blaikie via cfe-commits
On Wed, Apr 26, 2017 at 2:18 PM Vedant Kumar  wrote:

>
> > On Apr 26, 2017, at 2:16 PM, David Blaikie  wrote:
> >
> > Sorry about that - thought I synced up moments before the commit.
>
> No worries, it's an innocent race.
>
>
> > Stuff like this is generally easier to fix forward, imho. Though the
> fact that this wouldn't've compiled without the changes does provide some
> misgivings about the quality of the patch (but I've certainly committed
> some things as shots from the hip that broke the build & were still good to
> fix forward)
>
> Understood. I guess I thought it was safer to revert in this case, because
> testing didn't include.. building clang?


Yeah - same thought, for sure.


> But it was a simple enough fix, I'll go with that next time.


I think either option's fine here - I wouldn't object to the revert (where
it's a hard build break for any compiler - the -Werror build breaks I tend
to be more interested in fixing forward) for precisely the reason you
mention. If clang was never built, how could this patch be well tested, etc.

Whichever suits you at the time seems fine :)


> Reverted my revert in r301472.
>

Thanks!


>
> vedant
>
> >
> >
> > On Wed, Apr 26, 2017 at 2:14 PM Vedant Kumar  wrote:
> > Hi David,
> >
> > It looks like this conflicts with my revert. I will revert my revert,
> since this seems like it fixes things.
> >
> > vedant
> >
> > > On Apr 26, 2017, at 1:58 PM, David Blaikie via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> > >
> > > Author: dblaikie
> > > Date: Wed Apr 26 15:58:21 2017
> > > New Revision: 301470
> > >
> > > URL: http://llvm.org/viewvc/llvm-project?rev=301470&view=rev
> > > Log:
> > > Fix API breaks
> > >
> > > Modified:
> > >cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp
> > >cfe/trunk/lib/CodeGen/MacroPPCallbacks.h
> > >
> > > Modified: cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp
> > > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp?rev=301470&r1=301469&r2=301470&view=diff
> > >
> ==
> > > --- cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp (original)
> > > +++ cfe/trunk/lib/CodeGen/MacroPPCallbacks.cpp Wed Apr 26 15:58:21 2017
> > > @@ -198,7 +198,8 @@ void MacroPPCallbacks::MacroDefined(cons
> > > }
> > >
> > > void MacroPPCallbacks::MacroUndefined(const Token &MacroNameTok,
> > > -  const MacroDefinition &MD) {
> > > +  const MacroDefinition &MD,
> > > +  const MacroDirective *Undef) {
> > >   IdentifierInfo *Id = MacroNameTok.getIdentifierInfo();
> > >   SourceLocation location =
> getCorrectLocation(MacroNameTok.getLocation());
> > >   Gen->getCGDebugInfo()->CreateMacro(getCurrentScope(),
> > >
> > > Modified: cfe/trunk/lib/CodeGen/MacroPPCallbacks.h
> > > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MacroPPCallbacks.h?rev=301470&r1=301469&r2=301470&view=diff
> > >
> ==
> > > --- cfe/trunk/lib/CodeGen/MacroPPCallbacks.h (original)
> > > +++ cfe/trunk/lib/CodeGen/MacroPPCallbacks.h Wed Apr 26 15:58:21 2017
> > > @@ -110,8 +110,8 @@ public:
> > >   /// Hook called whenever a macro \#undef is seen.
> > >   ///
> > >   /// MD is released immediately following this callback.
> > > -  void MacroUndefined(const Token &MacroNameTok,
> > > -  const MacroDefinition &MD) override;
> > > +  void MacroUndefined(const Token &MacroNameTok, const
> MacroDefinition &MD,
> > > +  const MacroDirective *Undef) override;
> > > };
> > >
> > > } // end namespace clang
> > >
> > >
> > > ___
> > > 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] D32348: [libclang] Check for a record declaration before a template specialization.

2017-04-26 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

This change looks like it introduces a regression itself: given

  template struct A {};
  template using B = A;
  B bi;

... requesting the template arguments for the type `B` changes from 
producing  `int` to producing `int*` with this patch, which seems to directly 
oppose the intentions of https://reviews.llvm.org/D26663.

If the intent of this libclang function is to request the template arguments of 
the type as written, this change is wrong. If the intent is to request the 
template arguments of the desugared type, then https://reviews.llvm.org/D26663 
is wrong. But either way, it seems that reversing the order of these checks 
causes us to produce inconsistent results. Another example of the inconsistency:

  template using C = T;

With this patch, requesting the template arguments for `C` gives `int` but 
requesting the template arguments of `C>` gives `void` rather than 
`A`.


Repository:
  rL LLVM

https://reviews.llvm.org/D32348



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


r301482 - [ubsan] nullability-assign: Check assignments into C++ structs

2017-04-26 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Wed Apr 26 16:55:17 2017
New Revision: 301482

URL: http://llvm.org/viewvc/llvm-project?rev=301482&view=rev
Log:
[ubsan] nullability-assign: Check assignments into C++ structs

Fix the nullability-assign check so that it can handle assignments into
C++ structs. Previously, such assignments were not instrumented.

Testing: check-clang, check-ubsan, enabling the existing test in ObjC++
mode, and building some Apple frameworks with -fsanitize=nullability.

Added:
cfe/trunk/test/CodeGenCXX/ubsan-nullability-assign.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/test/CodeGenObjC/ubsan-nullability.m

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=301482&r1=301481&r2=301482&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Wed Apr 26 16:55:17 2017
@@ -4065,6 +4065,8 @@ LValue CodeGenFunction::EmitBinaryOperat
 
 RValue RV = EmitAnyExpr(E->getRHS());
 LValue LV = EmitCheckedLValue(E->getLHS(), TCK_Store);
+if (RV.isScalar())
+  EmitNullabilityCheck(LV, RV.getScalarVal(), E->getExprLoc());
 EmitStoreThroughLValue(RV, LV);
 return LV;
   }

Added: cfe/trunk/test/CodeGenCXX/ubsan-nullability-assign.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ubsan-nullability-assign.cpp?rev=301482&view=auto
==
--- cfe/trunk/test/CodeGenCXX/ubsan-nullability-assign.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/ubsan-nullability-assign.cpp Wed Apr 26 16:55:17 
2017
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -x c++ -triple x86_64-apple-darwin10 -emit-llvm -o - %s 
-fsanitize=nullability-assign | FileCheck %s
+
+struct S1 {
+  int *_Nonnull p;
+};
+
+struct S2 {
+  S1 s1;
+};
+
+union U1 {
+  S1 s1;
+  S2 s2;
+};
+
+// CHECK-LABEL: define void @{{.*}}f1
+void f1(int *p) {
+  U1 u;
+
+  // CHECK: [[ICMP:%.*]] = icmp ne i32* {{.*}}, null, !nosanitize
+  // CHECK-NEXT: br i1 [[ICMP]], {{.*}}, !nosanitize
+  // CHECK: call void @__ubsan_handle_type_mismatch{{.*}} !nosanitize
+  // CHECK: store
+  u.s1.p = p;
+
+  // CHECK: [[ICMP:%.*]] = icmp ne i32* {{.*}}, null, !nosanitize
+  // CHECK-NEXT: br i1 [[ICMP]], {{.*}}, !nosanitize
+  // CHECK: call void @__ubsan_handle_type_mismatch{{.*}} !nosanitize
+  // CHECK: store
+  u.s2.s1.p = p;
+
+  // CHECK-NOT: __ubsan_handle_type_mismatch
+  // CHECK-NOT: store
+  // CHECK: ret void
+}

Modified: cfe/trunk/test/CodeGenObjC/ubsan-nullability.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/ubsan-nullability.m?rev=301482&r1=301481&r2=301482&view=diff
==
--- cfe/trunk/test/CodeGenObjC/ubsan-nullability.m (original)
+++ cfe/trunk/test/CodeGenObjC/ubsan-nullability.m Wed Apr 26 16:55:17 2017
@@ -1,19 +1,22 @@
 // REQUIRES: asserts
 // RUN: %clang_cc1 -x objective-c -emit-llvm -triple 
x86_64-apple-macosx10.10.0 
-fsanitize=nullability-arg,nullability-assign,nullability-return -w %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -x objective-c++ -emit-llvm -triple 
x86_64-apple-macosx10.10.0 
-fsanitize=nullability-arg,nullability-assign,nullability-return -w %s -o - | 
FileCheck %s
 
 // CHECK: [[NONNULL_RV_LOC1:@.*]] = private unnamed_addr global {{.*}} i32 
109, i32 1 {{.*}} i32 100, i32 6
 // CHECK: [[NONNULL_ARG_LOC:@.*]] = private unnamed_addr global {{.*}} i32 
204, i32 15 {{.*}} i32 190, i32 23
 // CHECK: [[NONNULL_ASSIGN1_LOC:@.*]] = private unnamed_addr global {{.*}} i32 
305, i32 9
 // CHECK: [[NONNULL_ASSIGN2_LOC:@.*]] = private unnamed_addr global {{.*}} i32 
405, i32 10
-// CHECK: [[NONNULL_ASSIGN3_LOC:@.*]] = private unnamed_addr global {{.*}} i32 
505, i32 10
+// CHECK: [[NONNULL_ASSIGN3_LOC:@.*]] = private unnamed_addr global {{.*}} i32 
506, i32 10
 // CHECK: [[NONNULL_INIT1_LOC:@.*]] = private unnamed_addr global {{.*}} i32 
604, i32 25
 // CHECK: [[NONNULL_INIT2_LOC1:@.*]] = private unnamed_addr global {{.*}} i32 
707, i32 26
 // CHECK: [[NONNULL_INIT2_LOC2:@.*]] = private unnamed_addr global {{.*}} i32 
707, i32 29
 // CHECK: [[NONNULL_RV_LOC2:@.*]] = private unnamed_addr global {{.*}} i32 
817, i32 1 {{.*}} i32 800, i32 6
 
 #define NULL ((void *)0)
+#define INULL ((int *)NULL)
+#define INNULL ((int *_Nonnull)NULL)
 
-// CHECK-LABEL: define i32* @nonnull_retval1
+// CHECK-LABEL: define i32* @{{.*}}nonnull_retval1
 #line 100
 int *_Nonnull nonnull_retval1(int *p) {
   // CHECK: br i1 true, label %[[NULL:.*]], label %[[NONULL:.*]], !nosanitize
@@ -29,7 +32,7 @@ int *_Nonnull nonnull_retval1(int *p) {
 #line 190
 void nonnull_arg(int *_Nonnull p) {}
 
-// CHECK-LABEL: define void @call_func_with_nonnull_arg
+// CHECK-LABEL: define void @{{.*}}call_func_with_nonnull_arg
 #line 200
 void call_func_with_nonnull_arg(int *_Nonnull p) {
   // CHECK

[PATCH] D32348: [libclang] Check for a record declaration before a template specialization.

2017-04-26 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio added a comment.

In https://reviews.llvm.org/D32348#738704, @rsmith wrote:

> This change looks like it introduces a regression itself: given
>
>   template struct A {};
>   template using B = A;
>   B bi;
>
>
> ... requesting the template arguments for the type `B` changes from 
> producing  `int` to producing `int*` with this patch, which seems to directly 
> oppose the intentions of https://reviews.llvm.org/D26663.


FWIW when I wrote https://reviews.llvm.org/D26663, I did it because arguments 
weren't inspectionable at all for `using` declarations. Actually both of them 
would've worked for me.

>   template using C = T;
> 
> 
> With this patch, requesting the template arguments for `C` gives `int` 
> but requesting the template arguments of `C>` gives `void` rather 
> than `A`.

That being said, that is _specially_ annoying (good catch btw). Annoying enough 
to justify reverting this change I'd say...

I'll submit something with the test-cases. I guess people that depended on the 
old translation will just need to live with it... shrug.

I guess I could do something clever like: If it's both a 
`ClassTemplateSpecializationDecl`, and a `TemplateSpecializationType`, and the 
template arguments of the second happen to not be a template specialization, 
then use the `ClassTemplateSpecializationDecl`, otherwise the other, but that 
seems fairly tricky to maintain, so I'd rather just do the former.

Thanks for looking through it, btw.


Repository:
  rL LLVM

https://reviews.llvm.org/D32348



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


[PATCH] D32389: [libclang] Expose some target information via the C API.

2017-04-26 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio updated this revision to Diff 96834.
emilio added a comment.

Updated per review comments, thanks :)


Repository:
  rL LLVM

https://reviews.llvm.org/D32389

Files:
  clang/include/clang-c/Index.h
  clang/test/Index/target-info.c
  clang/tools/c-index-test/c-index-test.c
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXTranslationUnit.h
  clang/tools/libclang/libclang.exports

Index: clang/tools/libclang/libclang.exports
===
--- clang/tools/libclang/libclang.exports
+++ clang/tools/libclang/libclang.exports
@@ -79,6 +79,9 @@
 clang_TParamCommandComment_isParamPositionValid
 clang_TParamCommandComment_getDepth
 clang_TParamCommandComment_getIndex
+clang_TargetInfo_dispose
+clang_TargetInfo_getPointerWidth
+clang_TargetInfo_getTriple
 clang_Type_getAlignOf
 clang_Type_getClassType
 clang_Type_getSizeOf
@@ -250,6 +253,7 @@
 clang_getTokenSpelling
 clang_getTranslationUnitCursor
 clang_getTranslationUnitSpelling
+clang_getTranslationUnitTargetInfo
 clang_getTypeDeclaration
 clang_getTypeKindSpelling
 clang_getTypeSpelling
Index: clang/tools/libclang/CXTranslationUnit.h
===
--- clang/tools/libclang/CXTranslationUnit.h
+++ clang/tools/libclang/CXTranslationUnit.h
@@ -35,6 +35,10 @@
   clang::index::CommentToXMLConverter *CommentToXML;
 };
 
+struct CXTargetInfoImpl {
+  CXTranslationUnit TranslationUnit;
+};
+
 namespace clang {
 namespace cxtu {
 
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -26,6 +26,7 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticCategories.h"
 #include "clang/Basic/DiagnosticIDs.h"
+#include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/Version.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Frontend/CompilerInstance.h"
@@ -4015,6 +4016,50 @@
   return MakeCXCursor(CXXUnit->getASTContext().getTranslationUnitDecl(), TU);
 }
 
+CXTargetInfo clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit) {
+  if (isNotUsableTU(CTUnit)) {
+LOG_BAD_TU(CTUnit);
+return nullptr;
+  }
+
+  CXTargetInfoImpl* impl = new CXTargetInfoImpl();
+  impl->TranslationUnit = CTUnit;
+  return impl;
+}
+
+CXString clang_TargetInfo_getTriple(CXTargetInfo TargetInfo) {
+  if (!TargetInfo)
+return cxstring::createEmpty();
+
+  CXTranslationUnit CTUnit = TargetInfo->TranslationUnit;
+  assert(!isNotUsableTU(CTUnit) &&
+ "Unexpected unusable translation unit in TargetInfo");
+
+  ASTUnit *CXXUnit = cxtu::getASTUnit(CTUnit);
+  std::string Triple =
+CXXUnit->getASTContext().getTargetInfo().getTriple().normalize();
+  return cxstring::createDup(Triple);
+}
+
+int clang_TargetInfo_getPointerWidth(CXTargetInfo TargetInfo) {
+  if (!TargetInfo)
+return -1;
+
+  CXTranslationUnit CTUnit = TargetInfo->TranslationUnit;
+  assert(!isNotUsableTU(CTUnit) &&
+ "Unexpected unusable translation unit in TargetInfo");
+
+  ASTUnit *CXXUnit = cxtu::getASTUnit(CTUnit);
+  return CXXUnit->getASTContext().getTargetInfo().getMaxPointerWidth();
+}
+
+void clang_TargetInfo_dispose(CXTargetInfo TargetInfo) {
+  if (!TargetInfo)
+return;
+
+  delete TargetInfo;
+}
+
 //===--===//
 // CXFile Operations.
 //===--===//
Index: clang/tools/c-index-test/c-index-test.c
===
--- clang/tools/c-index-test/c-index-test.c
+++ clang/tools/c-index-test/c-index-test.c
@@ -1560,6 +1560,51 @@
 }
 
 /**/
+/* Target information testing.*/
+/**/
+
+static int print_target_info(int argc, const char **argv) {
+  CXIndex Idx;
+  CXTranslationUnit TU;
+  CXTargetInfo TargetInfo;
+  CXString Triple;
+  const char *FileName;
+  enum CXErrorCode Err;
+  int PointerWidth;
+
+  if (argc == 0) {
+fprintf(stderr, "No filename specified\n");
+return 1;
+  }
+
+  FileName = argv[1];
+
+  Idx = clang_createIndex(0, 1);
+  Err = clang_parseTranslationUnit2(Idx, FileName, argv, argc, NULL, 0,
+getDefaultParsingOptions(), &TU);
+  if (Err != CXError_Success) {
+fprintf(stderr, "Couldn't parse translation unit!\n");
+describeLibclangFailure(Err);
+clang_disposeIndex(Idx);
+return 1;
+  }
+
+  TargetInfo = clang_getTranslationUnitTargetInfo(TU);
+
+  Triple = clang_TargetInfo_getTriple(TargetInfo);
+  printf("TargetTriple: %s\n", clang_getCString(Triple));
+  clang_disposeString(Triple);
+
+  PointerWidth = clang_TargetInfo_getPointerWidth(TargetInfo);
+  printf("PointerWidth

Re: r301449 - PPCallbacks::MacroUndefined, change signature and add test.

2017-04-26 Thread Frederich Munch via cfe-commits
My fault, waited too long to land it and didn't catch the addition of the file 
in between.



From: v...@apple.com  on behalf of Vedant Kumar 
Sent: Wednesday, April 26, 2017 9:19 PM
To: Frederich Munch
Cc: cfe-commits; Vedant Kumar
Subject: Re: r301449 - PPCallbacks::MacroUndefined, change signature and add 
test.

And I reverted my revert in r301472. See the thread re: r301470.

Sorry for the noise,
vedant

> On Apr 26, 2017, at 2:12 PM, Vedant Kumar via cfe-commits 
>  wrote:
>
> Hi Frederich,
>
> I had to revert this to unblock myself (r301469).
>
> best,
> vedant
>
>> On Apr 26, 2017, at 1:51 PM, Evgenii Stepanov via cfe-commits 
>>  wrote:
>>
>> Please change the signature of all overriding definitions as well.
>>
>> /code/llvm/tools/clang/lib/CodeGen/MacroPPCallbacks.h:114:50: error:
>> non-virtual member function marked 'override' hides virtual member
>> function
>> const MacroDefinition &MD) override;
>>^
>> /code/llvm/tools/clang/include/clang/Lex/PPCallbacks.h:255:16: note:
>> hidden overloaded virtual function
>> 'clang::PPCallbacks::MacroUndefined' declared here: different number
>> of parameters (3 vs 2)
>> virtual void MacroUndefined(const Token &MacroNameTok,
>>
>> On Wed, Apr 26, 2017 at 12:47 PM, Frederich Munch via cfe-commits
>>  wrote:
>>> Author: marsupial
>>> Date: Wed Apr 26 14:47:31 2017
>>> New Revision: 301449
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=301449&view=rev
>>> Log:
>>> PPCallbacks::MacroUndefined, change signature and add test.
>>>
>>> Summary:
>>> The PPCallbacks::MacroUndefined callback is currently insufficient for 
>>> clients that need to track the MacroDirectives.
>>> This patch adds an additional argument to PPCallbacks::MacroUndefined that 
>>> is the undef MacroDirective.
>>>
>>> Reviewers: bruno, manmanren
>>>
>>> Reviewed By: bruno
>>>
>>> Subscribers: nemanjai, cfe-commits
>>>
>>> Differential Revision: https://reviews.llvm.org/D29923
>>>
>>> Modified:
>>>   cfe/trunk/include/clang/Lex/PPCallbacks.h
>>>   cfe/trunk/include/clang/Lex/PreprocessingRecord.h
>>>   cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
>>>   cfe/trunk/lib/Lex/PPDirectives.cpp
>>>   cfe/trunk/lib/Lex/PreprocessingRecord.cpp
>>>   cfe/trunk/tools/libclang/Indexing.cpp
>>>   cfe/trunk/unittests/Basic/SourceManagerTest.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPCallbacks.h?rev=301449&r1=301448&r2=301449&view=diff
>>> ==
>>> --- cfe/trunk/include/clang/Lex/PPCallbacks.h (original)
>>> +++ cfe/trunk/include/clang/Lex/PPCallbacks.h Wed Apr 26 14:47:31 2017
>>> @@ -247,10 +247,14 @@ public:
>>>  }
>>>
>>>  /// \brief Hook called whenever a macro \#undef is seen.
>>> +  /// \param Token The active Token
>>> +  /// \param MD A MacroDefinition for the named macro.
>>> +  /// \param Undef New MacroDirective if the macro was defined, null 
>>> otherwise.
>>>  ///
>>>  /// MD is released immediately following this callback.
>>>  virtual void MacroUndefined(const Token &MacroNameTok,
>>> -  const MacroDefinition &MD) {
>>> +  const MacroDefinition &MD,
>>> +  const MacroDirective *Undef) {
>>>  }
>>>
>>>  /// \brief Hook called whenever the 'defined' operator is seen.
>>> @@ -439,15 +443,17 @@ public:
>>>Second->MacroExpands(MacroNameTok, MD, Range, Args);
>>>  }
>>>
>>> -  void MacroDefined(const Token &MacroNameTok, const MacroDirective *MD) 
>>> override {
>>> +  void MacroDefined(const Token &MacroNameTok,
>>> +const MacroDirective *MD) override {
>>>First->MacroDefined(MacroNameTok, MD);
>>>Second->MacroDefined(MacroNameTok, MD);
>>>  }
>>>
>>>  void MacroUndefined(const Token &MacroNameTok,
>>> -  const MacroDefinition &MD) override {
>>> -First->MacroUndefined(MacroNameTok, MD);
>>> -Second->MacroUndefined(MacroNameTok, MD);
>>> +  const MacroDefinition &MD,
>>> +  const MacroDirective *Undef) override {
>>> +First->MacroUndefined(MacroNameTok, MD, Undef);
>>> +Second->MacroUndefined(MacroNameTok, MD, Undef);
>>>  }
>>>
>>>  void Defined(const Token &MacroNameTok, const MacroDefinition &MD,
>>>
>>> Modified: cfe/trunk/include/clang/Lex/PreprocessingRecord.h
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessingRecord.h?rev=301449&r1=301448&r2=301449&view=diff
>>> ==
>>> --- cfe/trunk/include/clang/Lex/PreprocessingRecord.h (original)
>>> +++ cfe/trunk/include/clang/Lex/PreprocessingRecord.h Wed Apr 26 14:47:31 
>>> 2017
>>> @@ -488,7 +488,8 @@ namespace clang {
>>>void MacroExpands(const Token &Id, const

[PATCH] D32565: Make test corrections necessary due to changing llvm::HashString

2017-04-26 Thread Scott Smith via Phabricator via cfe-commits
scott.smith created this revision.
Herald added a subscriber: klimek.

Certain test output is dependent on the order of the hash value computed by 
llvm::HashString.  Correct those so https://reviews.llvm.org/D32509 can be 
committed.


Repository:
  rL LLVM

https://reviews.llvm.org/D32565

Files:
  test/CodeGen/target-features-error-2.c
  test/CodeGen/target-features-error.c
  test/SemaCXX/typo-correction-delayed.cpp
  unittests/Tooling/CompilationDatabaseTest.cpp


Index: unittests/Tooling/CompilationDatabaseTest.cpp
===
--- unittests/Tooling/CompilationDatabaseTest.cpp
+++ unittests/Tooling/CompilationDatabaseTest.cpp
@@ -81,10 +81,10 @@
 
   std::vector expected_files;
   SmallString<16> PathStorage;
-  llvm::sys::path::native("//net/dir/file1", PathStorage);
-  expected_files.push_back(PathStorage.str());
   llvm::sys::path::native("//net/dir/file2", PathStorage);
   expected_files.push_back(PathStorage.str());
+  llvm::sys::path::native("//net/dir/file1", PathStorage);
+  expected_files.push_back(PathStorage.str());
   EXPECT_EQ(expected_files,
 getAllFiles("[{\"directory\":\"//net/dir\","
 "\"command\":\"command\","
Index: test/SemaCXX/typo-correction-delayed.cpp
===
--- test/SemaCXX/typo-correction-delayed.cpp
+++ test/SemaCXX/typo-correction-delayed.cpp
@@ -88,7 +89,10 @@
 struct NestedNode {
   NestedNode* Nest();
   NestedNode* next();
-  string text() const;
+  // Note, this test is dependent on the order in which identifiers are passed
+  // to the typo corrector, which is based on the hash function used.  For
+  // consistency, I am making the next keyword the first identifier returned.
+  string eext() const;
 };
 void f(NestedNode *node) {
   // There are two equidistant, usable corrections for Next: next and Nest
Index: test/CodeGen/target-features-error.c
===
--- test/CodeGen/target-features-error.c
+++ test/CodeGen/target-features-error.c
@@ -3,6 +3,5 @@
   return a + 4;
 }
 int bar() {
-  return foo(4); // expected-error {{always_inline function 'foo' requires 
target feature 'sse4.2', but would be inlined into function 'bar' that is 
compiled without support for 'sse4.2'}}
+  return foo(4); // expected-error {{always_inline function 'foo' requires 
target feature 'sse4.1', but would be inlined into function 'bar' that is 
compiled without support for 'sse4.1'}}
 }
-
Index: test/CodeGen/target-features-error-2.c
===
--- test/CodeGen/target-features-error-2.c
+++ test/CodeGen/target-features-error-2.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_SSE42
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_SSE41
 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_1
 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_2
 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_3
@@ -7,9 +7,12 @@
 #define __MM_MALLOC_H
 #include 
 
-#if NEED_SSE42
+// Really, this needs AVX, but because targetting AVX includes all the SSE 
features too, and
+// features are sorted by hash function, and we just return the first missing 
feature, then we end
+// up returning the subfeature sse4.1 instead of avx.
+#if NEED_SSE41
 int baz(__m256i a) {
-  return _mm256_extract_epi32(a, 3); // expected-error {{always_inline 
function '_mm256_extract_epi32' requires target feature 'sse4.2', but would be 
inlined into function 'baz' that is compiled without support for 'sse4.2'}}
+  return _mm256_extract_epi32(a, 3); // expected-error {{always_inline 
function '_mm256_extract_epi32' requires target feature 'sse4.1', but would be 
inlined into function 'baz' that is compiled without support for 'sse4.1'}}
 }
 #endif
 


Index: unittests/Tooling/CompilationDatabaseTest.cpp
===
--- unittests/Tooling/CompilationDatabaseTest.cpp
+++ unittests/Tooling/CompilationDatabaseTest.cpp
@@ -81,10 +81,10 @@
 
   std::vector expected_files;
   SmallString<16> PathStorage;
-  llvm::sys::path::native("//net/dir/file1", PathStorage);
-  expected_files.push_back(PathStorage.str());
   llvm::sys::path::native("//net/dir/file2", PathStorage);
   expected_files.push_back(PathStorage.str());
+  llvm::sys::path::native("//net/dir/file1", PathStorage);
+  expected_files.push_back(PathStorage.str());
   EXPECT_EQ(expected_files,
 getAllFiles("[{\"directory\":\"//net/dir\","
 "\"command\":\"command\","
Index: test/SemaCXX/typo-correction-delayed.cpp
===
--- test/SemaCXX/typo-correction-delayed.cpp
+++ test/SemaCXX/typo-correction-delayed.cpp
@@ -88,7 +89,10 @@
 struct Nes

[PATCH] D32565: Make test corrections necessary due to changing llvm::HashString

2017-04-26 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added a comment.

Please add this to https://reviews.llvm.org/D32509. I'll commit this and that 
as one patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D32565



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


[PATCH] D32475: [clang-format] Don’t propagate AvoidBinPacking into argument subexpressions

2017-04-26 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes added a comment.

@djasper how does this look?

I could try to simplify the examples further, but I feel it's important to have 
calls with many subexpressions to exercise this behavior properly. FWIW, my 
real-world use case is with `<<` appearing as an output stream operator inside 
a macro invocation.


https://reviews.llvm.org/D32475



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


[PATCH] D32566: Revert rL301328 and add tests for the regressions introduced.

2017-04-26 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio created this revision.
emilio added a project: clang-c.

See https://reviews.llvm.org/D32348#738704


Repository:
  rL LLVM

https://reviews.llvm.org/D32566

Files:
  clang/test/Index/print-type.cpp
  clang/tools/libclang/CXType.cpp


Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -147,16 +147,16 @@
 static Optional>
 GetTemplateArguments(QualType Type) {
   assert(!Type.isNull());
+  if (const auto *Specialization = Type->getAs())
+return Specialization->template_arguments();
+
   if (const auto *RecordDecl = Type->getAsCXXRecordDecl()) {
 const auto *TemplateDecl =
   dyn_cast(RecordDecl);
 if (TemplateDecl)
   return TemplateDecl->getTemplateArgs().asArray();
   }
 
-  if (const auto *Specialization = Type->getAs())
-return Specialization->template_arguments();
-
   return None;
 }
 
Index: clang/test/Index/print-type.cpp
===
--- clang/test/Index/print-type.cpp
+++ clang/test/Index/print-type.cpp
@@ -71,10 +71,9 @@
 Specialization& > templRefParam;
 auto autoTemplRefParam = templRefParam;
 
-template
-struct DefaultedTypeExample {};
-
-typedef DefaultedTypeExample DefaultedTypeAlias;
+template struct A {};
+template using C = T;
+using baz = C>;
 
 // RUN: c-index-test -test-print-type %s -std=c++14 | FileCheck %s
 // CHECK: Namespace=outer:1:11 (Definition) [type=] [typekind=Invalid] 
[isPOD=0]
@@ -120,7 +119,7 @@
 // CHECK: TemplateRef=Baz:9:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
-// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux, 
outer::inner::Bar::FooType>] [typekind=Unexposed] [templateargs/4= [type=int] 
[typekind=Int] [type=char *] [typekind=Pointer] [type=outer::Foo] 
[typekind=Record] [type=int] [typekind=Int]] [canonicaltype=outer::Qux, int>] [canonicaltypekind=Record] 
[canonicaltemplateargs/4= [type=int] [typekind=Int] [type=char *] 
[typekind=Pointer] [type=outer::Foo] [typekind=Record] [type=int] 
[typekind=Int]] [isPOD=1]
+// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux, 
outer::inner::Bar::FooType>] [typekind=Unexposed] [templateargs/4= [type=int] 
[typekind=Int] [type=char *] [typekind=Pointer] [type=Foo] 
[typekind=Unexposed] [type=outer::inner::Bar::FooType] [typekind=Typedef]] 
[canonicaltype=outer::Qux, int>] 
[canonicaltypekind=Record] [canonicaltemplateargs/4= [type=int] [typekind=Int] 
[type=char *] [typekind=Pointer] [type=outer::Foo] [typekind=Record] 
[type=int] [typekind=Int]] [isPOD=1]
 // CHECK: TemplateRef=Qux:12:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: FunctionTemplate=tbar:36:3 [type=T (int)] [typekind=FunctionProto] 
[canonicaltype=type-parameter-0-0 (int)] [canonicaltypekind=FunctionProto] 
[resulttype=T] [resulttypekind=Unexposed] [isPOD=0]
@@ -182,4 +181,4 @@
 // CHECK: VarDecl=autoTemplRefParam:72:6 (Definition) 
[type=Specialization &>] [typekind=Auto] [templateargs/1= 
[type=Specialization &] [typekind=LValueReference]] 
[canonicaltype=Specialization &>] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization 
&] [typekind=LValueReference]] [isPOD=1]
 // CHECK: UnexposedExpr=templRefParam:71:40 [type=const 
Specialization &>] [typekind=Unexposed] const 
[templateargs/1= [type=Specialization &] [typekind=LValueReference]] 
[canonicaltype=const Specialization &>] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization 
&] [typekind=LValueReference]] [isPOD=1]
 // CHECK: DeclRefExpr=templRefParam:71:40 
[type=Specialization &>] [typekind=Unexposed] 
[templateargs/1= [type=Specialization &] [typekind=LValueReference]] 
[canonicaltype=Specialization &>] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization 
&] [typekind=LValueReference]] [isPOD=1]
-// CHECK: TypedefDecl=DefaultedTypeAlias:77:35 (Definition) 
[type=DefaultedTypeAlias] [typekind=Typedef] [templateargs/2= [type=int] 
[typekind=Int] [type=int] [typekind=Int]] 
[canonicaltype=DefaultedTypeExample] [canonicaltypekind=Record] 
[canonicaltemplateargs/2= [type=int] [typekind=Int] [type=int] [typekind=Int]] 
[isPOD=0]
+// CHECK: TypeAliasDecl=baz:76:7 (Definition) [type=baz] [typekind=Typedef] 
[templateargs/1= [type=A] [typekind=Unexposed]] [canonicaltype=A] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=void] 
[typekind=Void]] [isPOD=0]


Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -147,16 +147,16 @@
 static Optional>
 GetTemplateArguments(QualType Type) {
   assert(!Type.isNull());
+  if (const auto *Specialization = Type->getAs())
+return Specialization->templ

[PATCH] D32309: [libcxx] [test] Resolve compiler warnings in LCM/GCD tests

2017-04-26 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal added a comment.

Hi folks, any update on this or is just fixing @rsmith's comment OK?

Thanks!


https://reviews.llvm.org/D32309



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


[PATCH] D32348: [libclang] Check for a record declaration before a template specialization.

2017-04-26 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio added a comment.

Revert + tests @ https://reviews.llvm.org/D32566


Repository:
  rL LLVM

https://reviews.llvm.org/D32348



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


[PATCH] D32348: [libclang] Check for a record declaration before a template specialization.

2017-04-26 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio added a comment.

> FWIW when I wrote https://reviews.llvm.org/D26663, I did it because arguments 
> weren't inspectionable at all for `using` declarations. Actually both of them 
> would've worked for me.

Also, this bit was not completely accurate, and you could inspect ones, but not 
others (you could inspect the ones that desugared into a RecordDecl that 
happened to be a template specialization, as shown by the bug you pointed out).


Repository:
  rL LLVM

https://reviews.llvm.org/D32348



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


r301486 - Fix comment. NFC

2017-04-26 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Wed Apr 26 17:37:38 2017
New Revision: 301486

URL: http://llvm.org/viewvc/llvm-project?rev=301486&view=rev
Log:
Fix comment. NFC

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=301486&r1=301485&r2=301486&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Apr 26 17:37:38 2017
@@ -5275,8 +5275,7 @@ ExprResult Sema::ActOnCallExpr(Scope *Sc
   if (Fn->getType() == Context.OverloadTy) {
 OverloadExpr::FindResult find = OverloadExpr::find(Fn);
 
-// We aren't supposed to apply this logic for if there'Scope an '&'
-// involved.
+// We aren't supposed to apply this logic if there's an '&' involved.
 if (!find.HasFormOfMemberPointer) {
   OverloadExpr *ovl = find.Expression;
   if (UnresolvedLookupExpr *ULE = dyn_cast(ovl))


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


r301487 - Replace HashString algorithm with xxHash64

2017-04-26 Thread Rui Ueyama via cfe-commits
Author: ruiu
Date: Wed Apr 26 17:45:04 2017
New Revision: 301487

URL: http://llvm.org/viewvc/llvm-project?rev=301487&view=rev
Log:
Replace HashString algorithm with xxHash64

The previous algorithm processed one character at a time, which is very
painful on a modern CPU. Replace it with xxHash64, which both already
exists in the codebase and is fairly fast.

Patch from Scott Smith!

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

Modified:
cfe/trunk/test/CodeGen/target-features-error-2.c
cfe/trunk/test/CodeGen/target-features-error.c
cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp
cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp

Modified: cfe/trunk/test/CodeGen/target-features-error-2.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-features-error-2.c?rev=301487&r1=301486&r2=301487&view=diff
==
--- cfe/trunk/test/CodeGen/target-features-error-2.c (original)
+++ cfe/trunk/test/CodeGen/target-features-error-2.c Wed Apr 26 17:45:04 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_SSE42
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_SSE41
 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_1
 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_2
 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_3
@@ -7,9 +7,12 @@
 #define __MM_MALLOC_H
 #include 
 
-#if NEED_SSE42
+// Really, this needs AVX, but because targetting AVX includes all the SSE 
features too, and
+// features are sorted by hash function, and we just return the first missing 
feature, then we end
+// up returning the subfeature sse4.1 instead of avx.
+#if NEED_SSE41
 int baz(__m256i a) {
-  return _mm256_extract_epi32(a, 3); // expected-error {{always_inline 
function '_mm256_extract_epi32' requires target feature 'sse4.2', but would be 
inlined into function 'baz' that is compiled without support for 'sse4.2'}}
+  return _mm256_extract_epi32(a, 3); // expected-error {{always_inline 
function '_mm256_extract_epi32' requires target feature 'sse4.1', but would be 
inlined into function 'baz' that is compiled without support for 'sse4.1'}}
 }
 #endif
 

Modified: cfe/trunk/test/CodeGen/target-features-error.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-features-error.c?rev=301487&r1=301486&r2=301487&view=diff
==
--- cfe/trunk/test/CodeGen/target-features-error.c (original)
+++ cfe/trunk/test/CodeGen/target-features-error.c Wed Apr 26 17:45:04 2017
@@ -3,6 +3,5 @@ int __attribute__((target("avx"), always
   return a + 4;
 }
 int bar() {
-  return foo(4); // expected-error {{always_inline function 'foo' requires 
target feature 'sse4.2', but would be inlined into function 'bar' that is 
compiled without support for 'sse4.2'}}
+  return foo(4); // expected-error {{always_inline function 'foo' requires 
target feature 'sse4.1', but would be inlined into function 'bar' that is 
compiled without support for 'sse4.1'}}
 }
-

Modified: cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp?rev=301487&r1=301486&r2=301487&view=diff
==
--- cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp (original)
+++ cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp Wed Apr 26 17:45:04 2017
@@ -52,6 +52,7 @@ void testNoCandidates() {
 }
 
 class string {};
+
 struct Item {
   void Nest();
   string text();
@@ -88,12 +89,16 @@ void f(LinkedNode *node) {
 struct NestedNode {
   NestedNode* Nest();
   NestedNode* next();
-  string text() const;
+  // Note, this test is dependent on the order in which identifiers are passed
+  // to the typo corrector, which is based on the hash function used.  For
+  // consistency, I am making the next keyword the first identifier returned.
+  string eext() const;
 };
 void f(NestedNode *node) {
   // There are two equidistant, usable corrections for Next: next and Nest
   NestedNode *next = node->Next();  // expected-error-re {{no member named 
'Next' in 'initializerCorrections::NestedNode'{{$
 }
+
 }
 
 namespace PR21669 {

Modified: cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp?rev=301487&r1=301486&r2=301487&view=diff
==
--- cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp Wed Apr 26 17:45:04 
2017
@@ -81,10 +81,10 @@ TEST(JSONCompilationDatabase, GetAllFile
 
   std::vector expected_files;
   SmallString<16> PathStorage;
-  llvm::sys::path::n

[PATCH] D31778: [Modules] Implement ODR-like semantics for tag types in C/ObjC

2017-04-26 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

@rsmith ping!


https://reviews.llvm.org/D31778



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


[PATCH] D28867: [Profile] Add off-by-default -Wprofile-instr-missing warning

2017-04-26 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 96847.
vsk retitled this revision from "[Profile] Warn about out-of-date profiles only 
when there are mismatches" to "[Profile] Add off-by-default 
-Wprofile-instr-missing warning".
vsk edited the summary of this revision.
vsk added a reviewer: davidxl.
vsk added a comment.

Apologies for the long delay. I've updated this patch so that 
-Wprofile-instr-out-of-date and -Wprofile-instr-missing are split up, as 
suggested by Rong and Mehdi.


https://reviews.llvm.org/D28867

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CodeGenModule.cpp
  test/Profile/c-outdated-data.c


Index: test/Profile/c-outdated-data.c
===
--- test/Profile/c-outdated-data.c
+++ test/Profile/c-outdated-data.c
@@ -4,23 +4,23 @@
 // doesn't play well with warnings that have no line number.
 
 // RUN: llvm-profdata merge %S/Inputs/c-outdated-data.proftext -o %t.profdata
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name 
c-outdated-data.c %s -o /dev/null -emit-llvm 
-fprofile-instrument-use-path=%t.profdata -Wprofile-instr-dropped 2>&1 | 
FileCheck %s
-// CHECK: warning: profile data may be out of date: of 3 functions, 1 has no 
data and 1 has mismatched data that will be ignored
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name 
c-outdated-data.c %s -o /dev/null -emit-llvm 
-fprofile-instrument-use-path=%t.profdata 2>&1 | FileCheck %s 
-check-prefix=NO_MISSING
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name 
c-outdated-data.c %s -o /dev/null -emit-llvm -Wprofile-instr-missing 
-fprofile-instrument-use-path=%t.profdata 2>&1 | FileCheck %s 
-check-prefix=WITH_MISSING
+
+// NO_MISSING: warning: profile data may be out of date: of 3 functions, 1 has 
mismatched data that will be ignored
+// NO_MISSING-NOT: 1 has no data
+
+// WITH_MISSING: warning: profile data may be out of date: of 3 functions, 1 
has mismatched data that will be ignored
+// WITH_MISSING: warning: profile data may be incomplete: of 3 functions, 1 
has no data
 
 void no_usable_data() {
   int i = 0;
 
   if (i) {}
-
-#ifdef GENERATE_OUTDATED_DATA
-  if (i) {}
-#endif
 }
 
-#ifndef GENERATE_OUTDATED_DATA
 void no_data() {
 }
-#endif
 
 int main(int argc, const char *argv[]) {
   no_usable_data();
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -369,9 +369,13 @@
 if (MainFile.empty())
   MainFile = "";
 Diags.Report(diag::warn_profile_data_unprofiled) << MainFile;
-  } else
-Diags.Report(diag::warn_profile_data_out_of_date) << Visited << Missing
-  << Mismatched;
+  } else {
+if (Mismatched > 0)
+  Diags.Report(diag::warn_profile_data_out_of_date) << Visited << 
Mismatched;
+
+if (Missing > 0)
+  Diags.Report(diag::warn_profile_data_missing) << Visited << Missing;
+  }
 }
 
 void CodeGenModule::Release() {
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -8931,8 +8931,13 @@
 let CategoryName = "Instrumentation Issue" in {
 def warn_profile_data_out_of_date : Warning<
   "profile data may be out of date: of %0 function%s0, %1 
%plural{1:has|:have}1"
-  " no data and %2 %plural{1:has|:have}2 mismatched data that will be 
ignored">,
+  " mismatched data that will be ignored">,
   InGroup;
+def warn_profile_data_missing : Warning<
+  "profile data may be incomplete: of %0 function%s0, %1 %plural{1:has|:have}1"
+  " no data">,
+  InGroup,
+  DefaultIgnore;
 def warn_profile_data_unprofiled : Warning<
   "no profile data available for file \"%0\"">,
   InGroup;
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -890,6 +890,7 @@
 def BackendOptimizationFailure : DiagGroup<"pass-failed">;
 
 // Instrumentation based profiling warnings.
+def ProfileInstrMissing : DiagGroup<"profile-instr-missing">;
 def ProfileInstrOutOfDate : DiagGroup<"profile-instr-out-of-date">;
 def ProfileInstrUnprofiled : DiagGroup<"profile-instr-unprofiled">;
 


Index: test/Profile/c-outdated-data.c
===
--- test/Profile/c-outdated-data.c
+++ test/Profile/c-outdated-data.c
@@ -4,23 +4,23 @@
 // doesn't play well with warnings that have no line number.
 
 // RUN: llvm-profdata merge %S/Inputs/c-outdated-data.proftext -o %t.profdata
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-outdated-data.c %s -o /dev/null -emit-llvm -fprofile-instrument-use-path=%t.profdata -Wprofile-instr-dropped 2>&1 |

r301491 - Revert r301487: Replace HashString algorithm with xxHash64

2017-04-26 Thread Rui Ueyama via cfe-commits
Author: ruiu
Date: Wed Apr 26 18:15:10 2017
New Revision: 301491

URL: http://llvm.org/viewvc/llvm-project?rev=301491&view=rev
Log:
Revert r301487: Replace HashString algorithm with xxHash64

This reverts commit r301487 to make buildbots green.

Modified:
cfe/trunk/test/CodeGen/target-features-error-2.c
cfe/trunk/test/CodeGen/target-features-error.c
cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp
cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp

Modified: cfe/trunk/test/CodeGen/target-features-error-2.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-features-error-2.c?rev=301491&r1=301490&r2=301491&view=diff
==
--- cfe/trunk/test/CodeGen/target-features-error-2.c (original)
+++ cfe/trunk/test/CodeGen/target-features-error-2.c Wed Apr 26 18:15:10 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_SSE41
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_SSE42
 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_1
 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_2
 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -verify -o - -D NEED_AVX_3
@@ -7,12 +7,9 @@
 #define __MM_MALLOC_H
 #include 
 
-// Really, this needs AVX, but because targetting AVX includes all the SSE 
features too, and
-// features are sorted by hash function, and we just return the first missing 
feature, then we end
-// up returning the subfeature sse4.1 instead of avx.
-#if NEED_SSE41
+#if NEED_SSE42
 int baz(__m256i a) {
-  return _mm256_extract_epi32(a, 3); // expected-error {{always_inline 
function '_mm256_extract_epi32' requires target feature 'sse4.1', but would be 
inlined into function 'baz' that is compiled without support for 'sse4.1'}}
+  return _mm256_extract_epi32(a, 3); // expected-error {{always_inline 
function '_mm256_extract_epi32' requires target feature 'sse4.2', but would be 
inlined into function 'baz' that is compiled without support for 'sse4.2'}}
 }
 #endif
 

Modified: cfe/trunk/test/CodeGen/target-features-error.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-features-error.c?rev=301491&r1=301490&r2=301491&view=diff
==
--- cfe/trunk/test/CodeGen/target-features-error.c (original)
+++ cfe/trunk/test/CodeGen/target-features-error.c Wed Apr 26 18:15:10 2017
@@ -3,5 +3,6 @@ int __attribute__((target("avx"), always
   return a + 4;
 }
 int bar() {
-  return foo(4); // expected-error {{always_inline function 'foo' requires 
target feature 'sse4.1', but would be inlined into function 'bar' that is 
compiled without support for 'sse4.1'}}
+  return foo(4); // expected-error {{always_inline function 'foo' requires 
target feature 'sse4.2', but would be inlined into function 'bar' that is 
compiled without support for 'sse4.2'}}
 }
+

Modified: cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp?rev=301491&r1=301490&r2=301491&view=diff
==
--- cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp (original)
+++ cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp Wed Apr 26 18:15:10 2017
@@ -52,7 +52,6 @@ void testNoCandidates() {
 }
 
 class string {};
-
 struct Item {
   void Nest();
   string text();
@@ -89,16 +88,12 @@ void f(LinkedNode *node) {
 struct NestedNode {
   NestedNode* Nest();
   NestedNode* next();
-  // Note, this test is dependent on the order in which identifiers are passed
-  // to the typo corrector, which is based on the hash function used.  For
-  // consistency, I am making the next keyword the first identifier returned.
-  string eext() const;
+  string text() const;
 };
 void f(NestedNode *node) {
   // There are two equidistant, usable corrections for Next: next and Nest
   NestedNode *next = node->Next();  // expected-error-re {{no member named 
'Next' in 'initializerCorrections::NestedNode'{{$
 }
-
 }
 
 namespace PR21669 {

Modified: cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp?rev=301491&r1=301490&r2=301491&view=diff
==
--- cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp Wed Apr 26 18:15:10 
2017
@@ -81,10 +81,10 @@ TEST(JSONCompilationDatabase, GetAllFile
 
   std::vector expected_files;
   SmallString<16> PathStorage;
-  llvm::sys::path::native("//net/dir/file2", PathStorage);
-  expected_files.push_back(PathStorage.str());
   llvm::sys::path::native("//net/dir/file1", PathStorage);
   expected_files.push_back(PathStorage.str());
+ 

r301497 - Don't accept -std= values that would switch us to a different source language.

2017-04-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Apr 26 18:44:33 2017
New Revision: 301497

URL: http://llvm.org/viewvc/llvm-project?rev=301497&view=rev
Log:
Don't accept -std= values that would switch us to a different source language.

We already prohibited this in most cases (in r130710), but had some bugs in our
enforcement of this rule. Specifically, this prevents the following
combinations:

 * -x c -std=clN.M, which would previously effectively act as if -x cl were
   used, despite the input being a C source file. (-x cl -std=cNN continues
   to be disallowed.)

 * -x c++ -std=cuda, which would previously select C++98 + CUDA, despite that
   not being a C++ standard. (-x cuda -std=c++NN is still permitted, and
   selects CUDA with the given C++ standard as its base language.
   -x cuda -std=cuda is still supported with the meaning of CUDA + C++98.)

 * -x renderscript -std=c++NN, which would previously form a hybrid "C++ with
   RenderScript extensions" language. We could support such a thing, but
   shouldn't do so by accident.

Modified:
cfe/trunk/include/clang/Frontend/LangStandard.h
cfe/trunk/include/clang/Frontend/LangStandards.def
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/LangStandards.cpp
cfe/trunk/test/Driver/unknown-std.c
cfe/trunk/test/Driver/unknown-std.cpp
cfe/trunk/test/Frontend/gnu-inline.c

Modified: cfe/trunk/include/clang/Frontend/LangStandard.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/LangStandard.h?rev=301497&r1=301496&r2=301497&view=diff
==
--- cfe/trunk/include/clang/Frontend/LangStandard.h (original)
+++ cfe/trunk/include/clang/Frontend/LangStandard.h Wed Apr 26 18:44:33 2017
@@ -11,6 +11,7 @@
 #define LLVM_CLANG_FRONTEND_LANGSTANDARD_H
 
 #include "clang/Basic/LLVM.h"
+#include "clang/Frontend/FrontendOptions.h"
 #include "llvm/ADT/StringRef.h"
 
 namespace clang {
@@ -39,7 +40,7 @@ enum LangFeatures {
 /// standard.
 struct LangStandard {
   enum Kind {
-#define LANGSTANDARD(id, name, desc, features) \
+#define LANGSTANDARD(id, name, lang, desc, features) \
 lang_##id,
 #include "clang/Frontend/LangStandards.def"
 lang_unspecified
@@ -48,6 +49,7 @@ struct LangStandard {
   const char *ShortName;
   const char *Description;
   unsigned Flags;
+  InputKind::Language Language;
 
 public:
   /// getName - Get the name of this standard.
@@ -56,6 +58,9 @@ public:
   /// getDescription - Get the description of this standard.
   const char *getDescription() const { return Description; }
 
+  /// Get the language that this standard describes.
+  InputKind::Language getLanguage() const { return Language; }
+
   /// Language supports '//' comments.
   bool hasLineComments() const { return Flags & frontend::LineComment; }
 

Modified: cfe/trunk/include/clang/Frontend/LangStandards.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/LangStandards.def?rev=301497&r1=301496&r2=301497&view=diff
==
--- cfe/trunk/include/clang/Frontend/LangStandards.def (original)
+++ cfe/trunk/include/clang/Frontend/LangStandards.def Wed Apr 26 18:44:33 2017
@@ -11,10 +11,11 @@
 #error "LANGSTANDARD must be defined before including this file"
 #endif
 
-/// LANGSTANDARD(IDENT, NAME, DESC, FEATURES)
+/// LANGSTANDARD(IDENT, NAME, LANG, DESC, FEATURES)
 ///
 /// \param IDENT - The name of the standard as a C++ identifier.
 /// \param NAME - The name of the standard.
+/// \param LANG - The InputKind::Language for which this is a standard.
 /// \param DESC - A short description of the standard.
 /// \param FEATURES - The standard features as flags, these are enums from the
 /// clang::frontend namespace, which is assumed to be be available.
@@ -29,128 +30,128 @@
 
 // C89-ish modes.
 LANGSTANDARD(c89, "c89",
- "ISO C 1990",
+ C, "ISO C 1990",
  C89 | ImplicitInt)
-LANGSTANDARD(c90, "c90",
+LANGSTANDARD(c90, "c90", C,
  "ISO C 1990",
  C89 | ImplicitInt)
 LANGSTANDARD(iso9899_1990, "iso9899:1990",
- "ISO C 1990",
+ C, "ISO C 1990",
  C89 | ImplicitInt)
 
 LANGSTANDARD(c94, "iso9899:199409",
- "ISO C 1990 with amendment 1",
+ C, "ISO C 1990 with amendment 1",
  C89 | Digraphs | ImplicitInt)
 
 LANGSTANDARD(gnu89, "gnu89",
- "ISO C 1990 with GNU extensions",
+ C, "ISO C 1990 with GNU extensions",
  LineComment | C89 | Digraphs | GNUMode | ImplicitInt)
 LANGSTANDARD(gnu90, "gnu90",
- "ISO C 1990 with GNU extensions",
+ C, "ISO C 1990 with GNU extensions",
  LineComment | C89 | Digraphs | GNUMode | ImplicitInt)
 
 // C99-ish modes
 LANGSTANDARD(c99, "c99",
- "ISO C 1999",
+ C, "ISO C 1999",
  LineComment | C99 | Digraphs | HexFloat)
 LA

r301500 - Remove unnecessary and somewhat inaccurate "C89" flag from language standards.

2017-04-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Apr 26 18:49:57 2017
New Revision: 301500

URL: http://llvm.org/viewvc/llvm-project?rev=301500&view=rev
Log:
Remove unnecessary and somewhat inaccurate "C89" flag from language standards.

Modified:
cfe/trunk/include/clang/Frontend/LangStandard.h
cfe/trunk/include/clang/Frontend/LangStandards.def
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Frontend/LangStandard.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/LangStandard.h?rev=301500&r1=301499&r2=301500&view=diff
==
--- cfe/trunk/include/clang/Frontend/LangStandard.h (original)
+++ cfe/trunk/include/clang/Frontend/LangStandard.h Wed Apr 26 18:49:57 2017
@@ -20,18 +20,17 @@ namespace frontend {
 
 enum LangFeatures {
   LineComment = (1 << 0),
-  C89 = (1 << 1),
-  C99 = (1 << 2),
-  C11 = (1 << 3),
-  CPlusPlus = (1 << 4),
-  CPlusPlus11 = (1 << 5),
-  CPlusPlus14 = (1 << 6),
-  CPlusPlus1z = (1 << 7),
-  Digraphs = (1 << 8),
-  GNUMode = (1 << 9),
-  HexFloat = (1 << 10),
-  ImplicitInt = (1 << 11),
-  OpenCL = (1 << 12)
+  C99 = (1 << 1),
+  C11 = (1 << 2),
+  CPlusPlus = (1 << 3),
+  CPlusPlus11 = (1 << 4),
+  CPlusPlus14 = (1 << 5),
+  CPlusPlus1z = (1 << 6),
+  Digraphs = (1 << 7),
+  GNUMode = (1 << 8),
+  HexFloat = (1 << 9),
+  ImplicitInt = (1 << 10),
+  OpenCL = (1 << 11)
 };
 
 }
@@ -64,9 +63,6 @@ public:
   /// Language supports '//' comments.
   bool hasLineComments() const { return Flags & frontend::LineComment; }
 
-  /// isC89 - Language is a superset of C89.
-  bool isC89() const { return Flags & frontend::C89; }
-
   /// isC99 - Language is a superset of C99.
   bool isC99() const { return Flags & frontend::C99; }
 

Modified: cfe/trunk/include/clang/Frontend/LangStandards.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/LangStandards.def?rev=301500&r1=301499&r2=301500&view=diff
==
--- cfe/trunk/include/clang/Frontend/LangStandards.def (original)
+++ cfe/trunk/include/clang/Frontend/LangStandards.def Wed Apr 26 18:49:57 2017
@@ -31,24 +31,24 @@
 // C89-ish modes.
 LANGSTANDARD(c89, "c89",
  C, "ISO C 1990",
- C89 | ImplicitInt)
+ ImplicitInt)
 LANGSTANDARD(c90, "c90", C,
  "ISO C 1990",
- C89 | ImplicitInt)
+ ImplicitInt)
 LANGSTANDARD(iso9899_1990, "iso9899:1990",
  C, "ISO C 1990",
- C89 | ImplicitInt)
+ ImplicitInt)
 
 LANGSTANDARD(c94, "iso9899:199409",
  C, "ISO C 1990 with amendment 1",
- C89 | Digraphs | ImplicitInt)
+ Digraphs | ImplicitInt)
 
 LANGSTANDARD(gnu89, "gnu89",
  C, "ISO C 1990 with GNU extensions",
- LineComment | C89 | Digraphs | GNUMode | ImplicitInt)
+ LineComment | Digraphs | GNUMode | ImplicitInt)
 LANGSTANDARD(gnu90, "gnu90",
  C, "ISO C 1990 with GNU extensions",
- LineComment | C89 | Digraphs | GNUMode | ImplicitInt)
+ LineComment | Digraphs | GNUMode | ImplicitInt)
 
 // C99-ish modes
 LANGSTANDARD(c99, "c99",

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=301500&r1=301499&r2=301500&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Apr 26 18:49:57 2017
@@ -1615,7 +1615,7 @@ void CompilerInvocation::setLangDefaults
   Opts.CPlusPlus1z = Std.isCPlusPlus1z();
   Opts.Digraphs = Std.hasDigraphs();
   Opts.GNUMode = Std.isGNUMode();
-  Opts.GNUInline = Std.isC89();
+  Opts.GNUInline = !Opts.C99 && !Opts.CPlusPlus;
   Opts.HexFloats = Std.hasHexFloats();
   Opts.ImplicitInt = Std.hasImplicitInt();
 


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


[PATCH] D32574: [libcxx] [test] Fixed possible loss of data warnings in tests on amd64

2017-04-26 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal created this revision.

In T_size_size.pass, there is an explicit template argument to std::min to ask
for unsigned, to avoid type deduction errors. However, C1XX' warnings still
hate this use, because a 64 bit value (a size_t) is being passed to a function
accepting an unsigned (a 32 bit value).

Instead of supplying explicit template arguments, make all the things involved
be unsigned, so there are no type mismatches (and thus, no warning).


https://reviews.llvm.org/D32574

Files:
  test/std/strings/basic.string/string.cons/T_size_size.pass.cpp


Index: test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
===
--- test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
+++ test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
@@ -36,7 +36,7 @@
 S s2(sv, pos, n);
 LIBCPP_ASSERT(s2.__invariants());
 assert(pos <= sv.size());
-unsigned rlen = std::min(sv.size() - pos, n);
+unsigned rlen = std::min(static_cast(sv.size()) - pos, n);
 assert(s2.size() == rlen);
 assert(T::compare(s2.data(), sv.data() + pos, rlen) == 0);
 assert(s2.get_allocator() == A());
@@ -68,7 +68,7 @@
 S s2(sv, pos, n, a);
 LIBCPP_ASSERT(s2.__invariants());
 assert(pos <= sv.size());
-unsigned rlen = std::min(sv.size() - pos, n);
+unsigned rlen = std::min(static_cast(sv.size()) - pos, n);
 assert(s2.size() == rlen);
 assert(T::compare(s2.data(), sv.data() + pos, rlen) == 0);
 assert(s2.get_allocator() == a);


Index: test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
===
--- test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
+++ test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
@@ -36,7 +36,7 @@
 S s2(sv, pos, n);
 LIBCPP_ASSERT(s2.__invariants());
 assert(pos <= sv.size());
-unsigned rlen = std::min(sv.size() - pos, n);
+unsigned rlen = std::min(static_cast(sv.size()) - pos, n);
 assert(s2.size() == rlen);
 assert(T::compare(s2.data(), sv.data() + pos, rlen) == 0);
 assert(s2.get_allocator() == A());
@@ -68,7 +68,7 @@
 S s2(sv, pos, n, a);
 LIBCPP_ASSERT(s2.__invariants());
 assert(pos <= sv.size());
-unsigned rlen = std::min(sv.size() - pos, n);
+unsigned rlen = std::min(static_cast(sv.size()) - pos, n);
 assert(s2.size() == rlen);
 assert(T::compare(s2.data(), sv.data() + pos, rlen) == 0);
 assert(s2.get_allocator() == a);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32573: [Driver] Rename GetNamedOutputPath() to addNamedOutputPath()

2017-04-26 Thread Jorge Gorbe via Phabricator via cfe-commits
jgorbe created this revision.

The current name is confusing: it looks like it should just compute the path 
and return it but it has the side effect of appending it to the compilation's 
list of result files. This change changes the verb in the method name from 
"get" to "add" to emphasize this side effect.


https://reviews.llvm.org/D32573

Files:
  include/clang/Driver/Driver.h
  lib/Driver/Driver.cpp


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -3308,7 +3308,7 @@
   UI.DependentToolChain->getTriple().normalize(),
   /*CreatePrefixForHost=*/true);
   auto CurI = InputInfo(
-  UA, GetNamedOutputPath(C, *UA, BaseInput, UI.DependentBoundArch,
+  UA, addNamedOutputPath(C, *UA, BaseInput, UI.DependentBoundArch,
  /*AtTopLevel=*/false, MultipleArchs,
  OffloadingPrefix),
   BaseInput);
@@ -3338,7 +3338,7 @@
 A->getOffloadingDeviceKind(), TC->getTriple().normalize(),
 /*CreatePrefixForHost=*/!!A->getOffloadingHostActiveKinds() &&
 !AtTopLevel);
-Result = InputInfo(A, GetNamedOutputPath(C, *JA, BaseInput, BoundArch,
+Result = InputInfo(A, addNamedOutputPath(C, *JA, BaseInput, BoundArch,
  AtTopLevel, MultipleArchs,
  OffloadingPrefix),
BaseInput);
@@ -3416,7 +3416,7 @@
   return Args.MakeArgString(Filename.c_str());
 }
 
-const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
+const char *Driver::addNamedOutputPath(Compilation &C, const JobAction &JA,
const char *BaseInput,
StringRef BoundArch, bool AtTopLevel,
bool MultipleArchs,
Index: include/clang/Driver/Driver.h
===
--- include/clang/Driver/Driver.h
+++ include/clang/Driver/Driver.h
@@ -449,19 +449,20 @@
   /// Returns the default name for linked images (e.g., "a.out").
   const char *getDefaultImageName() const;
 
-  /// GetNamedOutputPath - Return the name to use for the output of
-  /// the action \p JA. The result is appended to the compilation's
-  /// list of temporary or result files, as appropriate.
+  /// Computes the name to use for the output of the action \p JA and appends 
it
+  /// to the compilation's list of temporary or result files, as appropriate.
   ///
   /// \param C - The compilation.
   /// \param JA - The action of interest.
   /// \param BaseInput - The original input file that this action was
   /// triggered by.
-  /// \param BoundArch - The bound architecture. 
+  /// \param BoundArch - The bound architecture.
   /// \param AtTopLevel - Whether this is a "top-level" action.
   /// \param MultipleArchs - Whether multiple -arch options were supplied.
   /// \param NormalizedTriple - The normalized triple of the relevant target.
-  const char *GetNamedOutputPath(Compilation &C, const JobAction &JA,
+  //
+  //  \return The name to use for the output of the action \p JA.
+  const char *addNamedOutputPath(Compilation &C, const JobAction &JA,
  const char *BaseInput, StringRef BoundArch,
  bool AtTopLevel, bool MultipleArchs,
  StringRef NormalizedTriple) const;


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -3308,7 +3308,7 @@
   UI.DependentToolChain->getTriple().normalize(),
   /*CreatePrefixForHost=*/true);
   auto CurI = InputInfo(
-  UA, GetNamedOutputPath(C, *UA, BaseInput, UI.DependentBoundArch,
+  UA, addNamedOutputPath(C, *UA, BaseInput, UI.DependentBoundArch,
  /*AtTopLevel=*/false, MultipleArchs,
  OffloadingPrefix),
   BaseInput);
@@ -3338,7 +3338,7 @@
 A->getOffloadingDeviceKind(), TC->getTriple().normalize(),
 /*CreatePrefixForHost=*/!!A->getOffloadingHostActiveKinds() &&
 !AtTopLevel);
-Result = InputInfo(A, GetNamedOutputPath(C, *JA, BaseInput, BoundArch,
+Result = InputInfo(A, addNamedOutputPath(C, *JA, BaseInput, BoundArch,
  AtTopLevel, MultipleArchs,
  OffloadingPrefix),
BaseInput);
@@ -3416,7 +3416,7 @@
   return Args.MakeArgString(Filename.c_str());
 }
 
-const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
+const char *Driver::addNamedOutputPath(Compilation &C, const JobAction &JA,
const char *BaseInput,

r301503 - clang/Lex/PPCallbacks.h: Fix a warning in r301472. [-Wdocumentation]

2017-04-26 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Wed Apr 26 19:09:42 2017
New Revision: 301503

URL: http://llvm.org/viewvc/llvm-project?rev=301503&view=rev
Log:
clang/Lex/PPCallbacks.h: Fix a warning in r301472. [-Wdocumentation]

Modified:
cfe/trunk/include/clang/Lex/PPCallbacks.h

Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPCallbacks.h?rev=301503&r1=301502&r2=301503&view=diff
==
--- cfe/trunk/include/clang/Lex/PPCallbacks.h (original)
+++ cfe/trunk/include/clang/Lex/PPCallbacks.h Wed Apr 26 19:09:42 2017
@@ -247,7 +247,7 @@ public:
   }
 
   /// \brief Hook called whenever a macro \#undef is seen.
-  /// \param Token The active Token
+  /// \param MacroNameTok The active Token
   /// \param MD A MacroDefinition for the named macro.
   /// \param Undef New MacroDirective if the macro was defined, null otherwise.
   ///


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


r301507 - Improve diagnostics for bad -std= flag.

2017-04-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Apr 26 20:17:05 2017
New Revision: 301507

URL: http://llvm.org/viewvc/llvm-project?rev=301507&view=rev
Log:
Improve diagnostics for bad -std= flag.

Don't list deprecated -std= values (c++0x etc). Only produce one line of output
per standard, even if we know it by multiple names.

In passing, add missing -std=gnu++03 alias (supported by GCC), and add new
spelling '-std=cl1.0' for OpenCL 1.0 for consistency with the other values,
with the same meaning as the preexisting '-std=cl'.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Frontend/LangStandards.def
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Driver/unknown-std.c
cfe/trunk/test/Driver/unknown-std.cl
cfe/trunk/test/Driver/unknown-std.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=301507&r1=301506&r2=301507&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Wed Apr 26 20:17:05 
2017
@@ -233,7 +233,9 @@ def note_drv_t_option_is_global : Note<
   "The last /TC or /TP option takes precedence over earlier instances">;
 def note_drv_address_sanitizer_debug_runtime : Note<
   "AddressSanitizer doesn't support linking with debug runtime libraries yet">;
-def note_drv_use_standard : Note<"use '%0' for '%1' standard">;
+def note_drv_use_standard : Note<"use '%0'"
+  "%select{| or '%3'|, '%3', or '%4'|, '%3', '%4', or '%5'}2 "
+  "for '%1' standard">;
 
 def err_analyzer_config_no_value : Error<
   "analyzer-config option '%0' has a key but no value">;

Modified: cfe/trunk/include/clang/Frontend/LangStandards.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/LangStandards.def?rev=301507&r1=301506&r2=301507&view=diff
==
--- cfe/trunk/include/clang/Frontend/LangStandards.def (original)
+++ cfe/trunk/include/clang/Frontend/LangStandards.def Wed Apr 26 20:17:05 2017
@@ -24,20 +24,23 @@
 /// \param IDENT - The name of the standard as a C++ identifier.
 /// \param ALIAS - The alias of the standard.
 
+/// LANGSTANDARD_ALIAS_DEPR(IDENT, ALIAS)
+/// Same as LANGSTANDARD_ALIAS, but for a deprecated alias.
+
 #ifndef LANGSTANDARD_ALIAS
 #define LANGSTANDARD_ALIAS(IDENT, ALIAS)
 #endif
 
+#ifndef LANGSTANDARD_ALIAS_DEPR
+#define LANGSTANDARD_ALIAS_DEPR(IDENT, ALIAS) LANGSTANDARD_ALIAS(IDENT, ALIAS)
+#endif
+
 // C89-ish modes.
 LANGSTANDARD(c89, "c89",
  C, "ISO C 1990",
  ImplicitInt)
-LANGSTANDARD(c90, "c90", C,
- "ISO C 1990",
- ImplicitInt)
-LANGSTANDARD(iso9899_1990, "iso9899:1990",
- C, "ISO C 1990",
- ImplicitInt)
+LANGSTANDARD_ALIAS(c89, "c90")
+LANGSTANDARD_ALIAS(c89, "iso9899:1990")
 
 LANGSTANDARD(c94, "iso9899:199409",
  C, "ISO C 1990 with amendment 1",
@@ -46,104 +49,82 @@ LANGSTANDARD(c94, "iso9899:199409",
 LANGSTANDARD(gnu89, "gnu89",
  C, "ISO C 1990 with GNU extensions",
  LineComment | Digraphs | GNUMode | ImplicitInt)
-LANGSTANDARD(gnu90, "gnu90",
- C, "ISO C 1990 with GNU extensions",
- LineComment | Digraphs | GNUMode | ImplicitInt)
+LANGSTANDARD_ALIAS(gnu89, "gnu90")
 
 // C99-ish modes
 LANGSTANDARD(c99, "c99",
  C, "ISO C 1999",
  LineComment | C99 | Digraphs | HexFloat)
-LANGSTANDARD(c9x, "c9x",
- C, "ISO C 1999",
- LineComment | C99 | Digraphs | HexFloat)
-LANGSTANDARD(iso9899_1999, "iso9899:1999",
- C, "ISO C 1999",
- LineComment | C99 | Digraphs | HexFloat)
-LANGSTANDARD(iso9899_199x, "iso9899:199x",
- C, "ISO C 1999",
- LineComment | C99 | Digraphs | HexFloat)
+LANGSTANDARD_ALIAS(c99, "iso9899:1999")
+LANGSTANDARD_ALIAS_DEPR(c99, "c9x")
+LANGSTANDARD_ALIAS_DEPR(c99, "iso9899:199x")
 
 LANGSTANDARD(gnu99, "gnu99",
  C, "ISO C 1999 with GNU extensions",
  LineComment | C99 | Digraphs | GNUMode | HexFloat)
-LANGSTANDARD(gnu9x, "gnu9x",
- C, "ISO C 1999 with GNU extensions",
- LineComment | C99 | Digraphs | GNUMode | HexFloat)
+LANGSTANDARD_ALIAS_DEPR(gnu99, "gnu9x")
 
 // C11 modes
 LANGSTANDARD(c11, "c11",
  C, "ISO C 2011",
  LineComment | C99 | C11 | Digraphs | HexFloat)
-LANGSTANDARD(c1x, "c1x",
- C, "ISO C 2011",
- LineComment | C99 | C11 | Digraphs | HexFloat)
-LANGSTANDARD(iso9899_2011, "iso9899:2011",
- C, "ISO C 2011",
- LineComment | C99 | C11 | Digraphs | HexFloat)
-LANGSTANDARD(iso9899_201x, "iso9899:201x",
- C, "ISO C 2011",
- LineComment | C99 | C11 | Digraphs | HexFloat)
+

[PATCH] D32576: [Modules] Improve diagnostics for incomplete umbrella

2017-04-26 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno created this revision.

One of the -Wincomplete-umbrella warnings diagnoses when a header is present in 
the directory but it's not present in the umbrella header. Currently, this 
warning only happens on top level modules; any submodule using an umbrella 
header does not get this warning. Fix that by also considering the submodules.


https://reviews.llvm.org/D32576

Files:
  include/clang/Lex/Preprocessor.h
  lib/Lex/PPLexerChange.cpp
  test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h
  test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h
  test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap
  
test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.private.modulemap
  test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Baz.h
  test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Foo.h
  test/Modules/incomplete-umbrella.m

Index: test/Modules/incomplete-umbrella.m
===
--- /dev/null
+++ test/Modules/incomplete-umbrella.m
@@ -0,0 +1,15 @@
+// RUN: rm -rf %t
+// RUN: not %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -F%S/Inputs/incomplete-umbrella -fsyntax-only %s 2>&1 | FileCheck %s
+
+#import 
+#import 
+#import 
+@import Foo.Private;
+
+// CHECK: warning: umbrella header for module 'Foo' does not include header 'Bar.h'
+// CHECK: warning: umbrella header for module 'Foo.Private' does not include header 'Baz.h'
+int foo() {
+  int a = BAR_PUBLIC;
+  int b = BAZ_PRIVATE;
+  return 0;
+}
Index: test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Foo.h
===
--- /dev/null
+++ test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Foo.h
@@ -0,0 +1 @@
+// Foo.h
Index: test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Baz.h
===
--- /dev/null
+++ test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Baz.h
@@ -0,0 +1 @@
+#define BAZ_PRIVATE 1
Index: test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.private.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.private.modulemap
@@ -0,0 +1,5 @@
+explicit module Foo.Private {
+umbrella header "Foo.h"
+requires objc
+export *
+}
Index: test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap
@@ -0,0 +1,5 @@
+framework module Foo {
+umbrella header "FooPublic.h"
+requires objc
+export *
+}
Index: test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h
===
--- /dev/null
+++ test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h
@@ -0,0 +1 @@
+// FooPublic.h
Index: test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h
===
--- /dev/null
+++ test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h
@@ -0,0 +1 @@
+#define BAR_PUBLIC 1
Index: lib/Lex/PPLexerChange.cpp
===
--- lib/Lex/PPLexerChange.cpp
+++ lib/Lex/PPLexerChange.cpp
@@ -287,6 +287,49 @@
   return EndPos;
 }
 
+static void
+collectAllSubModulesWithUmbrellaHeader(Module *Mod,
+   SmallVectorImpl &SubMods) {
+  if (Mod->getUmbrellaHeader())
+SubMods.push_back(Mod);
+  for (auto *M : Mod->submodules())
+collectAllSubModulesWithUmbrellaHeader(M, SubMods);
+}
+
+void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(Module *Mod) {
+  assert(Mod->getUmbrellaHeader() && "Module must use umbrella header");
+  SourceLocation StartLoc =
+  SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
+  if (getDiagnostics().isIgnored(diag::warn_uncovered_module_header, StartLoc))
+return;
+
+  ModuleMap &ModMap = getHeaderSearchInfo().getModuleMap();
+  const DirectoryEntry *Dir = Mod->getUmbrellaDir().Entry;
+  vfs::FileSystem &FS = *FileMgr.getVirtualFileSystem();
+  std::error_code EC;
+  for (vfs::recursive_directory_iterator Entry(FS, Dir->getName(), EC), End;
+   Entry != End && !EC; Entry.increment(EC)) {
+using llvm::StringSwitch;
+
+// Check whether this entry has an extension typically associated with
+// headers.
+if (!StringSwitch(llvm::sys::path::extension(Entry->getName()))
+ .Cases(".h", ".H", ".hh", ".hpp", true)
+ .Default(false))
+  continue;
+
+if (const FileEntry *Header = getFileManager().getFile(Entry->getName()))
+  if (!get

[PATCH] D28670: [ObjC] Disallow vector parameters and return values in Objective-C methods on older X86 targets

2017-04-26 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

Thanks Alex. LGTM


Repository:
  rL LLVM

https://reviews.llvm.org/D28670



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


r301508 - Darwin: Define __STDC_NO_THREADS__ on Darwin targets

2017-04-26 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Wed Apr 26 20:47:22 2017
New Revision: 301508

URL: http://llvm.org/viewvc/llvm-project?rev=301508&view=rev
Log:
Darwin: Define __STDC_NO_THREADS__ on Darwin targets

Darwin doesn't support C11 threads.h.  Define `__STDC_NO_THREADS__` so
that users can check for it.

rdar://problem/18461003

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=301508&r1=301507&r2=301508&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Apr 26 20:47:22 2017
@@ -117,6 +117,7 @@ static void getDarwinDefines(MacroBuilde
  VersionTuple &PlatformMinVersion) {
   Builder.defineMacro("__APPLE_CC__", "6000");
   Builder.defineMacro("__APPLE__");
+  Builder.defineMacro("__STDC_NO_THREADS__");
   Builder.defineMacro("OBJC_NEW_PROPERTIES");
   // AddressSanitizer doesn't play well with source fortification, which is on
   // by default on Darwin.

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=301508&r1=301507&r2=301508&view=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Wed Apr 26 20:47:22 2017
@@ -9690,3 +9690,12 @@
 // MSVC-X64-NEXT:#define __CLANG_ATOMIC_SHORT_LOCK_FREE 2
 // MSVC-X64-NEXT:#define __CLANG_ATOMIC_WCHAR_T_LOCK_FREE 2
 // MSVC-X86-NOT:#define __GCC_ATOMIC{{.*}}
+
+// RUN: %clang_cc1 -E -dM -ffreestanding\
+// RUN:   -triple=aarch64-apple-ios9 < /dev/null\
+// RUN: | FileCheck -check-prefix=DARWIN %s
+// RUN: %clang_cc1 -E -dM -ffreestanding\
+// RUN:   -triple=aarch64-apple-macosx10.12 < /dev/null \
+// RUN: | FileCheck -check-prefix=DARWIN %s
+
+// DARWIN:#define __STDC_NO_THREADS__ 1


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


  1   2   >