[cfe-commits] r70250 - /cfe/trunk/tools/clang-cc/clang-cc.cpp
Chris Lattner
sabre at nondot.org
Mon Apr 27 14:25:27 PDT 2009
Author: lattner
Date: Mon Apr 27 16:25:27 2009
New Revision: 70250
URL: http://llvm.org/viewvc/llvm-project?rev=70250&view=rev
Log:
unnest some code, decoupling fixit rewriting from ast stuff.
Modified:
cfe/trunk/tools/clang-cc/clang-cc.cpp
Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=70250&r1=70249&r2=70250&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Mon Apr 27 16:25:27 2009
@@ -1723,39 +1723,38 @@
break;
}
- if (Consumer) {
- llvm::OwningPtr<ASTContext> ContextOwner;
-
- if (FixItAtLocations.size() > 0) {
- // Even without the "-fixit" flag, with may have some specific
- // locations where the user has requested fixes. Process those
- // locations now.
- if (!FixItRewrite)
- FixItRewrite = new FixItRewriter(PP.getDiagnostics(),
- PP.getSourceManager(),
- PP.getLangOptions());
-
- bool AddedFixitLocation = false;
- for (unsigned Idx = 0, Last = FixItAtLocations.size();
- Idx != Last; ++Idx) {
- RequestedSourceLocation Requested;
- if (FixItAtLocations[Idx].ResolveLocation(PP.getFileManager(),
- Requested)) {
- fprintf(stderr, "FIX-IT could not find file \"%s\"\n",
- FixItAtLocations[Idx].FileName.c_str());
- } else {
- FixItRewrite->addFixItLocation(Requested);
- AddedFixitLocation = true;
- }
+ if (FixItAtLocations.size() > 0) {
+ // Even without the "-fixit" flag, with may have some specific
+ // locations where the user has requested fixes. Process those
+ // locations now.
+ if (!FixItRewrite)
+ FixItRewrite = new FixItRewriter(PP.getDiagnostics(),
+ PP.getSourceManager(),
+ PP.getLangOptions());
+
+ bool AddedFixitLocation = false;
+ for (unsigned Idx = 0, Last = FixItAtLocations.size();
+ Idx != Last; ++Idx) {
+ RequestedSourceLocation Requested;
+ if (FixItAtLocations[Idx].ResolveLocation(PP.getFileManager(),
+ Requested)) {
+ fprintf(stderr, "FIX-IT could not find file \"%s\"\n",
+ FixItAtLocations[Idx].FileName.c_str());
+ } else {
+ FixItRewrite->addFixItLocation(Requested);
+ AddedFixitLocation = true;
}
+ }
- if (!AddedFixitLocation) {
- // All of the fix-it locations were bad. Don't fix anything.
- delete FixItRewrite;
- FixItRewrite = 0;
- }
+ if (!AddedFixitLocation) {
+ // All of the fix-it locations were bad. Don't fix anything.
+ delete FixItRewrite;
+ FixItRewrite = 0;
}
+ }
+ llvm::OwningPtr<ASTContext> ContextOwner;
+ if (Consumer) {
ContextOwner.reset(new ASTContext(PP.getLangOptions(),
PP.getSourceManager(),
PP.getTargetInfo(),
@@ -1764,7 +1763,7 @@
/* FreeMemory = */ !DisableFree,
/* size_reserve = */0,
/* InitializeBuiltins = */ImplicitIncludePCH.empty()));
-
+
if (!ImplicitIncludePCH.empty()) {
// The user has asked us to include a precompiled header. Load
// the precompiled header into the AST context.
@@ -1809,16 +1808,17 @@
ParseAST(PP, Consumer.get(), *ContextOwner.get(), Stats,
CompleteTranslationUnit);
-
- if (FixItRewrite)
- FixItRewrite->WriteFixedFile(InFile, OutputFile);
-
- // If in -disable-free mode, don't deallocate these when they go out of
- // scope.
- if (DisableFree)
- ContextOwner.take();
}
+ if (FixItRewrite)
+ FixItRewrite->WriteFixedFile(InFile, OutputFile);
+
+ // If in -disable-free mode, don't deallocate ASTContext.
+ if (DisableFree)
+ ContextOwner.take();
+ else
+ ContextOwner.reset(); // Delete ASTContext
+
if (VerifyDiagnostics)
if (CheckDiagnostics(PP))
exit(1);
More information about the cfe-commits
mailing list