-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow clang-extract to ignore errors pointed by clang
Sometime it is useful to not halt compilation if an error occurred because the generated code may still be useful when creating livepatches. Hence add a new option: ``` -DCE_IGNORE_CLANG_ERRORS ``` To ignore clang errors and continue compilation even so. Signed-off-by: Giuliano Belinassi <[email protected]>
- Loading branch information
1 parent
bfc113f
commit ec46efd
Showing
8 changed files
with
121 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
//===- ASTUnitHack.cpp - Hacks for the ASTUnit class ------------------*- C++ *-===// | ||
// | ||
// This project is licensed under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
/// \file | ||
/// Hacks for the ASTUnit class. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
/* Author: Giuliano Belinassi */ | ||
|
||
#include <clang/Frontend/ASTUnit.h> | ||
#include <clang/Frontend/CompilerInvocation.h> | ||
#include <clang/Serialization/InMemoryModuleCache.h> | ||
|
||
using namespace clang; | ||
|
||
/** Filesystem that will be used in our custom ASTUnit::create, so that way we | ||
* don't break clang's API. | ||
*/ | ||
IntrusiveRefCntPtr<llvm::vfs::FileSystem> _Hack_VFS; | ||
|
||
/** Hack to create an ASTUnit from LoadFromCompilerInvocationAction with a | ||
* virtual filesystem. That way we can use FrontendActions hooks when | ||
* creating the ASTUnit. | ||
*/ | ||
std::unique_ptr<ASTUnit> | ||
ASTUnit::create(std::shared_ptr<CompilerInvocation> CI, | ||
IntrusiveRefCntPtr<DiagnosticsEngine> Diags, | ||
CaptureDiagsKind CaptureDiagnostics, | ||
bool UserFilesAreVolatile) { | ||
|
||
std::unique_ptr<ASTUnit> AST(new ASTUnit(false)); | ||
ConfigureDiags(Diags, *AST, CaptureDiagnostics); | ||
|
||
AST->Diagnostics = Diags; | ||
AST->FileSystemOpts = CI->getFileSystemOpts(); | ||
AST->Invocation = std::move(CI); | ||
AST->FileMgr = new FileManager(AST->FileSystemOpts, _Hack_VFS); | ||
AST->UserFilesAreVolatile = UserFilesAreVolatile; | ||
AST->SourceMgr = new SourceManager(AST->getDiagnostics(), *AST->FileMgr, | ||
UserFilesAreVolatile); | ||
AST->ModuleCache = new InMemoryModuleCache; | ||
|
||
return AST; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* { dg-options "-DCE_EXTRACT_FUNCTIONS=f -DCE_NO_EXTERNALIZATION -DCE_IGNORE_CLANG_ERRORS" }*/ | ||
|
||
void f(void) | ||
{ | ||
return 3; | ||
} | ||
|
||
/* { dg-final { scan-tree-dump "void f" } } */ | ||
/* { dg-final { scan-tree-dump "return 3;" } } */ |