[PATCH] D66149: [BinaryFormat] Teach identify_magic about Tapi files.

2019-08-14 Thread Cyndy Ishida via Phabricator via cfe-commits
cishida abandoned this revision.
cishida added a comment.

Ran into issue with pushing update to this middle of stack revision. Will 
create new clean revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66149



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


[PATCH] D66149: [BinaryFormat] Teach identify_magic about Tapi files.

2019-08-14 Thread Cyndy Ishida via Phabricator via cfe-commits
cishida updated this revision to Diff 215174.
cishida added a comment.
Herald added subscribers: openmp-commits, libcxx-commits, lldb-commits, 
Sanitizers, cfe-commits, jdoerfert, asbirlea, Petar.Avramovic, thopre, jsji, 
jfb, kadircet, rupprecht, arphaman, atanasyan, jkorous, MaskRay, jrtc27, 
christof, cryptoad, kbarton, aheejin, jgravelle-google, arichardson, sbc100, 
javed.absar, mgorny, nhaehnle, jvesely, nemanjai, sdardis, emaste, dschuff, 
srhines.
Herald added a reviewer: bollu.
Herald added a reviewer: JDevlieghere.
Herald added a reviewer: martong.
Herald added a reviewer: espindola.
Herald added a reviewer: jfb.
Herald added a reviewer: shafik.
Herald added a reviewer: jdoerfert.
Herald added projects: clang, Sanitizers, LLDB, libc++, OpenMP.

- Reverse order of conditional for file_magic


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66149

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
  clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
  
clang-tools-extra/clangd/clients/clangd-vscode/test/semantic-highlighting.test.ts
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
  clang-tools-extra/clangd/unittests/TweakTesting.h
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/examples/clang-interpreter/main.cpp
  clang/include/clang/AST/ASTImporter.h
  clang/include/clang/AST/FormatString.h
  clang/include/clang/AST/RawCommentList.h
  clang/include/clang/Analysis/CFG.h
  clang/include/clang/Basic/Features.def
  clang/include/clang/Basic/IdentifierTable.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Driver/Driver.h
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/include/clang/Tooling/AllTUsExecution.h
  clang/include/clang/Tooling/Execution.h
  clang/include/clang/Tooling/Refactoring/Extract/SourceExtraction.h
  clang/include/clang/Tooling/StandaloneExecution.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/FormatStringParsing.h
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/Analysis/CFG.cpp
  clang/lib/Basic/IdentifierTable.cpp
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/DirectoryWatcher/CMakeLists.txt
  clang/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.h
  clang/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
  clang/lib/Tooling/Refactoring/Extract/Extract.cpp
  clang/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp
  clang/lib/Tooling/Refactoring/Extract/SourceExtraction.h
  clang/lib/Tooling/Refactoring/Transformer.cpp
  clang/test/Analysis/Inputs/ctu-other.cpp
  clang/test/Analysis/Inputs/ctu-other.cpp.externalDefMap.txt
  clang/test/Analysis/checker-plugins.c
  clang/test/Analysis/ctu-main.cpp
  clang/test/Analysis/diagnostics/find_last_store.c
  clang/test/Analysis/exploded-graph-rewriter/escapes.c
  clang/test/Analysis/exploded-graph-rewriter/explorers.dot
  clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
  clang/test/Analysis/exploded-graph-rewriter/store.dot
  clang/test/Analysis/exploded-graph-rewriter/trimmers.dot
  clang/test/Analysis/track-control-dependency-conditions.cpp
  clang/test/Analysis/uninit-const.c
  clang/test/Analysis/uninit-const.cpp
  clang/test/Analysis/uninit-vals.c
  clang/test/CodeGen/struct-copy.c
  clang/test/CodeGen/tbaa-struct.cpp
  clang/test/CodeGen/wasm-varargs.c
  clang/test/CodeGenCoroutines/coro-retcon-unreachable.ll
  clang/test/Misc/printer.c
  clang/test/Preprocessor/feature_tests.c
  clang/test/Preprocessor/feature_tests.cpp
  clang/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp
  clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
  clang/test/SemaObjC/format-strings-objc.m
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
  clang/tools/libclang/CXIndexDataConsumer.cpp
  clang/tools/libclang/CXIndexDataConsumer.h
  clang/unittests/Analysis/CFGTest.cpp
  clang/unittests/Tooling/ExecutionTest.cpp
  clang/utils/analyzer/exploded-graph-rewriter.py
  compiler-rt/lib/scudo/standalone/local_cache.h
  compiler-rt/lib/scudo/standalone/mutex.h
  compiler-rt/lib/scudo/standalone/primary

[PATCH] D63978: Clang Interface Stubs merger plumbing for Driver

2019-09-24 Thread Cyndy Ishida via Phabricator via cfe-commits
cishida added inline comments.



Comment at: clang/include/clang/Driver/Options.td:635
+  Flags<[CC1Option]>, Group,
+  HelpText<"Generate Inteface Stub Files, emit merged text not binary.">;
 def iterface_stub_version_EQ : JoinedOrSeparate<["-"], 
"interface-stub-version=">, Flags<[CC1Option]>;

nit: Interface 



Comment at: clang/lib/Driver/ToolChains/InterfaceStubs.h:14
+#include "clang/Driver/ToolChain.h"
+#include 
+

is this used anywhere? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63978



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


[PATCH] D80751: [clang][diagnostics] Add '-Wundef-prefix' warning option

2020-06-30 Thread Cyndy Ishida via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG89a0c4066b0e: [clang][diagnostics] Add 
'-Wundef-prefix' warning option (authored by zixuw, committed by 
cishida).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80751

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/DiagnosticOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/PPExpressions.cpp
  clang/test/Preprocessor/warn-macro-undef.c

Index: clang/test/Preprocessor/warn-macro-undef.c
===
--- /dev/null
+++ clang/test/Preprocessor/warn-macro-undef.c
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 %s -Eonly -Wundef -verify=undef
+// RUN: %clang_cc1 %s -Eonly -Wundef-prefix=A,BC -verify=undef-prefix
+// RUN: %clang_cc1 %s -Eonly -Wundef -Wundef-prefix=A,BC -verify=both
+// RUN: %clang_cc1 %s -Eonly -Werror=undef -verify=undef-error
+// RUN: %clang_cc1 %s -Eonly -Werror=undef-prefix -Wundef-prefix=A,BC -verify=undef-prefix-error
+// RUN: %clang_cc1 %s -Eonly -Werror=undef -Wundef-prefix=A,BC -verify=both-error
+
+extern int x;
+
+#if AB // #1
+#endif
+// undef-warning@#1 {{'AB' is not defined, evaluates to 0}}
+// undef-prefix-warning@#1 {{'AB' is not defined, evaluates to 0}}
+// both-warning@#1 {{'AB' is not defined, evaluates to 0}}
+// undef-error-error@#1 {{'AB' is not defined, evaluates to 0}}
+// undef-prefix-error-error@#1 {{'AB' is not defined, evaluates to 0}}
+// both-error-error@#1 {{'AB' is not defined, evaluates to 0}}
+
+#if B // #2
+#endif
+// undef-warning@#2 {{'B' is not defined, evaluates to 0}}
+// no warning for undef-prefix
+// both-warning@#2 {{'B' is not defined, evaluates to 0}}
+// undef-error-error@#2 {{'B' is not defined, evaluates to 0}}
+// no error for undef-prefix
+// both-error-error@#2 {{'B' is not defined, evaluates to 0}}
+
+#define BC 0
+#if BC // no warning/error
+#endif
+
+#undef BC
+#if BC // #3
+#endif
+// undef-warning@#3 {{'BC' is not defined, evaluates to 0}}
+// undef-prefix-warning@#3 {{'BC' is not defined, evaluates to 0}}
+// both-warning@#3 {{'BC' is not defined, evaluates to 0}}
+// undef-error-error@#3 {{'BC' is not defined, evaluates to 0}}
+// undef-prefix-error-error@#3 {{'BC' is not defined, evaluates to 0}}
+// both-error-error@#3 {{'BC' is not defined, evaluates to 0}}
+
+// Test that #pragma-enabled 'Wundef' can override 'Wundef-prefix'
+#pragma clang diagnostic error "-Wundef"
+
+#if C // #4
+#endif
+// undef-error@#4 {{'C' is not defined, evaluates to 0}}
+// undef-prefix-error@#4 {{'C' is not defined, evaluates to 0}}
+// both-error@#4 {{'C' is not defined, evaluates to 0}}
+// undef-error-error@#4 {{'C' is not defined, evaluates to 0}}
+// undef-prefix-error-error@#4 {{'C' is not defined, evaluates to 0}}
+// both-error-error@#4 {{'C' is not defined, evaluates to 0}}
Index: clang/lib/Lex/PPExpressions.cpp
===
--- clang/lib/Lex/PPExpressions.cpp
+++ clang/lib/Lex/PPExpressions.cpp
@@ -15,7 +15,6 @@
 //
 //===--===//
 
-#include "clang/Lex/Preprocessor.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
@@ -26,9 +25,12 @@
 #include "clang/Lex/LiteralSupport.h"
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/Token.h"
 #include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/SaveAndRestore.h"
@@ -251,8 +253,24 @@
 // If this identifier isn't 'defined' or one of the special
 // preprocessor keywords and it wasn't macro expanded, it turns
 // into a simple 0
-if (ValueLive)
+if (ValueLive) {
   PP.Diag(PeekTok, diag::warn_pp_undef_identifier) << II;
+
+  const DiagnosticsEngine &DiagEngine = PP.getDiagnostics();
+  // If 'Wundef' is enabled, do not emit 'undef-prefix' diagnostics.
+  if (DiagEngine.isIgnored(diag::warn_pp_undef_identifier,
+   PeekTok.getLocation())) {
+const std::vector UndefPrefixes =
+DiagEngine.getDiagnosticOptions().UndefPrefixes;
+const StringRef IdentifierName = II->getName();
+if (llvm::any_of(UndefPrefixes,
+ [&IdentifierName](const std::string &Prefix) {
+   return IdentifierName.startswith(Prefix);
+ }))
+  PP.Diag(PeekTok, diag::warn_pp_undef_prefix)
+  << AddFlagValue{llvm::join(UndefPr

[PATCH] D123148: [clang][extract-api] Process only APIs declared in inputs

2022-04-05 Thread Cyndy Ishida via Phabricator via cfe-commits
cishida added inline comments.



Comment at: clang/lib/ExtractAPI/ExtractAPIConsumer.cpp:66
+// Check if we have looked up this particular file entry previously instead
+// of querying the preprocessor for externsal sources.
+if (UnknownFileEntries.count(File))

s/externsal/external



Comment at: clang/lib/ExtractAPI/ExtractAPIConsumer.cpp:72
+// primarily to resolve headers found via headermaps, as they remap
+// locations.
+const auto *FileInfo = PP.getHeaderSearchInfo().getExistingFileInfo(File);

How is this searching by the way the header was included? It looks like 
comparisons are based on file locations as `KnownIncludes` stores file paths. 



Comment at: clang/test/ExtractAPI/known_files_only.c:6
+// RUN: %clang -extract-api --product-name=GlobalRecord -target 
arm64-apple-macosx \
+// RUN: %t/input1.h %t/input2.h %t/input3.h -o %t/output.json | FileCheck 
-allow-empty %s
+

It may be useful to add a test for the headermap case to ensure the remapped 
location is recognized. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123148

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


[PATCH] D123148: [clang][extract-api] Process only APIs declared in inputs

2022-04-06 Thread Cyndy Ishida via Phabricator via cfe-commits
cishida accepted this revision.
cishida added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123148

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


[PATCH] D123831: [POC][WIP] Use relative include in extract-api

2022-04-15 Thread Cyndy Ishida via Phabricator via cfe-commits
cishida added a comment.

> we might not always want to transform an absolute path because the resulting 
> relative include name might get remapped in a headermap, for example in test 
> known_files_only_hmap.c. But how does it work with modules where we need 
> relative includes? Is the setup in known_files_only_hmap even valid?

I think, in most cases, this shouldn't matter because if the header path input 
doesn't match the location stored in the header map, they should still have the 
same source content. The same should be true with header search resolution with 
modules & vfsoverlay


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123831

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


[PATCH] D124638: [clang] Track how headers get included generally during lookup time

2022-04-28 Thread Cyndy Ishida via Phabricator via cfe-commits
cishida created this revision.
cishida added reviewers: ributzka, zixuw, jansvoboda11.
Herald added a project: All.
cishida requested review of this revision.
Herald added a project: clang.

tapi & clang-extractapi both attempt to construct then check against
how a header was included to determine api information when working
against multiple search paths, headermap, and vfsoverlay mechanisms.
Validating this against what the preprocessor sees during lookup time
makes this check more reliable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124638

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/lib/Lex/HeaderSearch.cpp
  clang/unittests/Lex/HeaderSearchTest.cpp


Index: clang/unittests/Lex/HeaderSearchTest.cpp
===
--- clang/unittests/Lex/HeaderSearchTest.cpp
+++ clang/unittests/Lex/HeaderSearchTest.cpp
@@ -207,6 +207,7 @@
   EXPECT_TRUE(FI);
   EXPECT_TRUE(FI->IsValid);
   EXPECT_EQ(FI->Framework.str(), "Foo");
+  EXPECT_EQ(FI->Alias, "Foo/Foo.h");
 }
 
 // Helper struct with null terminator character to make MemoryBuffer happy.
@@ -275,6 +276,7 @@
   EXPECT_TRUE(FI);
   EXPECT_TRUE(FI->IsValid);
   EXPECT_EQ(FI->Framework.str(), "Foo");
+  EXPECT_EQ(FI->Alias, "Foo/Foo.h");
 }
 
 } // namespace
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1030,8 +1030,10 @@
 
 CurDir = It;
 
-// This file is a system header or C++ unfriendly if the dir is.
 HeaderFileInfo &HFI = getFileInfo(&File->getFileEntry());
+HFI.Alias = Filename.str();
+
+// This file is a system header or C++ unfriendly if the dir is.
 HFI.DirInfo = CurDir->getDirCharacteristic();
 
 // If the directory characteristic is User but this framework was
Index: clang/include/clang/Lex/HeaderSearch.h
===
--- clang/include/clang/Lex/HeaderSearch.h
+++ clang/include/clang/Lex/HeaderSearch.h
@@ -20,6 +20,7 @@
 #include "clang/Lex/ModuleMap.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
@@ -116,6 +117,9 @@
   /// of the framework.
   StringRef Framework;
 
+  /// Alias that this header is known as.
+  llvm::SmallString<64> Alias;
+
   HeaderFileInfo()
   : isImport(false), isPragmaOnce(false), DirInfo(SrcMgr::C_User),
 External(false), isModuleHeader(false), isCompilingModuleHeader(false),


Index: clang/unittests/Lex/HeaderSearchTest.cpp
===
--- clang/unittests/Lex/HeaderSearchTest.cpp
+++ clang/unittests/Lex/HeaderSearchTest.cpp
@@ -207,6 +207,7 @@
   EXPECT_TRUE(FI);
   EXPECT_TRUE(FI->IsValid);
   EXPECT_EQ(FI->Framework.str(), "Foo");
+  EXPECT_EQ(FI->Alias, "Foo/Foo.h");
 }
 
 // Helper struct with null terminator character to make MemoryBuffer happy.
@@ -275,6 +276,7 @@
   EXPECT_TRUE(FI);
   EXPECT_TRUE(FI->IsValid);
   EXPECT_EQ(FI->Framework.str(), "Foo");
+  EXPECT_EQ(FI->Alias, "Foo/Foo.h");
 }
 
 } // namespace
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1030,8 +1030,10 @@
 
 CurDir = It;
 
-// This file is a system header or C++ unfriendly if the dir is.
 HeaderFileInfo &HFI = getFileInfo(&File->getFileEntry());
+HFI.Alias = Filename.str();
+
+// This file is a system header or C++ unfriendly if the dir is.
 HFI.DirInfo = CurDir->getDirCharacteristic();
 
 // If the directory characteristic is User but this framework was
Index: clang/include/clang/Lex/HeaderSearch.h
===
--- clang/include/clang/Lex/HeaderSearch.h
+++ clang/include/clang/Lex/HeaderSearch.h
@@ -20,6 +20,7 @@
 #include "clang/Lex/ModuleMap.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
@@ -116,6 +117,9 @@
   /// of the framework.
   StringRef Framework;
 
+  /// Alias that this header is known as.
+  llvm::SmallString<64> Alias;
+
   HeaderFileInfo()
   : isImport(false), isPragmaOnce(false), DirInfo(SrcMgr::C_User),
 External(false), isModuleHeader(false), isCompilingModuleHeader(false),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124638: [clang] Track how headers get included generally during lookup time

2022-05-02 Thread Cyndy Ishida via Phabricator via cfe-commits
cishida added a comment.

In D124638#3481932 , @jansvoboda11 
wrote:

> Can you describe how come the check is not reliable without this patch? It 
> might be worth fixing the underlying reason for the unreliability first.

Different search paths alter where a header path may be resolved, in these 
cases we attempt to match the header based on how it was included 
``. We determine how the header was included by assembling from 
`HeaderFileInfo::Framework` and the filename associated with the `FileEntry`. 
This becomes inaccurate if a framework header is found without a header map and 
theres multiple locations to find it. This happens in an Xcode configuration 
when you have a Framework target, so theres potentially the same named headers 
in

- DeviredData/.../foo.framework/Headers/bar.h
- SDKROOT/foo.framework/Headers/bar.h
- SRCROOT/foo/bar.h

and search paths for all of them (depending on order). 
Given all the potential cases to cover, I think it would make sense to properly 
track what the include name was during lookup time as a reference-able source 
of truth.

Thank you for pointing out the potential performance cost. I could hold this 
information as apart of a container in `HeaderSearch` itself instead. This 
approach looks similar to `HeaderSearch:: IncludeAliases` which is only used 
for `include_alias`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124638

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


[PATCH] D124638: [clang] Track how headers get included generally during lookup time

2022-05-02 Thread Cyndy Ishida via Phabricator via cfe-commits
cishida added inline comments.



Comment at: clang/lib/Lex/HeaderSearch.cpp:1036
+
+// This file is a system header or C++ unfriendly if the dir is.
 HFI.DirInfo = CurDir->getDirCharacteristic();

tschuett wrote:
> Why did the comment move?
It refers to setting the `DirInfo` field, so I moved it to keep the comment 
near that assignment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124638

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


[PATCH] D124638: [clang] Track how headers get included generally during lookup time

2022-05-03 Thread Cyndy Ishida via Phabricator via cfe-commits
cishida updated this revision to Diff 426858.
cishida added a comment.

Hold include name in `HeaderSearch` itself, keeping HeaderFileInfo lightweight.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124638

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/lib/Lex/HeaderSearch.cpp
  clang/unittests/Lex/HeaderSearchTest.cpp


Index: clang/unittests/Lex/HeaderSearchTest.cpp
===
--- clang/unittests/Lex/HeaderSearchTest.cpp
+++ clang/unittests/Lex/HeaderSearchTest.cpp
@@ -207,6 +207,7 @@
   EXPECT_TRUE(FI);
   EXPECT_TRUE(FI->IsValid);
   EXPECT_EQ(FI->Framework.str(), "Foo");
+  EXPECT_EQ(Search.getIncludeNameForHeader(FE), "Foo/Foo.h");
 }
 
 // Helper struct with null terminator character to make MemoryBuffer happy.
@@ -275,6 +276,7 @@
   EXPECT_TRUE(FI);
   EXPECT_TRUE(FI->IsValid);
   EXPECT_EQ(FI->Framework.str(), "Foo");
+  EXPECT_EQ(Search.getIncludeNameForHeader(FE), "Foo/Foo.h");
 }
 
 } // namespace
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1030,8 +1030,11 @@
 
 CurDir = It;
 
+const auto FE = &File->getFileEntry();
+IncludeNames[FE] = Filename;
+
 // This file is a system header or C++ unfriendly if the dir is.
-HeaderFileInfo &HFI = getFileInfo(&File->getFileEntry());
+HeaderFileInfo &HFI = getFileInfo(FE);
 HFI.DirInfo = CurDir->getDirCharacteristic();
 
 // If the directory characteristic is User but this framework was
@@ -1460,6 +1463,13 @@
   return FrameworkNames.insert(Framework).first->first();
 }
 
+StringRef HeaderSearch::getIncludeNameForHeader(const FileEntry *File) const {
+  auto It = IncludeNames.find(File);
+  if (It == IncludeNames.end())
+return {};
+  return It->second;
+}
+
 bool HeaderSearch::hasModuleMap(StringRef FileName,
 const DirectoryEntry *Root,
 bool IsSystem) {
Index: clang/include/clang/Lex/HeaderSearch.h
===
--- clang/include/clang/Lex/HeaderSearch.h
+++ clang/include/clang/Lex/HeaderSearch.h
@@ -20,6 +20,7 @@
 #include "clang/Lex/ModuleMap.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
@@ -314,6 +315,9 @@
   /// whether they were valid or not.
   llvm::DenseMap LoadedModuleMaps;
 
+  // A map of discovered headers with their associated include file name.
+  llvm::DenseMap> IncludeNames;
+
   /// Uniqued set of framework names, which is used to track which
   /// headers were included as framework headers.
   llvm::StringSet FrameworkNames;
@@ -823,6 +827,13 @@
   /// Retrieve a uniqued framework name.
   StringRef getUniqueFrameworkName(StringRef Framework);
 
+  /// Retrieve the include name for the header.
+  ///
+  /// \param File The entry for a given header.
+  /// \returns The name of how the file was included when the header's location
+  /// was resolved.
+  StringRef getIncludeNameForHeader(const FileEntry *File) const;
+
   /// Suggest a path by which the specified file could be found, for use in
   /// diagnostics to suggest a #include. Returned path will only contain 
forward
   /// slashes as separators. MainFile is the absolute path of the file that we


Index: clang/unittests/Lex/HeaderSearchTest.cpp
===
--- clang/unittests/Lex/HeaderSearchTest.cpp
+++ clang/unittests/Lex/HeaderSearchTest.cpp
@@ -207,6 +207,7 @@
   EXPECT_TRUE(FI);
   EXPECT_TRUE(FI->IsValid);
   EXPECT_EQ(FI->Framework.str(), "Foo");
+  EXPECT_EQ(Search.getIncludeNameForHeader(FE), "Foo/Foo.h");
 }
 
 // Helper struct with null terminator character to make MemoryBuffer happy.
@@ -275,6 +276,7 @@
   EXPECT_TRUE(FI);
   EXPECT_TRUE(FI->IsValid);
   EXPECT_EQ(FI->Framework.str(), "Foo");
+  EXPECT_EQ(Search.getIncludeNameForHeader(FE), "Foo/Foo.h");
 }
 
 } // namespace
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1030,8 +1030,11 @@
 
 CurDir = It;
 
+const auto FE = &File->getFileEntry();
+IncludeNames[FE] = Filename;
+
 // This file is a system header or C++ unfriendly if the dir is.
-HeaderFileInfo &HFI = getFileInfo(&File->getFileEntry());
+HeaderFileInfo &HFI = getFileInfo(FE);
 HFI.DirInfo = CurDir->getDirCharacteristic();
 
 // If the directory characteristic is User but this framework was
@@ -1460,6 +1463,13 @@
   return FrameworkNames.insert(Framework).first->first();
 }
 
+StringRef HeaderSearch::getIncludeNameForHeader(const FileEntry *File) const

[PATCH] D124638: [clang] Track how headers get included generally during lookup time

2022-05-04 Thread Cyndy Ishida via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb6c67c3c6789: [clang] Track how headers get included 
generally during lookup time (authored by cishida).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124638

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/lib/Lex/HeaderSearch.cpp
  clang/unittests/Lex/HeaderSearchTest.cpp


Index: clang/unittests/Lex/HeaderSearchTest.cpp
===
--- clang/unittests/Lex/HeaderSearchTest.cpp
+++ clang/unittests/Lex/HeaderSearchTest.cpp
@@ -207,6 +207,7 @@
   EXPECT_TRUE(FI);
   EXPECT_TRUE(FI->IsValid);
   EXPECT_EQ(FI->Framework.str(), "Foo");
+  EXPECT_EQ(Search.getIncludeNameForHeader(FE), "Foo/Foo.h");
 }
 
 // Helper struct with null terminator character to make MemoryBuffer happy.
@@ -275,6 +276,7 @@
   EXPECT_TRUE(FI);
   EXPECT_TRUE(FI->IsValid);
   EXPECT_EQ(FI->Framework.str(), "Foo");
+  EXPECT_EQ(Search.getIncludeNameForHeader(FE), "Foo/Foo.h");
 }
 
 } // namespace
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1030,8 +1030,11 @@
 
 CurDir = It;
 
+const auto FE = &File->getFileEntry();
+IncludeNames[FE] = Filename;
+
 // This file is a system header or C++ unfriendly if the dir is.
-HeaderFileInfo &HFI = getFileInfo(&File->getFileEntry());
+HeaderFileInfo &HFI = getFileInfo(FE);
 HFI.DirInfo = CurDir->getDirCharacteristic();
 
 // If the directory characteristic is User but this framework was
@@ -1460,6 +1463,13 @@
   return FrameworkNames.insert(Framework).first->first();
 }
 
+StringRef HeaderSearch::getIncludeNameForHeader(const FileEntry *File) const {
+  auto It = IncludeNames.find(File);
+  if (It == IncludeNames.end())
+return {};
+  return It->second;
+}
+
 bool HeaderSearch::hasModuleMap(StringRef FileName,
 const DirectoryEntry *Root,
 bool IsSystem) {
Index: clang/include/clang/Lex/HeaderSearch.h
===
--- clang/include/clang/Lex/HeaderSearch.h
+++ clang/include/clang/Lex/HeaderSearch.h
@@ -20,6 +20,7 @@
 #include "clang/Lex/ModuleMap.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
@@ -314,6 +315,9 @@
   /// whether they were valid or not.
   llvm::DenseMap LoadedModuleMaps;
 
+  // A map of discovered headers with their associated include file name.
+  llvm::DenseMap> IncludeNames;
+
   /// Uniqued set of framework names, which is used to track which
   /// headers were included as framework headers.
   llvm::StringSet FrameworkNames;
@@ -823,6 +827,13 @@
   /// Retrieve a uniqued framework name.
   StringRef getUniqueFrameworkName(StringRef Framework);
 
+  /// Retrieve the include name for the header.
+  ///
+  /// \param File The entry for a given header.
+  /// \returns The name of how the file was included when the header's location
+  /// was resolved.
+  StringRef getIncludeNameForHeader(const FileEntry *File) const;
+
   /// Suggest a path by which the specified file could be found, for use in
   /// diagnostics to suggest a #include. Returned path will only contain 
forward
   /// slashes as separators. MainFile is the absolute path of the file that we


Index: clang/unittests/Lex/HeaderSearchTest.cpp
===
--- clang/unittests/Lex/HeaderSearchTest.cpp
+++ clang/unittests/Lex/HeaderSearchTest.cpp
@@ -207,6 +207,7 @@
   EXPECT_TRUE(FI);
   EXPECT_TRUE(FI->IsValid);
   EXPECT_EQ(FI->Framework.str(), "Foo");
+  EXPECT_EQ(Search.getIncludeNameForHeader(FE), "Foo/Foo.h");
 }
 
 // Helper struct with null terminator character to make MemoryBuffer happy.
@@ -275,6 +276,7 @@
   EXPECT_TRUE(FI);
   EXPECT_TRUE(FI->IsValid);
   EXPECT_EQ(FI->Framework.str(), "Foo");
+  EXPECT_EQ(Search.getIncludeNameForHeader(FE), "Foo/Foo.h");
 }
 
 } // namespace
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1030,8 +1030,11 @@
 
 CurDir = It;
 
+const auto FE = &File->getFileEntry();
+IncludeNames[FE] = Filename;
+
 // This file is a system header or C++ unfriendly if the dir is.
-HeaderFileInfo &HFI = getFileInfo(&File->getFileEntry());
+HeaderFileInfo &HFI = getFileInfo(FE);
 HFI.DirInfo = CurDir->getDirCharacteristic();
 
 // If the directory characteristic is User but this framework was
@@ -1460,6 +1463,13 @@
   return FrameworkNames.insert(Framework).first->first();
 }
 
+StringRef HeaderSearch::getInc

[PATCH] D126258: [Clang] Avoid misleading 'conflicting types' diagnostic with no-prototype decls.

2022-05-23 Thread Cyndy Ishida via Phabricator via cfe-commits
cishida created this revision.
cishida added reviewers: jyknight, aaron.ballman.
Herald added a subscriber: ributzka.
Herald added a project: All.
cishida requested review of this revision.
Herald added a project: clang.

Clang has recently started diagnosing prototype redeclaration errors like 
rG385e7df33046 


This flagged legitimate issues in a codebase but was confusing to resolve 
because it actually conflicted with a function declaration from a system header 
and not from the one emitted with "note: ".

This patch updates the error handling to use the canonical declaration's source 
location instead to avoid misleading errors like the one described.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126258

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/prototype-redecls.c


Index: clang/test/Sema/prototype-redecls.c
===
--- clang/test/Sema/prototype-redecls.c
+++ clang/test/Sema/prototype-redecls.c
@@ -12,6 +12,10 @@
 void blerp(short);  // expected-note {{previous}}
 void blerp(x) int x; {} // expected-error {{conflicting types for 'blerp'}}
 
+void foo(int); // expected-note {{previous}}
+void foo();
+void foo() {} // expected-error {{conflicting types for 'foo'}}
+
 void glerp(int);
 void glerp(x) short x; {} // Okay, promoted type is fine
 
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -3911,6 +3911,7 @@
 // ASTContext::typesAreCompatible().
 if (Old->hasPrototype() && !New->hasWrittenPrototype() && NewDeclIsDefn &&
 Old->getNumParams() != New->getNumParams()) {
+  Old = Old->getCanonicalDecl();
   Diag(New->getLocation(), diag::err_conflicting_types) << New;
   Diag(Old->getLocation(), PrevDiag) << Old << Old->getType();
   return true;


Index: clang/test/Sema/prototype-redecls.c
===
--- clang/test/Sema/prototype-redecls.c
+++ clang/test/Sema/prototype-redecls.c
@@ -12,6 +12,10 @@
 void blerp(short);  // expected-note {{previous}}
 void blerp(x) int x; {} // expected-error {{conflicting types for 'blerp'}}
 
+void foo(int); // expected-note {{previous}}
+void foo();
+void foo() {} // expected-error {{conflicting types for 'foo'}}
+
 void glerp(int);
 void glerp(x) short x; {} // Okay, promoted type is fine
 
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -3911,6 +3911,7 @@
 // ASTContext::typesAreCompatible().
 if (Old->hasPrototype() && !New->hasWrittenPrototype() && NewDeclIsDefn &&
 Old->getNumParams() != New->getNumParams()) {
+  Old = Old->getCanonicalDecl();
   Diag(New->getLocation(), diag::err_conflicting_types) << New;
   Diag(Old->getLocation(), PrevDiag) << Old << Old->getType();
   return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126258: [Clang] Avoid misleading 'conflicting types' diagnostic with no-prototype decls.

2022-05-23 Thread Cyndy Ishida via Phabricator via cfe-commits
cishida updated this revision to Diff 431543.
cishida added a comment.

Restrict using the canonical decl's source location to only when the prototype 
was inferred from previously seen decl.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126258

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/prototype-redecls.c


Index: clang/test/Sema/prototype-redecls.c
===
--- clang/test/Sema/prototype-redecls.c
+++ clang/test/Sema/prototype-redecls.c
@@ -12,6 +12,10 @@
 void blerp(short);  // expected-note {{previous}}
 void blerp(x) int x; {} // expected-error {{conflicting types for 'blerp'}}
 
+void foo(int); // expected-note {{previous}}
+void foo();
+void foo() {} // expected-error {{conflicting types for 'foo'}}
+
 void glerp(int);
 void glerp(x) short x; {} // Okay, promoted type is fine
 
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -3911,6 +3911,8 @@
 // ASTContext::typesAreCompatible().
 if (Old->hasPrototype() && !New->hasWrittenPrototype() && NewDeclIsDefn &&
 Old->getNumParams() != New->getNumParams()) {
+  if (Old->hasInheritedPrototype())
+Old = Old->getCanonicalDecl();
   Diag(New->getLocation(), diag::err_conflicting_types) << New;
   Diag(Old->getLocation(), PrevDiag) << Old << Old->getType();
   return true;


Index: clang/test/Sema/prototype-redecls.c
===
--- clang/test/Sema/prototype-redecls.c
+++ clang/test/Sema/prototype-redecls.c
@@ -12,6 +12,10 @@
 void blerp(short);  // expected-note {{previous}}
 void blerp(x) int x; {} // expected-error {{conflicting types for 'blerp'}}
 
+void foo(int); // expected-note {{previous}}
+void foo();
+void foo() {} // expected-error {{conflicting types for 'foo'}}
+
 void glerp(int);
 void glerp(x) short x; {} // Okay, promoted type is fine
 
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -3911,6 +3911,8 @@
 // ASTContext::typesAreCompatible().
 if (Old->hasPrototype() && !New->hasWrittenPrototype() && NewDeclIsDefn &&
 Old->getNumParams() != New->getNumParams()) {
+  if (Old->hasInheritedPrototype())
+Old = Old->getCanonicalDecl();
   Diag(New->getLocation(), diag::err_conflicting_types) << New;
   Diag(Old->getLocation(), PrevDiag) << Old << Old->getType();
   return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126258: [Clang] Avoid misleading 'conflicting types' diagnostic with no-prototype decls.

2022-05-24 Thread Cyndy Ishida via Phabricator via cfe-commits
cishida added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:3914-3918
+  if (Old->hasInheritedPrototype())
+Old = Old->getCanonicalDecl();
   Diag(New->getLocation(), diag::err_conflicting_types) << New;
   Diag(Old->getLocation(), PrevDiag) << Old << Old->getType();
   return true;

aaron.ballman wrote:
> I don't think it's safe to assign this new value to `Old` as that object is 
> what we eventually merge the declaration with (so we'll get the decl chain 
> order wrong, I believe).
Ah, I hadn't realized we still can merge decls together in a fatal error case. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126258

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


[PATCH] D126258: [Clang] Avoid misleading 'conflicting types' diagnostic with no-prototype decls.

2022-05-24 Thread Cyndy Ishida via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa1a14e817eeb: [Clang] Avoid misleading 'conflicting 
types' diagnostic with no-prototype decls. (authored by cishida).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126258

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/prototype-redecls.c


Index: clang/test/Sema/prototype-redecls.c
===
--- clang/test/Sema/prototype-redecls.c
+++ clang/test/Sema/prototype-redecls.c
@@ -12,6 +12,10 @@
 void blerp(short);  // expected-note {{previous}}
 void blerp(x) int x; {} // expected-error {{conflicting types for 'blerp'}}
 
+void foo(int); // expected-note {{previous}}
+void foo();
+void foo() {} // expected-error {{conflicting types for 'foo'}}
+
 void glerp(int);
 void glerp(x) short x; {} // Okay, promoted type is fine
 
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -3911,6 +3911,8 @@
 // ASTContext::typesAreCompatible().
 if (Old->hasPrototype() && !New->hasWrittenPrototype() && NewDeclIsDefn &&
 Old->getNumParams() != New->getNumParams()) {
+  if (Old->hasInheritedPrototype())
+Old = Old->getCanonicalDecl();
   Diag(New->getLocation(), diag::err_conflicting_types) << New;
   Diag(Old->getLocation(), PrevDiag) << Old << Old->getType();
   return true;


Index: clang/test/Sema/prototype-redecls.c
===
--- clang/test/Sema/prototype-redecls.c
+++ clang/test/Sema/prototype-redecls.c
@@ -12,6 +12,10 @@
 void blerp(short);  // expected-note {{previous}}
 void blerp(x) int x; {} // expected-error {{conflicting types for 'blerp'}}
 
+void foo(int); // expected-note {{previous}}
+void foo();
+void foo() {} // expected-error {{conflicting types for 'foo'}}
+
 void glerp(int);
 void glerp(x) short x; {} // Okay, promoted type is fine
 
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -3911,6 +3911,8 @@
 // ASTContext::typesAreCompatible().
 if (Old->hasPrototype() && !New->hasWrittenPrototype() && NewDeclIsDefn &&
 Old->getNumParams() != New->getNumParams()) {
+  if (Old->hasInheritedPrototype())
+Old = Old->getCanonicalDecl();
   Diag(New->getLocation(), diag::err_conflicting_types) << New;
   Diag(Old->getLocation(), PrevDiag) << Old << Old->getType();
   return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63978: Clang Interface Stubs merger plumbing for Driver

2019-09-07 Thread Cyndy Ishida via Phabricator via cfe-commits
cishida added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3688
   .Case("experimental-ifs-v1", "experimental-ifs-v1")
-  .Default("");
+  .Default("experimental-ifs-v1");
 

nit: no need to check `ArgStr` if all outcomes are the same 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63978



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


[PATCH] D70763: [clang][IFS] Allow 2 output files when using -o and -c with clang IFS stubs.

2019-12-05 Thread Cyndy Ishida via Phabricator via cfe-commits
cishida marked an inline comment as done.
cishida added inline comments.



Comment at: clang/test/InterfaceStubs/driver-test3.c:6
+// RUN: %clang -target x86_64-unknown-linux-gnu -c -emit-interface-stubs %s -o 
%t/driver-test3.o
+// RUN: cat %t/driver-test3.ifs | FileCheck %s
+

wouldn't hurt to validate that the object file was generated


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70763



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


[PATCH] D117830: [HeaderSearch] Track framework name in LookupFile

2022-01-24 Thread Cyndy Ishida via Phabricator via cfe-commits
cishida added a comment.

My understanding for the header map restriction is because headermaps are 
generally emitted once for a framework build and only consumed to build such 
framework and this struct information is only queried during this.
It sounds like for the clangd support, you're not as interested in what 
framework is being built, but the name of the framework when included via 
framework style in any context. Is that correct? It seems fine to extend its 
use cases. @jansvoboda11 What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117830

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


[PATCH] D117830: [HeaderSearch] Track framework name in LookupFile

2022-01-24 Thread Cyndy Ishida via Phabricator via cfe-commits
cishida accepted this revision.
cishida added a comment.
This revision is now accepted and ready to land.

I followed up about this approach with folks more familiar with SourceKit and 
seems fine, so LGTM. I'd wait a day to see if Jan has any concerns.




Comment at: clang/lib/Lex/HeaderSearch.cpp:1043
 
 // If this file is found in a header map and uses the framework style of
 // includes, then this header is part of a framework we're building.

sammccall wrote:
> The comment here explicitly say "in a header map and". Unfortunately it 
> doesn't say why, and I don't know enough to guess.
nit/reminder: This should be updated now 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117830

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


[PATCH] D117830: [HeaderSearch] Track framework name in LookupFile

2022-01-26 Thread Cyndy Ishida via Phabricator via cfe-commits
cishida added inline comments.



Comment at: clang/lib/Lex/HeaderSearch.cpp:1043
 
 // If this file is found in a header map and uses the framework style of
 // includes, then this header is part of a framework we're building.

dgoldman wrote:
> cishida wrote:
> > sammccall wrote:
> > > The comment here explicitly say "in a header map and". Unfortunately it 
> > > doesn't say why, and I don't know enough to guess.
> > nit/reminder: This should be updated now 
> Updated, LMK if you have any suggestions on the wording here.
LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117830

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


[PATCH] D99811: [TextAPI] move source code files out of subdirectory, NFC

2021-04-02 Thread Cyndy Ishida via Phabricator via cfe-commits
cishida created this revision.
cishida added reviewers: steven_wu, ributzka.
Herald added subscribers: hiraditya, mgorny.
Herald added a reviewer: int3.
Herald added a project: lld-macho.
Herald added a reviewer: lld-macho.
cishida requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

TextAPI/ELF has moved out into InterfaceStubs, so theres no longer a
need to seperate out TextAPI between formats.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99811

Files:
  clang/docs/ClangFormattedStatus.rst
  lld/MachO/Config.h
  lld/MachO/Driver.cpp
  lld/MachO/DriverUtils.cpp
  lld/MachO/InputFiles.cpp
  lld/MachO/InputFiles.h
  lld/lib/ReaderWriter/MachO/File.h
  llvm/include/llvm/Object/TapiFile.h
  llvm/include/llvm/Object/TapiUniversal.h
  llvm/include/llvm/TextAPI/Architecture.def
  llvm/include/llvm/TextAPI/Architecture.h
  llvm/include/llvm/TextAPI/ArchitectureSet.h
  llvm/include/llvm/TextAPI/InterfaceFile.h
  llvm/include/llvm/TextAPI/MachO/Architecture.def
  llvm/include/llvm/TextAPI/MachO/Architecture.h
  llvm/include/llvm/TextAPI/MachO/ArchitectureSet.h
  llvm/include/llvm/TextAPI/MachO/InterfaceFile.h
  llvm/include/llvm/TextAPI/MachO/PackedVersion.h
  llvm/include/llvm/TextAPI/MachO/Platform.h
  llvm/include/llvm/TextAPI/MachO/Symbol.h
  llvm/include/llvm/TextAPI/MachO/Target.h
  llvm/include/llvm/TextAPI/MachO/TextAPIReader.h
  llvm/include/llvm/TextAPI/MachO/TextAPIWriter.h
  llvm/include/llvm/TextAPI/PackedVersion.h
  llvm/include/llvm/TextAPI/Platform.h
  llvm/include/llvm/TextAPI/Symbol.h
  llvm/include/llvm/TextAPI/Target.h
  llvm/include/llvm/TextAPI/TextAPIReader.h
  llvm/include/llvm/TextAPI/TextAPIWriter.h
  llvm/lib/Object/TapiUniversal.cpp
  llvm/lib/TextAPI/Architecture.cpp
  llvm/lib/TextAPI/ArchitectureSet.cpp
  llvm/lib/TextAPI/CMakeLists.txt
  llvm/lib/TextAPI/InterfaceFile.cpp
  llvm/lib/TextAPI/MachO/Architecture.cpp
  llvm/lib/TextAPI/MachO/ArchitectureSet.cpp
  llvm/lib/TextAPI/MachO/InterfaceFile.cpp
  llvm/lib/TextAPI/MachO/PackedVersion.cpp
  llvm/lib/TextAPI/MachO/Platform.cpp
  llvm/lib/TextAPI/MachO/Symbol.cpp
  llvm/lib/TextAPI/MachO/Target.cpp
  llvm/lib/TextAPI/MachO/TextAPIContext.h
  llvm/lib/TextAPI/MachO/TextStub.cpp
  llvm/lib/TextAPI/MachO/TextStubCommon.cpp
  llvm/lib/TextAPI/MachO/TextStubCommon.h
  llvm/lib/TextAPI/PackedVersion.cpp
  llvm/lib/TextAPI/Platform.cpp
  llvm/lib/TextAPI/Symbol.cpp
  llvm/lib/TextAPI/Target.cpp
  llvm/lib/TextAPI/TextAPIContext.h
  llvm/lib/TextAPI/TextStub.cpp
  llvm/lib/TextAPI/TextStubCommon.cpp
  llvm/lib/TextAPI/TextStubCommon.h
  llvm/tools/llvm-ifs/llvm-ifs.cpp
  llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
  llvm/tools/llvm-lipo/llvm-lipo.cpp
  llvm/unittests/TextAPI/TextStubHelpers.h
  llvm/unittests/TextAPI/TextStubV1Tests.cpp
  llvm/unittests/TextAPI/TextStubV2Tests.cpp
  llvm/unittests/TextAPI/TextStubV3Tests.cpp
  llvm/unittests/TextAPI/TextStubV4Tests.cpp

Index: llvm/unittests/TextAPI/TextStubV4Tests.cpp
===
--- llvm/unittests/TextAPI/TextStubV4Tests.cpp
+++ llvm/unittests/TextAPI/TextStubV4Tests.cpp
@@ -7,9 +7,9 @@
 //===---===/
 
 #include "TextStubHelpers.h"
-#include "llvm/TextAPI/MachO/InterfaceFile.h"
-#include "llvm/TextAPI/MachO/TextAPIReader.h"
-#include "llvm/TextAPI/MachO/TextAPIWriter.h"
+#include "llvm/TextAPI/InterfaceFile.h"
+#include "llvm/TextAPI/TextAPIReader.h"
+#include "llvm/TextAPI/TextAPIWriter.h"
 #include "gtest/gtest.h"
 #include 
 #include 
Index: llvm/unittests/TextAPI/TextStubV3Tests.cpp
===
--- llvm/unittests/TextAPI/TextStubV3Tests.cpp
+++ llvm/unittests/TextAPI/TextStubV3Tests.cpp
@@ -6,9 +6,9 @@
 //
 //===---===/
 #include "TextStubHelpers.h"
-#include "llvm/TextAPI/MachO/InterfaceFile.h"
-#include "llvm/TextAPI/MachO/TextAPIReader.h"
-#include "llvm/TextAPI/MachO/TextAPIWriter.h"
+#include "llvm/TextAPI/InterfaceFile.h"
+#include "llvm/TextAPI/TextAPIReader.h"
+#include "llvm/TextAPI/TextAPIWriter.h"
 #include "gtest/gtest.h"
 #include 
 #include 
Index: llvm/unittests/TextAPI/TextStubV2Tests.cpp
===
--- llvm/unittests/TextAPI/TextStubV2Tests.cpp
+++ llvm/unittests/TextAPI/TextStubV2Tests.cpp
@@ -6,9 +6,9 @@
 //
 //===---===/
 #include "TextStubHelpers.h"
-#include "llvm/TextAPI/MachO/InterfaceFile.h"
-#include "llvm/TextAPI/MachO/TextAPIReader.h"
-#include "llvm/TextAPI/MachO/TextAPIWriter.h"
+#include "llvm/TextAPI/InterfaceFile.h"
+#include "llvm/TextAPI/TextAPIReader.h"
+#include "llvm/TextAPI/TextAPIWriter.h"
 #include "gtest/gtest.h"
 #include 
 #include 
Index: llvm/unittests/TextAPI/TextStubV1Tests.cpp
===

[PATCH] D99811: [TextAPI] move source code files out of subdirectory, NFC

2021-04-05 Thread Cyndy Ishida via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0116d04d04f2: [TextAPI] move source code files out of 
subdirectory, NFC (authored by cishida).

Changed prior to commit:
  https://reviews.llvm.org/D99811?vs=335007&id=335291#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99811

Files:
  clang/docs/ClangFormattedStatus.rst
  lld/MachO/Config.h
  lld/MachO/Driver.cpp
  lld/MachO/DriverUtils.cpp
  lld/MachO/InputFiles.cpp
  lld/MachO/InputFiles.h
  lld/lib/ReaderWriter/MachO/File.h
  llvm/include/llvm/Object/TapiFile.h
  llvm/include/llvm/Object/TapiUniversal.h
  llvm/include/llvm/TextAPI/Architecture.def
  llvm/include/llvm/TextAPI/Architecture.h
  llvm/include/llvm/TextAPI/ArchitectureSet.h
  llvm/include/llvm/TextAPI/InterfaceFile.h
  llvm/include/llvm/TextAPI/MachO/Architecture.def
  llvm/include/llvm/TextAPI/MachO/Architecture.h
  llvm/include/llvm/TextAPI/MachO/ArchitectureSet.h
  llvm/include/llvm/TextAPI/MachO/InterfaceFile.h
  llvm/include/llvm/TextAPI/MachO/PackedVersion.h
  llvm/include/llvm/TextAPI/MachO/Platform.h
  llvm/include/llvm/TextAPI/MachO/Symbol.h
  llvm/include/llvm/TextAPI/MachO/Target.h
  llvm/include/llvm/TextAPI/MachO/TextAPIReader.h
  llvm/include/llvm/TextAPI/MachO/TextAPIWriter.h
  llvm/include/llvm/TextAPI/PackedVersion.h
  llvm/include/llvm/TextAPI/Platform.h
  llvm/include/llvm/TextAPI/Symbol.h
  llvm/include/llvm/TextAPI/Target.h
  llvm/include/llvm/TextAPI/TextAPIReader.h
  llvm/include/llvm/TextAPI/TextAPIWriter.h
  llvm/lib/Object/TapiUniversal.cpp
  llvm/lib/TextAPI/Architecture.cpp
  llvm/lib/TextAPI/ArchitectureSet.cpp
  llvm/lib/TextAPI/CMakeLists.txt
  llvm/lib/TextAPI/InterfaceFile.cpp
  llvm/lib/TextAPI/MachO/Architecture.cpp
  llvm/lib/TextAPI/MachO/ArchitectureSet.cpp
  llvm/lib/TextAPI/MachO/InterfaceFile.cpp
  llvm/lib/TextAPI/MachO/PackedVersion.cpp
  llvm/lib/TextAPI/MachO/Platform.cpp
  llvm/lib/TextAPI/MachO/Symbol.cpp
  llvm/lib/TextAPI/MachO/Target.cpp
  llvm/lib/TextAPI/MachO/TextAPIContext.h
  llvm/lib/TextAPI/MachO/TextStub.cpp
  llvm/lib/TextAPI/MachO/TextStubCommon.cpp
  llvm/lib/TextAPI/MachO/TextStubCommon.h
  llvm/lib/TextAPI/PackedVersion.cpp
  llvm/lib/TextAPI/Platform.cpp
  llvm/lib/TextAPI/Symbol.cpp
  llvm/lib/TextAPI/Target.cpp
  llvm/lib/TextAPI/TextAPIContext.h
  llvm/lib/TextAPI/TextStub.cpp
  llvm/lib/TextAPI/TextStubCommon.cpp
  llvm/lib/TextAPI/TextStubCommon.h
  llvm/tools/llvm-ifs/llvm-ifs.cpp
  llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
  llvm/tools/llvm-lipo/llvm-lipo.cpp
  llvm/unittests/TextAPI/TextStubHelpers.h
  llvm/unittests/TextAPI/TextStubV1Tests.cpp
  llvm/unittests/TextAPI/TextStubV2Tests.cpp
  llvm/unittests/TextAPI/TextStubV3Tests.cpp
  llvm/unittests/TextAPI/TextStubV4Tests.cpp

Index: llvm/unittests/TextAPI/TextStubV4Tests.cpp
===
--- llvm/unittests/TextAPI/TextStubV4Tests.cpp
+++ llvm/unittests/TextAPI/TextStubV4Tests.cpp
@@ -7,9 +7,9 @@
 //===---===/
 
 #include "TextStubHelpers.h"
-#include "llvm/TextAPI/MachO/InterfaceFile.h"
-#include "llvm/TextAPI/MachO/TextAPIReader.h"
-#include "llvm/TextAPI/MachO/TextAPIWriter.h"
+#include "llvm/TextAPI/InterfaceFile.h"
+#include "llvm/TextAPI/TextAPIReader.h"
+#include "llvm/TextAPI/TextAPIWriter.h"
 #include "gtest/gtest.h"
 #include 
 #include 
Index: llvm/unittests/TextAPI/TextStubV3Tests.cpp
===
--- llvm/unittests/TextAPI/TextStubV3Tests.cpp
+++ llvm/unittests/TextAPI/TextStubV3Tests.cpp
@@ -6,9 +6,9 @@
 //
 //===---===/
 #include "TextStubHelpers.h"
-#include "llvm/TextAPI/MachO/InterfaceFile.h"
-#include "llvm/TextAPI/MachO/TextAPIReader.h"
-#include "llvm/TextAPI/MachO/TextAPIWriter.h"
+#include "llvm/TextAPI/InterfaceFile.h"
+#include "llvm/TextAPI/TextAPIReader.h"
+#include "llvm/TextAPI/TextAPIWriter.h"
 #include "gtest/gtest.h"
 #include 
 #include 
Index: llvm/unittests/TextAPI/TextStubV2Tests.cpp
===
--- llvm/unittests/TextAPI/TextStubV2Tests.cpp
+++ llvm/unittests/TextAPI/TextStubV2Tests.cpp
@@ -6,9 +6,9 @@
 //
 //===---===/
 #include "TextStubHelpers.h"
-#include "llvm/TextAPI/MachO/InterfaceFile.h"
-#include "llvm/TextAPI/MachO/TextAPIReader.h"
-#include "llvm/TextAPI/MachO/TextAPIWriter.h"
+#include "llvm/TextAPI/InterfaceFile.h"
+#include "llvm/TextAPI/TextAPIReader.h"
+#include "llvm/TextAPI/TextAPIWriter.h"
 #include "gtest/gtest.h"
 #include 
 #include 
Index: llvm/unittests/TextAPI/TextStubV1Tests.cpp
===

[PATCH] D111468: [clang] Capture Framework when HeaderSearch is resolved via headermap

2021-10-08 Thread Cyndy Ishida via Phabricator via cfe-commits
cishida created this revision.
cishida added reviewers: dexonsmith, ributzka.
cishida requested review of this revision.
Herald added a project: clang.

When building frameworks, headermaps responsible for mapping angle-included 
headers to their source file location are passed via
`-I` and not `-index-header-map`. However, `-index-header-map` is only used for 
indexing purposes and not during most builds.
This patch holds on to the framework's name in HeaderFileInfo as this is 
retrieveable for cases outside of IndexHeaderMaps and 
still represents the framework that is being built.

resolves: rdar://84046893


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111468

Files:
  clang/lib/Lex/HeaderSearch.cpp
  clang/unittests/Lex/HeaderSearchTest.cpp


Index: clang/unittests/Lex/HeaderSearchTest.cpp
===
--- clang/unittests/Lex/HeaderSearchTest.cpp
+++ clang/unittests/Lex/HeaderSearchTest.cpp
@@ -18,6 +18,7 @@
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Serialization/InMemoryModuleCache.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "gtest/gtest.h"
 
 namespace clang {
@@ -47,7 +48,8 @@
   }
 
   void addHeaderMap(llvm::StringRef Filename,
-std::unique_ptr Buf) {
+std::unique_ptr Buf,
+bool isAngled = false) {
 VFS->addFile(Filename, 0, std::move(Buf), /*User=*/None, /*Group=*/None,
  llvm::sys::fs::file_type::regular_file);
 auto FE = FileMgr.getFile(Filename, true);
@@ -56,9 +58,10 @@
 // Test class supports only one HMap at a time.
 assert(!HMap);
 HMap = HeaderMap::Create(*FE, FileMgr);
+HMap->dump();
 auto DL =
 DirectoryLookup(HMap.get(), SrcMgr::C_User, /*isFramework=*/false);
-Search.AddSearchPath(DL, /*isAngled=*/false);
+Search.AddSearchPath(DL, isAngled);
   }
 
   IntrusiveRefCntPtr VFS;
@@ -179,5 +182,38 @@
 "d.h");
 }
 
+TEST_F(HeaderSearchTest, HeaderMapFrameworkLookup) {
+  typedef NullTerminatedFile, char> FileTy;
+  FileTy File;
+  File.init();
+
+  test::HMapFileMockMaker Maker(File);
+  auto a = Maker.addString("Foo/Foo.h");
+  auto b = Maker.addString("/tmp/Sources/Foo/Headers/");
+  auto c = Maker.addString("Foo.h");
+  Maker.addBucket("Foo/Foo.h", a, b, c);
+  addHeaderMap("product-headers.hmap", File.getBuffer(), /*isAngled=*/true);
+
+  StringRef HeaderName = "/tmp/Sources/Foo/Headers/Foo.h";
+  VFS->addFile(
+  HeaderName, 0, llvm::MemoryBuffer::getMemBufferCopy("", HeaderName),
+  /*User=*/None, /*Group=*/None, llvm::sys::fs::file_type::regular_file);
+
+  const DirectoryLookup *CurDir = nullptr;
+  auto FoundFile = Search.LookupFile(
+  "Foo/Foo.h", SourceLocation(), /*isAngled=*/true, /*FromDir=*/nullptr,
+  CurDir, /*Includers=*/{}, /*SearchPath=*/nullptr,
+  /*RelativePath=*/nullptr, /*RequestingModule=*/nullptr,
+  /*SuggestedModule=*/nullptr, /*IsMapped=*/nullptr,
+  /*IsFrameworkFound=*/nullptr);
+
+  EXPECT_TRUE(FoundFile.hasValue());
+  auto FE = FoundFile.getValue();
+  auto FI = Search.getExistingFileInfo(FE);
+  EXPECT_TRUE(FI);
+  EXPECT_TRUE(FI->IsValid);
+  EXPECT_EQ(FI->Framework.str(), "Foo");
+}
+
 } // namespace
 } // namespace clang
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -964,13 +964,13 @@
 
 // If this file is found in a header map and uses the framework style of
 // includes, then this header is part of a framework we're building.
-if (CurDir->isIndexHeaderMap()) {
+if (CurDir->isHeaderMap() && isAngled) {
   size_t SlashPos = Filename.find('/');
-  if (SlashPos != StringRef::npos) {
+  if (SlashPos != StringRef::npos)
+HFI.Framework =
+getUniqueFrameworkName(StringRef(Filename.begin(), SlashPos));
+  if (CurDir->isIndexHeaderMap())
 HFI.IndexHeaderMapHeader = 1;
-HFI.Framework = getUniqueFrameworkName(StringRef(Filename.begin(),
- SlashPos));
-  }
 }
 
 if (checkMSVCHeaderSearch(Diags, MSFE ? &MSFE->getFileEntry() : nullptr,


Index: clang/unittests/Lex/HeaderSearchTest.cpp
===
--- clang/unittests/Lex/HeaderSearchTest.cpp
+++ clang/unittests/Lex/HeaderSearchTest.cpp
@@ -18,6 +18,7 @@
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Serialization/InMemoryModuleCache.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "gtest/gtest.h"
 
 namespace clang {
@@ -47,7 +48,8 @@
   }
 
   void addHeaderMap(llvm::StringRef Filename,
-std::unique_ptr Buf) {
+std::unique_ptr Buf,
+bool isAngled = false) {
 VFS->addFile(Filename, 0,

[PATCH] D111468: [clang] Capture Framework when HeaderSearch is resolved via headermap

2021-10-14 Thread Cyndy Ishida via Phabricator via cfe-commits
cishida updated this revision to Diff 379721.
cishida added a comment.

Fix windows build.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111468

Files:
  clang/lib/Lex/HeaderSearch.cpp
  clang/unittests/Lex/HeaderSearchTest.cpp

Index: clang/unittests/Lex/HeaderSearchTest.cpp
===
--- clang/unittests/Lex/HeaderSearchTest.cpp
+++ clang/unittests/Lex/HeaderSearchTest.cpp
@@ -18,6 +18,7 @@
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Serialization/InMemoryModuleCache.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "gtest/gtest.h"
 
 namespace clang {
@@ -47,7 +48,8 @@
   }
 
   void addHeaderMap(llvm::StringRef Filename,
-std::unique_ptr Buf) {
+std::unique_ptr Buf,
+bool isAngled = false) {
 VFS->addFile(Filename, 0, std::move(Buf), /*User=*/None, /*Group=*/None,
  llvm::sys::fs::file_type::regular_file);
 auto FE = FileMgr.getFile(Filename, true);
@@ -58,7 +60,7 @@
 HMap = HeaderMap::Create(*FE, FileMgr);
 auto DL =
 DirectoryLookup(HMap.get(), SrcMgr::C_User, /*isFramework=*/false);
-Search.AddSearchPath(DL, /*isAngled=*/false);
+Search.AddSearchPath(DL, isAngled);
   }
 
   IntrusiveRefCntPtr VFS;
@@ -179,5 +181,48 @@
 "d.h");
 }
 
+TEST_F(HeaderSearchTest, HeaderMapFrameworkLookup) {
+  typedef NullTerminatedFile, char> FileTy;
+  FileTy File;
+  File.init();
+
+  std::string HeaderDirName = "/tmp/Sources/Foo/Headers/";
+  std::string HeaderName = "Foo.h";
+#ifdef _WIN32
+  // Force header path to be absolute on windows.
+  // As headermap content should represent absolute locations.
+  HeaderDirName = "C:" + HeaderDirName;
+#endif /*_WIN32*/
+
+  test::HMapFileMockMaker Maker(File);
+  auto a = Maker.addString("Foo/Foo.h");
+  auto b = Maker.addString(HeaderDirName);
+  auto c = Maker.addString(HeaderName);
+  Maker.addBucket("Foo/Foo.h", a, b, c);
+  addHeaderMap("product-headers.hmap", File.getBuffer(), /*isAngled=*/true);
+
+  VFS->addFile(
+  HeaderDirName + HeaderName, 0,
+  llvm::MemoryBuffer::getMemBufferCopy("", HeaderDirName + HeaderName),
+  /*User=*/None, /*Group=*/None, llvm::sys::fs::file_type::regular_file);
+
+  bool IsMapped = false;
+  const DirectoryLookup *CurDir = nullptr;
+  auto FoundFile = Search.LookupFile(
+  "Foo/Foo.h", SourceLocation(), /*isAngled=*/true, /*FromDir=*/nullptr,
+  CurDir, /*Includers=*/{}, /*SearchPath=*/nullptr,
+  /*RelativePath=*/nullptr, /*RequestingModule=*/nullptr,
+  /*SuggestedModule=*/nullptr, &IsMapped,
+  /*IsFrameworkFound=*/nullptr);
+
+  EXPECT_TRUE(FoundFile.hasValue());
+  EXPECT_TRUE(IsMapped);
+  auto &FE = FoundFile.getValue();
+  auto FI = Search.getExistingFileInfo(FE);
+  EXPECT_TRUE(FI);
+  EXPECT_TRUE(FI->IsValid);
+  EXPECT_EQ(FI->Framework.str(), "Foo");
+}
+
 } // namespace
 } // namespace clang
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1005,13 +1005,13 @@
 
 // If this file is found in a header map and uses the framework style of
 // includes, then this header is part of a framework we're building.
-if (CurDir->isIndexHeaderMap()) {
+if (CurDir->isHeaderMap() && isAngled) {
   size_t SlashPos = Filename.find('/');
-  if (SlashPos != StringRef::npos) {
+  if (SlashPos != StringRef::npos)
+HFI.Framework =
+getUniqueFrameworkName(StringRef(Filename.begin(), SlashPos));
+  if (CurDir->isIndexHeaderMap())
 HFI.IndexHeaderMapHeader = 1;
-HFI.Framework = getUniqueFrameworkName(StringRef(Filename.begin(),
- SlashPos));
-  }
 }
 
 if (checkMSVCHeaderSearch(Diags, MSFE ? &MSFE->getFileEntry() : nullptr,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111468: [clang] Capture Framework when HeaderSearch is resolved via headermap

2021-10-15 Thread Cyndy Ishida via Phabricator via cfe-commits
cishida added a comment.

In D111468#3066820 , @jansvoboda11 
wrote:

> LGTM.
>
> As a follow-up, do you think it would make sense to improve the 
> documentation/comments around "index header maps"? Variable names refer to 
> indexing while the documentation talks about building frameworks, which is 
> confusing without referring back to the original Radar.

Makes sense to me. If I understand correctly, the headermap kind was introduced 
to work around a task generation limitation in Xcode which no longer is an 
issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111468

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


[PATCH] D111468: [clang] Capture Framework when HeaderSearch is resolved via headermap

2021-10-15 Thread Cyndy Ishida via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG395e1fe30574: [clang] Capture Framework when HeaderSearch is 
resolved via headermap (authored by cishida).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111468

Files:
  clang/lib/Lex/HeaderSearch.cpp
  clang/unittests/Lex/HeaderSearchTest.cpp

Index: clang/unittests/Lex/HeaderSearchTest.cpp
===
--- clang/unittests/Lex/HeaderSearchTest.cpp
+++ clang/unittests/Lex/HeaderSearchTest.cpp
@@ -18,6 +18,7 @@
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Serialization/InMemoryModuleCache.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "gtest/gtest.h"
 
 namespace clang {
@@ -47,7 +48,8 @@
   }
 
   void addHeaderMap(llvm::StringRef Filename,
-std::unique_ptr Buf) {
+std::unique_ptr Buf,
+bool isAngled = false) {
 VFS->addFile(Filename, 0, std::move(Buf), /*User=*/None, /*Group=*/None,
  llvm::sys::fs::file_type::regular_file);
 auto FE = FileMgr.getFile(Filename, true);
@@ -58,7 +60,7 @@
 HMap = HeaderMap::Create(*FE, FileMgr);
 auto DL =
 DirectoryLookup(HMap.get(), SrcMgr::C_User, /*isFramework=*/false);
-Search.AddSearchPath(DL, /*isAngled=*/false);
+Search.AddSearchPath(DL, isAngled);
   }
 
   IntrusiveRefCntPtr VFS;
@@ -179,5 +181,48 @@
 "d.h");
 }
 
+TEST_F(HeaderSearchTest, HeaderMapFrameworkLookup) {
+  typedef NullTerminatedFile, char> FileTy;
+  FileTy File;
+  File.init();
+
+  std::string HeaderDirName = "/tmp/Sources/Foo/Headers/";
+  std::string HeaderName = "Foo.h";
+#ifdef _WIN32
+  // Force header path to be absolute on windows.
+  // As headermap content should represent absolute locations.
+  HeaderDirName = "C:" + HeaderDirName;
+#endif /*_WIN32*/
+
+  test::HMapFileMockMaker Maker(File);
+  auto a = Maker.addString("Foo/Foo.h");
+  auto b = Maker.addString(HeaderDirName);
+  auto c = Maker.addString(HeaderName);
+  Maker.addBucket("Foo/Foo.h", a, b, c);
+  addHeaderMap("product-headers.hmap", File.getBuffer(), /*isAngled=*/true);
+
+  VFS->addFile(
+  HeaderDirName + HeaderName, 0,
+  llvm::MemoryBuffer::getMemBufferCopy("", HeaderDirName + HeaderName),
+  /*User=*/None, /*Group=*/None, llvm::sys::fs::file_type::regular_file);
+
+  bool IsMapped = false;
+  const DirectoryLookup *CurDir = nullptr;
+  auto FoundFile = Search.LookupFile(
+  "Foo/Foo.h", SourceLocation(), /*isAngled=*/true, /*FromDir=*/nullptr,
+  CurDir, /*Includers=*/{}, /*SearchPath=*/nullptr,
+  /*RelativePath=*/nullptr, /*RequestingModule=*/nullptr,
+  /*SuggestedModule=*/nullptr, &IsMapped,
+  /*IsFrameworkFound=*/nullptr);
+
+  EXPECT_TRUE(FoundFile.hasValue());
+  EXPECT_TRUE(IsMapped);
+  auto &FE = FoundFile.getValue();
+  auto FI = Search.getExistingFileInfo(FE);
+  EXPECT_TRUE(FI);
+  EXPECT_TRUE(FI->IsValid);
+  EXPECT_EQ(FI->Framework.str(), "Foo");
+}
+
 } // namespace
 } // namespace clang
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1005,13 +1005,13 @@
 
 // If this file is found in a header map and uses the framework style of
 // includes, then this header is part of a framework we're building.
-if (CurDir->isIndexHeaderMap()) {
+if (CurDir->isHeaderMap() && isAngled) {
   size_t SlashPos = Filename.find('/');
-  if (SlashPos != StringRef::npos) {
+  if (SlashPos != StringRef::npos)
+HFI.Framework =
+getUniqueFrameworkName(StringRef(Filename.begin(), SlashPos));
+  if (CurDir->isIndexHeaderMap())
 HFI.IndexHeaderMapHeader = 1;
-HFI.Framework = getUniqueFrameworkName(StringRef(Filename.begin(),
- SlashPos));
-  }
 }
 
 if (checkMSVCHeaderSearch(Diags, MSFE ? &MSFE->getFileEntry() : nullptr,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits